Re: [PATCH] D13980: Add "x87" in x86 target feature map

2016-02-26 Thread Eric Christopher via cfe-commits
echristo added a comment.

Can you add an explicit test for soft/hard-float.

One inline comment as well, waiting on Richard to pipe up.

-eric



Comment at: lib/Basic/Targets.cpp:2603
@@ -2599,3 +2602,3 @@
   case CK_i386:
   case CK_i486:
   case CK_i586:

Waiting for rsmith to comment here.




http://reviews.llvm.org/D13980



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


Re: [PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.

2016-02-26 Thread Erik Kessler via cfe-commits
erik65536 updated this revision to Diff 49155.
erik65536 added a comment.

Change is() || is() to isOneOf() and added a test case.


http://reviews.llvm.org/D17621

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10379,6 +10379,9 @@
   verifyFormat("SomeClass::Constructor()\n"
": a(a) {}",
Style);
+  verifyFormat("SomeClass::Constructor() noexcept\n"
+   ": a(a) {}",
+   Style);
   verifyFormat("SomeClass::Constructor()\n"
": a(a)\n"
", b(b)\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -504,7 +504,7 @@
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->is(tok::r_paren))
+if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10379,6 +10379,9 @@
   verifyFormat("SomeClass::Constructor()\n"
": a(a) {}",
Style);
+  verifyFormat("SomeClass::Constructor() noexcept\n"
+   ": a(a) {}",
+   Style);
   verifyFormat("SomeClass::Constructor()\n"
": a(a)\n"
", b(b)\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -504,7 +504,7 @@
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->is(tok::r_paren))
+if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.

2016-02-26 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Do you have commit access?


http://reviews.llvm.org/D17621



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


Re: [PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.

2016-02-26 Thread Erik Kessler via cfe-commits
erik65536 added a comment.

I do not have commit access.


http://reviews.llvm.org/D17621



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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-26 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 49159.
hokein marked an inline comment as done.
hokein added a comment.

Nit: correct a comment.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,24 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/compilation-database-test/include
+// RUN: mkdir -p %T/compilation-database-test/a
+// RUN: mkdir -p %T/compilation-database-test/b
+// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
+// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
+// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
+// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
+// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
+// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
+// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
+// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5
+
+// CHECK-FIX1: int *AA = nullptr;
+// CHECK-FIX2: int *AB = nullptr;
+// CHECK-FIX3: int *BB = nullptr;
+// CHECK-FIX4: int *BC = nullptr;
+// CHECK-FIX5: int *HP = nullptr;
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,32 @@
+[
+{
+  "directory": "test_dir/a",
+  "command": "clang++ -o test.o test_dir/a/a.cpp",
+  "file": "test_dir/a/a.cpp"
+},
+{
+  "directory": "test_dir/a",
+  "command": "clang++ -o test.o test_dir/a/b.cpp",
+  "file": "test_dir/a/b.cpp"
+},
+{
+  "directory": "test_dir/",
+  "command": "clang++ -o test.o test_dir/b/b.cpp",
+  "file": "test_dir/b/b.cpp"
+},
+{
+  "directory": "test_dir/b",
+  "command": "clang++ -o test.o ../b/c.cpp",
+  "file": "test_dir/b/c.cpp"
+},
+{
+  "directory": "test_dir/b",
+  "command": "clang++ -I../include -o test.o ../b/d.cpp",
+  "file": "test_dir/b/d.cpp"
+},
+{
+  "directory": "test_dir/",
+  "command": "clang++ -o test.o test_dir/b/not-exist.cpp",
+  "file": "test_dir/b/not-exist.cpp"
+}
+]
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -57,13 +57,23 @@
 Error = DiagnosticsEngine::Error
   };
 
-  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError);
+  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
+ StringRef BuildDirectory);
 
   std::string CheckName;
   ClangTidyMessage Message;
   tooling::Replacements Fix;
   SmallVector Notes;
 
+  // A build directory of the diagnostic source file.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify the compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // Note: it is empty in unittest.
+  std::string BuildDirectory;
+
   Level DiagLevel;
   bool IsWarningAsError;
 };
@@ -198,6 +208,16 @@
   void setCheckProfileData(ProfileData *Profile);
   ProfileData *getCheckProfileData() const { return Profile; }
 
+  /// \brief Should be called when starting to process new translation unit.
+  void setCurrentBuildDirectory(StringRef BuildDirectory) {
+CurrentBuildDirectory = BuildDirectory;
+  }
+
+  /// \brief Returns build directory of the current translation unit.
+  const std::string &getCurrentBuildDirectory() {
+return CurrentBuildDirectory;
+  }
+
 private:
   // Calls setDiagnosticsEngine() and storeError().
   friend class ClangTidyDiagnosticConsumer;
@@ -222,6 +242,8 @@
 
   ClangTidyStats Stats;
 
+  st

Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-26 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Nice, the behavior now seems nicely isolated. Is this a purely stylistic kind 
of change or do you think every JS developer working on any kind of codebase 
will want it? Generally this feels like something we should carefully enable 
with a dedicated style option. Where can I find more information about it?


http://reviews.llvm.org/D17385



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


Re: [PATCH] D13980: Add "x87" in x86 target feature map

2016-02-26 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/Targets.cpp:2603
@@ -2599,3 +2602,3 @@
   case CK_i386:
   case CK_i486:
   case CK_i586:

echristo wrote:
> Waiting for rsmith to comment here.
> 
> 
This seems fine to me.


http://reviews.llvm.org/D13980



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


[clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Feb 26 03:19:33 2016
New Revision: 261991

URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
Log:
[clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

Summary:
The clang-tidy will trigger an assertion if it's not in the building directory.

TEST:
cd /
./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build 
tools/clang/tools/extra/clang-tidy/ClangTidy.cpp

The crash issue is gone after applying this patch.

Fixes PR24834, PR26241

Reviewers: bkramer, alexfh

Subscribers: rizsotto.mailinglist, cfe-commits

Differential Revision: http://reviews.llvm.org/D17335

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/

clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26 03:19:33 2016
@@ -107,6 +107,10 @@ public:
 DiagPrinter->BeginSourceFile(LangOpts);
   }
 
+  SourceManager& getSourceManager() {
+return SourceMgr;
+  }
+
   void reportDiagnostic(const ClangTidyError &Error) {
 const ClangTidyMessage &Message = Error.Message;
 SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
@@ -124,7 +128,10 @@ public:
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SourceLocation FixLoc = getLocation(Fix.getFilePath(), 
Fix.getOffset());
+SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+Files.makeAbsolutePath(FixAbsoluteFilePath);
+SourceLocation FixLoc =
+getLocation(FixAbsoluteFilePath, Fix.getOffset());
 SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
 Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
  Fix.getReplacementText());
@@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
   Context.setCurrentFile(File);
   Context.setASTContext(&Compiler.getASTContext());
 
+  auto WorkingDir = Compiler.getSourceManager()
+.getFileManager()
+.getVirtualFileSystem()
+->getCurrentWorkingDirectory();
+  if (WorkingDir)
+Context.setCurrentBuildDirectory(WorkingDir.get());
+
   std::vector> Checks;
   CheckFactories->createChecks(&Context, Checks);
 
@@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr &Errors, bool Fix,
   unsigned &WarningsAsErrorsCount) {
   ErrorReporter Reporter(Fix);
-  for (const ClangTidyError &Error : Errors)
+  vfs::FileSystem &FileSystem =
+  *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
+  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
+  if (!InitialWorkingDir)
+llvm::report_fatal_error("Cannot get current working path.");
+
+  for (const ClangTidyError &Error : Errors) {
+if (!Error.BuildDirectory.empty()) {
+  // By default, the working directory of file system is the current
+  // clang-tidy running directory.
+  //
+  // Change the directory to the one used during the analysis.
+  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
+}
 Reporter.reportDiagnostic(Error);
+// Return to the initial directory to correctly resolve next Error.
+FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
+  }
   Reporter.Finish();
   WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
 }

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=261991&r1=261990&r2=261991&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri Feb 
26 03:19:33 2016
@@ -116,8 +116,9 @@ ClangTidyMessage::ClangTidyMessage(Strin
 
 ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyError::Level DiagLevel,
-   bool IsWarningAsError)
-: CheckName(CheckName), DiagLevel(DiagLevel),
+   bo

Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-26 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261991: [clang-tidy] Fix a crash issue when clang-tidy runs 
with compilation database. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17335?vs=49159&id=49164#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17335

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp

Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -57,13 +57,23 @@
 Error = DiagnosticsEngine::Error
   };
 
-  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError);
+  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
+ StringRef BuildDirectory);
 
   std::string CheckName;
   ClangTidyMessage Message;
   tooling::Replacements Fix;
   SmallVector Notes;
 
+  // A build directory of the diagnostic source file.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify the compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // Note: it is empty in unittest.
+  std::string BuildDirectory;
+
   Level DiagLevel;
   bool IsWarningAsError;
 };
@@ -198,6 +208,16 @@
   void setCheckProfileData(ProfileData *Profile);
   ProfileData *getCheckProfileData() const { return Profile; }
 
+  /// \brief Should be called when starting to process new translation unit.
+  void setCurrentBuildDirectory(StringRef BuildDirectory) {
+CurrentBuildDirectory = BuildDirectory;
+  }
+
+  /// \brief Returns build directory of the current translation unit.
+  const std::string &getCurrentBuildDirectory() {
+return CurrentBuildDirectory;
+  }
+
 private:
   // Calls setDiagnosticsEngine() and storeError().
   friend class ClangTidyDiagnosticConsumer;
@@ -222,6 +242,8 @@
 
   ClangTidyStats Stats;
 
+  std::string CurrentBuildDirectory;
+
   llvm::DenseMap CheckNamesByDiagnosticID;
 
   ProfileData *Profile;
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -116,8 +116,9 @@
 
 ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyError::Level DiagLevel,
-   bool IsWarningAsError)
-: CheckName(CheckName), DiagLevel(DiagLevel),
+   bool IsWarningAsError,
+   StringRef BuildDirectory)
+: CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
   IsWarningAsError(IsWarningAsError) {}
 
 // Returns true if GlobList starts with the negative indicator ('-'), removes it
@@ -335,7 +336,8 @@
 bool IsWarningAsError =
 DiagLevel == DiagnosticsEngine::Warning &&
 Context.getWarningAsErrorFilter().contains(CheckName);
-Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError));
+Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError,
+Context.getCurrentBuildDirectory()));
   }
 
   ClangTidyDiagnosticRenderer Converter(
Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -107,6 +107,10 @@
 DiagPrinter->BeginSourceFile(LangOpts);
   }
 
+  SourceManager& getSourceManager() {
+return SourceMgr;
+  }
+
   void reportDiagnostic(const ClangTidyError &Error) {
 const ClangTidyMessage &Message = Error.Message;
 SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
@@ -124,7 +128,10 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SourceLocation FixLoc = getLocation(Fix.getFilePath(), Fix.getOffset());
+SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+Files.makeAbsolutePath(FixAbsoluteFilePath);
+SourceLocation FixLoc =
+getLocation(FixAbsoluteFilePath, Fix.getOffset());
 SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
 Diag << FixItHint::CreateReplacem

Re: [PATCH] D13980: Add "x87" in x86 target feature map

2016-02-26 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks!

-eric


http://reviews.llvm.org/D13980



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


[clang-tools-extra] r261998 - [clang-tidy] Minor change in the doc

2016-02-26 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Feb 26 04:24:29 2016
New Revision: 261998

URL: http://llvm.org/viewvc/llvm-project?rev=261998&view=rev
Log:
[clang-tidy] Minor change in the doc

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=261998&r1=261997&r2=261998&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Fri Feb 26 04:24:29 2016
@@ -11,7 +11,7 @@ See also:
 
The list of clang-tidy checks 
 
-:program:`clang-tidy` is a clang-based C++ linter tool. Its purpose is to
+:program:`clang-tidy` is a clang-based C++ "linter" tool. Its purpose is to
 provide an extensible framework for diagnosing and fixing typical programming
 errors, like style violations, interface misuse, or bugs that can be deduced 
via
 static analysis. :program:`clang-tidy` is modular and provides a convenient


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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Could you please change my role to the Subscriber and add Joey as a reviewer 
please.


http://reviews.llvm.org/D17578



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


Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target

2016-02-26 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/CodeGen/TargetInfo.cpp:7211
@@ +7210,3 @@
+
+/// SPIR uses emitTargetMD to emit spir spec requried metadate.
+void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,

Could you change the comment please to something more specific. For example:
"Emit SPIR specific metadata: OpenCL and SPIR version."


Comment at: lib/CodeGen/TargetInfo.cpp:7214
@@ +7213,3 @@
+ CodeGen::CodeGenModule &CGM) const {
+  assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL\n");
+  llvm::LLVMContext &Ctx = CGM.getModule().getContext();

Remove \n


Comment at: test/CodeGenOpenCL/spir_version.cl:15
@@ +14,2 @@
+// CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
+// CL20: [[SPIR]] = !{i32 2, i32 0}

Forgotten to check OpenCL version here?


http://reviews.llvm.org/D17596



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


r261999 - Test commit.

2016-02-26 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Feb 26 04:43:34 2016
New Revision: 261999

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

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=261999&r1=261998&r2=261999&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Feb 26 04:43:34 2016
@@ -47,23 +47,23 @@ namespace clang {
 unsigned AnonymousDeclNumber;
 GlobalDeclID NamedDeclForTagDecl;
 IdentifierInfo *TypedefNameForLinkage;
-
+
 bool HasPendingBody;
 
 uint64_t GetCurrentCursorOffset();
-
+
 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
   return Reader.ReadSourceLocation(F, R, I);
 }
-
+
 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
   return Reader.ReadSourceRange(F, R, I);
 }
-
+
 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
   return Reader.GetTypeSourceInfo(F, R, I);
 }
-
+
 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
   return Reader.ReadDeclID(F, R, I);
 }


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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a subscriber: omtcyf0.
omtcyf0 added a comment.

@xazax.hun did you actually run the tool on the LLVM codebase?

Because this check generates **tons** of false-positive reports during codebase 
analysis.

See the minimal example below.

  omtcyf0-laptop:playground omtcyf0$ cat main.cpp 
  #include 
  
  int main() {
std::vector numbers = {1, 2, 3, 4, 5, 6};
for (std::vector::const_iterator it = begin(numbers), end = 
end(numbers);
 it != end; ++it) {
  (*it)++;
}
return 0;
  }
  omtcyf0-laptop:playground omtcyf0$ 
/Users/omtcyf0/Documents/dev/build/Release/llvm/bin/clang-tidy 
-checks=misc-suspicious-semicolon main.cpp 
  Error while trying to load a compilation database:
  Could not auto-detect compilation database for file "main.cpp"
  No compilation database found in /Users/omtcyf0/Documents/dev/playground or 
any parent directory
  json-compilation-database: Error while opening JSON database: No such file or 
directory
  Running without flags.
  1 warning and 1 error generated.
  Error while processing /Users/omtcyf0/Documents/dev/playground/main.cpp.
  /Users/omtcyf0/Documents/dev/playground/main.cpp:6:17: warning: potentially 
unintended semicolon [misc-suspicious-semicolon]
 it != end; ++it) {
  ^
  /usr/include/wchar.h:89:10: error: 'stdarg.h' file not found 
[clang-diagnostic-error]
  #include 
   ^

And this is happening all over the LLVM codebase, because there is nothing bad 
there.

Can you please fix that?


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects

2016-02-26 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@majnemer, this error in the header is now gone. Thank you! On to more errors! 
;-)

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D17619



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D16535#362685, @omtcyf0 wrote:

