[PATCH] D56349: [CMake][Fuchsia] Enable x86 relaxation by default

2019-01-04 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm.  Wouldn't hurt to comment that this depends on a linker new enough to 
support the new reloc types (only reason it's conditional at all) and since we 
default to lld we don't worry about host system linkers that might be too old 
to support the new reloc types.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56349



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


[PATCH] D56350: [CMake][Fuchsia] Enable experimental new pass manager by default

2019-01-04 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D56350



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


[PATCH] D56348: [CMake][Fuchsia] Enable --build-id linker flag by default

2019-01-04 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D56348



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


[PATCH] D56350: [CMake][Fuchsia] Enable experimental new pass manager by default

2019-01-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, mgorny.

This change enableds experimental new pass manager.


Repository:
  rC Clang

https://reviews.llvm.org/D56350

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -16,6 +16,7 @@
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER ON CACHE BOOL "")
 
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -16,6 +16,7 @@
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER ON CACHE BOOL "")
 
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56349: [CMake][Fuchsia] Enable x86 relaxation by default

2019-01-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, mgorny.

This enables x86 relaxation by default.


Repository:
  rC Clang

https://reviews.llvm.org/D56349

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -15,6 +15,7 @@
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
+set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -15,6 +15,7 @@
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
+set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56348: [CMake][Fuchsia] Enable --build-id linker flag by default

2019-01-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, mgorny.

This enables passing --build-id to linker by default.


Repository:
  rC Clang

https://reviews.llvm.org/D56348

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -14,6 +14,8 @@
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
+
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)
   set(LLVM_ENABLE_LLD ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -14,6 +14,8 @@
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
+
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 if(NOT APPLE)
   set(LLVM_ENABLE_LLD ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r350143 - Add vtable anchor to classes.

2019-01-04 Thread Richard Trieu via cfe-commits
This was a cleanup before some other refactoring I wanted to do, but that
refactoring has been put on hold for a bit, so I committed this change to
improve the codebase a little and not have to redo it later.

On Mon, Dec 31, 2018 at 4:50 PM David Blaikie  wrote:

> While I realize it's in the coding standard - is there any particular
> other motivation for this? (Given you've been doing layering cleanup - I'm
> wondering fi this is an interesting workaround for some layering problems,
> for instance?)
>
> On Sat, Dec 29, 2018 at 1:05 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Dec 28 18:02:30 2018
>> New Revision: 350143
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350143&view=rev
>> Log:
>> Add vtable anchor to classes.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/AST/DeclTemplate.h
>> cfe/trunk/include/clang/Lex/ModuleMap.h
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/AST/DeclTemplate.cpp
>> cfe/trunk/lib/Lex/ModuleMap.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Dec 28 18:02:30 2018
>> @@ -3918,6 +3918,7 @@ class MSPropertyDecl : public Declarator
>>: DeclaratorDecl(MSProperty, DC, L, N, T, TInfo, StartL),
>>  GetterId(Getter), SetterId(Setter) {}
>>
>> +  void anchor() override;
>>  public:
>>friend class ASTDeclReader;
>>
>>
>> Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Dec 28 18:02:30 2018
>> @@ -751,6 +751,7 @@ class RedeclarableTemplateDecl : public
>>  return getMostRecentDecl();
>>}
>>
>> +  void anchor() override;
>>  protected:
>>template  struct SpecEntryTraits {
>>  using DeclType = EntryType;
>>
>> Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
>> +++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Dec 28 18:02:30 2018
>> @@ -45,6 +45,8 @@ class SourceManager;
>>  /// A mechanism to observe the actions of the module map parser as it
>>  /// reads module map files.
>>  class ModuleMapCallbacks {
>> +  virtual void anchor();
>> +
>>  public:
>>virtual ~ModuleMapCallbacks() = default;
>>
>>
>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Dec 28 18:02:30 2018
>> @@ -2910,6 +2910,8 @@ void DecompositionDecl::printName(llvm::
>>os << ']';
>>  }
>>
>> +void MSPropertyDecl::anchor() {}
>> +
>>  MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC,
>> SourceLocation L, DeclarationName
>> N,
>> QualType T, TypeSourceInfo *TInfo,
>>
>> Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Dec 28 18:02:30 2018
>> @@ -149,6 +149,8 @@ void *allocateDefaultArgStorageChain(con
>>  // RedeclarableTemplateDecl Implementation
>>
>>  
>> //===--===//
>>
>> +void RedeclarableTemplateDecl::anchor() {}
>> +
>>  RedeclarableTemplateDecl::CommonBase
>> *RedeclarableTemplateDecl::getCommonPtr() const {
>>if (Common)
>>  return Common;
>>
>> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=350143&r1=350142&r2=350143&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
>> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Dec 28 18:02:30 2018
>> @@ -54,6 +54,8 @@
>>
>>  using namespace clang;
>>
>> +void ModuleMapCallbacks:

[PATCH] D55662: [Sema][ObjC] Do not warn about repeated uses of weak variables when the variables are accessed in an unevaluated context.

2019-01-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D55662#1346077 , @rjmccall wrote:

> Hmm.  Are we resolving the placeholder expression twice here?  That might be 
> the basic problem.


Yes, `CheckPlaceholderExpr` is called in `Sema::DeduceAutoType` to deduce the 
type of the auto variable and then called again when 
`InitializationSequence::InitializeFrom` generates the Expr for initialization.

If we want to avoid calling `CheckPlaceholderExpr` twice, I think it's possible 
to cache the results of `ObjCPropertyOpBuilder::buildRValueOperation` in Sema. 
Alternatively, we can just pass down a flag that indicates we are deducing auto 
types and pass it to the constructor of `ObjCPropertyOpBuilder`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55662



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


Re: r350404 - Refactor the way we handle diagnosing unused expression results.

2019-01-04 Thread Richard Smith via cfe-commits
On Fri, 4 Jan 2019 at 17:33, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Nice, this is finding bugs:
> https://bugs.chromium.org/p/chromium/issues/detail?id=919262
>
> However, I noticed that for that case, the same warning is printed twice:
>
> ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
> error: expression result unused [-Werror,-Wunused-value]
>   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>^~~
> ../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
> error: expression result unused [-Werror,-Wunused-value]
>   NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
>
>
> Is that expected?
>

The first diagnostic appears when parsing the template, the second one
appears when instantiating it. In the complete diagnostic output:

../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
error: expression result unused [-Werror,-Wunused-value]
  NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
   ^~~

../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
error: expression result unused [-Werror,-Wunused-value]
  NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
   ^~~
../../third_party/crashpad/crashpad/util/win/process_info.cc(531,17):
note: in instantiation of function template specialization
'crashpad::GetProcessBasicInformation'
requested here
  bool result =
GetProcessBasicInformation(
^

It'd be nice to suppress the diagnostic during instantiation if it appeared
during the initial parse (generally, not with something specific to this
warning).

Code is here:
>
> https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/process_info.cc?q=crashpad/util/win/process_info.cc&sq=package:chromium&g=0&l=227
>
> https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/ntstatus_logging.h?type=cs&q=NTSTATUS_LOG&sq=package:chromium&g=0&l=63
>
>
> On Fri, Jan 4, 2019 at 12:01 PM Aaron Ballman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: aaronballman
>> Date: Fri Jan  4 08:58:14 2019
>> New Revision: 350404
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350404&view=rev
>> Log:
>> Refactor the way we handle diagnosing unused expression results.
>>
>> Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places
>> where we want diagnostics, we now diagnose unused expression statements and
>> full expressions in a more generic way when acting on the final expression
>> statement. This results in more appropriate diagnostics for [[nodiscard]]
>> where we were previously lacking them, such as when the body of a for loop
>> is not a compound statement.
>>
>> This patch fixes PR39837.
>>
>> Modified:
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Parse/ParseObjc.cpp
>> cfe/trunk/lib/Parse/ParseOpenMP.cpp
>> cfe/trunk/lib/Parse/ParseStmt.cpp
>> cfe/trunk/lib/Sema/SemaCoroutine.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/SemaLambda.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/lib/Sema/TreeTransform.h
>> cfe/trunk/test/CXX/stmt.stmt/stmt.select/p3.cpp
>> cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
>> cfe/trunk/test/Parser/cxx1z-init-statement.cpp
>> cfe/trunk/test/Parser/switch-recovery.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
>> cfe/trunk/test/SemaCXX/for-range-examples.cpp
>> cfe/trunk/test/SemaCXX/warn-unused-result.cpp
>>
>> Modified: cfe/trunk/include/clang/Parse/Parser.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=350404&r1=350403&r2=350404&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Parse/Parser.h (original)
>> +++ cfe/trunk/include/clang/Parse/Parser.h Fri Jan  4 08:58:14 2019
>> @@ -360,6 +360,11 @@ class Parser : public CodeCompletionHand
>>/// just a regular sub-expression.
>>SourceLocation ExprStatementTokLoc;
>>
>> +  /// Tests whether an expression value is discarded based on token
>> lookahead.
>> +  /// It will return true if the lexer is currently processing the })
>> +  /// terminating a GNU statement expression and false otherwise.
>> +  bool isExprValueDiscarded();
>> +
>>  public:
>>Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
>>~Parser() override;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350404&r1=350403&r2=350404&

[PATCH] D56345: [clang-format] Assert that filenames are not empty

2019-01-04 Thread Jonas Rickert via Phabricator via cfe-commits
jr created this revision.
jr added reviewers: krasimir, djasper.
Herald added a subscriber: cfe-commits.

Adds asserts to catch empty filenames, which otherwise will cause a crash in 
SourceManager.
The clang-format tool now outputs an error if an empty filename is used.
Fixes bug: 34667


Repository:
  rC Clang

https://reviews.llvm.org/D56345

Files:
  lib/Basic/SourceManager.cpp
  lib/Format/Format.cpp
  tools/clang-format/ClangFormat.cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -117,7 +117,8 @@
 static FileID createInMemoryFile(StringRef FileName, MemoryBuffer *Source,
  SourceManager &Sources, FileManager &Files,
  llvm::vfs::InMemoryFileSystem *MemFS) {
-  MemFS->addFileNoOwn(FileName, 0, Source);
+  bool DidAddFile = MemFS->addFileNoOwn(FileName, 0, Source);
+  assert(DidAddFile && "Could not add file to InMemoryFileSystem");
   return Sources.createFileID(Files.getFile(FileName), SourceLocation(),
   SrcMgr::C_User);
 }
@@ -262,6 +263,10 @@
   if (fillRanges(Code.get(), Ranges))
 return true;
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
+  if (AssumedFileName.empty()) {
+llvm::errs() << "error: empty filenames are not allowed\n";
+return true;
+  }
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1984,6 +1984,7 @@
 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
+  assert(!FileName.empty());
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
@@ -2152,6 +2153,7 @@
  ArrayRef Ranges, unsigned FirstStartColumn,
  unsigned NextStartColumn, unsigned LastStartColumn, StringRef 
FileName,
  FormattingAttemptStatus *Status) {
+  assert(!FileName.empty());
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
 return {tooling::Replacements(), 0};
@@ -2228,6 +2230,7 @@
 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
   ArrayRef Ranges,
   StringRef FileName) {
+  assert(!FileName.empty());
   // cleanups only apply to C++ (they mostly concern ctor commas etc.)
   if (Style.Language != FormatStyle::LK_Cpp)
 return tooling::Replacements();
@@ -2248,6 +2251,7 @@
   StringRef Code,
   ArrayRef Ranges,
   StringRef FileName) {
+  assert(!FileName.empty());
   return NamespaceEndCommentsFixer(Environment(Code, FileName, Ranges), Style)
   .process()
   .first;
@@ -2257,6 +2261,7 @@
 StringRef Code,
 ArrayRef Ranges,
 StringRef FileName) {
+  assert(!FileName.empty());
   return UsingDeclarationsSorter(Environment(Code, FileName, Ranges), Style)
   .process()
   .first;
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -2219,10 +2219,11 @@
   // is deleted.
   IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
-  InMemoryFileSystem->addFile(
+  bool DidAddFile = InMemoryFileSystem->addFile(
   FileName, 0,
   llvm::MemoryBuffer::getMemBuffer(Content, FileName,
/*RequiresNullTerminator=*/false));
+  assert(DidAddFile && "Could not add file to InMemoryFileSystem");
   // This is passed to `SM` as reference, so the pointer has to be referenced
   // in `Environment` so that `FileMgr` can out-live this function scope.
   FileMgr =


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -117,7 +117,8 @@
 static FileID createInMemoryFile(StringRef FileName, MemoryBuffer *Source,
  SourceManager &Sources, FileManager &Files,
  llvm::vfs::InMemoryFileSystem *MemFS) {
-  MemFS->addFileNoOwn(FileName, 0, Source);
+  bool DidAddFile = MemFS->addFileNoOwn(FileName, 0, Source);
+  assert(DidAddFile && "Could not add file to InMemoryFileSystem");
   return Sources.createFileID(Files.getFile(FileName), SourceLocation(),
   

[PATCH] D56343: [clang-tidy] Refactor: Compose Method on check_clang_tidy.py

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 180349.
LegalizeAdulthood added a comment.

Extract Function try_run


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

https://reviews.llvm.org/D56343

Files:
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,33 +42,7 @@
 def csv(string):
   return string.split(',')
 
-def main():
-  parser = argparse.ArgumentParser()
-  parser.add_argument('-expect-clang-tidy-error', action='store_true')
-  parser.add_argument('-resource-dir')
-  parser.add_argument('-assume-filename')
-  parser.add_argument('input_file_name')
-  parser.add_argument('check_name')
-  parser.add_argument('temp_file_name')
-  parser.add_argument('-check-suffix', '-check-suffixes',
-  default=[''], type=csv,
-  help="comma-separated list of FileCheck suffixes")
-
-  args, extra_args = parser.parse_known_args()
-
-  resource_dir = args.resource_dir
-  assume_file_name = args.assume_filename
-  input_file_name = args.input_file_name
-  check_name = args.check_name
-  temp_file_name = args.temp_file_name
-  expect_clang_tidy_error = args.expect_clang_tidy_error
-
-  file_name_with_extension = assume_file_name or input_file_name
-  _, extension = os.path.splitext(file_name_with_extension)
-  if extension not in ['.c', '.hpp', '.m', '.mm']:
-extension = '.cpp'
-  temp_file_name = temp_file_name + extension
-
+def get_extra_args(resource_dir, extension, extra_args):
   clang_tidy_extra_args = extra_args
   if len(clang_tidy_extra_args) == 0:
 clang_tidy_extra_args = ['--']
@@ -85,9 +59,9 @@
   if resource_dir is not None:
 clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
 
-  with open(input_file_name, 'r') as input_file:
-input_text = input_file.read()
+  return clang_tidy_extra_args
 
+def get_prefixes(check_suffix, input_text):
   check_fixes_prefixes = []
   check_messages_prefixes = []
   check_notes_prefixes = []
@@ -96,7 +70,7 @@
   has_check_messages = False
   has_check_notes = False
 
-  for check in args.check_suffix:
+  for check in check_suffix:
 if check and not re.match('^[A-Z0-9\-]+$', check):
   sys.exit('Only A..Z, 0..9 and "-" are ' +
 'allowed in check suffixes list, but "%s" was given' % (check))
@@ -126,15 +100,91 @@
 check_messages_prefixes.append(check_messages_prefix)
 check_notes_prefixes.append(check_notes_prefix)
 
+  return (has_check_fixes, has_check_messages, has_check_notes, \
+check_fixes_prefixes, check_messages_prefixes, check_notes_prefixes)
+
+def try_run(args, raise_error = True):
+  try:
+process_output = \
+  subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
+  except subprocess.CalledProcessError as e:
+process_output = e.output.decode()
+print('%s failed:\n%s' % (' '.join(args), process_output))
+if raise_error:
+  raise
+  return process_output
+
+def check_fixes(check_fixes_prefixes, has_check_fixes, input_file_name, temp_file_name):
+  if has_check_fixes:
+try_run(['FileCheck', '-input-file=' + temp_file_name, input_file_name,
+'-check-prefixes=' + ','.join(check_fixes_prefixes),
+'-strict-whitespace'])
+  return
+
+def check_messages(check_messages_prefixes, has_check_messages, clang_tidy_output, input_file_name, temp_file_name):
+  if has_check_messages:
+messages_file = temp_file_name + '.msg'
+write_file(messages_file, clang_tidy_output)
+try_run(['FileCheck', '-input-file=' + messages_file, input_file_name,
+   '-check-prefixes=' + ','.join(check_messages_prefixes),
+   '-implicit-check-not={{warning|error}}:'])
+  return
+
+def check_notes(check_notes_prefixes, has_check_notes, clang_tidy_output, input_file_name, temp_file_name):
+  if has_check_notes:
+notes_file = temp_file_name + '.notes'
+filtered_output = [line for line in clang_tidy_output.splitlines()
+   if not "note: FIX-IT applied" in line]
+write_file(notes_file, '\n'.join(filtered_output))
+try_run(['FileCheck', '-input-file=' + notes_file, input_file_name,
+   '-check-prefixes=' + ','.join(check_notes_prefixes),
+   '-implicit-check-not={{note|warning|error}}:'])
+  return
+
+def main():
+  parser = argparse.ArgumentParser()
+  parser.add_argument('-expect-clang-tidy-error', action='store_true')
+  parser.add_argument('-resource-dir')
+  parser.add_argument('-assume-filename')
+  parser.add_argument('input_file_name')
+  parser.add_argument('check_name')
+  parser.add_argument('temp_file_name')
+  parser.add_argument('-check-suffix', '-check-suffixes',
+  default=[''], type=csv,
+  help="comma-separated list of FileCheck suffixes")
+
+  args, extra_args = parser.parse_known_args()
+
+  resource_dir = args.r

Re: r350404 - Refactor the way we handle diagnosing unused expression results.

2019-01-04 Thread Nico Weber via cfe-commits
Nice, this is finding bugs:
https://bugs.chromium.org/p/chromium/issues/detail?id=919262

However, I noticed that for that case, the same warning is printed twice:

../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
error: expression result unused [-Werror,-Wunused-value]
  NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";
   ^~~
../../third_party/crashpad/crashpad/util/win/process_info.cc(227,36):
error: expression result unused [-Werror,-Wunused-value]
  NTSTATUS_LOG(ERROR, status), "NtQueryInformationProcess";


Is that expected? Code is here:
https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/process_info.cc?q=crashpad/util/win/process_info.cc&sq=package:chromium&g=0&l=227
https://cs.chromium.org/chromium/src/third_party/crashpad/crashpad/util/win/ntstatus_logging.h?type=cs&q=NTSTATUS_LOG&sq=package:chromium&g=0&l=63


On Fri, Jan 4, 2019 at 12:01 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Fri Jan  4 08:58:14 2019
> New Revision: 350404
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350404&view=rev
> Log:
> Refactor the way we handle diagnosing unused expression results.
>
> Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places
> where we want diagnostics, we now diagnose unused expression statements and
> full expressions in a more generic way when acting on the final expression
> statement. This results in more appropriate diagnostics for [[nodiscard]]
> where we were previously lacking them, such as when the body of a for loop
> is not a compound statement.
>
> This patch fixes PR39837.
>
> Modified:
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/ParseObjc.cpp
> cfe/trunk/lib/Parse/ParseOpenMP.cpp
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Sema/SemaCoroutine.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/SemaLambda.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/test/CXX/stmt.stmt/stmt.select/p3.cpp
> cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
> cfe/trunk/test/Parser/cxx1z-init-statement.cpp
> cfe/trunk/test/Parser/switch-recovery.cpp
> cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
> cfe/trunk/test/SemaCXX/for-range-examples.cpp
> cfe/trunk/test/SemaCXX/warn-unused-result.cpp
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=350404&r1=350403&r2=350404&view=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Fri Jan  4 08:58:14 2019
> @@ -360,6 +360,11 @@ class Parser : public CodeCompletionHand
>/// just a regular sub-expression.
>SourceLocation ExprStatementTokLoc;
>
> +  /// Tests whether an expression value is discarded based on token
> lookahead.
> +  /// It will return true if the lexer is currently processing the })
> +  /// terminating a GNU statement expression and false otherwise.
> +  bool isExprValueDiscarded();
> +
>  public:
>Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
>~Parser() override;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350404&r1=350403&r2=350404&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan  4 08:58:14 2019
> @@ -1365,6 +1365,7 @@ public:
>void PopCompoundScope();
>
>sema::CompoundScopeInfo &getCurCompoundScope() const;
> +  bool isCurCompoundStmtAStmtExpr() const;
>
>bool hasAnyUnrecoverableErrorsInThisFunction() const;
>
> @@ -3685,16 +3686,17 @@ public:
>  return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
>}
>FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
> -return FullExprArg(ActOnFinishFullExpr(Arg, CC).get());
> +return FullExprArg(
> +ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
>}
>FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) {
>  ExprResult FE =
> -  ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
> -  /*DiscardedValue*/ true);
> +ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() :
> SourceLocation(),
> +/*DiscardedValue*/ true);
>  return FullExprArg(FE.get());
>}
>
> -  StmtResult ActOnExprStmt(ExprResult Arg);
> +  StmtResul

r350453 - Let new test from r350340 still pass even after r350451.

2019-01-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan  4 17:19:14 2019
New Revision: 350453

URL: http://llvm.org/viewvc/llvm-project?rev=350453&view=rev
Log:
Let new test from r350340 still pass even after r350451.

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

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=350453&r1=350452&r2=350453&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Fri Jan  4 17:19:14 2019
@@ -152,10 +152,6 @@ FrontendAction::CreateWrappedASTConsumer
   if (!Consumer)
 return nullptr;
 
-  // If there are no registered plugins we don't need to wrap the consumer
-  if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
-return Consumer;
-
   // Validate -add-plugin args.
   bool FoundAllPlugins = true;
   for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) {
@@ -174,6 +170,10 @@ FrontendAction::CreateWrappedASTConsumer
   if (!FoundAllPlugins)
 return nullptr;
 
+  // If there are no registered plugins we don't need to wrap the consumer
+  if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
+return Consumer;
+
   // If this is a code completion run, avoid invoking the plugin consumers
   if (CI.hasCodeCompletionConsumer())
 return Consumer;


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


Re: r350340 - Validate -add-plugin arguments.

2019-01-04 Thread Nico Weber via cfe-commits
Thanks for the note. 350451 will hopefully help.

On Fri, Jan 4, 2019 at 2:18 PM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Nico,
>
> This commit broke tests on llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
> builder:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/41673
>
> . . .
> Failing Tests (2):
> Clang :: CodeGenCXX/debug-info-class-limited-plugin.test
> Clang :: Frontend/plugin-vs-debug-info.cpp
>
> Please have a look ASAP?
>
> Thanks
>
> Galina
>
> On Thu, Jan 3, 2019 at 10:29 AM Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: nico
>> Date: Thu Jan  3 10:26:06 2019
>> New Revision: 350340
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350340&view=rev
>> Log:
>> Validate -add-plugin arguments.
>>
>> -plugin already prints an error if the name of an unknown plugin is
>> passed.
>> -add-plugin used to silently ignore that, now it errors too.
>>
>> Differential Revision: https://reviews.llvm.org/D56273
>>
>> Added:
>> cfe/trunk/test/Frontend/plugin-unknown.c
>> Modified:
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>
>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=350340&r1=350339&r2=350340&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jan  3 10:26:06 2019
>> @@ -33,6 +33,7 @@
>>  #include "clang/Frontend/DependencyOutputOptions.h"
>>  #include "clang/Frontend/FrontendDiagnostic.h"
>>  #include "clang/Frontend/FrontendOptions.h"
>> +#include "clang/Frontend/FrontendPluginRegistry.h"
>>  #include "clang/Frontend/LangStandard.h"
>>  #include "clang/Frontend/MigratorOptions.h"
>>  #include "clang/Frontend/PreprocessorOutputOptions.h"
>> @@ -1663,7 +1664,20 @@ static InputKind ParseFrontendArgs(Front
>>  Opts.ProgramAction = frontend::PluginAction;
>>  Opts.ActionName = A->getValue();
>>}
>> -  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
>> +  for (const std::string &Arg : Args.getAllArgValues(OPT_add_plugin)) {
>> +bool Found = false;
>> +for (FrontendPluginRegistry::iterator it =
>> FrontendPluginRegistry::begin(),
>> +  ie =
>> FrontendPluginRegistry::end();
>> + it != ie; ++it) {
>> +  if (it->getName() == Arg)
>> +Found = true;
>> +}
>> +if (!Found) {
>> +  Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
>> +  continue;
>> +}
>> +Opts.AddPluginActions.push_back(Arg);
>> +  }
>>for (const auto *AA : Args.filtered(OPT_plugin_arg))
>>  Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
>>
>>
>> Added: cfe/trunk/test/Frontend/plugin-unknown.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugin-unknown.c?rev=350340&view=auto
>>
>> ==
>> --- cfe/trunk/test/Frontend/plugin-unknown.c (added)
>> +++ cfe/trunk/test/Frontend/plugin-unknown.c Thu Jan  3 10:26:06 2019
>> @@ -0,0 +1,5 @@
>> +// RUN: not %clang_cc1 -plugin asdf %s 2>&1 | FileCheck %s
>> +// RUN: not %clang_cc1 -add-plugin asdf %s 2>&1 | FileCheck
>> --check-prefix=ADD %s
>> +
>> +// CHECK: unable to find plugin 'asdf'
>> +// ADD: unable to find plugin 'asdf'
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350451 - Move -add-plugin validation after -load was executed.

2019-01-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan  4 17:10:20 2019
New Revision: 350451

URL: http://llvm.org/viewvc/llvm-project?rev=350451&view=rev
Log:
Move -add-plugin validation after -load was executed.

Moves the code added in r350340 around a bit, to hopefully make the existing
plugin tests pass when clang is built with examples enabled.

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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=350451&r1=350450&r2=350451&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jan  4 17:10:20 2019
@@ -1666,20 +1666,7 @@ static InputKind ParseFrontendArgs(Front
 Opts.ProgramAction = frontend::PluginAction;
 Opts.ActionName = A->getValue();
   }
-  for (const std::string &Arg : Args.getAllArgValues(OPT_add_plugin)) {
-bool Found = false;
-for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-  ie = FrontendPluginRegistry::end();
- it != ie; ++it) {
-  if (it->getName() == Arg)
-Found = true;
-}
-if (!Found) {
-  Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
-  continue;
-}
-Opts.AddPluginActions.push_back(Arg);
-  }
+  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
   for (const auto *AA : Args.filtered(OPT_plugin_arg))
 Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
 

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=350451&r1=350450&r2=350451&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Fri Jan  4 17:10:20 2019
@@ -156,6 +156,24 @@ FrontendAction::CreateWrappedASTConsumer
   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
 return Consumer;
 
+  // Validate -add-plugin args.
+  bool FoundAllPlugins = true;
+  for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) {
+bool Found = false;
+for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
+  ie = FrontendPluginRegistry::end();
+ it != ie; ++it) {
+  if (it->getName() == Arg)
+Found = true;
+}
+if (!Found) {
+  CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name) << Arg;
+  FoundAllPlugins = false;
+}
+  }
+  if (!FoundAllPlugins)
+return nullptr;
+
   // If this is a code completion run, avoid invoking the plugin consumers
   if (CI.hasCodeCompletionConsumer())
 return Consumer;


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


[PATCH] D56343: [clang-tidy] Refactor: Compose Method on check_clang_tidy.py

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: serge-sans-paille.

Break up the huge main() function


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56343

Files:
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,33 +42,7 @@
 def csv(string):
   return string.split(',')
 
-def main():
-  parser = argparse.ArgumentParser()
-  parser.add_argument('-expect-clang-tidy-error', action='store_true')
-  parser.add_argument('-resource-dir')
-  parser.add_argument('-assume-filename')
-  parser.add_argument('input_file_name')
-  parser.add_argument('check_name')
-  parser.add_argument('temp_file_name')
-  parser.add_argument('-check-suffix', '-check-suffixes',
-  default=[''], type=csv,
-  help="comma-separated list of FileCheck suffixes")
-
-  args, extra_args = parser.parse_known_args()
-
-  resource_dir = args.resource_dir
-  assume_file_name = args.assume_filename
-  input_file_name = args.input_file_name
-  check_name = args.check_name
-  temp_file_name = args.temp_file_name
-  expect_clang_tidy_error = args.expect_clang_tidy_error
-
-  file_name_with_extension = assume_file_name or input_file_name
-  _, extension = os.path.splitext(file_name_with_extension)
-  if extension not in ['.c', '.hpp', '.m', '.mm']:
-extension = '.cpp'
-  temp_file_name = temp_file_name + extension
-
+def get_extra_args(resource_dir, extension, extra_args):
   clang_tidy_extra_args = extra_args
   if len(clang_tidy_extra_args) == 0:
 clang_tidy_extra_args = ['--']
@@ -85,9 +59,9 @@
   if resource_dir is not None:
 clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
 
-  with open(input_file_name, 'r') as input_file:
-input_text = input_file.read()
+  return clang_tidy_extra_args
 
+def get_prefixes(check_suffix, input_text):
   check_fixes_prefixes = []
   check_messages_prefixes = []
   check_notes_prefixes = []
@@ -96,7 +70,7 @@
   has_check_messages = False
   has_check_notes = False
 
-  for check in args.check_suffix:
+  for check in check_suffix:
 if check and not re.match('^[A-Z0-9\-]+$', check):
   sys.exit('Only A..Z, 0..9 and "-" are ' +
 'allowed in check suffixes list, but "%s" was given' % (check))
@@ -126,56 +100,23 @@
 check_messages_prefixes.append(check_messages_prefix)
 check_notes_prefixes.append(check_notes_prefix)
 
-  assert has_check_fixes or has_check_messages or has_check_notes
-  # Remove the contents of the CHECK lines to avoid CHECKs matching on
-  # themselves.  We need to keep the comments to preserve line numbers while
-  # avoiding empty lines which could potentially trigger formatting-related
-  # checks.
-  cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
-
-  write_file(temp_file_name, cleaned_test)
-
-  original_file_name = temp_file_name + ".orig"
-  write_file(original_file_name, cleaned_test)
-
-  args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \
-clang_tidy_extra_args
-  if expect_clang_tidy_error:
-args.insert(0, 'not')
-  print('Running ' + repr(args) + '...')
-  try:
-clang_tidy_output = \
-subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
-  except subprocess.CalledProcessError as e:
-print('clang-tidy failed:\n' + e.output.decode())
-raise
-
-  print(' clang-tidy output ---\n' +
-clang_tidy_output +
-'\n--')
-
-  try:
-diff_output = subprocess.check_output(
-['diff', '-u', original_file_name, temp_file_name],
-stderr=subprocess.STDOUT)
-  except subprocess.CalledProcessError as e:
-diff_output = e.output
-
-  print('-- Fixes -\n' +
-diff_output.decode() +
-'\n--')
+  return (has_check_fixes, has_check_messages, has_check_notes, \
+check_fixes_prefixes, check_messages_prefixes, check_notes_prefixes)
 
+def check_fixes(check_fixes_prefixes, has_check_fixes, input_file_name, temp_file_name):
   if has_check_fixes:
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
-   '-check-prefixes=' + ','.join(check_fixes_prefixes),
-   '-strict-whitespace'],
+'-check-prefixes=' + ','.join(check_fixes_prefixes),
+'-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
   raise
+  return
 
+def check_messages(check_message

[PATCH] D56341: [python] Make the collections import future-proof

2019-01-04 Thread Jakub Stasiak via Phabricator via cfe-commits
jstasiak created this revision.
jstasiak added reviewers: mgorny, michaelplatings, serge-sans-paille.
Herald added subscribers: cfe-commits, arphaman.

On Python 3.7 the old code raises a warning:

  

  DeprecationWarning: Using or importing the ABCs from 'collections' instead of 
from 'collections.abc' is deprecated, and in 3.8 it will stop working
  class ArgumentsIterator(collections.Sequence):

  

On Python 3.8 it wouldn't work anymore.


Repository:
  rC Clang

https://reviews.llvm.org/D56341

Files:
  bindings/python/clang/cindex.py


Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -64,7 +64,6 @@
 # o implement additional SourceLocation, SourceRange, and File methods.
 
 from ctypes import *
-import collections
 
 import clang.enumerations
 
@@ -123,6 +122,14 @@
 def b(x):
 return x
 
+# Importing ABC-s directly from collections is deprecated since Python 3.7,
+# will stop working in Python 3.8.
+# See: https://docs.python.org/dev/whatsnew/3.7.html#id3
+if sys.version_info[:2] >= (3, 7):
+from collections import abc as collections_abc
+else:
+import collections as collections_abc
+
 # We only support PathLike objects on Python version with os.fspath present
 # to be consistent with the Python standard library. On older Python versions
 # we only support strings and we have dummy fspath to just pass them through.
@@ -2181,7 +2188,7 @@
 The returned object is iterable and indexable. Each item in the
 container is a Type instance.
 """
-class ArgumentsIterator(collections.Sequence):
+class ArgumentsIterator(collections_abc.Sequence):
 def __init__(self, parent):
 self.parent = parent
 self.length = None


Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -64,7 +64,6 @@
 # o implement additional SourceLocation, SourceRange, and File methods.
 
 from ctypes import *
-import collections
 
 import clang.enumerations
 
@@ -123,6 +122,14 @@
 def b(x):
 return x
 
+# Importing ABC-s directly from collections is deprecated since Python 3.7,
+# will stop working in Python 3.8.
+# See: https://docs.python.org/dev/whatsnew/3.7.html#id3
+if sys.version_info[:2] >= (3, 7):
+from collections import abc as collections_abc
+else:
+import collections as collections_abc
+
 # We only support PathLike objects on Python version with os.fspath present
 # to be consistent with the Python standard library. On older Python versions
 # we only support strings and we have dummy fspath to just pass them through.
@@ -2181,7 +2188,7 @@
 The returned object is iterable and indexable. Each item in the
 container is a Type instance.
 """
-class ArgumentsIterator(collections.Sequence):
+class ArgumentsIterator(collections_abc.Sequence):
 def __init__(self, parent):
 self.parent = parent
 self.length = None
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  Is there a reasonable way to make your targets delegate to a different 
`TargetInfo` implementation for most things so that you can generally match the 
host target for things like type sizes and alignments?


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

https://reviews.llvm.org/D56318



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


[PATCH] D56299: [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350441: [OpenMP] Refactor const restriction for linear 
(authored by jdenny, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56299?vs=180301&id=180320#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56299

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
  test/OpenMP/distribute_simd_linear_messages.cpp
  test/OpenMP/for_linear_messages.cpp
  test/OpenMP/for_simd_linear_messages.cpp
  test/OpenMP/parallel_for_linear_messages.cpp
  test/OpenMP/parallel_for_simd_linear_messages.cpp
  test/OpenMP/simd_linear_messages.cpp
  test/OpenMP/target_parallel_for_linear_messages.cpp
  test/OpenMP/target_parallel_for_simd_linear_messages.cpp
  test/OpenMP/target_simd_linear_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
  test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
  test/OpenMP/taskloop_simd_linear_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  test/OpenMP/teams_distribute_simd_linear_messages.cpp

Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -11531,20 +11531,12 @@
   }
   Type = Type.getNonReferenceType();
 
-  // A list item must not be const-qualified.
-  if (Type.isConstant(Context)) {
-Diag(ELoc, diag::err_omp_const_variable)
-<< getOpenMPClauseName(OMPC_linear);
-if (D) {
-  bool IsDecl =
-  !VD ||
-  VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly;
-  Diag(D->getLocation(),
-   IsDecl ? diag::note_previous_decl : diag::note_defined_here)
-  << D;
-}
+  // OpenMP 5.0 [2.19.3, List Item Privatization, Restrictions]
+  // A variable that is privatized must not have a const-qualified type
+  // unless it is of class type with a mutable member. This restriction does
+  // not apply to the firstprivate clause.
+  if (rejectConstNotMutableType(*this, D, Type, OMPC_linear, ELoc))
 return true;
-  }
 
   // A list item must be of integral or pointer type.
   Type = Type.getUnqualifiedType().getCanonicalType();
Index: test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
@@ -169,7 +169,7 @@
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -250,7 +250,7 @@
 
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
Index: test/OpenMP/parallel_for_linear_messages.cpp
===
--- test/OpenMP/parallel_for_linear_messages.cpp
+++ test/OpenMP/parallel_for_linear_messages.cpp
@@ -146,7 +146,7 @@
   for (int k = 0; k < argc; ++k)
 ++k;
 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-// expected-error@+1 {{const-qualified variable cannot be linear}}
+// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
 #pragma omp parallel for linear(a, b : B::ib)
   for (int k = 0; k < argc; ++k)
 ++k;
@@ -231,7 +231,7 @@
   for (int k = 0; k < argc; ++k)
 ++k;
 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-// expected-error@+1 {{const-qualified variable cannot be linear}}
+// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
 #pragma omp parallel for linear(a, b)
   for (int k = 0; k < argc; ++k)
 ++k;
Index: test/OpenMP/for_simd_linear_messages.cpp
===
--- test/OpenMP/for_simd_linear_messages.cpp
+++ test/OpenMP/for_simd_linear_messages.cpp
@@ -122,7 +122,7 @@
   #pragma omp for simd linear (S1) // expected-error {{'S1'

r350441 - [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Fri Jan  4 14:12:13 2019
New Revision: 350441

URL: http://llvm.org/viewvc/llvm-project?rev=350441&view=rev
Log:
[OpenMP] Refactor const restriction for linear

As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/for_linear_messages.cpp
cfe/trunk/test/OpenMP/for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=350441&r1=350440&r2=350441&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jan  4 14:12:13 2019
@@ -11531,20 +11531,12 @@ bool Sema::CheckOpenMPLinearDecl(const V
   }
   Type = Type.getNonReferenceType();
 
-  // A list item must not be const-qualified.
-  if (Type.isConstant(Context)) {
-Diag(ELoc, diag::err_omp_const_variable)
-<< getOpenMPClauseName(OMPC_linear);
-if (D) {
-  bool IsDecl =
-  !VD ||
-  VD->isThisDeclarationADefinition(Context) == 
VarDecl::DeclarationOnly;
-  Diag(D->getLocation(),
-   IsDecl ? diag::note_previous_decl : diag::note_defined_here)
-  << D;
-}
+  // OpenMP 5.0 [2.19.3, List Item Privatization, Restrictions]
+  // A variable that is privatized must not have a const-qualified type
+  // unless it is of class type with a mutable member. This restriction does
+  // not apply to the firstprivate clause.
+  if (rejectConstNotMutableType(*this, D, Type, OMPC_linear, ELoc))
 return true;
-  }
 
   // A list item must be of integral or pointer type.
   Type = Type.getUnqualifiedType().getCanonicalType();

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp?rev=350441&r1=350440&r2=350441&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp Fri 
Jan  4 14:12:13 2019
@@ -189,7 +189,7 @@ template int foomain(I
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}}
+#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -294,7 +294,7 @@ int main(int argc, char **argv) {
 
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{const-qualified 
variable cannot be linear}} expected-error {{incomplete type 'S1' where a 
complete type is required}}
+#pragma omp distribute parallel for simd linear (a, b) // expected-error 
{{linear variable with incomplete type 'S1'}} expected-error {{argument of a 
linear clause should be of integral or pointer type, not 'S2'}} expected-error 
{{incomplete type 'S1' where a complete type is required}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target

Modified: cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp?rev=350441&r1=350440&r2=350441&view=diff
==

[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2019-01-04 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp:196
   test_ctor_under_alloc();
+  test_ctor_with_different_value_type();
 }

Quuxplusone wrote:
> I suggest that interesting test cases include "array of `int` to vector of 
> `unsigned int`" (trivial, but unimplemented in this patch) and "array of 
> `iostream*` to vector of `ostream*`" (non-trivial because each pointer must 
> be adjusted).
What is that supposed to test? My `float/int` test is to make sure we have 
`is_same<_RawSourceTp, _RawDestTp>::value` and don't try to `memcpy` unrelated 
types. I've chosen `float` and `int` because it is easier for a human to reason 
about them.

`int` and `unsigned int` are interested for testing for values that are outside 
of common range. But in this case you pay more attention to conversion between 
ints, not to the behaviour of the constructor. That's my interpretation but 
maybe I've missed some of your intentions.


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

https://reviews.llvm.org/D48342



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


[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2019-01-04 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 180316.
vsapsai added a comment.

- Tweak the test.
- Use for `__construct_range_forward` approach recommended by @ldionne (it 
works with C++03).
- Use `__is_default_allocator` for `__construct_forward` and 
`__construct_backward`.

Didn't introduce `remove_const` to `__construct_forward` and
`__construct_backward` because they don't allow mixing types.


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

https://reviews.llvm.org/D48342

Files:
  libcxx/include/memory
  
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp


Index: 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
===
--- 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ 
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -146,9 +146,20 @@
 #endif
 }
 
+// Initialize a vector with a different value type. Make sure initialization
+// is performed with each element value, not with a memory blob.
+void test_ctor_with_different_value_type() {
+  float array[3] = {0.0f, 1.0f, 2.0f};
+  std::vector v(array, array + 3);
+  assert(v[0] == 0);
+  assert(v[1] == 1);
+  assert(v[2] == 2);
+}
+
 
 int main() {
   basic_test_cases();
   emplaceable_concept_tests(); // See PR34898
   test_ctor_under_alloc();
+  test_ctor_with_different_value_type();
 }
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -1502,6 +1502,12 @@
 typedef typename _Alloc::difference_type type;
 };
 
+template 
+struct __is_default_allocator : false_type {};
+
+template 
+struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
+
 template 
 struct _LIBCPP_TEMPLATE_VIS allocator_traits
 {
@@ -1615,7 +1621,7 @@
 static
 typename enable_if
 <
-(is_same >::value
+(__is_default_allocator::value
 || !__has_construct::value) &&
  is_trivially_move_constructible<_Tp>::value,
 void
@@ -1640,23 +1646,25 @@
 construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
 }
 
-template 
+template ::type,
+  class _RawDestTp = typename remove_const<_DestTp>::type>
 _LIBCPP_INLINE_VISIBILITY
 static
 typename enable_if
 <
-(is_same >::value
-|| !__has_construct::value) &&
- is_trivially_move_constructible<_Tp>::value,
+is_trivially_move_constructible<_DestTp>::value &&
+is_same<_RawSourceTp, _RawDestTp>::value &&
+(__is_default_allocator::value ||
+ !__has_construct::value),
 void
 >::type
-__construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, 
_Tp*& __begin2)
+__construct_range_forward(allocator_type&, _SourceTp* __begin1, 
_SourceTp* __end1, _DestTp*& __begin2)
 {
-typedef typename remove_const<_Tp>::type _Vp;
 ptrdiff_t _Np = __end1 - __begin1;
 if (_Np > 0)
 {
-_VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * 
sizeof(_Tp));
+_VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np 
* sizeof(_DestTp));
 __begin2 += _Np;
 }
 }
@@ -1679,7 +1687,7 @@
 static
 typename enable_if
 <
-(is_same >::value
+(__is_default_allocator::value
 || !__has_construct::value) &&
  is_trivially_move_constructible<_Tp>::value,
 void


Index: libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
===
--- libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -146,9 +146,20 @@
 #endif
 }
 
+// Initialize a vector with a different value type. Make sure initialization
+// is performed with each element value, not with a memory blob.
+void test_ctor_with_different_value_type() {
+  float array[3] = {0.0f, 1.0f, 2.0f};
+  std::vector v(array, array + 3);
+  assert(v[0] == 0);
+  assert(v[1] == 1);
+  assert(v[2] == 2);
+}
+
 
 int main() {
   basic_test_cases();
   emplaceable_concept_tests(); // See PR34898
   test_ctor_under_alloc();
+  test_ctor_with_different_value_type();
 }
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -1502,6 +1502,12 @@
 typedef typename _Alloc::difference_type type;
 };
 
+template 
+struct __is_default_allocator : false_type {};
+
+template 
+struct __is_default_allocator<_VS

r350433 - Fix default-function-attr.c so that it works on Windows.

2019-01-04 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Jan  4 12:51:54 2019
New Revision: 350433

URL: http://llvm.org/viewvc/llvm-project?rev=350433&view=rev
Log:
Fix default-function-attr.c so that it works on Windows.

Modified:
cfe/trunk/test/CodeGen/default-function-attr.c

Modified: cfe/trunk/test/CodeGen/default-function-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/default-function-attr.c?rev=350433&r1=350432&r2=350433&view=diff
==
--- cfe/trunk/test/CodeGen/default-function-attr.c (original)
+++ cfe/trunk/test/CodeGen/default-function-attr.c Fri Jan  4 12:51:54 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -default-function-attr foo=bar -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -default-function-attr foo=bar 
-emit-llvm %s -o - | FileCheck %s
 
 // CHECK: define void @foo() #[[X:[0-9]+]]
 void foo() {}


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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Thanks for the review!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56113



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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D56113



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


[PATCH] D56299: [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 180301.
jdenny added a comment.

Update for changes to earlier patches in series.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56299

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/for_linear_messages.cpp
  clang/test/OpenMP/for_simd_linear_messages.cpp
  clang/test/OpenMP/parallel_for_linear_messages.cpp
  clang/test/OpenMP/parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/simd_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/target_simd_linear_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
  clang/test/OpenMP/taskloop_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
@@ -169,7 +169,7 @@
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
-#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -250,7 +250,7 @@
 
 
 #pragma omp target
-#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
@@ -169,7 +169,7 @@
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -250,7 +250,7 @@
 
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
Index: clang/test/OpenMP/taskloop_simd_linear_messages.cpp
===
--- clang/test/OpenMP/taskloop_simd_linear_messages.cpp
+++ clang/test/OpenMP/taskloop_simd_linear_messages.cpp
@@ -132,7 +132,7 @@
   #pragma omp taskloop simd linear (S1) // expected-error {{'S1' does not refer to a value}}
   for (int k = 0; k < argc; ++k) ++k;
   // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   #pragma omp taskloop simd linear (val(a, b):B::ib)
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}}
@@ -221,7 +221,7 @@
   #pragma omp taskloop simd linear (S1) // expected-error {{'S1' does not refer to a value}}
   for (int k = 0; k < argc; ++k) ++k;
   // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  // expected-error@+1 {{argument of a linea

[PATCH] D56321: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

I've commit the changes, but forgot to tag the proper Diff link in the commit 
message. I just updated it.


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

https://reviews.llvm.org/D56321



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


[PATCH] D56038: hwasan: Implement lazy thread initialization for the interceptor ABI.

2019-01-04 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350429: hwasan: Implement lazy thread initialization for the 
interceptor ABI. (authored by pcc, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56038?vs=179390&id=180291#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56038

Files:
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  lib/CodeGen/CGCall.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/default-function-attr.c
  test/Driver/fsanitize.c

Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -163,6 +163,8 @@
 def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">;
 def debug_info_macro : Flag<["-"], "debug-info-macro">,
   HelpText<"Emit macro debug information">;
+def default_function_attr : Separate<["-"], "default-function-attr">,
+  HelpText<"Apply given attribute to all functions">;
 def dwarf_version_EQ : Joined<["-"], "dwarf-version=">;
 def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">;
 def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -39,6 +39,7 @@
   bool AsanPoisonCustomArrayCookie = false;
   bool AsanGlobalsDeadStripping = false;
   bool AsanUseOdrIndicator = false;
+  std::string HwasanAbi;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
   bool SafeStackRuntime = false;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -998,6 +998,10 @@
 : Flag<["-"], "fno-sanitize-address-use-odr-indicator">,
   Group,
   HelpText<"Disable ODR indicator globals">;
+def fsanitize_hwaddress_abi_EQ
+: Joined<["-"], "fsanitize-hwaddress-abi=">,
+  Group,
+  HelpText<"Select the HWAddressSanitizer ABI to target (interceptor or platform, default interceptor)">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Flags<[CoreOption, DriverOption]>,
Index: include/clang/Basic/CodeGenOptions.h
===
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/CodeGenOptions.h
@@ -286,6 +286,8 @@
   /// Set of XRay instrumentation kinds to emit.
   XRayInstrSet XRayInstrumentationBundle;
 
+  std::vector DefaultFunctionAttrs;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -837,3 +837,11 @@
 //
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,kernel-memory  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-KMSAN
 // CHECK-SCUDO-KMSAN: error: invalid argument '-fsanitize=kernel-memory' not allowed with '-fsanitize=scudo'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-INTERCEPTOR-ABI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=interceptor %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-INTERCEPTOR-ABI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
+// CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
+// CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
+// CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
Index: test/CodeGen/default-function-attr.c
===
--- test/CodeGen/default-function-attr.c
+++ test/CodeGen/default-function-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -default-function-attr foo=bar -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define void @foo() #[[X:[0-9]+]]
+void foo() {}
+
+// CHECK: attributes #[[X]] = {{.*}} "foo"="bar"
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ 

r350429 - hwasan: Implement lazy thread initialization for the interceptor ABI.

2019-01-04 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Jan  4 11:27:04 2019
New Revision: 350429

URL: http://llvm.org/viewvc/llvm-project?rev=350429&view=rev
Log:
hwasan: Implement lazy thread initialization for the interceptor ABI.

The problem is similar to D55986 but for threads: a process with the
interceptor hwasan library loaded might have some threads started by
instrumented libraries and some by uninstrumented libraries, and we
need to be able to run instrumented code on the latter.

The solution is to perform per-thread initialization lazily. If a
function needs to access shadow memory or add itself to the per-thread
ring buffer its prologue checks to see whether the value in the
sanitizer TLS slot is null, and if so it calls __hwasan_thread_enter
and reloads from the TLS slot. The runtime does the same thing if it
needs to access this data structure.

This change means that the code generator needs to know whether we
are targeting the interceptor runtime, since we don't want to pay
the cost of lazy initialization when targeting a platform with native
hwasan support. A flag -fsanitize-hwaddress-abi={interceptor,platform}
has been introduced for selecting the runtime ABI to target. The
default ABI is set to interceptor since it's assumed that it will
be more common that users will be compiling application code than
platform code.

Because we can no longer assume that the TLS slot is initialized,
the pthread_create interceptor is no longer necessary, so it has
been removed.

Ideally, lazy initialization should only cost one instruction in the
hot path, but at present the call may cause us to spill arguments
to the stack, which means more instructions in the hot path (or
theoretically in the cold path if the spills are moved with shrink
wrapping). With an appropriately chosen calling convention for
the per-thread initialization function (TODO) the hot path should
always need just one instruction and the cold path should need two
instructions with no spilling required.

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

Added:
cfe/trunk/test/CodeGen/default-function-attr.c
Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=350429&r1=350428&r2=350429&view=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Fri Jan  4 11:27:04 2019
@@ -286,6 +286,8 @@ public:
   /// Set of XRay instrumentation kinds to emit.
   XRayInstrSet XRayInstrumentationBundle;
 
+  std::vector DefaultFunctionAttrs;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=350429&r1=350428&r2=350429&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jan  4 11:27:04 2019
@@ -163,6 +163,8 @@ let Flags = [CC1Option, CC1AsOption, NoD
 def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">;
 def debug_info_macro : Flag<["-"], "debug-info-macro">,
   HelpText<"Emit macro debug information">;
+def default_function_attr : Separate<["-"], "default-function-attr">,
+  HelpText<"Apply given attribute to all functions">;
 def dwarf_version_EQ : Joined<["-"], "dwarf-version=">;
 def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">;
 def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=350429&r1=350428&r2=350429&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jan  4 11:27:04 2019
@@ -998,6 +998,10 @@ def fno_sanitize_address_use_odr_indicat
 : Flag<["-"], "fno-sanitize-address-use-odr-indicator">,
   Group,
   HelpText<"Disable ODR indicator globals">;
+def fsanitize_hwaddress_abi_EQ
+: Joined<["-"], "fsanitize-hwaddress-abi=">,
+  Group,
+  HelpText<"Select the HWAddressSanitizer ABI to target (interceptor or 
platform, default interceptor)">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group;
 def fno_sanitize_recover : Flag<["-"], "fno-sani

[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1346693 , @rjmccall wrote:

> No, no, I understand that you're not changing pointer sizes, but this is one 
> example of trying to match the ABI of the target environment, and I'm trying 
> to understand how far that goes.  What does it mean to be in the "MSVC" 
> environment when you're actually just compiling for the GPU?  Why are you 
> using OS headers in the first place?  Do you need struct layout to match MSVC 
> (presumably on x86-64)?  What should happen with the C++ ABI?


HIP is single source program. The same source code is compiled for both host 
and device. Since HIP is an extension to C++, it uses the C++ header files of 
the system. This is true for both host code and device code. On linux, both 
uses gcc header files. On windows, when MSVC is installed and default target 
environment is MSVC, the host compilation will use MSVC header files, so does 
the device compilation. For device compilation, most of the stuff in MSVC 
headers do not matter, e.g. function declarations, since they are for host. 
What matters are mostly type definitions. They should be consistent for both 
device and host. Since MSVC supports C++11, it should work. As an example, CUDA 
SDK supports MSVC.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56321: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 180289.

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

https://reviews.llvm.org/D56321

Files:
  lib/Driver/Driver.cpp
  test/Driver/hip-link-shared-library.hip


Index: test/Driver/hip-link-shared-library.hip
===
--- test/Driver/hip-link-shared-library.hip
+++ test/Driver/hip-link-shared-library.hip
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o %S/Inputs/in.so \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"]
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2323,6 +2323,18 @@
   // If this is an unbundling action use it as is for each CUDA toolchain.
   if (auto *UA = dyn_cast(HostAction)) {
 CudaDeviceActions.clear();
+auto *IA = cast(UA->getInputs().back());
+std::string FileName = IA->getInputArg().getAsString(Args);
+// Check if the type of the file is the same as the action. Do not
+// unbundle it if it is not. Do not unbundle .so files, for example,
+// which are not object files.
+if (IA->getType() == types::TY_Object &&
+(!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+  return ABRT_Inactive;
+
 for (auto Arch : GpuArchList) {
   CudaDeviceActions.push_back(UA);
   UA->registerDependentActionInfo(ToolChains[0], 
CudaArchToString(Arch),


Index: test/Driver/hip-link-shared-library.hip
===
--- test/Driver/hip-link-shared-library.hip
+++ test/Driver/hip-link-shared-library.hip
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o %S/Inputs/in.so \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"]
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", "{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2323,6 +2323,18 @@
   // If this is an unbundling action use it as is for each CUDA toolchain.
   if (auto *UA = dyn_cast(HostAction)) {
 CudaDeviceActions.clear();
+auto *IA = cast(UA->getInputs().back());
+std::string FileName = IA->getInputArg().getAsString(Args);
+// Check if the type of the file is the same as the action. Do not
+// unbundle it if it is not. Do not unbundle .so files, for example,
+// which are not object files.
+if (IA->getType() == types::TY_Object &&
+(!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+  return ABRT_Inactive;
+
 for (auto Arch : GpuArchList) {
   CudaDeviceActions.push_back(UA);
   UA->registerDependentActionInfo(ToolChains[0], CudaArchToString(Arch),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r350340 - Validate -add-plugin arguments.

2019-01-04 Thread Galina Kistanova via cfe-commits
Hello Nico,

This commit broke tests on llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
builder:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/41673

. . .
Failing Tests (2):
Clang :: CodeGenCXX/debug-info-class-limited-plugin.test
Clang :: Frontend/plugin-vs-debug-info.cpp

Please have a look ASAP?

Thanks

Galina

On Thu, Jan 3, 2019 at 10:29 AM Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Thu Jan  3 10:26:06 2019
> New Revision: 350340
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350340&view=rev
> Log:
> Validate -add-plugin arguments.
>
> -plugin already prints an error if the name of an unknown plugin is passed.
> -add-plugin used to silently ignore that, now it errors too.
>
> Differential Revision: https://reviews.llvm.org/D56273
>
> Added:
> cfe/trunk/test/Frontend/plugin-unknown.c
> Modified:
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=350340&r1=350339&r2=350340&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jan  3 10:26:06 2019
> @@ -33,6 +33,7 @@
>  #include "clang/Frontend/DependencyOutputOptions.h"
>  #include "clang/Frontend/FrontendDiagnostic.h"
>  #include "clang/Frontend/FrontendOptions.h"
> +#include "clang/Frontend/FrontendPluginRegistry.h"
>  #include "clang/Frontend/LangStandard.h"
>  #include "clang/Frontend/MigratorOptions.h"
>  #include "clang/Frontend/PreprocessorOutputOptions.h"
> @@ -1663,7 +1664,20 @@ static InputKind ParseFrontendArgs(Front
>  Opts.ProgramAction = frontend::PluginAction;
>  Opts.ActionName = A->getValue();
>}
> -  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
> +  for (const std::string &Arg : Args.getAllArgValues(OPT_add_plugin)) {
> +bool Found = false;
> +for (FrontendPluginRegistry::iterator it =
> FrontendPluginRegistry::begin(),
> +  ie =
> FrontendPluginRegistry::end();
> + it != ie; ++it) {
> +  if (it->getName() == Arg)
> +Found = true;
> +}
> +if (!Found) {
> +  Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
> +  continue;
> +}
> +Opts.AddPluginActions.push_back(Arg);
> +  }
>for (const auto *AA : Args.filtered(OPT_plugin_arg))
>  Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
>
>
> Added: cfe/trunk/test/Frontend/plugin-unknown.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/plugin-unknown.c?rev=350340&view=auto
>
> ==
> --- cfe/trunk/test/Frontend/plugin-unknown.c (added)
> +++ cfe/trunk/test/Frontend/plugin-unknown.c Thu Jan  3 10:26:06 2019
> @@ -0,0 +1,5 @@
> +// RUN: not %clang_cc1 -plugin asdf %s 2>&1 | FileCheck %s
> +// RUN: not %clang_cc1 -add-plugin asdf %s 2>&1 | FileCheck
> --check-prefix=ADD %s
> +
> +// CHECK: unable to find plugin 'asdf'
> +// ADD: unable to find plugin 'asdf'
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56321: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350426: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported 
file types (authored by aaronenyeshi, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56321?vs=180249&id=180288#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56321

Files:
  cfe/trunk/test/Driver/hip-link-shared-library.hip


Index: cfe/trunk/test/Driver/hip-link-shared-library.hip
===
--- cfe/trunk/test/Driver/hip-link-shared-library.hip
+++ cfe/trunk/test/Driver/hip-link-shared-library.hip
@@ -9,3 +9,4 @@
 // CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
 // CHECK-NOT: offload bundler
 // CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
+


Index: cfe/trunk/test/Driver/hip-link-shared-library.hip
===
--- cfe/trunk/test/Driver/hip-link-shared-library.hip
+++ cfe/trunk/test/Driver/hip-link-shared-library.hip
@@ -9,3 +9,4 @@
 // CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], output: "[[IMG3:.*out]]"
 // CHECK-NOT: offload bundler
 // CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", "{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

No, no, I understand that you're not changing pointer sizes, but this is one 
example of trying to match the ABI of the target environment, and I'm trying to 
understand how far that goes.  What does it mean to be in the "MSVC" 
environment when you're actually just compiling for the GPU?  Why are you using 
OS headers in the first place?  Do you need struct layout to match MSVC 
(presumably on x86-64)?  What should happen with the C++ ABI?


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

https://reviews.llvm.org/D56318



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


r350426 - [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Fri Jan  4 11:09:20 2019
New Revision: 350426

URL: http://llvm.org/viewvc/llvm-project?rev=350426&view=rev
Log:
[HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

The offload bundler action should not unbundle the input file types that does 
not match the action type. This fixes an issue where .so files are unbundled 
when the action type is object files.

Reviewers: yaxunl

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

Modified:
cfe/trunk/test/Driver/hip-link-shared-library.hip

Modified: cfe/trunk/test/Driver/hip-link-shared-library.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-link-shared-library.hip?rev=350426&r1=350425&r2=350426&view=diff
==
--- cfe/trunk/test/Driver/hip-link-shared-library.hip (original)
+++ cfe/trunk/test/Driver/hip-link-shared-library.hip Fri Jan  4 11:09:20 2019
@@ -9,3 +9,4 @@
 // CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
 // CHECK-NOT: offload bundler
 // CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
+


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


[PATCH] D56326: [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive

2019-01-04 Thread Lingda Li via Phabricator via cfe-commits
lildmh created this revision.
Herald added subscribers: cfe-commits, jfb, arphaman, guansong, jholewinski.

Repository:
  rC Clang

https://reviews.llvm.org/D56326

Files:
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclOpenMP.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTDumper.cpp
  lib/AST/CXXInheritance.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclOpenMP.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/OpenMP/declare_mapper_ast_print.c
  test/OpenMP/declare_mapper_ast_print.cpp
  test/OpenMP/declare_mapper_messages.c
  test/OpenMP/declare_mapper_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6230,6 +6230,7 @@
   case Decl::Import:
   case Decl::OMPThreadPrivate:
   case Decl::OMPDeclareReduction:
+  case Decl::OMPDeclareMapper:
   case Decl::OMPRequires:
   case Decl::ObjCTypeParam:
   case Decl::BuiltinTemplate:
Index: test/OpenMP/declare_mapper_messages.cpp
===
--- /dev/null
+++ test/OpenMP/declare_mapper_messages.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 %s
+
+int temp; // expected-note {{'temp' declared here}}
+
+class vec { // expected-note {{definition of 'vec' is not complete until the closing '}'}}
+private:
+  int p;// expected-note {{declared private here}}
+public:
+  int len;
+#pragma omp declare mapper(id: vec v) map(v.len)// expected-error {{member access into incomplete type 'vec'}}
+  double *data;
+};
+
+#pragma omp declare mapper  // expected-error {{expected '(' after 'declare mapper'}}
+#pragma omp declare mapper {// expected-error {{expected '(' after 'declare mapper'}}
+#pragma omp declare mapper( // expected-error {{expected a type}} expected-error {{expected declarator on 'omp declare mapper' directive}}
+#pragma omp declare mapper(#// expected-error {{expected a type}} expected-error {{expected declarator on 'omp declare mapper' directive}}
+#pragma omp declare mapper(v// expected-error {{unknown type name 'v'}} expected-error {{expected declarator on 'omp declare mapper' directive}}
+#pragma omp declare mapper(vec  // expected-error {{expected declarator on 'omp declare mapper' directive}}
+#pragma omp declare mapper(S v  // expected-error {{unknown type name 'S'}}
+#pragma omp declare mapper(vec v// expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp declare mapper(aa: vec v)   // expected-error {{expected at least one clause on '#pragma omp declare mapper' directive}}
+#pragma omp declare mapper(bb: vec v) private(v)// expected-error {{expected at least one clause on '#pragma omp declare mapper' directive}} // expected-error {{unexpected OpenMP clause 'private' in directive '#pragma omp declare mapper'}}
+#pragma omp declare mapper(cc: vec v) map(v) (  // expected-warning {{extra tokens at the end of '#pragma omp declare mapper' are ignored}}
+
+#pragma omp declare mapper(++: vec v) map(v.len)// expected-error {{illegal identifier on 'omp declare mapper' directive}}
+#pragma omp declare mapper(id1: vec v) map(v.len, temp)

[PATCH] D56321: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Can you rename the lit test as hip-link-shared-library.hip? That is more 
meaningful. Thanks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56321



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


[PATCH] D55620: [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2019-01-04 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350424: [ThinLTO] Clang changes to utilize new pass to 
handle chains of aliases (authored by tejohnson, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55620

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/lto-newpm-pipeline.c


Index: cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
===
--- cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
+++ cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -996,9 +997,11 @@
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
 MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
 
-  // Lastly, add a semantically necessary pass for LTO.
-  if (IsLTO || IsThinLTO)
+  // Lastly, add semantically necessary passes for LTO.
+  if (IsLTO || IsThinLTO) {
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
+  }
 } else {
   // Map our optimization levels into one of the distinct levels used to
   // configure the pipeline.
@@ -1019,10 +1022,12 @@
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
 Level, CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
 MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
 CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else {
 MPM = PB.buildPerModuleDefaultPipeline(Level,


Index: cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
===
--- cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
+++ cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scala

r350425 - [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Fri Jan  4 11:05:41 2019
New Revision: 350425

URL: http://llvm.org/viewvc/llvm-project?rev=350425&view=rev
Log:
[HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

The offload bundler action should not unbundle the input file types that does 
not match the action type. This fixes an issue where .so files are unbundled 
when the action type is object files.

Added:
cfe/trunk/test/Driver/hip-link-shared-library.hip
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=350425&r1=350424&r2=350425&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan  4 11:05:41 2019
@@ -2323,6 +2323,18 @@ class OffloadingActionBuilder final {
   // If this is an unbundling action use it as is for each CUDA toolchain.
   if (auto *UA = dyn_cast(HostAction)) {
 CudaDeviceActions.clear();
+auto *IA = cast(UA->getInputs().back());
+std::string FileName = IA->getInputArg().getAsString(Args);
+// Check if the type of the file is the same as the action. Do not
+// unbundle it if it is not. Do not unbundle .so files, for example,
+// which are not object files.
+if (IA->getType() == types::TY_Object &&
+(!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+  return ABRT_Inactive;
+
 for (auto Arch : GpuArchList) {
   CudaDeviceActions.push_back(UA);
   UA->registerDependentActionInfo(ToolChains[0], 
CudaArchToString(Arch),

Added: cfe/trunk/test/Driver/hip-link-shared-library.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-link-shared-library.hip?rev=350425&view=auto
==
--- cfe/trunk/test/Driver/hip-link-shared-library.hip (added)
+++ cfe/trunk/test/Driver/hip-link-shared-library.hip Fri Jan  4 11:05:41 2019
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o %S/Inputs/in.so \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"]
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"


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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:1115
+
+static bool isConstNotMutableType(Sema &SemaRef, ValueDecl *D) {
+  return checkConstNotMutableType(SemaRef, D, /*ReportDiag*/ false,

I would say it is better to outlined check as a standalone function rather than 
use `checkConstNotMutableType` for this purpose


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

https://reviews.llvm.org/D56113



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


r350424 - [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2019-01-04 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Jan  4 11:05:01 2019
New Revision: 350424

URL: http://llvm.org/viewvc/llvm-project?rev=350424&view=rev
Log:
[ThinLTO] Clang changes to utilize new pass to handle chains of aliases

Summary:
As with NameAnonGlobals, invoke the new CanonicalizeAliases via clang
when using the new PM.

Depends on D54507.

Reviewers: pcc, davidxl

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/lto-newpm-pipeline.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=350424&r1=350423&r2=350424&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan  4 11:05:01 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -996,9 +997,11 @@ void EmitAssemblyHelper::EmitAssemblyWit
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
 MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
 
-  // Lastly, add a semantically necessary pass for LTO.
-  if (IsLTO || IsThinLTO)
+  // Lastly, add semantically necessary passes for LTO.
+  if (IsLTO || IsThinLTO) {
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
+  }
 } else {
   // Map our optimization levels into one of the distinct levels used to
   // configure the pipeline.
@@ -1019,10 +1022,12 @@ void EmitAssemblyHelper::EmitAssemblyWit
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
 Level, CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
 MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
 CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else {
 MPM = PB.buildPerModuleDefaultPipeline(Level,

Modified: cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lto-newpm-pipeline.c?rev=350424&r1=350423&r2=350424&view=diff
==
--- cfe/trunk/test/CodeGen/lto-newpm-pipeline.c (original)
+++ cfe/trunk/test/CodeGen/lto-newpm-pipeline.c Fri Jan  4 11:05:01 2019
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 


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


[PATCH] D56299: [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 180283.
jdenny added a comment.

Update for changes to earlier patches in series.


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

https://reviews.llvm.org/D56299

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/for_linear_messages.cpp
  clang/test/OpenMP/for_simd_linear_messages.cpp
  clang/test/OpenMP/parallel_for_linear_messages.cpp
  clang/test/OpenMP/parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/simd_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/target_simd_linear_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
  clang/test/OpenMP/taskloop_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
@@ -169,7 +169,7 @@
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
-#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -250,7 +250,7 @@
 
 
 #pragma omp target
-#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
@@ -169,7 +169,7 @@
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
@@ -250,7 +250,7 @@
 
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
+#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target
Index: clang/test/OpenMP/taskloop_simd_linear_messages.cpp
===
--- clang/test/OpenMP/taskloop_simd_linear_messages.cpp
+++ clang/test/OpenMP/taskloop_simd_linear_messages.cpp
@@ -132,7 +132,7 @@
   #pragma omp taskloop simd linear (S1) // expected-error {{'S1' does not refer to a value}}
   for (int k = 0; k < argc; ++k) ++k;
   // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
   #pragma omp taskloop simd linear (val(a, b):B::ib)
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}}
@@ -221,7 +221,7 @@
   #pragma omp taskloop simd linear (S1) // expected-error {{'S1' does not refer to a value}}
   for (int k = 0; k < argc; ++k) ++k;
   // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  // expected-error@+1 {{argument of a linear clause should be of in

[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1346456 , @rjmccall wrote:

> What's the general idea here, that you're going to pretend to be the 
> environment's "standard" CPU target of the right pointer width and try to 
> match the ABI exactly?  This seems like a pretty treacherous road to go down.


The pointer width does not change. In both case it is 64 bit. The only 
difference is that MSVC uses unsigned long long as size_t whereas by default 
AMDGPU uses unsigned long as size_t. They have the same size but in AST they 
are different type. When HIP is compiled in MSVC environment, it has to use 
header files of MSVC. This nominal difference in size_t definition causes 
compilation error since MSVC header files contains typedef of size_t as 
unsigned long long. Since we cannot change header files of MSVC, we have to 
change our own size_t definition.

We do not want to change our device ABI.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56323: [clang-tidy] Handle member variables in readability-simplify-boolean-expr

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 180276.
LegalizeAdulthood added a comment.

No, really, fix typo in id


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56323

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  test/clang-tidy/readability-simplify-bool-expr-members.cpp

Index: test/clang-tidy/readability-simplify-bool-expr-members.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simplify-bool-expr-members.cpp
@@ -0,0 +1,360 @@
+// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t
+
+struct X {
+  explicit operator bool();
+};
+
+class A {
+public:
+  int m;
+};
+
+struct S {
+  S() : m_ar(s_a) {}
+
+  void operator_equals();
+  void operator_or();
+  void operator_and();
+  void ternary_operator();
+  void operator_not_equal();
+  void simple_conditional_assignment_statements();
+  void complex_conditional_assignment_statements();
+  void chained_conditional_assignment();
+  bool non_null_pointer_condition();
+  bool null_pointer_condition();
+  bool negated_non_null_pointer_condition();
+  bool negated_null_pointer_condition();
+  bool integer_not_zero();
+  bool member_pointer_nullptr();
+  bool integer_member_implicit_cast();
+  bool expr_with_cleanups();
+
+  bool m_b1 = false;
+  bool m_b2 = false;
+  bool m_b3 = false;
+  bool m_b4 = false;
+  int *m_p = nullptr;
+  int A::*m_m = nullptr;
+  int m_i = 0;
+  A *m_a = nullptr;
+  static A s_a;
+  A &m_ar;
+};
+
+void S::operator_equals() {
+  int i = 0;
+  m_b1 = (i > 2);
+  if (m_b1 == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 5;
+  } else {
+i = 6;
+  }
+  m_b2 = (i > 4);
+  if (m_b2 == false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b2\) {$}}
+i = 7;
+  } else {
+i = 9;
+  }
+  m_b3 = (i > 6);
+  if (true == m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 10;
+  } else {
+i = 11;
+  }
+  m_b4 = (i > 8);
+  if (false == m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b4\) {$}}
+i = 12;
+  } else {
+i = 13;
+  }
+}
+
+void S::operator_or() {
+  int i = 0;
+  m_b1 = (i > 10);
+  if (m_b1 || false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 14;
+  } else {
+i = 15;
+  }
+  m_b2 = (i > 10);
+  if (m_b2 || true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 16;
+  } else {
+i = 17;
+  }
+  m_b3 = (i > 10);
+  if (false || m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 18;
+  } else {
+i = 19;
+  }
+  m_b4 = (i > 10);
+  if (true || m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 20;
+  } else {
+i = 21;
+  }
+}
+
+void S::operator_and() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (m_b1 && false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 22;
+  } else {
+i = 23;
+  }
+  m_b2 = (i > 20);
+  if (m_b2 && true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b2\) {$}}
+i = 24;
+  } else {
+i = 25;
+  }
+  m_b3 = (i > 20);
+  if (false && m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 26;
+  } else {
+i = 27;
+  }
+  m_b4 = (i > 20);
+  if (true && m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b4\) {$}}
+i = 28;
+  } else {
+i = 29;
+  }
+}
+
+void S::ternary_operator() {
+  int i = 0;
+  m_b1 = (i > 20) ? true : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b1 = i > 20;$}}
+
+  m_b2 = (i > 20) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b2 = i <= 20;$}}
+
+  m_b3 = ((i > 20)) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b3 = i <= 20;$}}
+}
+
+void S::operator_not_equal() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (false != m_b1) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 30;
+  } else {
+i = 31;
+  }
+  m_b2 = (i > 20);
+ 

[PATCH] D56323: Handle member variables in readability-simplify-boolean-expr

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 180275.
LegalizeAdulthood added a comment.

Fix typo in id


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

https://reviews.llvm.org/D56323

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  test/clang-tidy/readability-simplify-bool-expr-members.cpp

Index: test/clang-tidy/readability-simplify-bool-expr-members.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simplify-bool-expr-members.cpp
@@ -0,0 +1,360 @@
+// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t
+
+struct X {
+  explicit operator bool();
+};
+
+class A {
+public:
+  int m;
+};
+
+struct S {
+  S() : m_ar(s_a) {}
+
+  void operator_equals();
+  void operator_or();
+  void operator_and();
+  void ternary_operator();
+  void operator_not_equal();
+  void simple_conditional_assignment_statements();
+  void complex_conditional_assignment_statements();
+  void chained_conditional_assignment();
+  bool non_null_pointer_condition();
+  bool null_pointer_condition();
+  bool negated_non_null_pointer_condition();
+  bool negated_null_pointer_condition();
+  bool integer_not_zero();
+  bool member_pointer_nullptr();
+  bool integer_member_implicit_cast();
+  bool expr_with_cleanups();
+
+  bool m_b1 = false;
+  bool m_b2 = false;
+  bool m_b3 = false;
+  bool m_b4 = false;
+  int *m_p = nullptr;
+  int A::*m_m = nullptr;
+  int m_i = 0;
+  A *m_a = nullptr;
+  static A s_a;
+  A &m_ar;
+};
+
+void S::operator_equals() {
+  int i = 0;
+  m_b1 = (i > 2);
+  if (m_b1 == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 5;
+  } else {
+i = 6;
+  }
+  m_b2 = (i > 4);
+  if (m_b2 == false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b2\) {$}}
+i = 7;
+  } else {
+i = 9;
+  }
+  m_b3 = (i > 6);
+  if (true == m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 10;
+  } else {
+i = 11;
+  }
+  m_b4 = (i > 8);
+  if (false == m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b4\) {$}}
+i = 12;
+  } else {
+i = 13;
+  }
+}
+
+void S::operator_or() {
+  int i = 0;
+  m_b1 = (i > 10);
+  if (m_b1 || false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 14;
+  } else {
+i = 15;
+  }
+  m_b2 = (i > 10);
+  if (m_b2 || true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 16;
+  } else {
+i = 17;
+  }
+  m_b3 = (i > 10);
+  if (false || m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 18;
+  } else {
+i = 19;
+  }
+  m_b4 = (i > 10);
+  if (true || m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 20;
+  } else {
+i = 21;
+  }
+}
+
+void S::operator_and() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (m_b1 && false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 22;
+  } else {
+i = 23;
+  }
+  m_b2 = (i > 20);
+  if (m_b2 && true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b2\) {$}}
+i = 24;
+  } else {
+i = 25;
+  }
+  m_b3 = (i > 20);
+  if (false && m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 26;
+  } else {
+i = 27;
+  }
+  m_b4 = (i > 20);
+  if (true && m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b4\) {$}}
+i = 28;
+  } else {
+i = 29;
+  }
+}
+
+void S::ternary_operator() {
+  int i = 0;
+  m_b1 = (i > 20) ? true : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b1 = i > 20;$}}
+
+  m_b2 = (i > 20) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b2 = i <= 20;$}}
+
+  m_b3 = ((i > 20)) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b3 = i <= 20;$}}
+}
+
+void S::operator_not_equal() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (false != m_b1) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 30;
+  } else {
+i = 31;
+  }
+  m_b2 = (i > 20);
+  if (true != m_b2) {
+// CHECK-MESSAGES: :[[@L

[PATCH] D56323: Handle member variables in readability-simplify-boolean-expr

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: cfe-commits.
LegalizeAdulthood updated this revision to Diff 180274.
LegalizeAdulthood added a comment.

Fix typo in id


- Add readability-simplify-boolean-expr test cases for member variables

Fixes #40179


https://reviews.llvm.org/D56323

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  test/clang-tidy/readability-simplify-bool-expr-members.cpp

Index: test/clang-tidy/readability-simplify-bool-expr-members.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simplify-bool-expr-members.cpp
@@ -0,0 +1,360 @@
+// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t
+
+struct X {
+  explicit operator bool();
+};
+
+class A {
+public:
+  int m;
+};
+
+struct S {
+  S() : m_ar(s_a) {}
+
+  void operator_equals();
+  void operator_or();
+  void operator_and();
+  void ternary_operator();
+  void operator_not_equal();
+  void simple_conditional_assignment_statements();
+  void complex_conditional_assignment_statements();
+  void chained_conditional_assignment();
+  bool non_null_pointer_condition();
+  bool null_pointer_condition();
+  bool negated_non_null_pointer_condition();
+  bool negated_null_pointer_condition();
+  bool integer_not_zero();
+  bool member_pointer_nullptr();
+  bool integer_member_implicit_cast();
+  bool expr_with_cleanups();
+
+  bool m_b1 = false;
+  bool m_b2 = false;
+  bool m_b3 = false;
+  bool m_b4 = false;
+  int *m_p = nullptr;
+  int A::*m_m = nullptr;
+  int m_i = 0;
+  A *m_a = nullptr;
+  static A s_a;
+  A &m_ar;
+};
+
+void S::operator_equals() {
+  int i = 0;
+  m_b1 = (i > 2);
+  if (m_b1 == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 5;
+  } else {
+i = 6;
+  }
+  m_b2 = (i > 4);
+  if (m_b2 == false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b2\) {$}}
+i = 7;
+  } else {
+i = 9;
+  }
+  m_b3 = (i > 6);
+  if (true == m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 10;
+  } else {
+i = 11;
+  }
+  m_b4 = (i > 8);
+  if (false == m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b4\) {$}}
+i = 12;
+  } else {
+i = 13;
+  }
+}
+
+void S::operator_or() {
+  int i = 0;
+  m_b1 = (i > 10);
+  if (m_b1 || false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 14;
+  } else {
+i = 15;
+  }
+  m_b2 = (i > 10);
+  if (m_b2 || true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 16;
+  } else {
+i = 17;
+  }
+  m_b3 = (i > 10);
+  if (false || m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 18;
+  } else {
+i = 19;
+  }
+  m_b4 = (i > 10);
+  if (true || m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 20;
+  } else {
+i = 21;
+  }
+}
+
+void S::operator_and() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (m_b1 && false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 22;
+  } else {
+i = 23;
+  }
+  m_b2 = (i > 20);
+  if (m_b2 && true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b2\) {$}}
+i = 24;
+  } else {
+i = 25;
+  }
+  m_b3 = (i > 20);
+  if (false && m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 26;
+  } else {
+i = 27;
+  }
+  m_b4 = (i > 20);
+  if (true && m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b4\) {$}}
+i = 28;
+  } else {
+i = 29;
+  }
+}
+
+void S::ternary_operator() {
+  int i = 0;
+  m_b1 = (i > 20) ? true : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b1 = i > 20;$}}
+
+  m_b2 = (i > 20) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b2 = i <= 20;$}}
+
+  m_b3 = ((i > 20)) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b3 = i <= 20;$}}
+}
+
+void S::operator_not_equal() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (false != m_b1) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+  

[PATCH] D56323: Handle member variables in readability-simplify-boolean-expr

2019-01-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 180274.
LegalizeAdulthood added a comment.

Fix typo in id


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

https://reviews.llvm.org/D56323

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  test/clang-tidy/readability-simplify-bool-expr-members.cpp

Index: test/clang-tidy/readability-simplify-bool-expr-members.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simplify-bool-expr-members.cpp
@@ -0,0 +1,360 @@
+// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t
+
+struct X {
+  explicit operator bool();
+};
+
+class A {
+public:
+  int m;
+};
+
+struct S {
+  S() : m_ar(s_a) {}
+
+  void operator_equals();
+  void operator_or();
+  void operator_and();
+  void ternary_operator();
+  void operator_not_equal();
+  void simple_conditional_assignment_statements();
+  void complex_conditional_assignment_statements();
+  void chained_conditional_assignment();
+  bool non_null_pointer_condition();
+  bool null_pointer_condition();
+  bool negated_non_null_pointer_condition();
+  bool negated_null_pointer_condition();
+  bool integer_not_zero();
+  bool member_pointer_nullptr();
+  bool integer_member_implicit_cast();
+  bool expr_with_cleanups();
+
+  bool m_b1 = false;
+  bool m_b2 = false;
+  bool m_b3 = false;
+  bool m_b4 = false;
+  int *m_p = nullptr;
+  int A::*m_m = nullptr;
+  int m_i = 0;
+  A *m_a = nullptr;
+  static A s_a;
+  A &m_ar;
+};
+
+void S::operator_equals() {
+  int i = 0;
+  m_b1 = (i > 2);
+  if (m_b1 == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 5;
+  } else {
+i = 6;
+  }
+  m_b2 = (i > 4);
+  if (m_b2 == false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b2\) {$}}
+i = 7;
+  } else {
+i = 9;
+  }
+  m_b3 = (i > 6);
+  if (true == m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 10;
+  } else {
+i = 11;
+  }
+  m_b4 = (i > 8);
+  if (false == m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(!m_b4\) {$}}
+i = 12;
+  } else {
+i = 13;
+  }
+}
+
+void S::operator_or() {
+  int i = 0;
+  m_b1 = (i > 10);
+  if (m_b1 || false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 14;
+  } else {
+i = 15;
+  }
+  m_b2 = (i > 10);
+  if (m_b2 || true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 16;
+  } else {
+i = 17;
+  }
+  m_b3 = (i > 10);
+  if (false || m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b3\) {$}}
+i = 18;
+  } else {
+i = 19;
+  }
+  m_b4 = (i > 10);
+  if (true || m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(true\) {$}}
+i = 20;
+  } else {
+i = 21;
+  }
+}
+
+void S::operator_and() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (m_b1 && false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 22;
+  } else {
+i = 23;
+  }
+  m_b2 = (i > 20);
+  if (m_b2 && true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b2\) {$}}
+i = 24;
+  } else {
+i = 25;
+  }
+  m_b3 = (i > 20);
+  if (false && m_b3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(false\) {$}}
+i = 26;
+  } else {
+i = 27;
+  }
+  m_b4 = (i > 20);
+  if (true && m_b4) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b4\) {$}}
+i = 28;
+  } else {
+i = 29;
+  }
+}
+
+void S::ternary_operator() {
+  int i = 0;
+  m_b1 = (i > 20) ? true : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b1 = i > 20;$}}
+
+  m_b2 = (i > 20) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b2 = i <= 20;$}}
+
+  m_b3 = ((i > 20)) ? false : true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}} in ternary expression result
+  // CHECK-FIXES: {{^  m_b3 = i <= 20;$}}
+}
+
+void S::operator_not_equal() {
+  int i = 0;
+  m_b1 = (i > 20);
+  if (false != m_b1) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: {{.*}} to boolean operator
+// CHECK-FIXES: {{^  if \(m_b1\) {$}}
+i = 30;
+  } else {
+i = 31;
+  }
+  m_b2 = (i > 20);
+  if (true != m_b2) {
+// CHECK-MESSAGES: :[[@L

[PATCH] D55620: [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2019-01-04 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D55620



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


[PATCH] D55620: [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2019-01-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 180272.
tejohnson added a comment.

Update comment


Repository:
  rC Clang

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

https://reviews.llvm.org/D55620

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/lto-newpm-pipeline.c


Index: test/CodeGen/lto-newpm-pipeline.c
===
--- test/CodeGen/lto-newpm-pipeline.c
+++ test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -59,6 +59,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -995,9 +996,11 @@
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
 MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
 
-  // Lastly, add a semantically necessary pass for LTO.
-  if (IsLTO || IsThinLTO)
+  // Lastly, add semantically necessary passes for LTO.
+  if (IsLTO || IsThinLTO) {
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
+  }
 } else {
   // Map our optimization levels into one of the distinct levels used to
   // configure the pipeline.
@@ -1018,10 +1021,12 @@
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
 Level, CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
 MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
 CodeGenOpts.DebugPassManager);
+MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else {
 MPM = PB.buildPerModuleDefaultPipeline(Level,


Index: test/CodeGen/lto-newpm-pipeline.c
===
--- test/CodeGen/lto-newpm-pipeline.c
+++ test/CodeGen/lto-newpm-pipeline.c
@@ -27,12 +27,14 @@
 
 // CHECK-FULL-O0: Starting llvm::Module pass manager run.
 // CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 // CHECK-FULL-O0: Finished llvm::Module pass manager run.
 
 // CHECK-THIN-O0: Starting llvm::Module pass manager run.
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 // CHECK-THIN-O0: Finished llvm::Module pass manager run.
@@ -48,6 +50,7 @@
 // LoopVectorizePass.
 // CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
 // CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
 // CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -59,6 +59,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -995,9 +996,11 @@
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))

[PATCH] D55620: [ThinLTO] Clang changes to utilize new pass to handle chains of aliases

2019-01-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

ping on the clang side change as well


Repository:
  rC Clang

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

https://reviews.llvm.org/D55620



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


[PATCH] D55865: [ObjC] Add a new attribute to opt-out of implicit callee retain/release in ARC

2019-01-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350422: [ObjCARC] Add an new attribute, 
objc_externally_retained (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55865?vs=180196&id=180271#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55865

Files:
  cfe/trunk/docs/AutomaticReferenceCounting.rst
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclObjC.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/CodeGenObjC/externally-retained.m
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
  cfe/trunk/test/SemaObjC/externally-retained-no-arc.m
  cfe/trunk/test/SemaObjC/externally-retained.m

Index: cfe/trunk/test/CodeGenObjC/externally-retained.m
===
--- cfe/trunk/test/CodeGenObjC/externally-retained.m
+++ cfe/trunk/test/CodeGenObjC/externally-retained.m
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fobjc-arc -fblocks -Wno-objc-root-class -O0 %s -S -emit-llvm -o - | FileCheck %s --dump-input-on-failure
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fobjc-arc -fblocks -Wno-objc-root-class -O0 -xobjective-c++ -std=c++11 %s -S -emit-llvm -o - | FileCheck %s --check-prefix CHECKXX --dump-input-on-failure
+
+#define EXT_RET __attribute__((objc_externally_retained))
+
+@interface ObjTy @end
+
+ObjTy *global;
+
+#if __cplusplus
+// Suppress name mangling in C++ mode for the sake of check lines.
+extern "C" void param(ObjTy *p);
+extern "C" void local();
+extern "C" void in_init();
+extern "C" void anchor();
+extern "C" void block_capture(ObjTy *);
+extern "C" void esc(void (^)());
+extern "C" void escp(void (^)(ObjTy *));
+extern "C" void block_param();
+#endif
+
+void param(ObjTy *p) EXT_RET {
+  // CHECK-LABEL: define void @param
+  // CHECK-NOT: llvm.objc.
+  // CHECK ret
+}
+
+void local() {
+  EXT_RET ObjTy *local = global;
+  // CHECK-LABEL: define void @local
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+
+void in_init() {
+  // Test that we do the right thing when a variable appears in it's own
+  // initializer. Here, we release the value stored in 'wat' after overwriting
+  // it, in case it was somehow set to point to a non-null object while it's
+  // initializer is being evaluated.
+  EXT_RET ObjTy *wat = 0 ? wat : global;
+
+  // CHECK-LABEL: define void @in_init
+  // CHECK: [[WAT:%.*]] = alloca
+  // CHECK-NEXT: store {{.*}} null, {{.*}} [[WAT]]
+  // CHECK-NEXT: [[GLOBAL:%.*]] = load {{.*}} @global
+  // CHECK-NEXT: [[WAT_LOAD:%.*]] = load {{.*}} [[WAT]]
+  // CHECK-NEXT: store {{.*}} [[GLOBAL]], {{.*}} [[WAT]]
+  // CHECK-NEXT: [[CASTED:%.*]] = bitcast {{.*}} [[WAT_LOAD]] to
+  // CHECK-NEXT: call void @llvm.objc.release(i8* [[CASTED]])
+
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+
+void esc(void (^)());
+
+void block_capture(ObjTy *obj) EXT_RET {
+  esc(^{ (void)obj; });
+
+  // CHECK-LABEL: define void @block_capture
+  // CHECK-NOT: llvm.objc.
+  // CHECK: call i8* @llvm.objc.retain
+  // CHECK-NOT: llvm.objc.
+  // CHECK: call void @esc
+  // CHECK-NOT: llvm.objc.
+  // CHECK: call void @llvm.objc.storeStrong({{.*}} null)
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+
+  // CHECK-LABEL: define {{.*}} void @__copy_helper_block_
+  // CHECK-NOT: llvm.objc.
+  // CHECK: llvm.objc.storeStrong
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+
+  // CHECK-LABEL: define {{.*}} void @__destroy_helper_block_
+  // CHECK-NOT: llvm.objc.
+  // CHECK: llvm.objc.storeStrong({{.*}} null)
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+
+void escp(void (^)(ObjTy *));
+
+void block_param() {
+  escp(^(ObjTy *p) EXT_RET {});
+
+  // CHECK-LABEL: define internal void @__block_param_block_invoke
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+
+@interface Inter
+-(void)m1: (ObjTy *)w;
+@end
+
+@implementation Inter
+-(void)m1: (ObjTy *) w EXT_RET {
+  // CHECK-LABEL: define internal void @"\01-[Inter m1:]"
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+-(void)m2: (ObjTy *) w EXT_RET {
+  // CHECK-LABEL: define internal void @"\01-[Inter m2:]"
+  // CHECK-NOT: llvm.objc.
+  // CHECK: ret
+}
+@end
+
+#if __cplusplus
+// Verify that the decltype(p) is resolved before 'p' is made implicitly const.
+__attribute__((objc_externally_retained))
+void foo(ObjTy *p, decltype(p) *) {}
+// CHECKXX: _Z3fooP5ObjTyPU8__strongS0_
+#endif
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===

r350422 - [ObjCARC] Add an new attribute, objc_externally_retained

2019-01-04 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Jan  4 10:33:06 2019
New Revision: 350422

URL: http://llvm.org/viewvc/llvm-project?rev=350422&view=rev
Log:
[ObjCARC] Add an new attribute, objc_externally_retained

This attribute, called "objc_externally_retained", exposes clang's
notion of pseudo-__strong variables in ARC. Pseudo-strong variables
"borrow" their initializer, meaning that they don't retain/release
it, instead assuming that someone else is keeping their value alive.

If a function is annotated with this attribute, implicitly strong
parameters of that function aren't implicitly retained/released in
the function body, and are implicitly const. This is useful to expose
for performance reasons, most functions don't need the extra safety
of the retain/release, so programmers can opt out as needed.

This attribute can also apply to declarations of local variables,
with similar effect.

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

Added:
cfe/trunk/test/CodeGenObjC/externally-retained.m
cfe/trunk/test/SemaObjC/externally-retained-no-arc.m
cfe/trunk/test/SemaObjC/externally-retained.m
Modified:
cfe/trunk/docs/AutomaticReferenceCounting.rst
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/docs/AutomaticReferenceCounting.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AutomaticReferenceCounting.rst?rev=350422&r1=350421&r2=350422&view=diff
==
--- cfe/trunk/docs/AutomaticReferenceCounting.rst (original)
+++ cfe/trunk/docs/AutomaticReferenceCounting.rst Fri Jan  4 10:33:06 2019
@@ -1734,20 +1734,78 @@ A program is ill-formed if it refers to
   rest of the language.  Not draining the pool during an unwind is apparently
   required by the Objective-C exceptions implementation.
 
+.. _arc.misc.externally_retained:
+
+Externally-Retained Variables
+-
+
+In some situations, variables with strong ownership are considered
+externally-retained by the implementation. This means that the variable is
+retained elsewhere, and therefore the implementation can elide retaining and
+releasing its value. Such a variable is implicitly ``const`` for safety. In
+contrast with ``__unsafe_unretained``, an externally-retained variable still
+behaves as a strong variable outside of initialization and destruction. For
+instance, when an externally-retained variable is captured in a block the value
+of the variable is retained and released on block capture and destruction. It
+also affects C++ features such as lambda capture, ``decltype``, and template
+argument deduction.
+
+Implicitly, the implementation assumes that the :ref:`self parameter in a
+non-init method ` and the :ref:`variable in a for-in loop
+` are externally-retained.
+
+Externally-retained semantics can also be opted into with the
+``objc_externally_retained`` attribute. This attribute can apply to strong 
local
+variables, functions, methods, or blocks:
+
+.. code-block:: objc
+
+  @class WobbleAmount;
+
+  @interface Widget : NSObject
+  -(void)wobble:(WobbleAmount *)amount;
+  @end
+
+  @implementation Widget
+
+  -(void)wobble:(WobbleAmount *)amount
+   __attribute__((objc_externally_retained)) {
+// 'amount' and 'alias' aren't retained on entry, nor released on exit.
+__attribute__((objc_externally_retained)) WobbleAmount *alias = amount;
+  }
+  @end
+
+Annotating a function with this attribute makes every parameter with strong
+retainable object pointer type externally-retained, unless the variable was
+explicitly qualified with ``__strong``. For instance, ``first_param`` is
+externally-retained (and therefore ``const``) below, but not ``second_param``:
+
+.. code-block:: objc
+
+  __attribute__((objc_externally_retained))
+  void f(NSArray *first_param, __strong NSArray *second_param) {
+// ...
+  }
+
+You can test if your compiler has support for ``objc_externally_retained`` with
+``__has_attribute``:
+
+.. code-block:: objc
+
+  #if __has_attribute(objc_externally_retained)
+  // Use externally retained...
+  #endif
+
 .. _arc.misc.self:
 
 ``self``
 
 
-The ``self`` parameter variable of an Objective-C method is never actually
-retained by the implementation.  It is undefined behavior, or at least
-dangerous, to cause an object to be deallocated during a message send to that
-object.
-
-To make this safe, for Objective-C instance methods ``self`` is implicitly
-``const`` unless the method is in th

[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-04 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

In D56215#1345880 , @krytarowski wrote:

> In D56215#1345845 , @ruiu wrote:
>
> > Not sure what I understand the point, but as to make lld work on/for 
> > NetBSD, I wonder if you can just add -L to the command line in the 
> > compiler driver. Isn't a NetBSD triple passed to the compiler driver? If 
> > so, I wonder if you can add a few extra options when invoking the linker.
>
>
> This describes the original patch of passing flags from compiler driver and 
> breaks GNU ld compat. Joerg expects to pass no extra `-L` or 
> `--disable-new-dtags` options, treating lld as a drop-in replacement for GNU 
> ld.


I don't think you would lose anything by passing `-L` and 
`--disable-new-dtags` from compiler driver. These flags wouldn't do any harm to 
GNU linkers.


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

https://reviews.llvm.org/D56215



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


Re: [PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-04 Thread Joerg Sonnenberger via cfe-commits
On Fri, Jan 04, 2019 at 02:48:35PM +, Alexander Richardson via Phabricator 
wrote:
> Or if you really need to call the linker directly without specifying
> search paths you could also install a shell script as /usr/bin/ld that
> passes the appropriate flags to /usr/bin/ld.lld?

That's not a honest suggestion, is it?

> I don't think ifdefs in the source code are a good idea. Cross linking
> should just work as expected. But you could look at the OS field in the
> first input ELF file to choose default config options/a different
> emulation for NetBSD.

No, #if is certainly wrong. Using the OS field doesn't work though,
because it is typically not set. I think only FreeBSD ever did.

> The approach we are using in CheriBSD to differentiate between MIPS and
> CHERI pure-capability to either pass an explicitly
> `-m elf_btsmip_cheri_fbsd`/ `-m elf_btsmip_fbsd` or infer whether it is
> CHERI or MIPS based on the e_flags field of the first input file.

Yeah, but introducing new emulation names goes back to having to modify
things, which would defeat the purpose just as well.

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


[PATCH] D55933: [Sema] Do not print default template parameters.

2019-01-04 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: lib/AST/TypePrinter.cpp:179
+// `X` gets canonicalized to `X`. We disable
+// canonicalization so that `printTag()`` can see the template parameters 
as
+// written.

courbet wrote:
> Quuxplusone wrote:
> > Nit: there's an extra ` on this line.
> > 
> > I think I vaguely understand the purpose of this switch now. It feels ugly, 
> > but I have no concrete suggestion for improvement. Do you not need a case 
> > here to delay canonicalization of `X&` also?
> Indeed. Fixed + added tests.
And `void(*)(X)`?  And possibly `int[X::value]`, but 
I think that might be what `Type::DependentSizedArray` is doing in there. And 
`void (^)(X)` in Objective-C++.

Surely there should be a list somewhere of all the "compound types" that need 
to go here. And then this starts feeling a lot like the visitor pattern. I 
still don't know how it _should_ look, but this switch is feeling ickier and 
ickier.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55933



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 3 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:23
+static bool isAliasedTemplateParamType(QualType ParamType) {
+  return (ParamType.getCanonicalType()->isTemplateTypeParmType() ||
+  ParamType->isInstantiationDependentType());

JonasToth wrote:
> I think you don't need the first part of that condition. 
> `isInstantiationDependent` should include that, no?
> 
> I would prefer having this as a matcher, but i don't insist.
I agree, cleaner less code and easier to understand..moving it to a matcher



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:111
+ hasAnyParameter(anyOf(
+ parmVarDecl(hasType(references(functionObj))),
+ parmVarDecl(hasType(functionObj)),

JonasToth wrote:
> you can merge these two lines with `anyOf(functionObj, 
> references(functionObj))`, i think thats cleaner
I had to move the hasType inside the anyOf?



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:130
+  // Check for the existence of the keyword being used as the 
``[[nodiscard]]``.
+  if (!doesNoDiscardMacroExist(Context, NoDiscardMacro)) {
+diag(retLoc, "function %0 should be marked " + NoDiscardMacro)

JonasToth wrote:
> Please remove the duplication with `diag`.
> You can store the diagnostic in flight and append something afterwards:
> 
> ```
> auto Diag = diag(...);
> 
> if (canTransform)
>Diag << Change;
> ```
that feels cleaner


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

https://reviews.llvm.org/D55433



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 180266.
MyDeveloperDay marked 4 inline comments as done.
MyDeveloperDay added a comment.

Update with view comments from @JonasToth

- remove unnecessary static functions
- move checks into matchers
- remove duplicated diag call


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

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp
  test/clang-tidy/modernize-use-nodiscard.h

Index: test/clang-tidy/modernize-use-nodiscard.h
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.h
@@ -0,0 +1,5 @@
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,218 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17 
+
+#include 
+
+namespace boost {
+template  
+class function;
+}
+
+#include "modernize-use-nodiscard.h"
+
+#define BOOLEAN_FUNC bool f23() const
+
+typedef unsigned my_unsigned;
+typedef unsigned &my_unsigned_reference;
+typedef const unsigned &my_unsigned_const_reference;
+
+class Foo {
+public:
+using size_type = unsigned;
+
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard] 
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+
+bool f6();
+
+bool f7(int &);
+
+bool f8(int &) const;
+
+bool f9(int *) const;
+
+bool f10(const int &, int &) const;
+
+NO_DISCARD bool f12() const;
+
+MUST_USE_RESULT bool f13() const;
+
+[[nodiscard]] bool f11() const;
+
+[[clang::warn_unused_result]] bool f11a() const;
+
+[[gnu::warn_unused_result]] bool f11b() const;
+
+bool _f20() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool _f20() const;
+
+NO_RETURN bool f21() const;
+
+~Foo();
+
+bool operator+=(int) const;
+
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD const bool f15() const;
+
+inline const bool f16() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const bool f16() const;
+
+inline const std::string &f45() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f45' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const std::string &f45() const;
+
+inline virtual const bool f17() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
+
+// inline with body
+bool f18() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f18' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f18() const {
+return 

[PATCH] D55865: [ObjC] Add a new attribute to opt-out of implicit callee retain/release in ARC

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

LGTM aside from a few minor nits/questions.




Comment at: clang/docs/AutomaticReferenceCounting.rst:1747
+contrast with ``__unsafe_unretained``, an externally-retained variable still
+behaves as a strong variable outside of initialization and deinitialization. 
For
+instance, when an externally-retained variable is captured in a block the value

deinitialization -> destruction  ?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6160
+  for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); I != E; ++I) {
+auto *PVD = const_cast(getFunctionOrMethodParam(D, I));
+QualType Ty = PVD->getType();

The `const_cast<>` here feels a bit nasty, but I'm not certain it's worth an 
overload of `getFunctionOrMethodParam()` to hide it away. Your call on whether 
you want to add the overload or not.


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

https://reviews.llvm.org/D55865



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-04 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

In D56215#1346342 , @arichardson wrote:

> In D56215#1346061 , @mgorny wrote:
>
> > For the record, another option is to actually fix other software not to 
> > call LD directly.
>
>
> Or if you really need to call the linker directly without specifying search 
> paths you could also install a shell script as /usr/bin/ld that passes the 
> appropriate flags to /usr/bin/ld.lld?
>
> I don't think ifdefs in the source code are a good idea. Cross linking should 
> just work as expected. But you could look at the OS field in the first input 
> ELF file to choose default config options/a different emulation for NetBSD.
>
> The approach we are using in CheriBSD to differentiate between MIPS and CHERI 
> pure-capability to either pass an explicitly `-m elf_btsmip_cheri_fbsd`/ `-m 
> elf_btsmip_fbsd` or infer whether it is CHERI or MIPS based on the e_flags 
> field of the first input file.


This would be the best option to use a shell wrapper for someone who needs it, 
but we cannot convince Joerg for almost 2 years.


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

https://reviews.llvm.org/D56215



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


[PATCH] D53891: [LTO] Add option to enable LTOUnit splitting, and disable unless needed

2019-01-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D53891



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


[PATCH] D55710: add pragmas to control Software Pipelining optimisation

2019-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I commit this in r350414, thank you for the patch!


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

https://reviews.llvm.org/D55710



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


r350415 - [OPENMP][NVPTX]Use new functions from the runtime library.

2019-01-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jan  4 09:25:09 2019
New Revision: 350415

URL: http://llvm.org/viewvc/llvm-project?rev=350415&view=rev
Log:
[OPENMP][NVPTX]Use new functions from the runtime library.

Updated codegen to use the new functions from the runtime library.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=350415&r1=350414&r2=350415&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Jan  4 09:25:09 2019
@@ -56,12 +56,12 @@ enum OpenMPRTLFunctionNVPTX {
   /// Call to int64_t __kmpc_shuffle_int64(int64_t element,
   /// int16_t lane_offset, int16_t warp_size);
   OMPRTL_NVPTX__kmpc_shuffle_int64,
-  /// Call to __kmpc_nvptx_parallel_reduce_nowait(kmp_int32
+  /// Call to __kmpc_nvptx_parallel_reduce_nowait_v2(ident_t *loc, kmp_int32
   /// global_tid, kmp_int32 num_vars, size_t reduce_size, void* reduce_data,
   /// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
-  OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
+  OMPRTL_NVPTX__kmpc_parallel_reduce_nowait_v2,
   /// Call to __kmpc_nvptx_teams_reduce_nowait_simple(ident_t *loc, kmp_int32
   /// global_tid, kmp_critical_name *lck)
   OMPRTL_NVPTX__kmpc_nvptx_teams_reduce_nowait_simple,
@@ -91,10 +91,11 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_parallel_level,
   /// Call to int8_t __kmpc_is_spmd_exec_mode();
   OMPRTL_NVPTX__kmpc_is_spmd_exec_mode,
-  /// Call to void __kmpc_get_team_static_memory(const void *buf, size_t size,
-  /// int16_t is_shared, const void **res);
+  /// Call to void __kmpc_get_team_static_memory(int16_t isSPMDExecutionMode,
+  /// const void *buf, size_t size, int16_t is_shared, const void **res);
   OMPRTL_NVPTX__kmpc_get_team_static_memory,
-  /// Call to void __kmpc_restore_team_static_memory(int16_t is_shared);
+  /// Call to void __kmpc_restore_team_static_memory(int16_t
+  /// isSPMDExecutionMode, int16_t is_shared);
   OMPRTL_NVPTX__kmpc_restore_team_static_memory,
   /// Call to void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid);
   OMPRTL__kmpc_barrier,
@@ -1646,12 +1647,12 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_shuffle_int64");
 break;
   }
-  case OMPRTL_NVPTX__kmpc_parallel_reduce_nowait: {
-// Build int32_t kmpc_nvptx_parallel_reduce_nowait(kmp_int32 global_tid,
-// kmp_int32 num_vars, size_t reduce_size, void* reduce_data,
-// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
-// lane_offset, int16_t Algorithm Version),
-// void (*kmp_InterWarpCopyFctPtr)(void* src, int warp_num));
+  case OMPRTL_NVPTX__kmpc_parallel_reduce_nowait_v2: {
+// Build int32_t kmpc_nvptx_parallel_reduce_nowait_v2(ident_t *loc,
+// kmp_int32 global_tid, kmp_int32 num_vars, size_t reduce_size, void*
+// reduce_data, void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t
+// lane_id, int16_t lane_offset, int16_t Algorithm Version), void
+// (*kmp_InterWarpCopyFctPtr)(void* src, int warp_num));
 llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
  CGM.Int16Ty, CGM.Int16Ty};
 auto *ShuffleReduceFnTy =
@@ -1661,7 +1662,8 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 auto *InterWarpCopyFnTy =
 llvm::FunctionType::get(CGM.VoidTy, InterWarpCopyTypeParams,
 /*isVarArg=*/false);
-llvm::Type *TypeParams[] = {CGM.Int32Ty,
+llvm::Type *TypeParams[] = {getIdentTyPointerTy(),
+CGM.Int32Ty,
 CGM.Int32Ty,
 CGM.SizeTy,
 CGM.VoidPtrTy,
@@ -1670,7 +1672,7 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 auto *FnTy =
 llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg=*/false);
 RTLFn = CGM.CreateRuntimeFunction(
-Fn

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-04 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Mostly nits left. I think the check is good to go afterwards :)




Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:23
+static bool isAliasedTemplateParamType(QualType ParamType) {
+  return (ParamType.getCanonicalType()->isTemplateTypeParmType() ||
+  ParamType->isInstantiationDependentType());

I think you don't need the first part of that condition. 
`isInstantiationDependent` should include that, no?

I would prefer having this as a matcher, but i don't insist.



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:111
+ hasAnyParameter(anyOf(
+ parmVarDecl(hasType(references(functionObj))),
+ parmVarDecl(hasType(functionObj)),

you can merge these two lines with `anyOf(functionObj, 
references(functionObj))`, i think thats cleaner



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:128
+
+  auto &Context = *Result.Context;
+  // Check for the existence of the keyword being used as the 
``[[nodiscard]]``.

I would say ok-ish, but `ASTContext &Context = *Result.Context;` would be 
better.



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:130
+  // Check for the existence of the keyword being used as the 
``[[nodiscard]]``.
+  if (!doesNoDiscardMacroExist(Context, NoDiscardMacro)) {
+diag(retLoc, "function %0 should be marked " + NoDiscardMacro)

Please remove the duplication with `diag`.
You can store the diagnostic in flight and append something afterwards:

```
auto Diag = diag(...);

if (canTransform)
   Diag << Change;
```


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

https://reviews.llvm.org/D55433



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


r350414 - Add two new pragmas for controlling software pipelining optimizations.

2019-01-04 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jan  4 09:20:00 2019
New Revision: 350414

URL: http://llvm.org/viewvc/llvm-project?rev=350414&view=rev
Log:
Add two new pragmas for controlling software pipelining optimizations.

This patch adds #pragma clang loop pipeline and #pragma clang loop 
pipeline_initiation_interval for debugging or reducing compile time purposes. 
It is possible to disable SWP for concrete loops to save compilation time or to 
find bugs by not doing SWP to certain loops. It is possible to set value of 
initiation interval to concrete number to save compilation time by not doing 
extra pipeliner passes or to check created schedule for specific initiation 
interval.

Patch by Alexey Lapshin.

Added:
cfe/trunk/test/CodeGenCXX/pragma-pipeline.cpp
cfe/trunk/test/Parser/pragma-pipeline.cpp
cfe/trunk/test/Sema/pragma-pipeline.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGLoopInfo.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/SemaStmtAttr.cpp
cfe/trunk/test/Parser/pragma-loop.cpp
cfe/trunk/test/Parser/pragma-unroll-and-jam.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=350414&r1=350413&r2=350414&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jan  4 09:20:00 2019
@@ -2867,7 +2867,9 @@ def LoopHint : Attr {
   /// unroll_count: unrolls loop 'Value' times.
   /// unroll_and_jam: attempt to unroll and jam loop if State == Enable.
   /// unroll_and_jam_count: unroll and jams loop 'Value' times.
-  /// distribute: attempt to distribute loop if State == Enable
+  /// distribute: attempt to distribute loop if State == Enable.
+  /// pipeline: disable pipelining loop if State == Disable.
+  /// pipeline_initiation_interval: create loop schedule with initiation 
interval equal to 'Value'.
 
   /// #pragma unroll  directive
   /// : fully unrolls loop.
@@ -2882,10 +2884,10 @@ def LoopHint : Attr {
   let Args = [EnumArgument<"Option", "OptionType",
   ["vectorize", "vectorize_width", "interleave", 
"interleave_count",
"unroll", "unroll_count", "unroll_and_jam", 
"unroll_and_jam_count",
-   "distribute"],
+   "pipeline", "pipeline_initiation_interval", 
"distribute"],
   ["Vectorize", "VectorizeWidth", "Interleave", 
"InterleaveCount",
"Unroll", "UnrollCount", "UnrollAndJam", 
"UnrollAndJamCount",
-   "Distribute"]>,
+   "PipelineDisabled", "PipelineInitiationInterval", 
"Distribute"]>,
   EnumArgument<"State", "LoopHintState",
["enable", "disable", "numeric", "assume_safety", 
"full"],
["Enable", "Disable", "Numeric", "AssumeSafety", 
"Full"]>,
@@ -2902,6 +2904,8 @@ def LoopHint : Attr {
 case UnrollCount: return "unroll_count";
 case UnrollAndJam: return "unroll_and_jam";
 case UnrollAndJamCount: return "unroll_and_jam_count";
+case PipelineDisabled: return "pipeline";
+case PipelineInitiationInterval: return "pipeline_initiation_interval";
 case Distribute: return "distribute";
 }
 llvm_unreachable("Unhandled LoopHint option.");

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=350414&r1=350413&r2=350414&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Jan  4 09:20:00 2019
@@ -2578,10 +2578,10 @@ def LoopHintDocs : Documentation {
   let Heading = "#pragma clang loop";
   let Content = [{
 The ``#pragma clang loop`` directive allows loop optimization hints to be
-specified for the subsequent loop. The directive allows vectorization,
-interleaving, and unrolling to be enabled or disabled. Vector width as well
-as interleave and unrolling count can be manually specified. See
-`language extensions
+specified for the subsequent loop. The directive allows pipelining to be
+disabled, or vectorization, interleaving, and unrolling to be enabled or 
disabled.
+Vector width, interleave count, unrolling count, and the initiation interval
+for pipelining can be explicitly specified. See `language extensions
 
`_
 for details.
   }];
@@ -2642,6 +2642,56 @@ for further details including limitation
   }];
 }
 
+def PipelineHintDocs : Documentation {
+  let Category = 

[PATCH] D55955: Properly diagnose [[nodiscard]] on the body of a range-based for loop

2019-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed with minor modifications for the range-based for loop changes in 
r350404.


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

https://reviews.llvm.org/D55955



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


[PATCH] D56090: Add a matcher for members of an initializer list expression

2019-01-04 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked 4 inline comments as done.
hwright added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3527
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder);

klimek wrote:
> aaron.ballman wrote:
> > hwright wrote:
> > > aaron.ballman wrote:
> > > > I'm not certain we want the `IgnoreParenImpCasts()` here -- what if 
> > > > someone wants to match an initializer that uses one of those properties?
> > > The `hasArg` implementation directly above has the same call to 
> > > `IgnoreParenImpCasts()`.  Is it also in error?  (It would seem that they 
> > > should both be consistent.)
> > Yeah, I noticed that as well. Doing some code archaeology, it seems that 
> > `hasArg()` has had that form since its inception and it was never 
> > explicitly discussed what should happen there.
> > 
> > @klimek -- do you have opinions here, since you wrote the original code for 
> > `hasArg()`? Should we be leaving the paren and implicit cast stripping up 
> > to the caller rather than doing it automatically?
> Sigh, yea, this is one of those hard decisions: in the end, we decided that 
> the downside of surprise of users not seeing what they expected (due to an 
> imp cast) was less bad than basically taking away the ability to match imp 
> casts, so we stopped putting ignoreparenimpcasts everywhere. I'm not entirely 
> sure how to rate consistency with hasArg vs. getting us towards a more 
> explicit world, but my gut would probably go with leaving the 
> ignoreparenimpcasts out and see how bad people find it.
Removed the call to `IgnoreParenImpCasts()`.


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

https://reviews.llvm.org/D56090



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


r350404 - Refactor the way we handle diagnosing unused expression results.

2019-01-04 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jan  4 08:58:14 2019
New Revision: 350404

URL: http://llvm.org/viewvc/llvm-project?rev=350404&view=rev
Log:
Refactor the way we handle diagnosing unused expression results.

Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where 
we want diagnostics, we now diagnose unused expression statements and full 
expressions in a more generic way when acting on the final expression 
statement. This results in more appropriate diagnostics for [[nodiscard]] where 
we were previously lacking them, such as when the body of a for loop is not a 
compound statement.

This patch fixes PR39837.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaCoroutine.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/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CXX/stmt.stmt/stmt.select/p3.cpp
cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
cfe/trunk/test/Parser/cxx1z-init-statement.cpp
cfe/trunk/test/Parser/switch-recovery.cpp
cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
cfe/trunk/test/SemaCXX/for-range-examples.cpp
cfe/trunk/test/SemaCXX/warn-unused-result.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=350404&r1=350403&r2=350404&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jan  4 08:58:14 2019
@@ -360,6 +360,11 @@ class Parser : public CodeCompletionHand
   /// just a regular sub-expression.
   SourceLocation ExprStatementTokLoc;
 
+  /// Tests whether an expression value is discarded based on token lookahead.
+  /// It will return true if the lexer is currently processing the })
+  /// terminating a GNU statement expression and false otherwise.
+  bool isExprValueDiscarded();
+
 public:
   Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
   ~Parser() override;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350404&r1=350403&r2=350404&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan  4 08:58:14 2019
@@ -1365,6 +1365,7 @@ public:
   void PopCompoundScope();
 
   sema::CompoundScopeInfo &getCurCompoundScope() const;
+  bool isCurCompoundStmtAStmtExpr() const;
 
   bool hasAnyUnrecoverableErrorsInThisFunction() const;
 
@@ -3685,16 +3686,17 @@ public:
 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
   }
   FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
-return FullExprArg(ActOnFinishFullExpr(Arg, CC).get());
+return FullExprArg(
+ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
   }
   FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) {
 ExprResult FE =
-  ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
-  /*DiscardedValue*/ true);
+ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
+/*DiscardedValue*/ true);
 return FullExprArg(FE.get());
   }
 
-  StmtResult ActOnExprStmt(ExprResult Arg);
+  StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
   StmtResult ActOnExprStmtError();
 
   StmtResult ActOnNullStmt(SourceLocation SemiLoc,
@@ -5340,13 +5342,12 @@ public:
   CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
  bool BoundToLvalueReference);
 
-  ExprResult ActOnFinishFullExpr(Expr *Expr) {
-return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc()
-  : SourceLocation());
+  ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
+return ActOnFinishFullExpr(
+Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
   }
   ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
- bool DiscardedValue = false,
- bool IsConstexpr = false);
+ bool DiscardedValue, bool IsConstexpr = 
false);
   StmtResult ActOnFinishFullStmt(Stmt *Stmt);
 
   // Marks SS invalid if it represents an incomplete type.

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=350404&r1=350403&r2=350404&view=diff

[PATCH] D56090: Add a matcher for members of an initializer list expression

2019-01-04 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 180248.
hwright added a comment.

Removed `IgnoreParenImpCasts` call.


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

https://reviews.llvm.org/D56090

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2255,6 +2255,18 @@
   notMatches("void x() { int a; if(a == 0) return; }", BinAsgmtOperator));
 }
 
+TEST(HasInit, Basic) {
+  EXPECT_TRUE(
+matches("int x{0};",
+initListExpr(hasInit(0, expr();
+  EXPECT_FALSE(
+matches("int x{0};",
+initListExpr(hasInit(1, expr();
+  EXPECT_FALSE(
+matches("int x;",
+initListExpr(hasInit(0, expr();
+}
+
 TEST(Matcher, isMain) {
   EXPECT_TRUE(
 matches("int main() {}", functionDecl(isMain(;
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -273,6 +273,7 @@
   REGISTER_MATCHER(hasInClassInitializer);
   REGISTER_MATCHER(hasIncrement);
   REGISTER_MATCHER(hasIndex);
+  REGISTER_MATCHER(hasInit);
   REGISTER_MATCHER(hasInitializer);
   REGISTER_MATCHER(hasKeywordSelector);
   REGISTER_MATCHER(hasLHS);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3514,6 +3514,19 @@
   *Node.getArg(N)->IgnoreParenImpCasts(), Finder, Builder));
 }
 
+/// Matches the n'th item of an initializer list expression.
+///
+/// Example matches y.
+/// (matcher = initListExpr(hasInit(0, expr(
+/// \code
+///   int x{y}.
+/// \endcode
+AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N), Finder, Builder);
+}
+
 /// Matches declaration statements that contain a specific number of
 /// declarations.
 ///
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -718,7 +718,7 @@
 
 
 MatcherStmt>blockExprMatcherBlockExpr>...
-MAtches a reference to a 
block.
+Matches a reference to a 
block.
 
 Example: matches "^{}":
   void f() { ^{}(); }
@@ -5866,6 +5866,15 @@
 
 
 
+MatcherInitListExpr>hasInitunsigned N, 
ast_matchers::MatcherExpr> 
InnerMatcher
+Matches the n'th item of an 
initializer list expression.
+
+Example matches y.
+(matcher = initListExpr(hasInit(0, expr(
+  int x{y}.
+
+
+
 MatcherInitListExpr>hasSyntacticFormMatcherExpr> 
InnerMatcher
 Matches the 
syntactic form of init list expressions
 (if expression have it).


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2255,6 +2255,18 @@
   notMatches("void x() { int a; if(a == 0) return; }", BinAsgmtOperator));
 }
 
+TEST(HasInit, Basic) {
+  EXPECT_TRUE(
+matches("int x{0};",
+initListExpr(hasInit(0, expr();
+  EXPECT_FALSE(
+matches("int x{0};",
+initListExpr(hasInit(1, expr();
+  EXPECT_FALSE(
+matches("int x;",
+initListExpr(hasInit(0, expr();
+}
+
 TEST(Matcher, isMain) {
   EXPECT_TRUE(
 matches("int main() {}", functionDecl(isMain(;
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -273,6 +273,7 @@
   REGISTER_MATCHER(hasInClassInitializer);
   REGISTER_MATCHER(hasIncrement);
   REGISTER_MATCHER(hasIndex);
+  REGISTER_MATCHER(hasInit);
   REGISTER_MATCHER(hasInitializer);
   REGISTER_MATCHER(hasKeywordSelector);
   REGISTER_MATCHER(hasLHS);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3514,6 +3514,19 @@
   *Node.

[PATCH] D56225: [HIP] Use nul instead of /dev/null when running on windows

2019-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:210
   std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
-  std::string BundlerInputArg = "-inputs=/dev/null";
+  std::string BundlerInputArg = "-inputs=" NULL_FILE;
 

How hard would it be to just implement the TODO and get away from a reliance on 
a null file?


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

https://reviews.llvm.org/D56225



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

What's the general idea here, that you're going to pretend to be the 
environment's "standard" CPU target of the right pointer width and try to match 
the ABI exactly?  This seems like a pretty treacherous road to go down.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56321: [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types

2019-01-04 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 created this revision.
ashi1 added a reviewer: yaxunl.
Herald added a subscriber: cfe-commits.

The offload bundler action should not unbundle the input file types that does 
not match the action type. This fixes an issue where .so files are unbundled 
when the action type is object files.


Repository:
  rC Clang

https://reviews.llvm.org/D56321

Files:
  lib/Driver/Driver.cpp
  test/Driver/hip-offload.hip


Index: test/Driver/hip-offload.hip
===
--- test/Driver/hip-offload.hip
+++ test/Driver/hip-offload.hip
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o %S/Inputs/in.so \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], 
outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"]
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], 
output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], 
output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", 
"{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2323,6 +2323,18 @@
   // If this is an unbundling action use it as is for each CUDA toolchain.
   if (auto *UA = dyn_cast(HostAction)) {
 CudaDeviceActions.clear();
+auto *IA = cast(UA->getInputs().back());
+std::string FileName = IA->getInputArg().getAsString(Args);
+// Check if the type of the file is the same as the action. Do not
+// unbundle it if it is not. Do not unbundle .so files, for example,
+// which are not object files.
+if (IA->getType() == types::TY_Object &&
+(!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+  return ABRT_Inactive;
+
 for (auto Arch : GpuArchList) {
   CudaDeviceActions.push_back(UA);
   UA->registerDependentActionInfo(ToolChains[0], 
CudaArchToString(Arch),


Index: test/Driver/hip-offload.hip
===
--- test/Driver/hip-offload.hip
+++ test/Driver/hip-offload.hip
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+// RUN: %clang --hip-link -ccc-print-bindings -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %t.o %S/Inputs/in.so \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: # "amdgcn-amd-amdhsa" - "offload bundler", inputs: ["[[IN:.*o]]"], outputs: ["[[OBJ1:.*o]]", "[[OBJ2:.*o]]", "[[OBJ3:.*o]]"]
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ2]]"], output: "[[IMG2:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[OBJ3]]"], output: "[[IMG3:.*out]]"
+// CHECK-NOT: offload bundler
+// CHECK: # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[OBJ1]]", "{{.*}}/Inputs/in.so", "[[IMG2]]", "[[IMG3]]"], output: "a.out"
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2323,6 +2323,18 @@
   // If this is an unbundling action use it as is for each CUDA toolchain.
   if (auto *UA = dyn_cast(HostAction)) {
 CudaDeviceActions.clear();
+auto *IA = cast(UA->getInputs().back());
+std::string FileName = IA->getInputArg().getAsString(Args);
+// Check if the type of the file is the same as the action. Do not
+// unbundle it if it is not. Do not unbundle .so files, for example,
+// which are not object files.
+if (IA->getType() == types::TY_Object &&
+(!llvm::sys::path::has_extension(FileName) ||
+ types::lookupTypeForExtension(
+ llvm::sys::path::extension(FileName).drop_front()) !=
+ types::TY_Object))
+  return ABRT_Inactive;
+
 for (auto Arch : GpuArchList) {
   CudaDeviceActions.push_back(UA);
   UA->registerDependentActionInfo(ToolChains[0], CudaArchToString(Arch),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55948: Modify DeclaratorChuck::getFunction to use DeclSpec for qualifiers

2019-01-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:8175
   DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo();
-  if (FTI.TypeQuals != 0) {
-if (FTI.TypeQuals & Qualifiers::Const)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "const" << SourceRange(D.getIdentifierLoc());
-if (FTI.TypeQuals & Qualifiers::Volatile)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "volatile" << SourceRange(D.getIdentifierLoc());
-if (FTI.TypeQuals & Qualifiers::Restrict)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "restrict" << SourceRange(D.getIdentifierLoc());
+  if (FTI.MethodQualifiers && FTI.MethodQualifiers->getTypeQualifiers() != 0) {
+auto DiagQual = [&](DeclSpec::TQ TypeQual, StringRef QualName,

Anastasia wrote:
> rjmccall wrote:
> > Anastasia wrote:
> > > rjmccall wrote:
> > > > Anastasia wrote:
> > > > > rjmccall wrote:
> > > > > > I think you should add a `hasMethodQualifiers` method to FTI that 
> > > > > > does this check.  Note that it needs to check for attributes, too, 
> > > > > > and I think you need to figure out some way to generalize 
> > > > > > `forEachCVRUQual` to cover those.
> > > > > Are there any attributes I should handle currently?
> > > > > 
> > > > > Also are you suggesting to add another `forEach...` method or extend 
> > > > > existing? If the latter, I might not be able to use it in all places 
> > > > > I use it now.
> > > > Adding another method might be easier.  How many clients actually use 
> > > > the TQ?
> > > In **DeclSpec.cpp** I definitely  need just TQ. I am not sure about 
> > > **SemaType.cpp**. All other places (3x) I guess should be possible to 
> > > generalize. Although I am not very clear if I should be checking all 
> > > attr. It might be a bit exhaustive since the use cases are for the 
> > > function?
> > > 
> > > Perhaps, I could add an extra helper `forEachQualifier` that can call 
> > > `forEachCVRUQual` and then I could add a FIXME to complete the rest. We 
> > > can extend it as we discover what's missing. For example I will add 
> > > address spaces there in my next patch. Would this make sense?
> > > 
> > > As for `hasMethodQualifiers` just to be clear I would need to check for 
> > > all qualifiers including reference qualifier, attributes, etc?
> > That seems like a reasonable short-term plan.  Maybe there needs to be some 
> > way to describe an individual qualifier; we can hash that out in a separate 
> > patch.
> > 
> > > As for `hasMethodQualifiers` just to be clear I would need to check for 
> > > all qualifiers including reference qualifier, attributes, etc?
> > 
> > Maybe, although at least one of the cases below wants to check for 
> > ref-qualifiers separately.  Maybe it should be `hasMethodTypeQualifiers`, 
> > and it implies that `MethodQualifiers->forEachQualifier` will invoke the 
> > callback at least once.
> I think it should be sufficient to check that `MethodQualifiers` exist 
> because we only create it if we have either a type qual or any attribute. 
Hmm.  I think we can remove qualifiers, and we do sometimes (at least in 
recovery situations, and possibly in others), so it's better not to rely on 
that.  But I think for attributes you can just check whether there are any 
attributes rather than carefully checking whether any attribute is a type 
qualifier.


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

https://reviews.llvm.org/D55948



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


[PATCH] D55337: NFC: Move dumpDeclRef to NodeDumper

2019-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/TextNodeDumper.h:28
const comments::FullComment *> {
+  TextTreeStructure &TreeStructure;
   raw_ostream &OS;

steveire wrote:
> aaron.ballman wrote:
> > This makes me a bit wary because you create a node dumper in the same 
> > situations you make a tree structure object, but now there's a strict 
> > ordering between the two object creations. If you're doing this 
> > construction local to a function, you wind up with a dangling reference 
> > unless you're careful (which is unfortunate, but not the end of the world). 
> > If you're doing this construction as part of a constructor's initializer 
> > list, you now have to properly order the member declarations within the 
> > class and that is also unfortunate. Given that those are the two common 
> > scenarios for how I envision constructing an ast dump of some kind, I worry 
> > about the fragility. e.g.,
> > ```
> > unique_ptr createASTDumper(...) {
> >   TextTreeStructure TreeStructure;
> >   TextNodeDumper NodeDumper(TreeStructure); // Oops, dangling reference
> >   return make_unique(TreeStructure, NodeDumper, 
> > ...);
> > }
> > 
> > // vs
> > 
> > struct MySuperAwesomeASTDumper : ... {
> >   MySuperAwesomeASTDumper() : TreeStructure(...), NodeDumper(TreeStructure, 
> > ...) {}
> > private:
> >   TextTreeStructure TreeStructure; // This order is now SUPER important
> >   TextNodeDumper NodeDumper;
> > };
> > ```
> > There's a part of me that wonders if a better approach is to have this 
> > object passed to the `dumpFoo()` calls as a reference parameter. This way, 
> > the caller is still responsible for creating an object, but the creation 
> > order between the tree and the node dumper isn't as fragile.
> In your first snippet there is a dangling reference because the author of 
> `MySuperAwesomeASTDumper` decided to make the members references. If the 
> members are references, code like your first snippet will cause dangling 
> references and nothing can prevent that. Adding `TreeStructure&` to Visit 
> methods as you suggested does not prevent it.
> 
> The only solution is make the `MySuperAwesomeASTDumper` not use member 
> references (ie your second snippet). The order is then in fact not 
> problematic because "taking a reference to an uninitialized object is legal".
>  The order is then in fact not problematic because "taking a reference to an 
> uninitialized object is legal".

This presumes that the constructors aren't using those references to the 
uninitialized object, which would be illegal. That's what I mean about this 
being very fragile -- if the stars line up correctly, everything works fine, 
but if the stars aren't aligned just right, you get really hard problems to 
track down.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55337



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


[PATCH] D55955: Properly diagnose [[nodiscard]] on the body of a range-based for loop

2019-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 3 inline comments as done.
aaron.ballman added inline comments.



Comment at: test/Parser/switch-recovery.cpp:108
   expected-error {{no member named 'x' in the global namespace; 
did you mean simply 'x'?}} \
-  expected-warning 2 {{expression result unused}}
+  expected-warning {{expression result unused}}
 9:: :y; // expected-error {{expected ';' after expression}} \

rsmith wrote:
> Hmm, why do we only get one warning here? I'd expect one warning for the `8;` 
> and one for the `x;` (after applying the fixes from the errors).
We get the one for the `8;` but the other one is a `TypoExpr` and it claims 
it's type dependent, and we don't warn on type dependent so we bail out pretty 
early in `Expr::isUnusedResultAWarning()`.



Comment at: test/SemaCXX/for-range-examples.cpp:181
 for (+x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} 
expected-error {{expected ';'}}
-for (+y : {1, 2, 3}) {} // expected-error {{must declare a variable}}
+for (+y : {1, 2, 3}) {} // expected-error {{must declare a variable}} 
expected-warning {{expression result unused}}
   }

rsmith wrote:
> The new warnings here aren't ideal; do you know why they show up?
Because the first part in a for loop can be an expression, but only if it's not 
a range-based for loop. However, I was able to do some lookahead to retain the 
old behavior here.


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

https://reviews.llvm.org/D55955



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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:9736
 
+static bool rejectConstNotMutableType(Sema &SemaRef, ValueDecl *D,
+  OpenMPClauseKind CKind,

ABataev wrote:
> ABataev wrote:
> > This function and the original code has a lot of common code. Could you, 
> > please, use this function somehow for the original too? Or outline the 
> > common code into standalone function
> Also, probably missed the check if the OpenMP version is >= 4.0
> This function and the original code has a lot of common code. Could you, 
> please, use this function somehow for the original too? Or outline the common 
> code into standalone function

Sure, I'll work on that.

> Also, probably missed the check if the OpenMP version is >= 4.0

This is what I was trying to explain in my last comment: I now realize that 3.1 
also has the const restriction for private and lastprivate.  For example:

> A variable that appears in a private clause must not have a const-qualified 
> type
> unless it is of class type with a mutable member. 

To make it clear that this isn't limited to 4.0 and later, perhaps I should 
also quote 3.1 at the calls to  rejectConstNotMutableType.

However, clang didn't previously implement those restrictions for private and 
lastprivate probably because the check for conflicts with predetermined shared 
was sufficient to catch those cases.

So, for 3.1, it should be correct for clang to report either diagnostic, but 
again I think the new diagnostic is clearer. For 4.0 and later, only the new 
diagnostic makes sense.  So, my patch makes clang report the new diagnostic for 
all OpenMP versions.

Of course, I can adjust if this doesn't make sense to you.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56113



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


Re: [PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-04 Thread Joerg Sonnenberger via cfe-commits
On Fri, Jan 04, 2019 at 05:52:46AM +, Michał Górny via Phabricator via 
llvm-commits wrote:
> mgorny added a comment.
> 
> For the record, another option is to actually fix other software not to call 
> LD directly.

See thousand monkeys. It doesn't really scale.

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


r350398 - Prevent unreachable when checking invalid multiversion decls.

2019-01-04 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jan  4 07:24:06 2019
New Revision: 350398

URL: http://llvm.org/viewvc/llvm-project?rev=350398&view=rev
Log:
Prevent unreachable when checking invalid multiversion decls.

CPUSpecifc/CPUDispatch call resolution assumed that all declarations
that would be passed are valid, however this was an invalid assumption.
This patch deals with those situations by making the valid version take
priority.  Note that the checked ordering is arbitrary, since both are
replaced by calls to the resolver later.

Change-Id: I7ff2ec88c55a721d51bc1f39ea1a1fe242b4e45f

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/attr-cpuspecific.c

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=350398&r1=350397&r2=350398&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan  4 07:24:06 2019
@@ -9023,6 +9023,11 @@ static bool isBetterMultiversionCandidat
   !Cand2.Function->isMultiVersion())
 return false;
 
+  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
+  // is obviously better.
+  if (Cand1.Function->isInvalidDecl()) return false;
+  if (Cand2.Function->isInvalidDecl()) return true;
+
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
   bool Cand1CPUDisp = Cand1.Function->hasAttr();

Modified: cfe/trunk/test/Sema/attr-cpuspecific.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-cpuspecific.c?rev=350398&r1=350397&r2=350398&view=diff
==
--- cfe/trunk/test/Sema/attr-cpuspecific.c (original)
+++ cfe/trunk/test/Sema/attr-cpuspecific.c Fri Jan  4 07:24:06 2019
@@ -92,3 +92,15 @@ __vectorcall int __attribute__((cpu_spec
 int __attribute__((cpu_dispatch(atom))) disp_with_body(void) {
   return 5;
 }
+
+// expected-error@+1 {{invalid option 'INVALID'}}
+int __attribute__((cpu_specific(INVALID))) called_invalid_value(void){ return 
1;}
+// expected-warning@+3 {{attribute declaration must precede definition}}
+// expected-note@-2 2 {{previous definition is here}}
+// expected-error@+1 {{redefinition of}}
+int __attribute__((cpu_specific(pentium_iii))) called_invalid_value(void){ 
return 2;}
+int __attribute__((cpu_specific(pentium_4))) called_invalid_value(void){ 
return 3;}
+
+int use3(void) {
+  return called_invalid_value();
+}


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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
Herald added subscribers: tpr, nhaehnle, jvesely.

In 64 bit MSVC environment size_t is defined as unsigned long long. Fix AMDGPU 
target info to match it in MSVC environment.


https://reviews.llvm.org/D56318

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Driver/Driver.cpp
  test/SemaCUDA/amdgpu-size_t.cu


Index: test/SemaCUDA/amdgpu-size_t.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-size_t.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa-msvc -fms-compatibility 
-fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef unsigned __int64 size_t;
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -614,7 +614,11 @@
 StringRef DeviceTripleStr;
 auto OFK = Action::OFK_HIP;
 DeviceTripleStr = "amdgcn-amd-amdhsa";
-llvm::Triple HIPTriple(DeviceTripleStr);
+StringRef Env;
+if (HostTriple.getEnvironment() == llvm::Triple::MSVC)
+  Env = HostTriple.getEnvironmentName();
+llvm::Triple HIPTriple(Env.empty() ? Twine(DeviceTripleStr) :
+DeviceTripleStr + "-" + Env);
 // Use the HIP and host triples as the key into the ToolChains map,
 // because the device toolchain we create depends on both.
 auto &HIPTC = ToolChains[HIPTriple.str() + "/" + HostTriple.str()];
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -254,9 +254,15 @@
   PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
   if (getMaxPointerWidth() == 64) {
 LongWidth = LongAlign = 64;
-SizeType = UnsignedLong;
-PtrDiffType = SignedLong;
-IntPtrType = SignedLong;
+if (Triple.getEnvironment() == llvm::Triple::MSVC) {
+  SizeType = UnsignedLongLong;
+  PtrDiffType = SignedLongLong;
+  IntPtrType = SignedLongLong;
+} else {
+  SizeType = UnsignedLong;
+  PtrDiffType = SignedLong;
+  IntPtrType = SignedLong;
+}
   }
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;


Index: test/SemaCUDA/amdgpu-size_t.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-size_t.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef unsigned __int64 size_t;
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -614,7 +614,11 @@
 StringRef DeviceTripleStr;
 auto OFK = Action::OFK_HIP;
 DeviceTripleStr = "amdgcn-amd-amdhsa";
-llvm::Triple HIPTriple(DeviceTripleStr);
+StringRef Env;
+if (HostTriple.getEnvironment() == llvm::Triple::MSVC)
+  Env = HostTriple.getEnvironmentName();
+llvm::Triple HIPTriple(Env.empty() ? Twine(DeviceTripleStr) :
+DeviceTripleStr + "-" + Env);
 // Use the HIP and host triples as the key into the ToolChains map,
 // because the device toolchain we create depends on both.
 auto &HIPTC = ToolChains[HIPTriple.str() + "/" + HostTriple.str()];
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -254,9 +254,15 @@
   PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
   if (getMaxPointerWidth() == 64) {
 LongWidth = LongAlign = 64;
-SizeType = UnsignedLong;
-PtrDiffType = SignedLong;
-IntPtrType = SignedLong;
+if (Triple.getEnvironment() == llvm::Triple::MSVC) {
+  SizeType = UnsignedLongLong;
+  PtrDiffType = SignedLongLong;
+  IntPtrType = SignedLongLong;
+} else {
+  SizeType = UnsignedLong;
+  PtrDiffType = SignedLong;
+  IntPtrType = SignedLong;
+}
   }
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-04 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D56215#1346061 , @mgorny wrote:

> For the record, another option is to actually fix other software not to call 
> LD directly.


Or if you really need to call the linker directly without specifying search 
paths you could also install a shell script as /usr/bin/ld that passes the 
appropriate flags to /usr/bin/ld.lld?

I don't think ifdefs in the source code are a good idea. Cross linking should 
just work as expected. But you could look at the OS field in the first input 
ELF file to choose default config options/a different emulation for NetBSD.

The approach we are using in CheriBSD to differentiate between MIPS and CHERI 
pure-capability to either pass an explicitly `-m elf_btsmip_cheri_fbsd`/ `-m 
elf_btsmip_fbsd` or infer whether it is CHERI or MIPS based on the e_flags 
field of the first input file.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56299: [OpenMP] Refactor const restriction for linear

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D56299



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


[PATCH] D56298: [OpenMP] Refactor const restriction for reductions

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D56298



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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:9736
 
+static bool rejectConstNotMutableType(Sema &SemaRef, ValueDecl *D,
+  OpenMPClauseKind CKind,

ABataev wrote:
> This function and the original code has a lot of common code. Could you, 
> please, use this function somehow for the original too? Or outline the common 
> code into standalone function
Also, probably missed the check if the OpenMP version is >= 4.0


Repository:
  rC Clang

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

https://reviews.llvm.org/D56113



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


[PATCH] D56113: [OpenMP] Replace predetermined shared for const variable

2019-01-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:9736
 
+static bool rejectConstNotMutableType(Sema &SemaRef, ValueDecl *D,
+  OpenMPClauseKind CKind,

This function and the original code has a lot of common code. Could you, 
please, use this function somehow for the original too? Or outline the common 
code into standalone function


Repository:
  rC Clang

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

https://reviews.llvm.org/D56113



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


[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.

This would save us some memory and disk space:

- Dex usage (269 MB vs 278 MB)
- Disk (73 MB vs 76 MB)

It would save more when we index the main file symbol.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56314

Files:
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -655,10 +655,18 @@
 void Foo::ssf() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
-   QName("Foo::g"), QName("Foo::sf"),
-   QName("Foo::ssf"), QName("Foo::x")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   QName("Foo"),
+   AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::g"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::sf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::ssf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::x"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, Scopes) {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -531,6 +531,18 @@
   getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
 
+  S.Origin = Opts.Origin;
+  if (ND.getAvailability() == AR_Deprecated)
+S.Flags |= Symbol::Deprecated;
+
+  auto Insert = [this](const Symbol& S) {
+Symbols.insert(S);
+return Symbols.find(S.ID);
+  };
+
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion))
+return Insert(S);
+
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -569,12 +581,7 @@
 if (TypeStorage)
   S.Type = TypeStorage->raw();
   }
-
-  S.Origin = Opts.Origin;
-  if (ND.getAvailability() == AR_Deprecated)
-S.Flags |= Symbol::Deprecated;
-  Symbols.insert(S);
-  return Symbols.find(S.ID);
+  return Insert(S);
 }
 
 void SymbolCollector::addDefinition(const NamedDecl &ND,
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -229,6 +229,9 @@
 None = 0,
 /// Whether or not this symbol is meant to be used for the code completion.
 /// See also isIndexedForCodeCompletion().
+/// Note that we don't store completion information (signature, snippet,
+/// documentation, type, inclues, etc) if the symbol is not indexed for 
code
+/// completion.
 IndexedForCodeCompletion = 1 << 0,
 /// Indicates if the symbol is deprecated.
 Deprecated = 1 << 1,


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -655,10 +655,18 @@
 void Foo::ssf() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
-   QName("Foo::g"), QName("Foo::sf"),
-   QName("Foo::ssf"), QName("Foo::x")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   QName("Foo"),
+   AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::g"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::sf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::ssf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+   AllOf(QName("Foo::x"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, Scopes) {
Index: clangd/index/SymbolCollector.cpp
=

[PATCH] D55948: Modify DeclaratorChuck::getFunction to use DeclSpec for qualifiers

2019-01-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:8175
   DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo();
-  if (FTI.TypeQuals != 0) {
-if (FTI.TypeQuals & Qualifiers::Const)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "const" << SourceRange(D.getIdentifierLoc());
-if (FTI.TypeQuals & Qualifiers::Volatile)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "volatile" << SourceRange(D.getIdentifierLoc());
-if (FTI.TypeQuals & Qualifiers::Restrict)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "restrict" << SourceRange(D.getIdentifierLoc());
+  if (FTI.MethodQualifiers && FTI.MethodQualifiers->getTypeQualifiers() != 0) {
+auto DiagQual = [&](DeclSpec::TQ TypeQual, StringRef QualName,

rjmccall wrote:
> Anastasia wrote:
> > rjmccall wrote:
> > > Anastasia wrote:
> > > > rjmccall wrote:
> > > > > I think you should add a `hasMethodQualifiers` method to FTI that 
> > > > > does this check.  Note that it needs to check for attributes, too, 
> > > > > and I think you need to figure out some way to generalize 
> > > > > `forEachCVRUQual` to cover those.
> > > > Are there any attributes I should handle currently?
> > > > 
> > > > Also are you suggesting to add another `forEach...` method or extend 
> > > > existing? If the latter, I might not be able to use it in all places I 
> > > > use it now.
> > > Adding another method might be easier.  How many clients actually use the 
> > > TQ?
> > In **DeclSpec.cpp** I definitely  need just TQ. I am not sure about 
> > **SemaType.cpp**. All other places (3x) I guess should be possible to 
> > generalize. Although I am not very clear if I should be checking all attr. 
> > It might be a bit exhaustive since the use cases are for the function?
> > 
> > Perhaps, I could add an extra helper `forEachQualifier` that can call 
> > `forEachCVRUQual` and then I could add a FIXME to complete the rest. We can 
> > extend it as we discover what's missing. For example I will add address 
> > spaces there in my next patch. Would this make sense?
> > 
> > As for `hasMethodQualifiers` just to be clear I would need to check for all 
> > qualifiers including reference qualifier, attributes, etc?
> That seems like a reasonable short-term plan.  Maybe there needs to be some 
> way to describe an individual qualifier; we can hash that out in a separate 
> patch.
> 
> > As for `hasMethodQualifiers` just to be clear I would need to check for all 
> > qualifiers including reference qualifier, attributes, etc?
> 
> Maybe, although at least one of the cases below wants to check for 
> ref-qualifiers separately.  Maybe it should be `hasMethodTypeQualifiers`, and 
> it implies that `MethodQualifiers->forEachQualifier` will invoke the callback 
> at least once.
I think it should be sufficient to check that `MethodQualifiers` exist because 
we only create it if we have either a type qual or any attribute. 


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

https://reviews.llvm.org/D55948



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


[PATCH] D55948: Modify DeclaratorChuck::getFunction to use DeclSpec for qualifiers

2019-01-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 180226.
Anastasia marked an inline comment as done.
Anastasia added a comment.

- Added `forEachQualifiers` to `DeclSpec`.
- Removed dead code.
- Moved lambdas definition inline into the function parameters.


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

https://reviews.llvm.org/D55948

Files:
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -724,12 +724,8 @@
   /*NumArgs=*/0,
   /*EllipsisLoc=*/NoLoc,
   /*RParenLoc=*/NoLoc,
-  /*TypeQuals=*/0,
   /*RefQualifierIsLvalueRef=*/true,
   /*RefQualifierLoc=*/NoLoc,
-  /*ConstQualifierLoc=*/NoLoc,
-  /*VolatileQualifierLoc=*/NoLoc,
-  /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
   /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
@@ -737,8 +733,7 @@
   /*NumExceptions=*/0,
   /*NoexceptExpr=*/nullptr,
   /*ExceptionSpecTokens=*/nullptr,
-  /*DeclsInPrototype=*/None,
-  loc, loc, declarator));
+  /*DeclsInPrototype=*/None, loc, loc, declarator));
 
   // For consistency, make sure the state still has us as processing
   // the decl spec.
@@ -4460,7 +4455,7 @@
   // does not have a K&R-style identifier list), then the arguments are part
   // of the type, otherwise the argument list is ().
   const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
-  IsQualifiedFunction = FTI.TypeQuals || FTI.hasRefQualifier();
+  IsQualifiedFunction = FTI.MethodQualifiers || FTI.hasRefQualifier();
 
   // Check for auto functions and trailing return type and adjust the
   // return type accordingly.
@@ -4698,7 +4693,9 @@
 EPI.ExtInfo = EI;
 EPI.Variadic = FTI.isVariadic;
 EPI.HasTrailingReturn = FTI.hasTrailingReturnType();
-EPI.TypeQuals.addCVRUQualifiers(FTI.TypeQuals);
+EPI.TypeQuals.addCVRUQualifiers(
+FTI.MethodQualifiers ? FTI.MethodQualifiers->getTypeQualifiers()
+ : 0);
 EPI.RefQualifier = !FTI.hasRefQualifier()? RQ_None
 : FTI.RefQualifierIsLValueRef? RQ_LValue
 : RQ_RValue;
@@ -5024,14 +5021,15 @@
 SmallVector RemovalLocs;
 const DeclaratorChunk &Chunk = D.getTypeObject(I);
 assert(Chunk.Kind == DeclaratorChunk::Function);
+
 if (Chunk.Fun.hasRefQualifier())
   RemovalLocs.push_back(Chunk.Fun.getRefQualifierLoc());
-if (Chunk.Fun.TypeQuals & Qualifiers::Const)
-  RemovalLocs.push_back(Chunk.Fun.getConstQualifierLoc());
-if (Chunk.Fun.TypeQuals & Qualifiers::Volatile)
-  RemovalLocs.push_back(Chunk.Fun.getVolatileQualifierLoc());
-if (Chunk.Fun.TypeQuals & Qualifiers::Restrict)
-  RemovalLocs.push_back(Chunk.Fun.getRestrictQualifierLoc());
+
+if (Chunk.Fun.MethodQualifiers)
+  Chunk.Fun.MethodQualifiers->forEachQualifier(
+  [&](DeclSpec::TQ TypeQual, StringRef QualName,
+  SourceLocation SL) { RemovalLocs.push_back(SL); });
+
 if (!RemovalLocs.empty()) {
   llvm::sort(RemovalLocs,
  BeforeThanCompare(S.getSourceManager()));
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -884,8 +884,10 @@
 //   This function call operator is declared const (9.3.1) if and only if
 //   the lambda-expression's parameter-declaration-clause is not followed
 //   by mutable. It is neither virtual nor declared volatile. [...]
-if (!FTI.hasMutableQualifier())
-  FTI.TypeQuals |= DeclSpec::TQ_const;
+if (!FTI.hasMutableQualifier()) {
+  FTI.getOrCreateMethodQualifiers().SetTypeQual(DeclSpec::TQ_const,
+SourceLocation());
+}
 
 MethodTyInfo = GetTypeForDeclarator(ParamInfo, CurScope);
 assert(MethodTyInfo && "no type from lambda-declarator");
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8172,16 +8172,12 @@
   }
 
   DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo();
-  if (FTI.TypeQuals != 0) {
-if (FTI.TypeQuals & Qualifiers::Const)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "const" << SourceRange(D.getIdentifierLoc());
-if (FTI.TypeQuals & Qualifiers::Volatile)
-  Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
-<< "volatile" << Sou

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:30
+// TODO: Find a better way of detecting a function template.
+static bool isFunctionTemplate(const QualType &ParamType) {
+  // Try to catch both std::function and boost::function

JonasToth wrote:
> MyDeveloperDay wrote:
> > JonasToth wrote:
> > > Do you want a function-template (`template  void foo(T 
> > > argument);`) or the template-function `{std,boost}::function`?
> > > For the first the approach should be the same as above, for the second 
> > > your implementation might work.
> > > 
> > > But a matcher with `hasAnyName("::std::function", "::boost::function")` 
> > > would be cleaner if you can use that instead.
> > I can't seem to get the hasName or hasAnyName matcher pick up 
> > std::function<> as an argument
> > 
> > Using clang-query, I can't get this to work, did I miss something?
> > 
> > ```
> > match 
> > functionDecl(hasAnyParameter(hasType(namedDecl(hasName("::std::function").bind("x")
> > ```
> > 
> I experimented a bit and found something that might work for you. See the 
> attachment.
> {F7791969}
This really helped thank you!


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

https://reviews.llvm.org/D55433



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


[PATCH] D55933: [Sema] Do not print default template parameters.

2019-01-04 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: lib/AST/TypePrinter.cpp:179
+// `X` gets canonicalized to `X`. We disable
+// canonicalization so that `printTag()`` can see the template parameters 
as
+// written.

Quuxplusone wrote:
> Nit: there's an extra ` on this line.
> 
> I think I vaguely understand the purpose of this switch now. It feels ugly, 
> but I have no concrete suggestion for improvement. Do you not need a case 
> here to delay canonicalization of `X&` also?
Indeed. Fixed + added tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55933



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


[PATCH] D55933: [Sema] Do not print default template parameters.

2019-01-04 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 180220.
courbet marked 2 inline comments as done.
courbet added a comment.

Handle {L,R}Value references.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55933

Files:
  include/clang/AST/NestedNameSpecifier.h
  lib/AST/NestedNameSpecifier.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCXX/static-assert-cxx17.cpp
  test/SemaCXX/static-assert.cpp

Index: test/SemaCXX/static-assert.cpp
===
--- test/SemaCXX/static-assert.cpp
+++ test/SemaCXX/static-assert.cpp
@@ -127,7 +127,7 @@
 static_assert(!(std::is_const()()), "message");
 // expected-error@-1{{static_assert failed due to requirement '!(std::is_const()())' "message"}}
 static_assert(std::is_same()), int>::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_same, int>::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_same, int>::value' "message"}}
 static_assert(std::is_const::value, "message");
 // expected-error@-1{{static_assert failed due to requirement 'std::is_const::value' "message"}}
 static_assert(std::is_const::value, "message");
Index: test/SemaCXX/static-assert-cxx17.cpp
===
--- test/SemaCXX/static-assert-cxx17.cpp
+++ test/SemaCXX/static-assert-cxx17.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -triple=x86_64-linux-gnu
 
-template 
+template 
 struct S1 {
   static constexpr const bool value = false;
 };
@@ -14,7 +14,7 @@
   static inline constexpr bool var = global_inline_var;
 };
 
-template 
+template 
 inline constexpr bool constexpr_return_false() {
   return false;
 }
@@ -23,6 +23,8 @@
 void foo() {
   static_assert(S1::value);
   // expected-error@-1{{static_assert failed due to requirement 'S1::value'}}
+  static_assert(S1::value);
+  // expected-error@-1{{static_assert failed due to requirement 'S1::value'}}
 }
 template void foo();
 // expected-note@-1{{in instantiation of function template specialization 'foo' requested here}}
@@ -66,7 +68,7 @@
   using U = float;
 };
 
-template 
+template 
 struct X {
   int i = 0;
   int j = 0;
@@ -74,7 +76,8 @@
 };
 
 template 
-void foo6() {
+void test_template_parameter_from_default() {
+  X x;
   static_assert(X());
   // expected-error@-1{{static_assert failed due to requirement 'X()'}}
   static_assert(X{});
@@ -93,12 +96,60 @@
   // expected-error@-1{{static_assert failed due to requirement '(const X *)nullptr'}}
   static_assert(static_cast *>(nullptr));
   // expected-error@-1{{static_assert failed due to requirement 'static_cast *>(nullptr)'}}
+  static_assert(static_cast &>(x));
+  // expected-error@-1{{static_assert failed due to requirement 'static_cast &>(x)'}}
+  static_assert(static_cast &&>(x));
+  // expected-error@-1{{static_assert failed due to requirement 'static_cast &&>(x)'}}
   static_assert((const X[]){} == nullptr);
-  // expected-error@-1{{static_assert failed due to requirement '(X const[0]){} == nullptr'}}
+  // expected-error@-1{{static_assert failed due to requirement '(const X [0]){} == nullptr'}}
   static_assert(sizeof(X().X::~X())>) == 0);
   // expected-error@-1{{static_assert failed due to requirement 'sizeof(X) == 0'}}
+  static_assert(constexpr_return_false());
+  // expected-error@-1{{static_assert failed due to requirement 'constexpr_return_false()'}}
+}
+template void test_template_parameter_from_default();
+// expected-note@-1{{in instantiation of function template specialization 'test_template_parameter_from_default' requested here}}
+
+template 
+void test_template_parameter_as_written() {
+  static_assert(X());
+  // expected-error@-1{{static_assert failed due to requirement 'X()'}}
+  static_assert(sizeof(X) == 0);
+  // expected-error@-1{{static_assert failed due to requirement 'sizeof(X) == 0'}}
   static_assert(constexpr_return_false());
   // expected-error@-1{{static_assert failed due to requirement 'constexpr_return_false()'}}
 }
-template void foo6();
-// expected-note@-1{{in instantiation of function template specialization 'foo6' requested here}}
+template void test_template_parameter_as_written();
+// expected-note@-1{{in instantiation of function template specialization 'test_template_parameter_as_written' requested here}}
+
+
+template
+struct is_pointerable { static constexpr bool value = false; };
+
+template
+struct is_pointerable { static constexpr bool value = true; };
+
+template
+void test_is_pointerable()
+{
+static_assert(is_pointerable::value);
+// expected-error@-1{{due to requirement 'is_pointerable::value'}}
+static_assert(not is_pointerable::value);
+// expected-error@-1{{due to requirement '!is_pointerable::value'}}
+}
+template void test_is_pointerable();
+// expected-note@-1{{in instantiation of function template specialization 'test_is_point

[PATCH] D56198: [Basic] Extend DiagnosticEngine to store and format Qualifiers

2019-01-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350386: [Basic] Extend DiagnosticEngine to store and format 
Qualifiers. (authored by stulova, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D56198

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTDiagnostic.cpp
  lib/Basic/Diagnostic.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/addr-of-overloaded-function.cpp
  test/SemaCXX/warn-overloaded-virtual.cpp

Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -6701,6 +6701,24 @@
   return type;
 }
 
+/// Insertion operator for diagnostics. This allows sending Qualifiers into a
+/// diagnostic with <<.
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+   Qualifiers Q) {
+  DB.AddTaggedVal(Q.getAsOpaqueValue(),
+  DiagnosticsEngine::ArgumentKind::ak_qual);
+  return DB;
+}
+
+/// Insertion operator for partial diagnostics. This allows sending Qualifiers
+/// into a diagnostic with <<.
+inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+   Qualifiers Q) {
+  PD.AddTaggedVal(Q.getAsOpaqueValue(),
+  DiagnosticsEngine::ArgumentKind::ak_qual);
+  return PD;
+}
+
 /// Insertion operator for diagnostics.  This allows sending QualType's into a
 /// diagnostic with <<.
 inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1809,11 +1809,7 @@
   "|: different number of parameters (%5 vs %6)"
   "|: type mismatch at %ordinal5 parameter%diff{ ($ vs $)|}6,7"
   "|: different return type%diff{ ($ vs $)|}5,6"
-  "|: different qualifiers ("
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}5 vs "
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: different qualifiers (%5 vs %6)"
   "|: different exception specifications}4">;
 
 def err_lvalue_to_rvalue_ref : Error<"rvalue reference %diff{to type $ cannot "
@@ -3593,11 +3589,7 @@
 "| has type mismatch at %ordinal5 parameter"
 "%diff{ (expected $ but has $)|}6,7"
 "| has different return type%diff{ ($ expected but has $)|}5,6"
-"| has different qualifiers (expected "
-"%select{none|const|restrict|const and restrict|volatile|const and volatile"
-"|volatile and restrict|const, volatile, and restrict}5 but found "
-"%select{none|const|restrict|const and restrict|volatile|const and volatile"
-"|volatile and restrict|const, volatile, and restrict}6)"
+"| has different qualifiers (expected %5 but found %6)"
 "| has different exception specification}4">;
 
 def note_ovl_candidate_inherited_constructor : Note<
@@ -6470,11 +6462,7 @@
   "|: different number of parameters (%2 vs %3)"
   "|: type mismatch at %ordinal2 parameter%diff{ ($ vs $)|}3,4"
   "|: different return type%diff{ ($ vs $)|}2,3"
-  "|: different qualifiers ("
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}2 vs "
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}3)"
+  "|: different qualifiers (%2 vs %3)"
   "|: different exception specifications}1">;
 def warn_using_directive_in_header : Warning<
   "using namespace directive in global context in header">,
@@ -6748,11 +6736,7 @@
   "|: different number of parameters (%5 vs %6)"
   "|: type mismatch at %ordinal5 parameter%diff{ ($ vs $)|}6,7"
   "|: different return type%diff{ ($ vs $)|}5,6"
-  "|: different qualifiers ("
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}5 vs "
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: different qualifiers (%5 vs %6)"
   "|: different exception specifications}4">;
 def err_typecheck_missing_return_type_incompatible : Error<
   "%diff{return type $ must match previous return type $|"
Index: include/clang/Basic/Diagnostic.h
===
--- include/clang/Basic/Diagnostic.h
+++ include/clang/Basic/Diagnostic.h
@@ -177,6 +177,9 @@
 /// IdentifierInfo
 ak_identifierinfo,
 
+/// Qualifiers
+ak_qua

r350386 - [Basic] Extend DiagnosticEngine to store and format Qualifiers.

2019-01-04 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Jan  4 03:50:36 2019
New Revision: 350386

URL: http://llvm.org/viewvc/llvm-project?rev=350386&view=rev
Log:
[Basic] Extend DiagnosticEngine to store and format Qualifiers.
 
Qualifiers can now be streamed into the DiagnosticEngine using
regular << operator. If Qualifiers are empty 'unqualified' will
be printed in the diagnostic otherwise regular qual syntax is
used.

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


Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=350386&r1=350385&r2=350386&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Jan  4 03:50:36 2019
@@ -6701,6 +6701,24 @@ inline const Type *Type::getPointeeOrArr
   return type;
 }
 
+/// Insertion operator for diagnostics. This allows sending Qualifiers into a
+/// diagnostic with <<.
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+   Qualifiers Q) {
+  DB.AddTaggedVal(Q.getAsOpaqueValue(),
+  DiagnosticsEngine::ArgumentKind::ak_qual);
+  return DB;
+}
+
+/// Insertion operator for partial diagnostics. This allows sending Qualifiers
+/// into a diagnostic with <<.
+inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+   Qualifiers Q) {
+  PD.AddTaggedVal(Q.getAsOpaqueValue(),
+  DiagnosticsEngine::ArgumentKind::ak_qual);
+  return PD;
+}
+
 /// Insertion operator for diagnostics.  This allows sending QualType's into a
 /// diagnostic with <<.
 inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=350386&r1=350385&r2=350386&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Jan  4 03:50:36 2019
@@ -177,6 +177,9 @@ public:
 /// IdentifierInfo
 ak_identifierinfo,
 
+/// Qualifiers
+ak_qual,
+
 /// QualType
 ak_qualtype,
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=350386&r1=350385&r2=350386&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan  4 03:50:36 
2019
@@ -1809,11 +1809,7 @@ def err_init_conversion_failed : Error<
   "|: different number of parameters (%5 vs %6)"
   "|: type mismatch at %ordinal5 parameter%diff{ ($ vs $)|}6,7"
   "|: different return type%diff{ ($ vs $)|}5,6"
-  "|: different qualifiers ("
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}5 vs "
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: different qualifiers (%5 vs %6)"
   "|: different exception specifications}4">;
 
 def err_lvalue_to_rvalue_ref : Error<"rvalue reference %diff{to type $ cannot "
@@ -3593,11 +3589,7 @@ def note_ovl_candidate : Note<
 "| has type mismatch at %ordinal5 parameter"
 "%diff{ (expected $ but has $)|}6,7"
 "| has different return type%diff{ ($ expected but has $)|}5,6"
-"| has different qualifiers (expected "
-"%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}5 but found "
-"%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}6)"
+"| has different qualifiers (expected %5 but found %6)"
 "| has different exception specification}4">;
 
 def note_ovl_candidate_inherited_constructor : Note<
@@ -6470,11 +6462,7 @@ def note_hidden_overloaded_virtual_decla
   "|: different number of parameters (%2 vs %3)"
   "|: type mismatch at %ordinal2 parameter%diff{ ($ vs $)|}3,4"
   "|: different return type%diff{ ($ vs $)|}2,3"
-  "|: different qualifiers ("
-  "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}2

[PATCH] D56241: expose a control flag for interger to pointer ext warning

2019-01-04 Thread abdoul-kader keita via Phabricator via cfe-commits
Kader marked an inline comment as done.
Kader added a comment.

@lebedev.ri  Thanks.
I think do not have commit access. What should be my next step ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56241



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 180212.
MyDeveloperDay marked 3 inline comments as done.
MyDeveloperDay added a comment.

Address review comments

- remove using strings to locate std::function and boost::function arguments 
using matcher with ``hasAnyName()`` instead
- add tests to check for const, const & for above


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

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp
  test/clang-tidy/modernize-use-nodiscard.h

Index: test/clang-tidy/modernize-use-nodiscard.h
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.h
@@ -0,0 +1,5 @@
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,218 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17 
+
+#include 
+
+namespace boost {
+template  
+class function;
+}
+
+#include "modernize-use-nodiscard.h"
+
+#define BOOLEAN_FUNC bool f23() const
+
+typedef unsigned my_unsigned;
+typedef unsigned &my_unsigned_reference;
+typedef const unsigned &my_unsigned_const_reference;
+
+class Foo {
+public:
+using size_type = unsigned;
+
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard] 
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+
+bool f6();
+
+bool f7(int &);
+
+bool f8(int &) const;
+
+bool f9(int *) const;
+
+bool f10(const int &, int &) const;
+
+NO_DISCARD bool f12() const;
+
+MUST_USE_RESULT bool f13() const;
+
+[[nodiscard]] bool f11() const;
+
+[[clang::warn_unused_result]] bool f11a() const;
+
+[[gnu::warn_unused_result]] bool f11b() const;
+
+bool _f20() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool _f20() const;
+
+NO_RETURN bool f21() const;
+
+~Foo();
+
+bool operator+=(int) const;
+
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD const bool f15() const;
+
+inline const bool f16() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const bool f16() const;
+
+inline const std::string &f45() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f45' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const std::string &f45() const;
+
+inline virtual const bool f17() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
+
+// inline with body
+bool f18() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f18' should be marked NO_DISCARD [modernize-use-nodiscard]
+// C

[PATCH] D56090: Add a matcher for members of an initializer list expression

2019-01-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3527
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder);

aaron.ballman wrote:
> hwright wrote:
> > aaron.ballman wrote:
> > > I'm not certain we want the `IgnoreParenImpCasts()` here -- what if 
> > > someone wants to match an initializer that uses one of those properties?
> > The `hasArg` implementation directly above has the same call to 
> > `IgnoreParenImpCasts()`.  Is it also in error?  (It would seem that they 
> > should both be consistent.)
> Yeah, I noticed that as well. Doing some code archaeology, it seems that 
> `hasArg()` has had that form since its inception and it was never explicitly 
> discussed what should happen there.
> 
> @klimek -- do you have opinions here, since you wrote the original code for 
> `hasArg()`? Should we be leaving the paren and implicit cast stripping up to 
> the caller rather than doing it automatically?
Sigh, yea, this is one of those hard decisions: in the end, we decided that the 
downside of surprise of users not seeing what they expected (due to an imp 
cast) was less bad than basically taking away the ability to match imp casts, 
so we stopped putting ignoreparenimpcasts everywhere. I'm not entirely sure how 
to rate consistency with hasArg vs. getting us towards a more explicit world, 
but my gut would probably go with leaving the ignoreparenimpcasts out and see 
how bad people find it.


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

https://reviews.llvm.org/D56090



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