> @xazax.hun did you actually run the tool on the LLVM codebase?
>
> Because this check generates **tons** of false-positive reports during 
> codebase analysis.
>
> See the minimal example below.
>
>   omtcyf0-laptop:playground omtcyf0$ cat main.cpp 
>   #include 
>  
>   int main() {
> std::vector numbers = {1, 2, 3, 4, 5, 6};
> for (std::vector::iterator it = std::begin(numbers),
> end = std::end(numbers);
>  it != end; ++it) {
>   (*it)++;
> }
> return 0;
>   }
>   omtcyf0-laptop:playground omtcyf0$ 
> /Users/omtcyf0/Documents/dev/build/Release/llvm/bin/clang-tidy 
> -checks=misc-suspicious-semicolon main.cpp 
>   Error while trying to load a compilation database:
>   Could not auto-detect compilation database for file "main.cpp"
>   No compilation database found in /Users/omtcyf0/Documents/dev/playground or 
> any parent directory
>   json-compilation-database: Error while opening JSON database: No such file 
> or directory
>   Running without flags.
>   1 warning and 1 error generated.
>   Error while processing /Users/omtcyf0/Documents/dev/playground/main.cpp.
>   /Users/omtcyf0/Documents/dev/playground/main.cpp:6:17: warning: potentially 
> unintended semicolon [misc-suspicious-semicolon]
>  it != end; ++it) {
>   ^
>   /usr/include/wchar.h:89:10: error: 'stdarg.h' file not found 
> [clang-diagnostic-error]
>   #include 
>^
>
>
> And this is happening all over the LLVM codebase, because there is nothing 
> bad there.
>
> Can you please fix that?


Kirill, the problem in your case may be related to the check seeing incomplete 
AST due to compilation errors. Can you append `-- -std=c++11` to your 
clang-tidy invocation and try again whether it will be able to parse the file 
completely (i.e. without any "file not found" and other compilation errors)?


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Having said that, it makes sense to handle invalid AST in the check somehow 
(e.g. completely disable the check), so it doesn't generate spurious errors.


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

In http://reviews.llvm.org/D16535#362689, @alexfh wrote:

> In http://reviews.llvm.org/D16535#362685, @omtcyf0 wrote:
>
> > @xazax.hun did you actually run the tool on the LLVM codebase?
> >
> > Because this check generates **tons** of false-positive reports during 
> > codebase analysis.
> >
> > See the minimal example below.
> >
> >   omtcyf0-laptop:playground omtcyf0$ cat main.cpp 
> >   #include 
> >  
> >   int main() {
> > std::vector numbers = {1, 2, 3, 4, 5, 6};
> > for (std::vector::iterator it = std::begin(numbers),
> > end = std::end(numbers);
> >  it != end; ++it) {
> >   (*it)++;
> > }
> > return 0;
> >   }
> >   omtcyf0-laptop:playground omtcyf0$ 
> > /Users/omtcyf0/Documents/dev/build/Release/llvm/bin/clang-tidy 
> > -checks=misc-suspicious-semicolon main.cpp 
> >   Error while trying to load a compilation database:
> >   Could not auto-detect compilation database for file "main.cpp"
> >   No compilation database found in /Users/omtcyf0/Documents/dev/playground 
> > or any parent directory
> >   json-compilation-database: Error while opening JSON database: No such 
> > file or directory
> >   Running without flags.
> >   1 warning and 1 error generated.
> >   Error while processing /Users/omtcyf0/Documents/dev/playground/main.cpp.
> >   /Users/omtcyf0/Documents/dev/playground/main.cpp:6:17: warning: 
> > potentially unintended semicolon [misc-suspicious-semicolon]
> >  it != end; ++it) {
> >   ^
> >   /usr/include/wchar.h:89:10: error: 'stdarg.h' file not found 
> > [clang-diagnostic-error]
> >   #include 
> >^
> >
> >
> > And this is happening all over the LLVM codebase, because there is nothing 
> > bad there.
> >
> > Can you please fix that?
>
>
> Kirill, the problem in your case may be related to the check seeing 
> incomplete AST due to compilation errors. Can you append `-- -std=c++11` to 
> your clang-tidy invocation and try again whether it will be able to parse the 
> file completely (i.e. without any "file not found" and other compilation 
> errors)?


Yes, you're right, it does suppress the warning.

However, running vanilla `run-clang-tidy.py` on the LLVM codebase still outputs 
such issues. Is it the `run-clang-tidy.py`'s fault? The compilation database 
contains the -std=c++11 specifiers, I assumed this gets added to the clang-tidy 
options while performing analysis of these sources, doesn't it?


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

Hm. Seems like this **is** either me using `run-clang-tidy.py` wrong or it 
working not properly, because I still get compilation errors. I believe I've 
done the same thing yesterday using the older tree and I didn't get any.

Thus said, everything's alright if the AST is acquired correctly. Otherwise the 
check works not as expected, so the fix Alexander wrote about is needed.


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


[PATCH] D17637: [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics

2016-02-26 Thread Chuang-Yu Cheng via cfe-commits
cycheng created this revision.
cycheng added reviewers: kbarton, nemanjai, hfinkel.
cycheng added subscribers: cfe-commits, tjablin.

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

Fix compile error when building ffmpeg for PowerPC64LE because of some 
vec_vsx_ld/vec_vsx_st intrinsics are not supported by current clang.

New added intrinsics:
  # (vector) {signed|unsigned} {short|char} vec_vsx_ld: (total: 8)
  # bool vec_vsx_ld: (total: 1)
  # (vector) {signed|unsigned} {short|char} vec_vsx_st: (total: 8)
  # bool vec_vsx_st: (total: 1)

Total: 18 intrinsics

http://reviews.llvm.org/D17637

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -2,16 +2,28 @@
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE
 
+vector signed char vsc = { -8,  9, -10, 11, -12, 13, -14, 15,
+   -0,  1,  -2,  3,  -4,  5,  -6,  7};
 vector unsigned char vuc = { 8,  9, 10, 11, 12, 13, 14, 15,
  0,  1,  2,  3,  4,  5,  6,  7};
+vector bool char vbc = { 0, 1, 0, 1, 0, 1, 0, 1,
+ 0, 1, 0, 1, 0, 1, 0, 1 };
 vector float vf = { -1.5, 2.5, -3.5, 4.5 };
 vector double vd = { 3.5, -7.5 };
 vector signed int vsi = { -1, 2, -3, 4 };
 vector unsigned int vui = { 0, 1, 2, 3 };
 vector bool long long vbll = { 1, 0 };
 vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
+vector signed short vss = { -1, 2, -3, 4, -5, 6, -7, 8 };
+vector unsigned short vus = { 0, 1, 2, 3, 4, 5, 6, 7 };
 double d = 23.4;
+signed char sc = { -8,  9, -10, 11, -12, 13, -14, 15,
+   -0,  1,  -2,  3,  -4,  5,  -6,  7};
+unsigned char uc = { 8,  9, 10, 11, 12, 13, 14, 15,
+ 0,  1,  2,  3,  4,  5,  6,  7};
+signed short ss = { -1, 2, -3, 4, -5, 6, -7, 8 };
+unsigned short us = { 0, 1, 2, 3, 4, 5, 6, 7 };
 
 vector float res_vf;
 vector double res_vd;
@@ -21,7 +33,17 @@
 vector bool long long res_vbll;
 vector signed long long res_vsll;
 vector unsigned long long res_vull;
+vector signed short res_vss;
+vector unsigned short res_vus;
+vector bool char res_vbc;
+vector signed char res_vsc;
+vector unsigned char res_vuc;
+
 double res_d;
+signed char res_sc;
+unsigned char res_uc;
+signed short res_ss;
+unsigned short res_us;
 
 void dummy() { }
 
@@ -316,16 +338,68 @@
 // CHECK: @llvm.ppc.vsx.lxvd2x
 // CHECK-LE: @llvm.ppc.vsx.lxvd2x
 
+  res_vull = vec_vsx_ld(0, &vull);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+// CHECK-LE: @llvm.ppc.vsx.lxvd2x
+
+  res_vd = vec_vsx_ld(0, &vd);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+// CHECK-LE: @llvm.ppc.vsx.lxvd2x
+
+  res_vss = vec_vsx_ld(0, &vss);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vss = vec_vsx_ld(0, &ss);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vus = vec_vsx_ld(0, &vus);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vus = vec_vsx_ld(0, &us);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vbc = vec_vsx_ld(0, &vbc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vsc = vec_vsx_ld(0, &vsc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vuc = vec_vsx_ld(0, &vuc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vsc = vec_vsx_ld(0, &sc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vuc = vec_vsx_ld(0, &uc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
   /* vec_vsx_st */
 
   vec_vsx_st(vsi, 0, &res_vsi);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
 
+  vec_vsx_st(vsi, 0, &res_si);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
   vec_vsx_st(vui, 0, &res_vui);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
 
+  vec_vsx_st(vui, 0, &res_ui);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
   vec_vsx_st(vf, 0, &res_vf);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
@@ -342,6 +416,50 @@
 // CHECK: @llvm.ppc.vsx.stxvd2x
 // CHECK-LE: @llvm.ppc.vsx.stxvd2x
 
+  vec_vsx_st(vss, 0, &res_vss);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vss, 0, &res_ss);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vus, 0, &res_vus);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vus, 0, &res_us);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vsc, 0, &res_vsc);
+// CHECK

Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

I think, the check can be submitted as is and guards against spurious errors on 
invalid AST can be added as a follow up.


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D17640: [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

2016-02-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good! Thank you for coming up with the reduced test.


Repository:
  rL LLVM

http://reviews.llvm.org/D17640



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


r262012 - Giving this attribute documentation group a heading; fixes a documentation generation error.

2016-02-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Feb 26 07:30:58 2016
New Revision: 262012

URL: http://llvm.org/viewvc/llvm-project?rev=262012&view=rev
Log:
Giving this attribute documentation group a heading; fixes a documentation 
generation error.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262012&r1=262011&r2=262012&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Feb 26 07:30:58 2016
@@ -1583,7 +1583,10 @@ s6.11.5 for details.
 
 def OpenCLAccessDocs : Documentation {
   let Category = DocCatStmt;
-  let Content = [{
+  let Heading = "__read_only, __write_only, __read_write (read_only, "
+"write_only, read_write)";
+  let Content = [
+{
 The access qualifiers must be used with image object arguments or pipe 
arguments
 to declare if they are being read or written by a kernel or function.
 
@@ -1596,7 +1599,7 @@ names are reserved for use as access qua
   write_only image2d_t imageB)
   {
   ...
-  }
+}
 
 In the above example imageA is a read-only 2D image object, and imageB is a
 write-only 2D image object.
@@ -1604,7 +1607,8 @@ write-only 2D image object.
 The read_write (or __read_write) qualifier can not be used with pipe.
 
 More details can be found in the OpenCL C language Spec v2.0, Section 6.6.
-  }];
+}
+  ];
 }
 
 def DocOpenCLAddressSpaces : DocumentationCategory<"OpenCL Address Spaces"> {


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


r262013 - Fixing an issue with the code block so that it does not appear as a list.

2016-02-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Feb 26 07:39:38 2016
New Revision: 262013

URL: http://llvm.org/viewvc/llvm-project?rev=262013&view=rev
Log:
Fixing an issue with the code block so that it does not appear as a list.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262013&r1=262012&r2=262013&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Feb 26 07:39:38 2016
@@ -1583,10 +1583,8 @@ s6.11.5 for details.
 
 def OpenCLAccessDocs : Documentation {
   let Category = DocCatStmt;
-  let Heading = "__read_only, __write_only, __read_write (read_only, "
-"write_only, read_write)";
-  let Content = [
-{
+  let Heading = "__read_only, __write_only, __read_write (read_only, 
write_only, read_write)";
+  let Content = [{
 The access qualifiers must be used with image object arguments or pipe 
arguments
 to declare if they are being read or written by a kernel or function.
 
@@ -1596,10 +1594,9 @@ names are reserved for use as access qua
   .. code-block:: c
   kernel void
   foo (read_only image2d_t imageA,
-  write_only image2d_t imageB)
-  {
+  write_only image2d_t imageB) {
   ...
-}
+  }
 
 In the above example imageA is a read-only 2D image object, and imageB is a
 write-only 2D image object.
@@ -1607,8 +1604,7 @@ write-only 2D image object.
 The read_write (or __read_write) qualifier can not be used with pipe.
 
 More details can be found in the OpenCL C language Spec v2.0, Section 6.6.
-}
-  ];
+}];
 }
 
 def DocOpenCLAddressSpaces : DocumentationCategory<"OpenCL Address Spaces"> {


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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D16535#362726, @alexfh wrote:

> I think, the check can be submitted as is and guards against spurious errors 
> on invalid AST can be added as a follow up.


This check is already submitted. However I did not found any API in tidy to 
check whether the compilation failed. It would be great to be able to query 
that information at the time of registering matchers.

I have one more question though: does it make sense to run clang tidy at all, 
when the compilation failed? Isn't it a better default behaviour to not to run 
any of the checks in that case?


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D16535#362761, @xazax.hun wrote:

> In http://reviews.llvm.org/D16535#362726, @alexfh wrote:
>
> > I think, the check can be submitted as is and guards against spurious 
> > errors on invalid AST can be added as a follow up.
>
>
> This check is already submitted.


Yup, /me needs to sleep more ;)

> However I did not found any API in tidy to check whether the compilation 
> failed. It would be great to be able to query that information at the time of 
> registering matchers.


This information is not available when registering matchers, since this happens 
before parsing. You can use `isInvalidDecl()` to check whether particular 
declaration had any errors, or 
`Result.Context->getTranslationUnitDecl()->isInvalidDecl()` to check the whole 
translation unit.

> I have one more question though: does it make sense to run clang tidy at all, 
> when the compilation failed? Isn't it a better default behaviour to not to 
> run any of the checks in that case?


There are some valid use cases for running checks on a non-compilable code, 
e.g. editor integration.


Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-26 Thread H.J. Lu via cfe-commits
On Tue, Feb 23, 2016 at 5:14 PM, Richard Smith  wrote:
> On Tue, Feb 23, 2016 at 8:28 AM, H.J. Lu  wrote:
>> On Tue, Feb 23, 2016 at 8:15 AM, Michael Matz  wrote:
>>> Hi,
>>>
>>> On Tue, 23 Feb 2016, H.J. Lu wrote:
>>>
 I thought

 ---
 An empty type is a type where it and all of its subobjects (recursively)
 are of class, structure, union, or array type.
 ---

 excluded

 struct empty
 {
 empty () = default;
 };
>>>
>>>
>>> Why would that be excluded?  There are no subobjects, hence all of them
>>> are of class, structure, union or array type, hence this is an empty type.
>>> (And that's good, it indeed looks quite empty to me).  Even if you would
>>> add a non-trivial copy ctor, making this thing not trivially copyable
>>> anymore, it would still be empty.  Hence, given your proposed language in
>>> the psABI, without reference to any other ABI (in particular not to the
>>> Itanium C++ ABI), you would then need to pass it without registers.  That
>>> can't be done, and that's exactly why I find that wording incomplete.  It
>>> needs implicit references to other languages ABIs to work.
>>>
>>
>> It is clear to me now.  Let's go with
>>
>> ---
>> An empty type is a type where it and all of its subobjects (recursively)
>> are of class, structure, union, or array type.  No memory slot nor
>> register should be used to pass or return an object of empty type that's
>> trivially copyable.
>> ---
>>
>> Any comments?
>
> Yes. "trivially copyable" is the wrong restriction. See
> http://mentorembedded.github.io/cxx-abi/abi.html#normal-call for the
> actual Itanium C++ ABI rule.

I looked it up.  " trivially copyable" is covered by C++ ABI.

> It's also completely nonsensical to mention this as a special case in
> relation to empty types. The special case applies to all function
> parameters, irrespective of whether they're empty -- this rule applies
> *long* before you consider whether the type is empty. For instance, in
> the x86-64 psABI, this should go right at the start of section 2.2.3
> ("Parameter Passing and Returning Values"). But please don't add it
> there -- it's completely redundant, as section 5.1 already says that
> the Itanium C++ ABI is used, so it's not necessary to duplicate rules
> from there.

Here is the final wording:

An empty type is a type where it and all of its subobjects (recursively)
are of class, structure, union, or array type.  No memory slot nor register
should be used to pass or return an object of empty type.

Footnote: Array of empty type can only passed by reference in C and C++.

Michael, can you put it in x86-64 psABI?  I will update i386 and IA MCU
psABIs.

Thanks.

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


Re: [PATCH] D16538: [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-02-26 Thread Joel Jones via cfe-commits
joelkevinjones added a comment.

The FIXME comment doesn't make sense to me. I'm not sure what sanitizer 
arguments would be passed to the assembler.


http://reviews.llvm.org/D16538



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


[PATCH] D17645: AMDGPU: Add missing Volcanic Islands targets

2016-02-26 Thread Tom Stellard via cfe-commits
tstellarAMD created this revision.
tstellarAMD added a reviewer: arsenm.
tstellarAMD added a subscriber: cfe-commits.

http://reviews.llvm.org/D17645

Files:
  lib/Basic/Targets.cpp
  test/Driver/r600-mcpu.cl

Index: test/Driver/r600-mcpu.cl
===
--- test/Driver/r600-mcpu.cl
+++ test/Driver/r600-mcpu.cl
@@ -38,6 +38,8 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 
2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 
2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 
2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -66,3 +68,5 @@
 // TONGA-CHECK: "-target-cpu" "tonga"
 // ICELAND-CHECK: "-target-cpu" "iceland"
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
+// FIJI-CHECK: "-target-cpu" "fiji"
+// STONEY-CHECK: "-target-cpu" "stoney"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1927,6 +1927,8 @@
   .Case("tonga",GK_VOLCANIC_ISLANDS)
   .Case("iceland",  GK_VOLCANIC_ISLANDS)
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
+  .Case("fiji", GK_VOLCANIC_ISLANDS)
+  .Case("stoney",   GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
 if (GPU == GK_NONE) {


Index: test/Driver/r600-mcpu.cl
===
--- test/Driver/r600-mcpu.cl
+++ test/Driver/r600-mcpu.cl
@@ -38,6 +38,8 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -66,3 +68,5 @@
 // TONGA-CHECK: "-target-cpu" "tonga"
 // ICELAND-CHECK: "-target-cpu" "iceland"
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
+// FIJI-CHECK: "-target-cpu" "fiji"
+// STONEY-CHECK: "-target-cpu" "stoney"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1927,6 +1927,8 @@
   .Case("tonga",GK_VOLCANIC_ISLANDS)
   .Case("iceland",  GK_VOLCANIC_ISLANDS)
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
+  .Case("fiji", GK_VOLCANIC_ISLANDS)
+  .Case("stoney",   GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
 if (GPU == GK_NONE) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-26 Thread Martin Probst via cfe-commits
>
> Nice, the behavior now seems nicely isolated. Is this a purely stylistic
> kind of change or do you think every JS developer working on any kind of
> codebase will want it? Generally this feels like something we should
> carefully enable with a dedicated style option. Where can I find more
> information about it?


According to Google JavaScript style, you should always use single quotes
for string literals. Outside of that, people usually prefer one over the
other (I think), some people just use both indiscriminately. We could make
it an option, and only turn it on for a specific Google style.

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


Re: [PATCH] D17640: [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

2016-02-26 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 49186.
hokein added a comment.

Correct test code format.


http://reviews.llvm.org/D17640

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp

Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -183,6 +183,18 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -327,7 +327,7 @@
NullMacros.end();
   }
 
-  MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+  MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
   ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
   if (ArgLoc.isFileID())


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -183,6 +183,18 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -327,7 +327,7 @@
NullMacros.end();
   }
 
-  MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+  MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
   ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
   if (ArgLoc.isFileID())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17640: [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

2016-02-26 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262024: [clang-tidy] Fix an assertion failure in 
`modernize-use-nullptr` check. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17640?vs=49186&id=49187#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17640

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -327,7 +327,7 @@
NullMacros.end();
   }
 
-  MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+  MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
   ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
   if (ArgLoc.isFileID())
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -183,6 +183,18 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -327,7 +327,7 @@
NullMacros.end();
   }
 
-  MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+  MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
   ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
   if (ArgLoc.isFileID())
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -183,6 +183,18 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r262024 - [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

2016-02-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Feb 26 09:34:35 2016
New Revision: 262024

URL: http://llvm.org/viewvc/llvm-project?rev=262024&view=rev
Log:
[clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D17640

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=262024&r1=262023&r2=262024&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Feb 26 
09:34:35 2016
@@ -327,7 +327,7 @@ private:
NullMacros.end();
   }
 
-  MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+  MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
   ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
   if (ArgLoc.isFileID())

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=262024&r1=262023&r2=262024&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Fri Feb 
26 09:34:35 2016
@@ -183,6 +183,18 @@ void test_macro_args() {
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.


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


r262025 - Reduce false positives in printf/scanf format checker

2016-02-26 Thread Andy Gibbs via cfe-commits
Author: andyg
Date: Fri Feb 26 09:35:16 2016
New Revision: 262025

URL: http://llvm.org/viewvc/llvm-project?rev=262025&view=rev
Log:
Reduce false positives in printf/scanf format checker

Summary:
The printf/scanf format checker is a little over-zealous in handling the 
conditional operator.  This patch reduces work by not checking code-paths that 
are never used and reduces false positives regarding uncovered arguments, for 
example in the code fragment:

printf(minimal ? "%i\n" : "%i: %s\n", code, msg);

Reviewers: rtrieu

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15636

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings-scanf.c
cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=262025&r1=262024&r2=262025&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Feb 26 09:35:16 2016
@@ -3256,6 +3256,51 @@ bool Sema::SemaBuiltinSetjmp(CallExpr *T
 }
 
 namespace {
+class UncoveredArgHandler {
+  enum { Unknown = -1, AllCovered = -2 };
+  signed FirstUncoveredArg;
+  SmallVector DiagnosticExprs;
+
+public:
+  UncoveredArgHandler() : FirstUncoveredArg(Unknown) { }
+
+  bool hasUncoveredArg() const {
+return (FirstUncoveredArg >= 0);
+  }
+
+  unsigned getUncoveredArg() const {
+assert(hasUncoveredArg() && "no uncovered argument");
+return FirstUncoveredArg;
+  }
+
+  void setAllCovered() {
+// A string has been found with all arguments covered, so clear out
+// the diagnostics.
+DiagnosticExprs.clear();
+FirstUncoveredArg = AllCovered;
+  }
+
+  void Update(signed NewFirstUncoveredArg, const Expr *StrExpr) {
+assert(NewFirstUncoveredArg >= 0 && "Outside range");
+
+// Don't update if a previous string covers all arguments.
+if (FirstUncoveredArg == AllCovered)
+  return;
+
+// UncoveredArgHandler tracks the highest uncovered argument index
+// and with it all the strings that match this index.
+if (NewFirstUncoveredArg == FirstUncoveredArg)
+  DiagnosticExprs.push_back(StrExpr);
+else if (NewFirstUncoveredArg > FirstUncoveredArg) {
+  DiagnosticExprs.clear();
+  DiagnosticExprs.push_back(StrExpr);
+  FirstUncoveredArg = NewFirstUncoveredArg;
+}
+  }
+
+  void Diagnose(Sema &S, bool IsFunctionCall, const Expr *ArgExpr);
+};
+
 enum StringLiteralCheckType {
   SLCT_NotALiteral,
   SLCT_UncheckedLiteral,
@@ -3271,7 +3316,8 @@ static void CheckFormatString(Sema &S, c
   Sema::FormatStringType Type,
   bool inFunctionCall,
   Sema::VariadicCallType CallType,
-  llvm::SmallBitVector &CheckedVarArgs);
+  llvm::SmallBitVector &CheckedVarArgs,
+  UncoveredArgHandler &UncoveredArg);
 
 // Determine if an expression is a string literal or constant string.
 // If this function returns false on the arguments to a function expecting a
@@ -3282,7 +3328,8 @@ checkFormatStringExpr(Sema &S, const Exp
   bool HasVAListArg, unsigned format_idx,
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs) {
+  llvm::SmallBitVector &CheckedVarArgs,
+  UncoveredArgHandler &UncoveredArg) {
  tryAgain:
   if (E->isTypeDependent() || E->isValueDependent())
 return SLCT_NotALiteral;
@@ -3303,17 +3350,39 @@ checkFormatStringExpr(Sema &S, const Exp
 // completely checked only if both sub-expressions were checked.
 const AbstractConditionalOperator *C =
 cast(E);
-StringLiteralCheckType Left =
-checkFormatStringExpr(S, C->getTrueExpr(), Args,
-  HasVAListArg, format_idx, firstDataArg,
-  Type, CallType, InFunctionCall, CheckedVarArgs);
-if (Left == SLCT_NotALiteral)
-  return SLCT_NotALiteral;
+
+// Determine whether it is necessary to check both sub-expressions, for
+// example, because the condition expression is a constant that can be
+// evaluated at compile time.
+bool CheckLeft = true, CheckRight = true;
+
+bool Cond;
+if (C->getCond()->EvaluateAsBooleanCondition(Cond, S.getASTContext())) {
+  if (Cond)
+CheckRight = false;
+  else
+CheckLeft = false;
+}
+
+StringLiteralCheckType Left;
+if (!CheckLeft)
+  Left = SLCT_UncheckedLiteral;
+else {
+  Left = checkFormatStringExpr(S, C->getTrueExpr(), Args,
+   HasVAListArg, format_idx, firstDataArg,
+  

Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-02-26 Thread Yaxun Liu via cfe-commits
yaxunl marked 2 inline comments as done.


Comment at: lib/Sema/SemaExpr.cpp:6194-6203
@@ +6193,12 @@
+
+  incompatTy = S.Context.getPointerType(
+  S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpace));
+  LHS = S.ImpCastExprToType(LHS.get(), incompatTy,
+(lhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+  RHS = S.ImpCastExprToType(RHS.get(), incompatTy,
+(rhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+} else {

pxli168 wrote:
> I am quite confused by these codes. It seems in some situations you need both 
> BitCast and AddressSpaceConversion.
> It seems the logic here is too complex. Maybe you can try to simplify it
> 
if the addr space is different, CK_AddressSpaceConversion is used, which 
corresponds to addrspacecast in LLVM (it is OK if pointee base types are 
different here, addrspacecast covers that, no need for an extra bitcast).

I've tried to simplify the logic. Any suggestion how to further simplify the 
logic?



Comment at: lib/Sema/SemaExpr.cpp:6220-6232
@@ -6186,7 +6219,15 @@
 ResultTy = S.Context.getBlockPointerType(ResultTy);
-  else
+  else {
+auto ResultAddrSpace = ResultTy.getQualifiers().getAddressSpace();
+LHSCastKind = lhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
+RHSCastKind = rhQual.getAddressSpace() == ResultAddrSpace
+  ? CK_BitCast
+  : CK_AddressSpaceConversion;
 ResultTy = S.Context.getPointerType(ResultTy);
+  }
 
-  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, CK_BitCast);
-  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, CK_BitCast);
+  LHS = S.ImpCastExprToType(LHS.get(), ResultTy, LHSCastKind);
+  RHS = S.ImpCastExprToType(RHS.get(), ResultTy, RHSCastKind);
   return ResultTy;

pxli168 wrote:
> Why change about block pointer?
> Block can not be used with ternary selection operator (?:) in OpenCL.
This change is for non-block pointer. 

For cases 

global int* g;
generic int* p;
0?g:p;

Anastasia suggested to change mergeTypes to return type generic int*, then an 
implicit cast needs to be inserted for g, which is handled here.



Repository:
  rL LLVM

http://reviews.llvm.org/D17412



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


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-02-26 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Hi Anastasia/Richard,

I found this issue when investigating some codegen issues in Clang -cc1 with 
-emit-llvm. I need to pass an llvm option -print-after-all to the LLVM pass 
manager which is used to run the optimization passes before emitting llvm. 
However it did not work. Then I found ParseCommandLineOptions was only called 
when target machine was set. I fixed this by always call 
ParseCommandLineOptions even though there is no target machine.

This bug causes difficulty for OpenCL since it is usually compiled without 
target machine.

Could you please review this? Thanks.


http://reviews.llvm.org/D17552



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


Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-26 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Sounds like a good plan. Should also mention the corresponding style guide 
reference in the commit message:

https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings


http://reviews.llvm.org/D17385



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


r262030 - Basic: fix __USER_LABEL_PREFIX__ on Cygwin

2016-02-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Feb 26 10:34:01 2016
New Revision: 262030

URL: http://llvm.org/viewvc/llvm-project?rev=262030&view=rev
Log:
Basic: fix __USER_LABEL_PREFIX__ on Cygwin

Adjust the user label prefix for cygwin x86_64.

Resolves PR26744.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262030&r1=262029&r2=262030&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb 26 10:34:01 2016
@@ -4226,6 +4226,7 @@ public:
   : X86_64TargetInfo(Triple) {
 TLSSupported = false;
 WCharType = UnsignedShort;
+UserLabelPrefix = "";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=262030&r1=262029&r2=262030&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Feb 26 10:34:01 2016
@@ -9049,3 +9049,10 @@
 // WEBASSEMBLY64-NEXT:#define __wasm64 1
 // WEBASSEMBLY64-NEXT:#define __wasm64__ 1
 // WEBASSEMBLY64-NEXT:#define __wasm__ 1
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple i686-windows-cygnus < 
/dev/null | FileCheck -match-full-lines -check-prefix CYGWIN-X32 %s
+// CYGWIN-X32: #define __USER_LABEL_PREFIX__ _
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple x86_64-windows-cygnus < 
/dev/null | FileCheck -match-full-lines -check-prefix CYGWIN-X64 %s
+// CYGWIN-X64: #define __USER_LABEL_PREFIX__
+


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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-02-26 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I think we are not covering all the possible cases with tests now! May be we 
could also create a separate cl file since it becomes quite large.



Comment at: lib/AST/ASTContext.cpp:7605
@@ -7604,3 +7604,3 @@
   // If two types are identical, they are compatible.
   if (LHSCan == RHSCan)
 return LHS;

I feel like the AS check should be lifted here instead, because here we check 
unqualified types and then return LHS type. In OpenCL we have to return either 
LHS or RHS type just like you do below if AS overlap.


Comment at: lib/AST/ASTContext.cpp:7616
@@ +7615,3 @@
+  if (LQuals.isAddressSpaceSupersetOf(RQuals))
+return LHS;
+  if (RQuals.isAddressSpaceSupersetOf(LQuals))

I think this should be rather done above (see comment to line 7605) w/o CVR 
Quals check.


Comment at: lib/AST/ASTContext.cpp:7624
@@ -7614,3 +7623,3 @@
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
 LQuals.getObjCLifetime() != RQuals.getObjCLifetime())

We should add !OpenCL here. Because for OpenCL this check is wrong to do.

But I am not sure whether we need to add an OpenCL check here though, as we 
don't seem to return any type but void for OpenCL after this statement anyways.

However, we might return 'generic void*' if AS overlap, instead of 'private 
void*' as we do now. Would this make more sense?




Comment at: lib/Sema/SemaExpr.cpp:6182
@@ +6181,3 @@
+  unsigned ResultAddrSpace;
+  if (lhQual.isAddressSpaceSupersetOf(rhQual)) {
+ResultAddrSpace = lhQual.getAddressSpace();

if we return generic pointer type in mergeTypes, we won't need ResultAddrSpace 
as it will be returned in CompisiteTy.


Comment at: lib/Sema/SemaExpr.cpp:6194-6203
@@ +6193,12 @@
+
+  incompatTy = S.Context.getPointerType(
+  S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpace));
+  LHS = S.ImpCastExprToType(LHS.get(), incompatTy,
+(lhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+  RHS = S.ImpCastExprToType(RHS.get(), incompatTy,
+(rhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+} else {

yaxunl wrote:
> pxli168 wrote:
> > I am quite confused by these codes. It seems in some situations you need 
> > both BitCast and AddressSpaceConversion.
> > It seems the logic here is too complex. Maybe you can try to simplify it
> > 
> if the addr space is different, CK_AddressSpaceConversion is used, which 
> corresponds to addrspacecast in LLVM (it is OK if pointee base types are 
> different here, addrspacecast covers that, no need for an extra bitcast).
> 
> I've tried to simplify the logic. Any suggestion how to further simplify the 
> logic?
> 
Yes, it's a bit complicated here because we are trying to extend C rules.

In general we might have the following situations:

1. If LHS and RHS types match exactly and:
(a) AS match => use standard C rules, no bitcast or addrspacecast
(b) AS overlap => generate addrspacecast
(c) As don't overlap => give an error
2. if LHS and RHS types don't match:
(a) AS match => use standard C rules, generate bitcast
(b) AS overlap => generate addrspacecast instead of bitcast
(c) AS don't overlap => give an error

I think however we are missing testing all of the cases at the moment. Could 
you please add more tests!


Repository:
  rL LLVM

http://reviews.llvm.org/D17412



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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Joey Gouly!

Thanks!


http://reviews.llvm.org/D17578



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


r262042 - Minor tweak to match the overall style.

2016-02-26 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Fri Feb 26 12:01:12 2016
New Revision: 262042

URL: http://llvm.org/viewvc/llvm-project?rev=262042&view=rev
Log:
Minor tweak to match the overall style.

Modified:
cfe/trunk/test/Sema/bitfield-layout.c

Modified: cfe/trunk/test/Sema/bitfield-layout.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield-layout.c?rev=262042&r1=262041&r2=262042&view=diff
==
--- cfe/trunk/test/Sema/bitfield-layout.c (original)
+++ cfe/trunk/test/Sema/bitfield-layout.c Fri Feb 26 12:01:12 2016
@@ -255,7 +255,7 @@ struct g13 {
 CHECK_SIZE(struct, g13, 16);
 CHECK_ALIGN(struct, g13, 8);
 CHECK_OFFSET(struct, g13, c, 8);
-#elif (__x86_64__)
+#elif defined(__x86_64__)
 CHECK_SIZE(struct, g13, 9);
 CHECK_ALIGN(struct, g13, 1);
 CHECK_OFFSET(struct, g13, c, 8);
@@ -274,7 +274,7 @@ struct __attribute__((packed)) g14 {
 CHECK_SIZE(struct, g14, 16);
 CHECK_ALIGN(struct, g14, 8);
 CHECK_OFFSET(struct, g14, c, 8);
-#elif (__x86_64__)
+#elif defined(__x86_64__)
 CHECK_SIZE(struct, g14, 9);
 CHECK_ALIGN(struct, g14, 1);
 CHECK_OFFSET(struct, g14, c, 8);


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


Re: [PATCH] D17627: Fix false positives for for-loop-analysis warning

2016-02-26 Thread Steven Wu via cfe-commits
steven_wu added subscribers: doug.gregor, rjmccall.
steven_wu added reviewers: rjmccall, doug.gregor.
steven_wu added a comment.

Looking through the subscript sounds fine but I would like to know if this is 
indeed the only case that is being ignored because of OpaqueValueExpr and if 
everything is behind OpaqueValueExpr is a bug in building AST.

John, Doug, any opinion on this?


http://reviews.llvm.org/D17627



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


Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-26 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 49214.
mprobst added a comment.

- Move code closer together by piping Replacements into the FormatTokenLexer.
- remove sstream import
- * Treat JavaScript single quoted string literals as tok::string_literal, not


http://reviews.llvm.org/D17385

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -250,7 +250,7 @@
   verifyFormat("f({'a': [{}]});");
 }
 
-TEST_F(FormatTestJS, SingleQuoteStrings) {
+TEST_F(FormatTestJS, SingleQuotedStrings) {
   verifyFormat("this.function('', true);");
 }
 
@@ -635,8 +635,9 @@
 }
 
 TEST_F(FormatTestJS, StringLiteralConcatenation) {
-  verifyFormat("var literal = 'hello ' +\n"
-   "'world';");
+  verifyFormat("var literal =\n"
+   "'hello ' + 'world';",
+   getGoogleJSStyleWithColumns(30));
 }
 
 TEST_F(FormatTestJS, RegexLiteralClassification) {
@@ -874,7 +875,7 @@
   verifyFormat("import {\n"
"  X,\n"
"  Y,\n"
-   "} from 'some/long/module.js';",
+   "} from\n'some/long/module.js';",
getGoogleJSStyleWithColumns(20));
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
   verifyFormat("import * as lib from 'some/module.js';");
@@ -1085,5 +1086,36 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, RequoteStringsSingle) {
+  EXPECT_EQ("var x = 'foo';", format("var x = \"foo\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo'o'\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo\\'o'\";"));
+  EXPECT_EQ("var x =\n"
+"'foo\\'';",
+// Code below is 15 chars wide, doesn't fit into the line with the
+// \ escape added.
+format("var x = \"foo'\";", getGoogleJSStyleWithColumns(15)));
+  // Removes no-longer needed \ escape from ".
+  EXPECT_EQ("var x = 'fo\"o';", format("var x = \"fo\\\"o\";"));
+  // Code below fits into 15 chars *after* removing the \ escape.
+  EXPECT_EQ("var x = 'fo\"o';",
+format("var x = \"fo\\\"o\";", getGoogleJSStyleWithColumns(15)));
+}
+
+TEST_F(FormatTestJS, RequoteStringsDouble) {
+  FormatStyle DoubleQuotes = getGoogleStyle(FormatStyle::LK_JavaScript);
+  DoubleQuotes.Quotes = FormatStyle::QS_Double;
+  verifyFormat("var x = \"foo\";", DoubleQuotes);
+  EXPECT_EQ("var x = \"foo\";", format("var x = 'foo';", DoubleQuotes));
+  EXPECT_EQ("var x = \"fo'o\";", format("var x = 'fo\\'o';", DoubleQuotes));
+}
+
+TEST_F(FormatTestJS, RequoteStringsLeave) {
+  FormatStyle LeaveQuotes = getGoogleStyle(FormatStyle::LK_JavaScript);
+  LeaveQuotes.Quotes = FormatStyle::QS_Leave;
+  verifyFormat("var x = \"foo\";", LeaveQuotes);
+  verifyFormat("var x = 'foo';", LeaveQuotes);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6642,7 +6642,7 @@
"   b};");
 
   verifyNoCrash("a<,");
-  
+
   // No braced initializer here.
   verifyFormat("void f() {\n"
"  struct Dummy {};\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -71,6 +71,14 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::QuoteStyle &Value) {
+IO.enumCase(Value, "leave", FormatStyle::QS_Leave);
+IO.enumCase(Value, "single", FormatStyle::QS_Single);
+IO.enumCase(Value, "double", FormatStyle::QS_Double);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
 IO.enumCase(Value, "None", FormatStyle::SFS_None);
@@ -335,6 +343,7 @@
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("UseTab", Style.UseTab);
+IO.mapOptional("QuoteStyle", Style.Quotes);
   }
 };
 
@@ -522,6 +531,7 @@
   LLVMStyle.SpacesBeforeTrailingComments = 1;
   LLVMStyle.Standard = FormatStyle::LS_Cpp11;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
+  LLVMStyle.Quotes = FormatStyle::QS_Leave;
   LLVMStyle.ReflowComments = true;
   LLVMStyle.SpacesInParentheses = false;
   LLVMStyle.SpacesInSquareBrackets = false;
@@ -590,6 +600,7 @@
 GoogleStyle.CommentPragmas = "@(export|see|visibility) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.SpacesInContainerLiterals = false;
+GoogleStyle.Quotes = FormatStyle::QS_Single;
   } else if (Language == FormatStyle::LK_Proto

Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-02-26 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 49213.
ahatanak added a comment.

ping and rebase.


http://reviews.llvm.org/D15599

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/attr-naked.c
  test/CodeGenCXX/attr-naked.cpp
  test/CodeGenCXX/ms-inline-asm-return.cpp

Index: test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- test/CodeGenCXX/ms-inline-asm-return.cpp
+++ test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks | FileCheck %s
+// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks -fms-compatibility | FileCheck %s
 
 // Check that we take EAX or EAX:EDX and return it from these functions for MSVC
 // compatibility.
@@ -98,3 +98,17 @@
 // CHECK-LABEL: define i32 @main()
 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
+
+// Don't set the return value if the function is marked as naked.
+__declspec(naked) int nakedFunc(int a, int b)
+{
+  __asm {
+ret
+  }
+}
+
+// CHECK: define i32 @{{.*}}nakedFunc
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect inteldialect "ret
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
Index: test/CodeGenCXX/attr-naked.cpp
===
--- /dev/null
+++ test/CodeGenCXX/attr-naked.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+class Class1 {
+public:
+  void __attribute__((naked)) m1() { __asm__ volatile("retq"); }
+  int __attribute__((naked)) m2() { __asm__ volatile("retq"); }
+};
+
+int foo1(int a, Class1 *c1) {
+  auto Fn = []() __attribute__((naked))->int {
+__asm__ volatile("retq");
+  };
+
+  if (a < 0)
+return Fn();
+
+  if (a > 0)
+return c1->m2();
+
+  c1->m1();
+  return 1;
+}
+
+// Check for the absence of llvm.trap.
+int __attribute__((naked)) foo2(int a) {
+  __asm__ volatile("retq");
+}
+
+// CHECK: define internal i32 @"_ZZ4foo1iP6Class1ENK3$_0clEv"(%class.anon* %this) [[ATTR1:#[0-9]]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+
+// CHECK: define linkonce_odr i32 @_ZN6Class12m2Ev(%class.Class1* %this) [[ATTR2:#[0-9]]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+// CHECK: define linkonce_odr void @_ZN6Class12m1Ev(%class.Class1* %this) [[ATTR2]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+// CHECK: define i32 @_Z4foo2i(i32 %a) [[ATTR2]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+// CHECK: attributes [[ATTR1]] = { {{.*}}naked{{.*}} }
+// CHECK: attributes [[ATTR2]] = { {{.*}}naked{{.*}} }
Index: test/CodeGen/attr-naked.c
===
--- test/CodeGen/attr-naked.c
+++ test/CodeGen/attr-naked.c
@@ -17,7 +17,7 @@
 
 // Make sure not to generate prolog or epilog for naked functions.
 __attribute((naked)) void t3(int x) {
-// CHECK: define void @t3(i32)
+// CHECK: define void @t3(i32 %x)
 // CHECK-NOT: alloca
 // CHECK-NOT: store
 // CHECK: unreachable
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3122,6 +3122,13 @@
   llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
  llvm::IntegerType *ResType);
 
+  /// Return true if CurCodeDecl has attribute Naked.
+  bool isNakedFunction() const;
+
+  /// Clean up naked functions removing allocas and their users and all blocks
+  /// except the entry.
+  void cleanupNakedFunction();
+
 public:
 #ifndef NDEBUG
   // Determine whether the given argument is an Objective-C method
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -355,6 +355,9 @@
 CGBuilderTy(*this, AllocaInsertPt).CreateCall(FrameEscapeFn, EscapeArgs);
   }
 
+  if (isNakedFunction())
+cleanupNakedFunction();
+
   // Remove the AllocaInsertPt instruction, which is just a convenience for us.
   llvm::Instruction *Ptr = AllocaInsertPt;
   AllocaInsertPt = nullptr;
@@ -1008,7 +1011,8 @@
   //   If the '}' that terminates a function is reached, and the value of the
   //   function call is used by the caller, the behavior is undefined.
   if (getLangOpts().CPlusPlus && !FD->hasImplicitReturnZero() && !SawAsmBlock &&
-  !FD->getReturnType()->isVoidType() && Builder.GetInsertBlock()) {
+

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-26 Thread Timon Van Overveldt via cfe-commits
timonvo updated this revision to Diff 49215.
timonvo added a comment.

That's basically the Diff 48015 I had at some point. Reverted back to it now. 
Now this patch doesn't declare any macros anymore.


http://reviews.llvm.org/D15883

Files:
  lib/Headers/unwind.h

Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -79,6 +79,10 @@
 struct _Unwind_Exception;
 typedef enum {
   _URC_NO_REASON = 0,
+#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
+!defined(__ARM_DWARF_EH__)
+  _URC_OK = 0, /* used by ARM EHABI */
+#endif
   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
 
   _URC_FATAL_PHASE2_ERROR = 2,
@@ -88,7 +92,11 @@
   _URC_END_OF_STACK = 5,
   _URC_HANDLER_FOUND = 6,
   _URC_INSTALL_CONTEXT = 7,
-  _URC_CONTINUE_UNWIND = 8
+  _URC_CONTINUE_UNWIND = 8,
+#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
+!defined(__ARM_DWARF_EH__)
+  _URC_FAILURE = 9 /* used by ARM EHABI */
+#endif
 } _Unwind_Reason_Code;
 
 typedef enum {
@@ -150,6 +158,15 @@
   _UVRSR_FAILED = 2
 } _Unwind_VRS_Result;
 
+#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__ARM_DWARF_EH__)
+typedef uint32_t _Unwind_State;
+#define _US_VIRTUAL_UNWIND_FRAME  ((_Unwind_State)0)
+#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
+#define _US_UNWIND_FRAME_RESUME   ((_Unwind_State)2)
+#define _US_ACTION_MASK   ((_Unwind_State)3)
+#define _US_FORCE_UNWIND  ((_Unwind_State)8)
+#endif
+
 _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
   _Unwind_VRS_RegClass __regclass,
   uint32_t __regno,


Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -79,6 +79,10 @@
 struct _Unwind_Exception;
 typedef enum {
   _URC_NO_REASON = 0,
+#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
+!defined(__ARM_DWARF_EH__)
+  _URC_OK = 0, /* used by ARM EHABI */
+#endif
   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
 
   _URC_FATAL_PHASE2_ERROR = 2,
@@ -88,7 +92,11 @@
   _URC_END_OF_STACK = 5,
   _URC_HANDLER_FOUND = 6,
   _URC_INSTALL_CONTEXT = 7,
-  _URC_CONTINUE_UNWIND = 8
+  _URC_CONTINUE_UNWIND = 8,
+#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
+!defined(__ARM_DWARF_EH__)
+  _URC_FAILURE = 9 /* used by ARM EHABI */
+#endif
 } _Unwind_Reason_Code;
 
 typedef enum {
@@ -150,6 +158,15 @@
   _UVRSR_FAILED = 2
 } _Unwind_VRS_Result;
 
+#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__ARM_DWARF_EH__)
+typedef uint32_t _Unwind_State;
+#define _US_VIRTUAL_UNWIND_FRAME  ((_Unwind_State)0)
+#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
+#define _US_UNWIND_FRAME_RESUME   ((_Unwind_State)2)
+#define _US_ACTION_MASK   ((_Unwind_State)3)
+#define _US_FORCE_UNWIND  ((_Unwind_State)8)
+#endif
+
 _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
   _Unwind_VRS_RegClass __regclass,
   uint32_t __regno,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262050 - SemaCXX: Support templates in availability attributes

2016-02-26 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Feb 26 13:27:00 2016
New Revision: 262050

URL: http://llvm.org/viewvc/llvm-project?rev=262050&view=rev
Log:
SemaCXX: Support templates in availability attributes

If the availability context is `FunctionTemplateDecl`, we should look
through it to the `FunctionDecl`.  This prevents a diagnostic in the
following case:

class C __attribute__((unavailable));
template  void foo(C&) __attribute__((unavailable));

This adds tests for availability in templates in many other cases, but
that was the only case that failed before this patch.

I added a feature `__has_feature(attribute_availability_in_templates)`
so users can test for this.

rdar://problem/24561029

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/SemaCXX/attr-unavailable.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=262050&r1=262049&r2=262050&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Feb 26 13:27:00 2016
@@ -467,6 +467,9 @@ static AvailabilityResult CheckAvailabil
 }
 
 AvailabilityResult Decl::getAvailability(std::string *Message) const {
+  if (auto *FTD = dyn_cast(this))
+return FTD->getTemplatedDecl()->getAvailability(Message);
+
   AvailabilityResult Result = AR_Available;
   std::string ResultMessage;
 

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=262050&r1=262049&r2=262050&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Feb 26 13:27:00 2016
@@ -1074,6 +1074,7 @@ static bool HasFeature(const Preprocesso
   .Case("attribute_availability_tvos", true)
   .Case("attribute_availability_watchos", true)
   .Case("attribute_availability_with_strict", true)
+  .Case("attribute_availability_in_templates", true)
   .Case("attribute_cf_returns_not_retained", true)
   .Case("attribute_cf_returns_retained", true)
   .Case("attribute_cf_returns_on_parameters", true)

Modified: cfe/trunk/test/SemaCXX/attr-unavailable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-unavailable.cpp?rev=262050&r1=262049&r2=262050&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-unavailable.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-unavailable.cpp Fri Feb 26 13:27:00 2016
@@ -5,7 +5,8 @@ double &foo(double); // expected-note {{
 void foo(...) __attribute__((__unavailable__)); // expected-note {{candidate 
function}} \
 // expected-note{{'foo' has been explicitly marked unavailable here}}
 
-void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly 
marked unavailable}}
+void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly 
marked unavailable}} \
+   // expected-note 2{{candidate function has been explicitly made 
unavailable}}
 
 void test_foo(short* sp) {
   int &ir = foo(1);
@@ -56,3 +57,62 @@ typedef enum UnavailableEnum AnotherUnav
 
 __attribute__((unavailable))
 UnavailableEnum testUnavailable(UnavailableEnum X) { return X; }
+
+
+// Check that unavailable classes can be used as arguments to unavailable
+// function, particularly in template functions.
+#if !__has_feature(attribute_availability_in_templates)
+#error "Missing __has_feature"
+#endif
+class __attribute((unavailable)) UnavailableClass; // \
+expected-note 3{{'UnavailableClass' has been explicitly marked 
unavailable here}}
+void unavail_class(UnavailableClass&); // expected-error {{'UnavailableClass' 
is unavailable}}
+void unavail_class_marked(UnavailableClass&) __attribute__((unavailable));
+template  void unavail_class(UnavailableClass&); // expected-error 
{{'UnavailableClass' is unavailable}}
+template  void unavail_class_marked(UnavailableClass&) 
__attribute__((unavailable));
+template  void templated(T&);
+void untemplated(UnavailableClass &UC) {  // expected-error 
{{'UnavailableClass' is unavailable}}
+  templated(UC);
+}
+void untemplated_marked(UnavailableClass &UC) __attribute__((unavailable)) {
+  templated(UC);
+}
+
+template  void templated_calls_bar() { bar(); } // \
+   // expected-error{{call to unavailable function 'bar'}}
+template  void templated_calls_bar_arg(T v) { bar(v); } // \
+   // expected-error{{call to unavailable function 'bar'}}
+template  void templated_calls_bar_arg_never_called(T v) { bar(v); }
+
+template 
+void unavail_templated_calls_bar() __attribute__((unavailable)) { // \
+  expected-note{{candidate function [with T = int] has been explicitly made 
unavailable}}
+  bar(5);
+}
+template 
+void unavail_templated_calls_bar_arg(T v) __attribu

Re: [PATCH] SemaCXX: Support templates in availability attributes

2016-02-26 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-24, at 10:01, Aaron Ballman  wrote:
> 
> On Tue, Feb 23, 2016 at 6:39 PM, Duncan P. N. Exon Smith
>  wrote:
>> 
>>> On 2016-Feb-23, at 11:18, Aaron Ballman  wrote:
>>> 
>>> On Tue, Feb 23, 2016 at 1:52 PM, Manman Ren  wrote:
 This patch looks good to me. But I am not sure if Aaron has any comment.
 
 On Feb 22, 2016, at 6:19 PM, Duncan P. N. Exon Smith 
 wrote:
 
 
 On 2016-Feb-22, at 17:24, Manman Ren  wrote:
 
 
 
 On Feb 8, 2016, at 8:17 PM, Duncan P. N. Exon Smith 
 wrote:
 
 This patch adds support for templates in availability attributes.
 - If the context for an availability diagnostic is a
 `FunctionTemplateDecl`, look through it to the `FunctionDecl`.
 
 
 AvailabilityResult Decl::getAvailability(std::string *Message) const {
 +  if (auto *FTD = dyn_cast(this))
 +return FTD->getTemplatedDecl()->getAvailability(Message);
 +
 AvailabilityResult Result = AR_Available;
 
 
 This looks generally correct to me.
 The UnavailableAttr is attached to the FunctionDecl, not the
 FunctionTemplateDecl, so looking through sounds right.
 
 - Add `__has_feature(attribute_availability_in_templates)`.
 
 
 @Aaron, any comment on this?
 This patch adds extra support for Availability attribute (similar to
 attribute_availability_with_strict in r261548).
 Not sure if has_attribute can be used for this purpose.
>>> 
>>> Given that we're already using __has_feature for the rest of the
>>> availability attribute stuff, I think it's better to keep it all
>>> grouped together instead of checking for some features with
>>> __has_feature and others with __has_attribute.
>> 
>> Besides that argument, this isn't adding any attributes, just checking
>> how they behave.
>> 
>>> If I understand
>>> properly, this is taking code that would have previously been
>>> ill-formed and making it well-formed, and that's why the feature
>>> testing macro is required?
>> 
>> Exactly.  Previously this was ill-formed:
>> ```
>> class Unavail __attribute__((unavailable));
>> 
>> template 
>> void foo(Unavail&) __attribute__((unavailable));
>> ```
>> 
>> Same for `__attribute((availability(macosx,unavailable)))`, and other
>> triggers of "unavailable".
> 
> Okay, this makes sense to me, thank you for the explanation. LGTM!
> 

r262050.  Thanks!

> ~Aaron
>> 
>>> 
>>> Thanks!
>>> 
>>> ~Aaron
>>> 
 
 Manman
 
 
 Is there anything else I should be testing to be sure availability
 works correctly in templates?
 
 
 Maybe
 test()
 calling unavailable function from an unavailable template function
 calling an unavailable template function
 
 I think these all work with the current compiler. But I am not sure if we
 have existing test coverage.
 
 
 Thanks for the ideas; let me know if you have any others.
 
 Can you have a look at the new patch?
 
 Cheers,
 Manman
 
 I'm working on a patch to add
 availability markup to the libc++ headers, and this is the only
 problem I've hit so far.  Anyone have thoughts on other things I
 should test?
 
 
 <0001-SemaCXX-Support-templates-in-availability-attributes.patch>

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


Re: [PATCH] D17589: Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT

2016-02-26 Thread Paul Robinson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262052: Fix Clang tests that used CHECK-NEXT-NOT and 
CHECK-DAG-NOT. (authored by probinson).

Changed prior to commit:
  http://reviews.llvm.org/D17589?vs=48999&id=49217#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17589

Files:
  cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
  cfe/trunk/test/CodeGen/alias.c
  cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
  cfe/trunk/test/Driver/hexagon-toolchain-elf.c
  cfe/trunk/test/SemaCXX/pragma-optimize.cpp

Index: cfe/trunk/test/SemaCXX/pragma-optimize.cpp
===
--- cfe/trunk/test/SemaCXX/pragma-optimize.cpp
+++ cfe/trunk/test/SemaCXX/pragma-optimize.cpp
@@ -151,14 +151,14 @@
 // CHECK-DAG: attributes [[ATTRYETANOTHEROPTNONE]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 
 // Check that the other functions do NOT have optnone.
-// CHECK-DAG-NOT: attributes [[ATTRFOO]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRBAZ]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRBAX]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRWOMBAT]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRTWICE]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER2]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER3]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRTHRICEINT]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRYETANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRFOO]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRBAZ]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRBAX]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRWOMBAT]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRTWICE]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER2]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER3]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRTHRICEINT]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRYETANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -40,8 +40,8 @@
 // X86-NOT: "amdgpu_num_vgpr"
 // X86-NOT: "amdgpu_num_sgpr"
 
-// CHECK-DAG-NOT: "amdgpu_num_vgpr"="0"
-// CHECK-DAG-NOT: "amdgpu_num_sgpr"="0"
+// CHECK-NOT: "amdgpu_num_vgpr"="0"
+// CHECK-NOT: "amdgpu_num_sgpr"="0"
 // CHECK-DAG: attributes [[ATTR_VGPR64]] = { nounwind "amdgpu_num_vgpr"="64"
 // CHECK-DAG: attributes [[ATTR_SGPR32]] = { nounwind "amdgpu_num_sgpr"="32"
 // CHECK-DAG: attributes [[ATTR_VGPR64_SGPR32]] = { nounwind "amdgpu_num_sgpr"="32" "amdgpu_num_vgpr"="64"
Index: cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
===
--- cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
+++ cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
@@ -23,5 +23,5 @@
 
 // CHECK: ldr
 // CHECK-YES-NEXT: nop
-// CHECK-NO-NEXT-NOT: nop
+// CHECK-NO-NOT: nop
 // CHECK-NEXT: madd
Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -24,20 +24,20 @@
 // CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
 // CHECKASM-DAG: .globl __mod_usb_device_table
 // CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids
-// CHECKASM-DAG-NOT: .size __mod_usb_device_table
+// CHECKASM-NOT: .size __mod_usb_device_table
 
 extern int g1;
 extern int g1 __attribute((alias("g0")));
 // CHECKBASIC-DAG: @g1 = alias i32, i32* @g0
 // CHECKASM-DAG: .globl g1
 // CHECKASM-DAG: g1 = g0
-// CHECKASM-DAG-NOT: .size g1
+// CHECKASM-NOT: .size g1
 
 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
 // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS
 // CHECKASM-DAG: .globl __libc_errno
 // CHECKASM-DAG: __libc_errno = TL_WITH_ALIAS
-// CHECKASM-DAG-NOT: .size __libc_errno
+// CHECKASM-NOT: .size __libc_errno
 
 void f0(void) { }
 extern void f1(void);
Index: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
===
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c
@@ -41,7 +41,7 @@
 // RUN:   %

r262052 - Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT.

2016-02-26 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 26 13:34:01 2016
New Revision: 262052

URL: http://llvm.org/viewvc/llvm-project?rev=262052&view=rev
Log:
Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT.
FileCheck actually doesn't support combo suffixes.

Differential Revision: http://reviews.llvm.org/D17589

Modified:
cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
cfe/trunk/test/CodeGen/alias.c
cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
cfe/trunk/test/Driver/hexagon-toolchain-elf.c
cfe/trunk/test/SemaCXX/pragma-optimize.cpp

Modified: cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c?rev=262052&r1=262051&r2=262052&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-fix-cortex-a53-835769.c Fri Feb 26 13:34:01 
2016
@@ -23,5 +23,5 @@ int64_t f_load_madd_64(int64_t a, int64_
 
 // CHECK: ldr
 // CHECK-YES-NEXT: nop
-// CHECK-NO-NEXT-NOT: nop
+// CHECK-NO-NOT: nop
 // CHECK-NEXT: madd

Modified: cfe/trunk/test/CodeGen/alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=262052&r1=262051&r2=262052&view=diff
==
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Fri Feb 26 13:34:01 2016
@@ -24,20 +24,20 @@ extern const int __mod_usb_device_table
 // CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds 
([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
 // CHECKASM-DAG: .globl __mod_usb_device_table
 // CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids
-// CHECKASM-DAG-NOT: .size __mod_usb_device_table
+// CHECKASM-NOT: .size __mod_usb_device_table
 
 extern int g1;
 extern int g1 __attribute((alias("g0")));
 // CHECKBASIC-DAG: @g1 = alias i32, i32* @g0
 // CHECKASM-DAG: .globl g1
 // CHECKASM-DAG: g1 = g0
-// CHECKASM-DAG-NOT: .size g1
+// CHECKASM-NOT: .size g1
 
 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
 // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS
 // CHECKASM-DAG: .globl __libc_errno
 // CHECKASM-DAG: __libc_errno = TL_WITH_ALIAS
-// CHECKASM-DAG-NOT: .size __libc_errno
+// CHECKASM-NOT: .size __libc_errno
 
 void f0(void) { }
 extern void f1(void);

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl?rev=262052&r1=262051&r2=262052&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl Fri Feb 26 13:34:01 2016
@@ -40,8 +40,8 @@ kernel void test_num_vgpr0_sgpr0() {
 // X86-NOT: "amdgpu_num_vgpr"
 // X86-NOT: "amdgpu_num_sgpr"
 
-// CHECK-DAG-NOT: "amdgpu_num_vgpr"="0"
-// CHECK-DAG-NOT: "amdgpu_num_sgpr"="0"
+// CHECK-NOT: "amdgpu_num_vgpr"="0"
+// CHECK-NOT: "amdgpu_num_sgpr"="0"
 // CHECK-DAG: attributes [[ATTR_VGPR64]] = { nounwind "amdgpu_num_vgpr"="64"
 // CHECK-DAG: attributes [[ATTR_SGPR32]] = { nounwind "amdgpu_num_sgpr"="32"
 // CHECK-DAG: attributes [[ATTR_VGPR64_SGPR32]] = { nounwind 
"amdgpu_num_sgpr"="32" "amdgpu_num_vgpr"="64"

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=262052&r1=262051&r2=262052&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Fri Feb 26 13:34:01 2016
@@ -41,7 +41,7 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK012 %s
 // CHECK012: "-cc1"
-// CHECK012-DAG-NOT: "-internal-isystem"
+// CHECK012-NOT: "-internal-isystem"
 // CHECK012-DAG: "-internal-externc-isystem" 
"{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/include"
 
 // RUN: %clangxx -### -target hexagon-unknown-elf -fno-integrated-as\
@@ -51,8 +51,8 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK013 %s
 // CHECK013: "-cc1"
-// CHECK013-DAG-NOT: "-internal-isystem"
-// CHECK013-DAG-NOT: "-internal-externc-isystem"
+// CHECK013-NOT: "-internal-isystem"
+// CHECK013-NOT: "-internal-externc-isystem"
 
 // 
-
 // Test -mcpu= -mv

Modified: cfe/trunk/test/SemaCXX/pragma-optimize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pragma-optimize.cpp?rev=262052&r1=262051&r2=262052&view=diff
==
--- cfe/trunk/test/SemaCXX/pragma-optimize.cpp (original)
+++ cfe/trunk/test/SemaCXX/pragma-optimize.cpp Fri Feb 2

r262056 - [dllexport] Sort out emission order of delayed exported classes

2016-02-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Feb 26 13:51:02 2016
New Revision: 262056

URL: http://llvm.org/viewvc/llvm-project?rev=262056&view=rev
Log:
[dllexport] Sort out emission order of delayed exported classes

Relands r260194 with a fix. If we have a template that transitions from
an extern template to an explicitly instantiated dllexport template, we
would add that class to the delayed exported class list without flushing
it.

For explicit instantiations, we can just flush the list of delayed
classes immediately. We don't have to worry about the bug fixed in
r260194 in this case because explicit instantiations can only occur at
file and namespace scope.

Fixes PR26490.

Added:
cfe/trunk/test/CodeGenCXX/dllexport-pr26549.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=262056&r1=262055&r2=262056&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Feb 26 13:51:02 2016
@@ -5295,11 +5295,18 @@ public:
 ArrayRef MemInits,
 bool AnyErrors);
 
+  /// \brief Check class-level dllimport/dllexport attribute. The caller must
+  /// ensure that referenceDLLExportedClassMethods is called some point later
+  /// when all outer classes of Class are complete.
   void checkClassLevelDLLAttribute(CXXRecordDecl *Class);
+
+  void referenceDLLExportedClassMethods();
+
   void propagateDLLAttrToBaseClassTemplate(
   CXXRecordDecl *Class, Attr *ClassAttr,
   ClassTemplateSpecializationDecl *BaseTemplateSpec,
   SourceLocation BaseLoc);
+
   void CheckCompletedCXXClass(CXXRecordDecl *Record);
   void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
  Decl *TagDecl,

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=262056&r1=262055&r2=262056&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 26 13:51:02 2016
@@ -9533,6 +9533,10 @@ void Sema::ActOnFinishCXXNonNestedClass(
   if (RD && Context.getTargetInfo().getCXXABI().isMicrosoft())
 getDefaultArgExprsForConstructors(*this, RD);
 
+  referenceDLLExportedClassMethods();
+}
+
+void Sema::referenceDLLExportedClassMethods() {
   if (!DelayedDllExportClasses.empty()) {
 // Calling ReferenceDllExportedMethods might cause the current function to
 // be called again, so use a local copy of DelayedDllExportClasses.

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=262056&r1=262055&r2=262056&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Feb 26 13:51:02 2016
@@ -7458,7 +7458,13 @@ Sema::ActOnExplicitInstantiation(Scope *
 getDLLAttr(Specialization)->clone(getASTContext()));
 A->setInherited(true);
 Def->addAttr(A);
+
+// We reject explicit instantiations in class scope, so there should
+// never be any delayed exported classes to worry about.
+assert(DelayedDllExportClasses.empty() &&
+   "delayed exports present at explicit instantiation");
 checkClassLevelDLLAttribute(Def);
+referenceDLLExportedClassMethods();
 
 // Propagate attribute to base class templates.
 for (auto &B : Def->bases()) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=262056&r1=262055&r2=262056&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Fri Feb 26 13:51:02 2016
@@ -1949,6 +1949,13 @@ Sema::InstantiateClass(SourceLocation Po
   bool MergeWithParentScope = 
!Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
+  // All dllexported classes created during instantiation should be fully
+  // emitted after instantiation completes. We may not be ready to emit any
+  // delayed classes already on the stack, so save them away and put them back
+  // later.
+  decltype(DelayedDllExportClasses) ExportedClasses;
+  std::swap(ExportedClasses, DelayedDllExportClasses);
+
   // Pull attributes from the pattern onto the instantiation.
   Inst

Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 49219.
ashi1 marked an inline comment as done.
ashi1 added a comment.

Revised with Xiuli Pan's comments.


http://reviews.llvm.org/D17578

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCL/event_t.cl
  test/SemaOpenCL/event_t.cl

Index: test/SemaOpenCL/event_t.cl
===
--- test/SemaOpenCL/event_t.cl
+++ test/SemaOpenCL/event_t.cl
@@ -14,5 +14,6 @@
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 
'event_t'}}
+  foo((event_t)1); // expected-error {{cannot cast non-zero value 'int' to 
'event_t'}}
 }
 
Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if (SrcExpr.get()->EvaluateAsInt(intValue, Self.Context)) {
+if (0 == intValue) {
+  Kind = CK_ZeroToOCLEvent;
+  return;
+} else {
+  Self.Diag(OpRange.getBegin(),
+diag::error_opencl_cast_non_zero_to_event_t)
+<< intValue.toString(10) << 
SrcExpr.get()->getSourceRange();
+  SrcExpr = ExprError();
+  return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7677,6 +7677,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "program scope variable must reside in %0 address space">;
 def err_missing_actual_pipe_type : Error<


Index: test/SemaOpenCL/event_t.cl
===
--- test/SemaOpenCL/event_t.cl
+++ test/SemaOpenCL/event_t.cl
@@ -14,5 +14,6 @@
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 'event_t'}}
+  foo((event_t)1); // expected-error {{cannot cast non-zero value 'int' to 'event_t'}}
 }
 
Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if (SrcExpr.get()->EvaluateAsInt(intValue, Self.Context)) {
+if (0 == intValue) {
+  Kind = CK_ZeroToOCLEvent;
+  return;
+} else {
+  Self.Diag(OpRange.getBegin(),
+diag::error_opencl_cast_non_zero_to_event_t)
+<< intValue.toString(10) << SrcExpr.get()->getSourceRange();
+  SrcExpr = ExprError();
+  return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7677,6 +7677,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero 

Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Sema/SemaCast.cpp:2318
@@ +2317,3 @@
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if (SrcExpr.get()->EvaluateAsInt(intValue, Self.Context)) {

Please name this variable properly: 
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Comment at: lib/Sema/SemaCast.cpp:2322-2323
@@ +2321,4 @@
+  Kind = CK_ZeroToOCLEvent;
+  return;
+} else {
+  Self.Diag(OpRange.getBegin(),

Don't have an else after return.  
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return


http://reviews.llvm.org/D17578



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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.





Comment at: lib/Sema/SemaCast.cpp:2317
@@ +2316,3 @@
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;

A similar patch has been submitted and rejected several times:

https://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg91067.html

http://marc.info/?l=cfe-commits&m=141198505414824&w=2

These were all before OpenCL 2.0.  The 1.2 spec does not allow this, so I think 
this should be guarded by an OpenCL version check.


http://reviews.llvm.org/D17578



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


Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-02-26 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

> After going a bit through the log, I think that there is no reason for clang 
> to not detect it, probably the check was just forgotten.

> 

> This patch is the check.


Which part of your patch (in SemaStmtAsm.cpp) is supposed to catch that? I 
applied this patch and rebuilt clang, but it still doesn't error out when it 
compiles the function in my example (foo1).

> "r" constraint means (taken from the spec:) A register operand is allowed 
> provided that it is in a general register.

>  ("%rcx") means - use the register rcx.


Isn't a) equivalent to b)?

a)
__asm__ __volatile__ ("asm1 %0, %1": "=a" (c) : "r" ("%ebx") : "cc", "ebx"); // 
do "b" and "%ebx" overlap?

b)
const char *s = "%ebx";
__asm__ __volatile__ ("asm1 %0, %1": "=a" (c) : "r" (s) : "cc", "ebx");

gcc and clang generate the same code for these two statements. I believe 
constraint "r" means clang can use any general purpose registers for the 
operand.


http://reviews.llvm.org/D15075



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-26 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.


Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:48-49
@@ +47,4 @@
+
+while(readWhitespace());
+  Token t = readNextToken();
+

In this documentation, can we please format code so that control structures 
don't look like function calls?  By this I mean write:
```
if (x >=y);
  x -= y;

while (readwhitespace());
  Token t = readNextToken();
```
instead of
```
if(x >=y);
  x -= y;

while(readwhitespace());
  Token t = readNextToken();
```



Repository:
  rL LLVM

http://reviews.llvm.org/D16535



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


r262065 - [CMake] Add BINUTILS_INCDIR to the default passthrough list for multi-stage builds

2016-02-26 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Feb 26 15:04:41 2016
New Revision: 262065

URL: http://llvm.org/viewvc/llvm-project?rev=262065&view=rev
Log:
[CMake] Add BINUTILS_INCDIR to the default passthrough list for multi-stage 
builds

This is needed to build the gold plugin in multi-stage builds.

Patch by Mike Edwards

Differential Revision: http://reviews.llvm.org/D17655

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=262065&r1=262064&r2=262065&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Feb 26 15:04:41 2016
@@ -711,6 +711,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 LLVM_VERSION_MINOR
 LLVM_VERSION_PATCH
 LLVM_VERSION_SUFFIX
+LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
 CMAKE_MAKE_PROGRAM)
 


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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-26 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Sema/SemaCast.cpp:2317
@@ +2316,3 @@
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;

tstellarAMD wrote:
> A similar patch has been submitted and rejected several times:
> 
> https://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg91067.html
> 
> http://marc.info/?l=cfe-commits&m=141198505414824&w=2
> 
> These were all before OpenCL 2.0.  The 1.2 spec does not allow this, so I 
> think this should be guarded by an OpenCL version check.
I opened a bug at khronos bugzilla requesting clarification of the issue:

https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15609

I will keep you updated.


http://reviews.llvm.org/D17578



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


r262071 - [CMake] Only configure Native target in stage 1, configure all in other stages

2016-02-26 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Feb 26 15:23:59 2016
New Revision: 262071

URL: http://llvm.org/viewvc/llvm-project?rev=262071&view=rev
Log:
[CMake] Only configure Native target in stage 1, configure all in other stages

This patch causes the 3-stage build pipeline to only build a host compiler in 
the first stage, and to build all targets for subsequent stages. The host 
target is determined via the Native target specifier added in r262070.

Modified:
cfe/trunk/cmake/caches/3-stage-base.cmake
cfe/trunk/cmake/caches/3-stage.cmake

Modified: cfe/trunk/cmake/caches/3-stage-base.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/3-stage-base.cmake?rev=262071&r1=262070&r2=262071&view=diff
==
--- cfe/trunk/cmake/caches/3-stage-base.cmake (original)
+++ cfe/trunk/cmake/caches/3-stage-base.cmake Fri Feb 26 15:23:59 2016
@@ -1,7 +1,6 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
-set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(LLVM_ENABLE_TIMESTAMPS OFF CACHE BOOL "")
 

Modified: cfe/trunk/cmake/caches/3-stage.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/3-stage.cmake?rev=262071&r1=262070&r2=262071&view=diff
==
--- cfe/trunk/cmake/caches/3-stage.cmake (original)
+++ cfe/trunk/cmake/caches/3-stage.cmake Fri Feb 26 15:23:59 2016
@@ -11,4 +11,6 @@ set(CLANG_BOOTSTRAP_TARGETS
   stage3-check-clang
   stage3-test-suite CACHE STRING "")
 
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
 include(${CMAKE_CURRENT_LIST_DIR}/3-stage-base.cmake)


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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-02-26 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 49232.
yaxunl marked 7 inline comments as done.
yaxunl added a comment.

Revised as Anastasis suggested.

Modified mergeTypes() for un-handled case.
Separate sema tests for condition operator to a new file.


Repository:
  rL LLVM

http://reviews.llvm.org/D17412

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/address-spaces-conversions.cl
  test/SemaOpenCL/condition-operator-cl2.0.cl

Index: test/SemaOpenCL/condition-operator-cl2.0.cl
===
--- /dev/null
+++ test/SemaOpenCL/condition-operator-cl2.0.cl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
+
+// Testing conditional operator with second and third operands of pointer types.
+
+#ifdef GENERIC
+#define AS generic
+#endif
+
+#ifdef GLOBAL
+#define AS global
+#endif
+
+#ifdef CONSTANT
+#define AS constant
+#endif
+
+void test_conversion(global int *arg_glob, local int *arg_loc,
+ constant int *arg_const, private int *arg_priv,
+ generic int *arg_gen, global char *arg_glob_ch,
+ local char *arg_loc_ch, constant char *arg_const_ch,
+ private char *arg_priv_ch, generic char *arg_gen_ch) {
+
+  AS int *var_cond;
+  arg_gen = 0 ? var_cond : arg_glob;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_loc;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_cond = 0 ? var_cond : arg_const;
+#ifdef GENERIC
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__generic int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_priv;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_gen;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  void *var_void_gen;
+  constant void*var_void_const;
+  var_void_gen = 0 ? var_cond : arg_glob_ch;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_void_gen = 0 ? var_cond : arg_loc_ch;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__local char *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__local char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_void_const = 0 ? var_cond : arg_const_ch;
+#ifdef GENERIC
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__generic int *' and '__constant char *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__constant char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_void_gen = 0 ? var_cond : arg_priv_ch;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and 'char *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{

Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-02-26 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/AST/ASTContext.cpp:7605
@@ -7604,3 +7604,3 @@
   // If two types are identical, they are compatible.
   if (LHSCan == RHSCan)
 return LHS;

Anastasia wrote:
> I feel like the AS check should be lifted here instead, because here we check 
> unqualified types and then return LHS type. In OpenCL we have to return 
> either LHS or RHS type just like you do below if AS overlap.
Here is still checking qualified type since 'Unqualified' is false. So this 
condition is for the case when the two types are the same.


Comment at: lib/AST/ASTContext.cpp:7624
@@ -7614,3 +7623,3 @@
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
 LQuals.getObjCLifetime() != RQuals.getObjCLifetime())

Anastasia wrote:
> We should add !OpenCL here. Because for OpenCL this check is wrong to do.
> 
> But I am not sure whether we need to add an OpenCL check here though, as we 
> don't seem to return any type but void for OpenCL after this statement 
> anyways.
> 
> However, we might return 'generic void*' if AS overlap, instead of 'private 
> void*' as we do now. Would this make more sense?
> 
> 
I think I need to handle all OpenCL cases above.
1. if types match, return LHS
2. if types differ, but addr spaces overlap and cvs qual match, return type 
with bigger addr space
3. otherwise return empty type

then we don't need check OpenCL here.


Comment at: lib/Sema/SemaExpr.cpp:6182
@@ +6181,3 @@
+  unsigned ResultAddrSpace;
+  if (lhQual.isAddressSpaceSupersetOf(rhQual)) {
+ResultAddrSpace = lhQual.getAddressSpace();

Anastasia wrote:
> if we return generic pointer type in mergeTypes, we won't need 
> ResultAddrSpace as it will be returned in CompisiteTy.
This part handles the case when mergeTypes() returns an empty type. Since the 
returned type is empty, we still need to find the result addr space.

This happens if the addr spaces are not overlapping or the unqualified pointee 
types are different.

For non-OpenCL case, Clang will insert implicit cast to void* for the two 
operands.

For OpenCL, we check the addr spaces. If they overlap, that means the 
unqualified pointee types are different, e.g.

global int* a;
generic char *b;
0?a:b;

in this case, to mimic the original Clang behavior, we insert casts so that we 
get  0?(generic void*)a:(generic void*)b.



Comment at: lib/Sema/SemaExpr.cpp:6194-6203
@@ +6193,12 @@
+
+  incompatTy = S.Context.getPointerType(
+  S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpace));
+  LHS = S.ImpCastExprToType(LHS.get(), incompatTy,
+(lhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+  RHS = S.ImpCastExprToType(RHS.get(), incompatTy,
+(rhQual.getAddressSpace() != ResultAddrSpace)
+? CK_AddressSpaceConversion
+: CK_BitCast);
+} else {

Anastasia wrote:
> yaxunl wrote:
> > pxli168 wrote:
> > > I am quite confused by these codes. It seems in some situations you need 
> > > both BitCast and AddressSpaceConversion.
> > > It seems the logic here is too complex. Maybe you can try to simplify it
> > > 
> > if the addr space is different, CK_AddressSpaceConversion is used, which 
> > corresponds to addrspacecast in LLVM (it is OK if pointee base types are 
> > different here, addrspacecast covers that, no need for an extra bitcast).
> > 
> > I've tried to simplify the logic. Any suggestion how to further simplify 
> > the logic?
> > 
> Yes, it's a bit complicated here because we are trying to extend C rules.
> 
> In general we might have the following situations:
> 
> 1. If LHS and RHS types match exactly and:
> (a) AS match => use standard C rules, no bitcast or addrspacecast
> (b) AS overlap => generate addrspacecast
> (c) As don't overlap => give an error
> 2. if LHS and RHS types don't match:
> (a) AS match => use standard C rules, generate bitcast
> (b) AS overlap => generate addrspacecast instead of bitcast
> (c) AS don't overlap => give an error
> 
> I think however we are missing testing all of the cases at the moment. Could 
> you please add more tests!
I think we are missing tests for 2a 2b 2c. I will add them.


Repository:
  rL LLVM

http://reviews.llvm.org/D17412



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


Re: [PATCH] D17637: [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics

2016-02-26 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM.
I will commit this a bit later, when I'll be around to watch the bots.


http://reviews.llvm.org/D17637



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


Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-02-26 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 49239.
sfantao marked 3 inline comments as done.
sfantao added a comment.

Use better disgnostic message and OMPArraySectionExpr::getBaseOriginalType.


http://reviews.llvm.org/D17547

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp

Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 200 %s
 template 
 struct SA {
   static int ss;
@@ -82,17 +82,111 @@
 void SAclient(int arg) {
   SA s;
   s.func(arg); // expected-note {{in instantiation of member function}}
+  double marr[10][10][10];
+  double marr2[5][10][1];
+  double mvla[5][arg][10];
+  double ***mptr;
+  const int n = 0;
+  const int m = 1;
 
   SB *p;
 
   SD u;
   SC r(p),t(p);
   #pragma omp target map(r)
   {}
+  #pragma omp target map(marr[2][0:2][0:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:][0:2][0:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[2][3][0:2])
+  {}
+  #pragma omp target map(marr[:][:][:])
+  {}
+  #pragma omp target map(marr[:2][:][:])
+  {}
+  #pragma omp target map(marr[arg:][:][:])
+  {}
+  #pragma omp target map(marr[arg:])
+  {}
+  #pragma omp target map(marr[arg:][:arg][:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:arg][:])
+  {}
+  #pragma omp target map(marr[:arg][n:])
+  {}
+  #pragma omp target map(marr[:][:arg][n:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[n:m][:arg][n:])
+  {}
+  #pragma omp target map(marr[:2][:1][:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:2][1:][:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:2][:][:1]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:2][:][1:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:1][:2][:])
+  {}
+  #pragma omp target map(marr[:1][0][:])
+  {}
+  #pragma omp target map(marr[:arg][:2][:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:1][3:1][:2])
+  {}
+  #pragma omp target map(marr[:1][3:arg][:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:1][3:2][:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr[:2][:10][:])
+  {}
+  #pragma omp target map(marr[:2][:][:5+5])
+  {}
+  #pragma omp target map(marr[:2][2+2-4:][0:5+5])
+  {}
+
+  #pragma omp target map(marr[:1][:2][0]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(marr2[:1][:2][0])
+  {}
+
+  #pragma omp target map(mvla[:1][:][0]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(mvla[:2][:arg][:]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(mvla[1][2:arg][:])
+  {}
+  #pragma omp target map(mvla[:1][:][:])
+  {}
+
+  #pragma omp target map(mptr[:2][2+2-4:1][0:5+5]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(mptr[:1][:2-1][2:4-3])
+  {}
+  #pragma omp target map(mptr[:1][:arg][2:4-3]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(mptr[:1][:2-1][0:2])
+  {}
+  #pragma omp target map(mptr[:1][:2][0:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+  #pragma omp target map(mptr[:1][:][0:2]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
+  {}
+  #pragma omp target map(mptr[:2][:1][0:2]) // expected-error {{can't prove employed array section specifies contiguous storage}}
+  {}
+
   #pragma omp target map(r.ArrS[0].B)
   {}
+  #pragma omp target map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
+  {}
+  #pragma omp target map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
+  {}
   #pragma omp target map(r.ArrS[0].Arr[1:23])
   {}
+  #pragma omp target map(r.ArrS[0].Ar

Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-02-26 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7767-7768
@@ -7766,4 +7766,4 @@
   "bit fields cannot be used to specify storage in a map clause">;
-def err_omp_array_section_in_rightmost_expression : Error<
-  "array section can only be associated with the rightmost variable in a map 
clause expression">;
+def err_omp_array_section_leads_to_non_contiguous_storage : Error<
+  "employed array section is or can be incompatible with contiguous storage 
requirements">;
 def err_omp_union_type_not_allowed : Error<

ABataev wrote:
> If you say 'can be' incompatible, then this must be a warning, not an error
I agree the diagnostic description is not the best. I changed it to: "can't 
prove employed array section specifies contiguous storage".

This has to be an error because there is no way to express non-contiguous in 
the offload runtime interface. So, we would have to codegen traps. The user 
would end up getting runtime crashes instead of a diagnostic that would be far 
more useful to direct the user to take the right actions.  


Comment at: lib/Sema/SemaOpenMP.cpp:8988-8995
@@ +8987,10 @@
+
+  // If this is an array subscript, it refers to the whole size if the size of
+  // the dimension is constant and equals 1. Also, an array section assumes the
+  // format of an array subscript if no colon is used.
+  if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) 
{
+if (auto *ATy = dyn_cast(BaseQTy.getTypePtr()))
+  return ATy->getSize().getSExtValue() == 1;
+return false;
+  }
+

ABataev wrote:
> I can't agree with that. For example:
> ```
> const int n = 0;
> arr[n:]
> ```
> It won't work with your solution, though we shall support it
Hi Alexey,

That example works fine. Note that CheckArrayExpressionReferToWholeSize only 
results in a error if  `AllowWholeSizeArraySection = false`. It is initially 
set to true, and will be set to false as components of the expression prove to 
be incompatible with that. I added a few regression test for when the bounds 
come from variables.

So:

```
struct S1 {
  int a;
  int b;
}
struct S2 {
  S1 a[10];
  int b;
}

foo (int arg) {
  int a[5][6];
  const int n = 0;
  S2 s;

  // valid - the array expression is in the right most component.
  #pragma omp target map(a[arg:])
  #pragma omp target map(a[:arg])
  #pragma omp target map(a[n:])
  // valid - this is valid only if n is zero and the compiler can prove that.
  #pragma omp target map(a[:][n:])

  // invalid - is only valid if arg is zero and that cannot be proved.
  #pragma omp target map(a[:][arg:])

  // invalid - it is contiguous storage but the OpenMP 4.5 spec explicitly say 
array sections only allowed in the rightmost expression if struct fields are 
involved.
  #pragma omp target map(s.a[n:1].b)
}
```


Comment at: lib/Sema/SemaOpenMP.cpp:9208-9220
@@ -9113,6 +9207,15 @@
 
+  // Determine the dimension we care about. We need to skip all the nested
+  // array sections to determine that.
+  unsigned Dimension = 0;
+  auto *BaseE = E;
+  while (auto *SE = dyn_cast(BaseE)) {
+BaseE = SE->getBase()->IgnoreParenImpCasts();
+++Dimension;
+  }
+
   // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
   //  If the type of a list item is a reference to a type T then the type
   //  will be considered to be T for all purposes of this clause.
-  QualType CurType = E->getType();
+  QualType CurType = BaseE->getType();
   if (CurType->isReferenceType())

ABataev wrote:
> OMPArraySectionExpr has static function getBaseOriginalType()
Oh, great, I hadn't noticed. I am using that now. Thanks!


http://reviews.llvm.org/D17547



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


Re: [PATCH] D17367: [OpenMP] Code generation for target data directive

2016-02-26 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 49244.
sfantao marked 2 inline comments as done.
sfantao added a comment.

Remove extra braces.

Waiting on dependency.


http://reviews.llvm.org/D17367

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_data_codegen.cpp

Index: test/OpenMP/target_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_codegen.cpp
@@ -0,0 +1,248 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] [i32 2]
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 1]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 5]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 1, i32 97]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+
+  // CK1-DAG: call void @__tgt_target_data_end(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P]]
+  #pragma omp target data if(1+3-5) device(arg) map(from: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target data map(la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // CK1: [[IFELSE]]
+  // CK1: br label %[[IFEND]]
+  // CK1: [[IFEND]]
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+
+  // CK1: [[IFTHEN]]

Re: [PATCH] D17622: [PGO] clang cc1 option change to enable IR level instrumenation

2016-02-26 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 49243.
xur added a comment.

Sean, Thanks for the review and suggestions.

Here is the patch that only adds -fprofile-instrument=llvm.

I'll have another patch using your suggestion on cc1 options for profile use 
compilation.


http://reviews.llvm.org/D17622

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/pgo-instrumentation.c

Index: test/CodeGen/pgo-instrumentation.c
===
--- test/CodeGen/pgo-instrumentation.c
+++ test/CodeGen/pgo-instrumentation.c
@@ -0,0 +1,9 @@
+// Test if PGO instrumentation and use pass are invoked.
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang_cc1 -O2 -fprofile-instrument=llvm %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN: PGOInstrumentationGenPass
+//
+// Ensure Pass PGOInstrumentationGenPass is not invoked.
+// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NOT: PGOInstrumentationGenPass
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -481,18 +481,23 @@
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
 
-  enum PGOInstrumentor { Unknown, None, Clang };
+  enum PGOInstrumentor { Unknown, None, Clang, LLVM };
   if (Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ)) {
 StringRef Value = A->getValue();
 PGOInstrumentor Method = llvm::StringSwitch(Value)
- .Case("clang", Clang)
  .Case("none", None)
+ .Case("clang", Clang)
+ .Case("llvm", LLVM)
  .Default(Unknown);
 switch (Method) {
+case LLVM:
+  Opts.setProfileInstr(CodeGenOptions::ProfileIRInstr);
+  break;
 case Clang:
   Opts.setProfileInstr(CodeGenOptions::ProfileClangInstr);
   break;
 case None:
+  // Null operation -- The default is ProfileNone.
   break;
 case Unknown:
   Diags.Report(diag::err_drv_invalid_pgo_instrumentor)
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -437,6 +437,12 @@
 Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
 MPM->add(createInstrProfilingPass(Options));
   }
+  if (CodeGenOpts.hasProfileIRInstr()) {
+if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+else
+  PMBuilder.PGOInstrGen = "default.profraw";
+  }
 
   if (!CodeGenOpts.SampleProfileFile.empty())
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -80,9 +80,10 @@
   };
 
   enum ProfileInstrKind {
-ProfileNoInstr,// No instrumentation.
-ProfileClangInstr  // Clang instrumentation to generate execution counts
+ProfileNone,   // Profile instrumentation is turned off.
+ProfileClangInstr, // Clang instrumentation to generate execution counts
// to use with PGO.
+ProfileIRInstr,// IR level PGO instrumentation in LLVM.
   };
 
   /// The code model to use (-mcmodel).
@@ -226,6 +227,11 @@
   bool hasProfileClangInstr() const {
 return getProfileInstr() == ProfileClangInstr;
   }
+
+  /// \brief Check if IR level profile instrumentation is on.
+  bool hasProfileIRInstr() const {
+return getProfileInstr() == ProfileIRInstr;
+  }
 };
 
 }  // end namespace clang
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -104,7 +104,7 @@
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
 
 /// \brief Choose profile instrumenation kind or no instrumentation.
-ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNoInstr)
+ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0

Re: [PATCH] D17368: [OpenMP] Code generation for target enter data directive

2016-02-26 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 49247.
sfantao marked 2 inline comments as done.
sfantao added a comment.

Remove extra braces.

Waiting on dependency.


http://reviews.llvm.org/D17368

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_enter_data_codegen.cpp

Index: test/OpenMP/target_enter_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_codegen.cpp
@@ -0,0 +1,221 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] zeroinitializer
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 1]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 5]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 1, i32 97]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  // CK1-NOT: __tgt_target_data_end
+  #pragma omp target enter data if(1+3-5) device(arg) map(alloc: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target enter data map(to: la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // CK1: [[IFELSE]]
+  // CK1: br label %[[IFEND]]
+  // CK1: [[IFEND]]
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  // CK1-NOT: __tgt_target_data_end
+  #pragma omp target enter data map(to: arg) if(arg) device(4)
+  {++arg;}
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  {++arg;}
+
+  // Region 03
+  // CK1-DAG: call void @__tgt_target_data_begin(i32 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz]]* [[GEPS:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE03]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inboun

Re: [PATCH] D17369: [OpenMP] Code generation for target exit data directive

2016-02-26 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 49249.
sfantao marked 2 inline comments as done.
sfantao added a comment.

Remove extra braces.

Waiting on dependency.


http://reviews.llvm.org/D17369

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_exit_data_codegen.cpp

Index: test/OpenMP/target_exit_data_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_codegen.cpp
@@ -0,0 +1,221 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -omptargets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+// CK1: [[ST:%.+]] = type { i32, double* }
+template 
+struct ST {
+  T a;
+  double *b;
+};
+
+ST gb;
+double gc[100];
+
+// CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i32] [i32 2]
+
+// CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i32] [i32 8]
+
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i32] [i32 6]
+
+// CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] 24]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i32] [i32 8, i32 104]
+
+// CK1-LABEL: _Z3fooi
+void foo(int arg) {
+  int la;
+  float lb[arg];
+
+  // Region 00
+  // CK1-NOT: __tgt_target_data_begin
+  // CK1-DAG: call void @__tgt_target_data_end(i32 [[DEV:%[^,]+]], i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1-DAG: [[DEV]] = load i32, i32* %{{[^,]+}},
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[BP0]]
+  // CK1-DAG: store i8* bitcast ([100 x double]* @gc to i8*), i8** [[P0]]
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data if(1+3-5) device(arg) map(from: gc)
+  {++arg;}
+
+  // Region 01
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data map(release: la) if(1+3-4)
+  {++arg;}
+
+  // Region 02
+  // CK1-NOT: __tgt_target_data_begin
+  // CK1: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
+  // CK1: [[IFTHEN]]
+  // CK1-DAG: call void @__tgt_target_data_end(i32 4, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE02]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE02]]{{.+}})
+  // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+  // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+  // CK1-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+  // CK1-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+  // CK1-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+  // CK1-DAG: [[CBPVAL0]] = bitcast i32* [[VAR0:%.+]] to i8*
+  // CK1-DAG: [[CPVAL0]] = bitcast i32* [[VAR0]] to i8*
+  // CK1: br label %[[IFEND:[^,]+]]
+
+  // CK1: [[IFELSE]]
+  // CK1: br label %[[IFEND]]
+  // CK1: [[IFEND]]
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  #pragma omp target exit data map(release: arg) if(arg) device(4)
+  {++arg;}
+
+  // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
+  {++arg;}
+
+  // Region 03
+  // CK1-NOT: __tgt_target_data_begin
+  // CK1-DAG: call void @__tgt_target_data_end(i32 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz]]* [[GEPS:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE03]]{{.+}})
+  // CK1-DAG:

Re: [PATCH] D17407: [Sema] PR25755 Fix crash when initializing out-of-order struct references

2016-02-26 Thread don hinton via cfe-commits
hintonda added a comment.

Current diff is incorrect, but I did find the problem.

When iterating over the fields of a record, we use an iterator.  The problem is 
that if we use a designator, we reset the iterator value, so we can no longer 
check Field != FieldEnd if the designators are out of order.

So, if we want to allow designators to be out of order, we'll need to keep 
track of what was actually initialized, not just that we initialized the 
correct number.  (see SemaInit.cpp:1825)

I'll work up a fix.


http://reviews.llvm.org/D17407



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


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-02-26 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Richard really is the constexpr owner so I'd like him to chime in if he can.



Comment at: include/clang/AST/Decl.h:1092
@@ -1091,3 +1091,3 @@
   /// succeeded, 0 otherwise.
-  APValue *evaluateValue() const;
-  APValue *evaluateValue(SmallVectorImpl &Notes) const;
+  APValue *evaluateValue(bool RespectMicrosoftABIIfNeeded = false) const;
+  APValue *evaluateValue(SmallVectorImpl &Notes,

Maybe this parameter would be better named `IsStaticLocalInit` or something.


Comment at: include/clang/Basic/DiagnosticASTKinds.td:151
@@ -150,1 +150,3 @@
   "%plural{1:byte|:bytes}1">;
+def note_constexpr_microsoft_abi_declrefexpr : Note<
+  "in the Microsoft ABI static local variables cannot contain references to "

> One solution to this would be to create a variation of evaluateValue() which 
> activates this new behavior and only use it from 
> CodeGenModule::EmitConstantInit(), so that the behavior of evaluateValue() in 
> this context doesn't change. How does that sound?

Right, only having this behavior change in the awkward static local case is 
good.

> By the way, I just realized that 
> CheckPotentialExpressionContainingDeclRefExpr() eats this diagnostic because 
> of the SpeculativeLookForDeclRefExprRAII object. Should I propagate it up 
> from CheckPotentialExpressionContainingDeclRefExpr() to make it user visible? 
> Right now the test case above only emits "constexpr variable 'p' must be 
> initialized by a constant expression" without any notes.

Yeah, I'd like it if we could get that note out. I'm surprised we can't use the 
normal recursive traversal to find the DeclRefExprs...


http://reviews.llvm.org/D16465



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


r262094 - [OpenMP] Fix parsing of delete map clause modifier in C++ mode.

2016-02-26 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Feb 26 18:01:58 2016
New Revision: 262094

URL: http://llvm.org/viewvc/llvm-project?rev=262094&view=rev
Log:
[OpenMP] Fix parsing of delete map clause modifier in C++ mode.

Summary: The map modifier 'delete' is parser in c++ mode as a delete keyword, 
which requires special handling in the map clause parsing.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: cfe-commits, fraggamuffin, caomhin

Differential Revision: http://reviews.llvm.org/D17629

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_exit_data_map_messages.c

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=262094&r1=262093&r2=262094&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Fri Feb 26 18:01:58 2016
@@ -1011,17 +1011,24 @@ OMPClause *Parser::ParseOpenMPVarListCla
 // Handle map type for map clause.
 ColonProtectionRAIIObject ColonRAII(*this);
 
-// the first identifier may be a list item, a map-type or
-//   a map-type-modifier
+/// The map clause modifier token can be either a identifier or the C++
+/// delete keyword.
+auto IsMapClauseModifierToken = [](const Token &Tok) {
+  return Tok.isOneOf(tok::identifier, tok::kw_delete);
+};
+
+// The first identifier may be a list item, a map-type or a
+// map-type-modifier. The map modifier can also be delete which has the 
same
+// spelling of the C++ delete keyword.
 MapType = static_cast(getOpenMPSimpleClauseType(
-Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
 DepLinMapLoc = Tok.getLocation();
 bool ColonExpected = false;
 
-if (Tok.is(tok::identifier)) {
+if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
 MapType = static_cast(getOpenMPSimpleClauseType(
-Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
 if (MapType == OMPC_MAP_unknown) {
   Diag(Tok, diag::err_omp_unknown_map_type);
 } else if (MapType == OMPC_MAP_always) {
@@ -1029,11 +1036,12 @@ OMPClause *Parser::ParseOpenMPVarListCla
 }
 ConsumeToken();
   } else if (PP.LookAhead(0).is(tok::comma)) {
-if (PP.LookAhead(1).is(tok::identifier) &&
+if (IsMapClauseModifierToken(PP.LookAhead(1)) &&
 PP.LookAhead(2).is(tok::colon)) {
   MapTypeModifier =
   static_cast(getOpenMPSimpleClauseType(
-   Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+  Kind,
+  IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
   if (MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 MapTypeModifier = OMPC_MAP_unknown;
@@ -1045,7 +1053,7 @@ OMPClause *Parser::ParseOpenMPVarListCla
   ConsumeToken();
 
   MapType = static_cast(getOpenMPSimpleClauseType(
-  Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+  Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
   if (MapType == OMPC_MAP_unknown || MapType == OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type);
   }

Modified: cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_enter_data_map_messages.c?rev=262094&r1=262093&r2=262094&view=diff
==
--- cfe/trunk/test/OpenMP/target_enter_data_map_messages.c (original)
+++ cfe/trunk/test/OpenMP/target_enter_data_map_messages.c Fri Feb 26 18:01:58 
2016
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp 
-ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp 
-ferror-limit 100 -o - -x c++ %s
 
 int main(int argc, char **argv) {
 

Modified: cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp?rev=262094&r1=262093&r2=262094&view=diff
==
--- cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp Fri Feb 26 18:01:58 
2016
@@ -23,6 +23,10 @@ T tmain(T argc, T *argv) {
 
 #pragma omp target exit data map(release: x[0:10], c)
 
+#pragma omp target exit data map(delete: x[0:10])
+

LLVM buildmaster will be updated and restarted tonight

2016-02-26 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 8 PM Pacific time
today.

Thanks

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


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-02-26 Thread Richard Smith via cfe-commits
rsmith added a comment.

We stand no hope of being bug-for-bug compatible with MSVC's constant 
expression evaluator -- we should assume there will be expressions that we 
evaluate as a constant and they do not, and vice versa. For reference, we have 
the same problem between code built by Clang and by GCC, and in some cases for 
linking together multiple object files compiled by clang (an initializer for a 
static local in an inline function can be constant in one TU but not another). 
But those have never been enough of a problem for us to actually fix the root 
cause.

Why is this set of MSVC behavior the right set to be compatible with? Is there 
some important code for which this makes us ABI-compatible? I really don't 
believe the heuristics you've got here are an exact match for the MSVC 
semantics...

This feels like patching the symptoms of a bigger issue; is there something we 
can do to address the underlying problem? Perhaps we could always emit a 
mutable variable for a static local, even if we are able to constant-initialize 
it.



Comment at: lib/AST/ExprConstant.cpp:9018
@@ -8917,1 +9017,3 @@
 
+  if (RespectMicrosoftABIIfNeeded &&
+  Ctx.getTargetInfo().getCXXABI().isMicrosoft() &&

This also needs to apply for implicitly-instantiated static data members of 
class templates.


Comment at: test/CodeGenCXX/static-init-msvc.cpp:6
@@ +5,3 @@
+
+void fun_and() {
+// CHECK-LABEL: @"\01?fun_and@@YAXXZ"()

These should all be `inline` functions. There's no need to apply any special 
behavior in any of these cases, as only one object file will contain a 
definition of the static local.


http://reviews.llvm.org/D16465



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


r262105 - Fix bug in using shadow decl checking: a using shadow decl should not conflict

2016-02-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 26 20:36:43 2016
New Revision: 262105

URL: http://llvm.org/viewvc/llvm-project?rev=262105&view=rev
Log:
Fix bug in using shadow decl checking: a using shadow decl should not conflict
with a prior UsingDecl -- those should not even really be found by the lookup
here, except that we use the same lookup results for two different checks, and
the other check needs them.

This happens to work in *almost all* cases, because either the lookup results
list the UsingDecl first (and the NonTag result gets replaced by something
else) or because the problematic declaration is a function (which causes us to
use different logic to detect conflicts). This can also be triggered from a
state only reachable through modules (where the name lookup results can contain
multiple UsingDecls in the same scope).

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/using-decl-1.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=262105&r1=262104&r2=262105&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 26 20:36:43 2016
@@ -7796,6 +7796,12 @@ bool Sema::CheckUsingShadowDecl(UsingDec
   for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
  I != E; ++I) {
 NamedDecl *D = (*I)->getUnderlyingDecl();
+// We can have UsingDecls in our Previous results because we use the same
+// LookupResult for checking whether the UsingDecl itself is a valid
+// redeclaration.
+if (isa(D))
+  continue;
+
 if (IsEquivalentForUsingDecl(Context, D, Target)) {
   if (UsingShadowDecl *Shadow = dyn_cast(*I))
 PrevShadow = Shadow;

Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=262105&r1=262104&r2=262105&view=diff
==
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Fri Feb 26 20:36:43 2016
@@ -338,3 +338,26 @@ struct B : A {
   enum { X = sizeof(field) };
 };
 }
+
+namespace tag_vs_var {
+  namespace N {
+struct X {};
+
+struct Y {};
+int Y;
+
+int Z;
+  }
+  using N::X;
+  using N::Y;
+  using N::Z;
+
+  namespace N {
+int X;
+
+struct Z {};
+  }
+  using N::X;
+  using N::Y;
+  using N::Z;
+}


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


Re: [PATCH] D16949: Fix for: Bug 5941 - improve diagnostic for * vs & confusion

2016-02-26 Thread Ryan Yee via cfe-commits
ryee88 updated this revision to Diff 49280.
ryee88 added a comment.

Moved test to a file that checks for similar diagnostics.


http://reviews.llvm.org/D16949

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/overload-call.cpp

Index: test/SemaCXX/overload-call.cpp
===
--- test/SemaCXX/overload-call.cpp
+++ test/SemaCXX/overload-call.cpp
@@ -639,3 +639,29 @@
 g(y); // expected-error {{ambiguous}}
   }
 }
+
+namespace PointerVsReferenceSuggestion{
+  class A;
+  
+  void f0(A *a); // expected-note {{candidate function not viable: cannot 
convert argument of incomplete type 'PointerVsReferenceSuggestion::A' to 
'PointerVsReferenceSuggestion::A *' for 1st argument; take the address of the 
argument with &}}
+  void f1(A &a) {
+f0(a); // expected-error {{no matching function for call to 'f0'}}
+  }
+  
+  void f2(A &a); // expected-note {{candidate function not viable: cannot 
convert argument of incomplete type 'PointerVsReferenceSuggestion::A *' to 
'PointerVsReferenceSuggestion::A &' for 1st argument; dereference the argument 
with *}}
+  void f3(A *a) {
+f2(a); // expected-error {{no matching function for call to 'f2'}}
+  }
+  
+  class B {};
+  
+  void f4(B *b); // expected-note {{candidate function not viable: no known 
conversion from 'PointerVsReferenceSuggestion::B' to 
'PointerVsReferenceSuggestion::B *' for 1st argument; take the address of the 
argument with &}}
+  void f5(B &b) {
+f4(b); // expected-error {{no matching function for call to 'f4'}}
+  }
+  
+  void f6(B &b); // expected-note {{candidate function not viable: no known 
conversion from 'PointerVsReferenceSuggestion::B *' to 
'PointerVsReferenceSuggestion::B &' for 1st argument; dereference the argument 
with *}}
+  void f7(B *b) {
+f6(b); // expected-error {{no matching function for call to 'f6'}}
+  }
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -9104,10 +9104,13 @@
   if (const PointerType *PTy = TempFromTy->getAs())
 TempFromTy = PTy->getPointeeType();
   if (TempFromTy->isIncompleteType()) {
+// Emit the generic diagnostic and, optionally, add the hints to it.
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
   << (unsigned) FnKind << FnDesc
   << (FromExpr ? FromExpr->getSourceRange() : SourceRange())
-  << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
+  << FromTy << ToTy << (unsigned) isObjectArgument << I+1
+  << (unsigned) (Cand->Fix.Kind);
+  
 MaybeEmitInheritedConstructorNote(S, Fn);
 return;
   }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3189,7 +3189,12 @@
 "function (the implicit move assignment operator)|"
 "constructor (inherited)}0%1 "
 "not viable: cannot convert argument of incomplete type "
-"%diff{$ to $|to parameter type}2,3">;
+"%diff{$ to $|to parameter type}2,3 for "
+"%select{%ordinal5 argument|object argument}4"
+"%select{|; dereference the argument with *|"
+"; take the address of the argument with &|"
+"; remove *|"
+"; remove &}6">;
 def note_ovl_candidate_bad_list_argument : Note<"candidate "
 "%select{function|function|constructor|"
 "function |function |constructor |"


Index: test/SemaCXX/overload-call.cpp
===
--- test/SemaCXX/overload-call.cpp
+++ test/SemaCXX/overload-call.cpp
@@ -639,3 +639,29 @@
 g(y); // expected-error {{ambiguous}}
   }
 }
+
+namespace PointerVsReferenceSuggestion{
+  class A;
+  
+  void f0(A *a); // expected-note {{candidate function not viable: cannot convert argument of incomplete type 'PointerVsReferenceSuggestion::A' to 'PointerVsReferenceSuggestion::A *' for 1st argument; take the address of the argument with &}}
+  void f1(A &a) {
+f0(a); // expected-error {{no matching function for call to 'f0'}}
+  }
+  
+  void f2(A &a); // expected-note {{candidate function not viable: cannot convert argument of incomplete type 'PointerVsReferenceSuggestion::A *' to 'PointerVsReferenceSuggestion::A &' for 1st argument; dereference the argument with *}}
+  void f3(A *a) {
+f2(a); // expected-error {{no matching function for call to 'f2'}}
+  }
+  
+  class B {};
+  
+  void f4(B *b); // expected-note {{candidate function not viable: no known conversion from 'PointerVsReferenceSuggestion::B' to 'PointerVsReferenceSuggestion::B *' for 1st argument; take the address of the argument with &}}
+  void f5(B &b) {
+f4(b); // expected-error {{no matching function for call to 'f4'}}
+  }
+  
+  void f6(B &b); // expected-note {{candidate function not viable: no known convers

Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.

2016-02-26 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Sorry for arriving late to party :-)

Thank you for great check! I found a quite lot of such problems in my code 
base, but I'd like to make suggestion for further improvements: PR26756.


Repository:
  rL LLVM

http://reviews.llvm.org/D17586



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


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-26 Thread Logan Chien via cfe-commits
logan accepted this revision.
logan added a comment.

LGTM.  It is good to go now.

@timonvo, do you have commit access?  Or, do you need some assistance?


http://reviews.llvm.org/D15883



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


Re: [PATCH] D17622: [PGO] clang cc1 option change to enable IR level instrumenation

2016-02-26 Thread Sean Silva via cfe-commits
silvas accepted this revision.
silvas added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM.


http://reviews.llvm.org/D17622



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


Re: [PATCH] D17407: [Sema] PR25755 Fix crash when initializing out-of-order struct references

2016-02-26 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 49281.
hintonda added a comment.

When checking record initialization, maintain a vector of remaining
fields that were not explicitly initialized and check only those
fields to see if they can be default initialized.


http://reviews.llvm.org/D17407

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/cxx0x-initializer-constructor.cpp

Index: test/SemaCXX/cxx0x-initializer-constructor.cpp
===
--- test/SemaCXX/cxx0x-initializer-constructor.cpp
+++ test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -407,3 +407,34 @@
 [0] = 1, [2] = 3
   }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 1}}
 }
+
+namespace PR23514 {
+struct Test {
+  int& a;
+  int& b;
+};
+
+int d = 0;
+auto a = Test { .b = d, .a = d, };
+
+struct S { // expected-note-re 2{{candidate constructor (the implicit {{.*}} constructor) not viable: requires 1 argument, but 0 were provided}}
+  S(int a) {} // expected-note {{candidate constructor not viable: requires single argument 'a', but no arguments were provided}}
+};
+
+struct P {
+  char i1;
+  char i2;
+  S s;
+};
+
+P p1 { .s = 2, .i1 = 1, 1, };
+P p2 { .s = 2, .i1 = 1, };
+
+struct PP {
+  char i1;
+  S s1;
+  S s2; // expected-note {{in implicit initialization of field 's2' with omitted initializer}}
+};
+
+PP pp { .s1 = 2, .i1 = 1, }; // expected-error {{no matching constructor for initialization of 'PR23514::S'}}
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1730,6 +1730,11 @@
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
+  SmallVector RemainingFields;
+  for (auto f = Field; f != FieldEnd; ++f) {
+RemainingFields.push_back(f);
+  }
+  RemainingFields.push_back(FieldEnd);
   bool InitializedSomething = false;
   bool CheckForMissingFields = true;
   while (Index < IList->getNumInits()) {
@@ -1750,6 +1755,12 @@
  true, TopLevelObject))
 hadError = true;
 
+  RemainingFields.erase(
+  std::remove_if(RemainingFields.begin(), RemainingFields.end(),
+ [&Field, &FieldEnd](RecordDecl::field_iterator f) {
+   return (f != FieldEnd && ++f == Field);
+ }),
+  RemainingFields.end());
   InitializedSomething = true;
 
   // Disable check for missing fields when designators are used.
@@ -1773,6 +1784,11 @@
 
 if (Field->isUnnamedBitfield()) {
   // Don't initialize unnamed bitfields, e.g. "int : 20;"
+  RemainingFields.erase(
+  std::remove_if(
+  RemainingFields.begin(), RemainingFields.end(),
+  [&Field](RecordDecl::field_iterator f) { return (f == Field); }),
+  RemainingFields.end());
   ++Field;
   continue;
 }
@@ -1786,6 +1802,11 @@
   IList->getInit(Index)->getLocStart());
 if (InvalidUse) {
   ++Index;
+  RemainingFields.erase(
+  std::remove_if(
+  RemainingFields.begin(), RemainingFields.end(),
+  [&Field](RecordDecl::field_iterator f) { return (f == Field); }),
+  RemainingFields.end());
   ++Field;
   hadError = true;
   continue;
@@ -1802,6 +1823,11 @@
   StructuredList->setInitializedFieldInUnion(*Field);
 }
 
+RemainingFields.erase(
+std::remove_if(
+RemainingFields.begin(), RemainingFields.end(),
+[&Field](RecordDecl::field_iterator f) { return (f == Field); }),
+RemainingFields.end());
 ++Field;
   }
 
@@ -1824,8 +1850,9 @@
   // Check that any remaining fields can be value-initialized.
   if (VerifyOnly && Field != FieldEnd && !DeclType->isUnionType() &&
   !Field->getType()->isIncompleteArrayType()) {
-// FIXME: Should check for holes left by designated initializers too.
-for (; Field != FieldEnd && !hadError; ++Field) {
+for (auto Field : RemainingFields) {
+  if (Field == FieldEnd || hadError)
+break;
   if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
 CheckEmptyInitializable(
 InitializedEntity::InitializeMember(*Field, &Entity),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits