Re: [PATCH] D19587: Addressed reviewer's post-submission comments from http://reviews.llvm.org/D18551.

2016-04-28 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 55382.
ioeric added a comment.

- removed redundant '#'


http://reviews.llvm.org/D19587

Files:
  lib/Format/AffectedRangeManager.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/Format.cpp
  lib/Format/WhitespaceManager.h

Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -37,7 +37,7 @@
 /// There may be multiple calls to \c breakToken for a given token.
 class WhitespaceManager {
 public:
-  WhitespaceManager(SourceManager &SourceMgr, const FormatStyle &Style,
+  WhitespaceManager(const SourceManager &SourceMgr, const FormatStyle &Style,
 bool UseCRLF)
   : SourceMgr(SourceMgr), Style(Style), UseCRLF(UseCRLF) {}
 
@@ -203,7 +203,7 @@
 unsigned Spaces, unsigned WhitespaceStartColumn);
 
   SmallVector Changes;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   tooling::Replacements Replaces;
   const FormatStyle &Style;
   bool UseCRLF;
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -784,7 +784,7 @@
 
 class FormatTokenLexer {
 public:
-  FormatTokenLexer(SourceManager &SourceMgr, FileID ID,
+  FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
const FormatStyle &Style, encoding::Encoding Encoding)
   : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
 LessStashed(false), Column(0), TrailingWhitespace(0),
@@ -1373,7 +1373,7 @@
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   FileID ID;
   const FormatStyle &Style;
   IdentifierTable IdentTable;
@@ -1451,25 +1451,21 @@
 
 class Environment {
 public:
-  Environment(const FormatStyle &Style, SourceManager &SM, FileID ID,
-  ArrayRef Ranges)
-  : Style(Style), ID(ID), CharRanges(Ranges.begin(), Ranges.end()), SM(SM) {
-  }
+  Environment(SourceManager &SM, FileID ID, ArrayRef Ranges)
+  : ID(ID), CharRanges(Ranges.begin(), Ranges.end()), SM(SM) {}
 
-  Environment(const FormatStyle &Style, FileID ID,
-  std::unique_ptr FileMgr,
+  Environment(FileID ID, std::unique_ptr FileMgr,
   std::unique_ptr VirtualSM,
   std::unique_ptr Diagnostics,
-  std::vector CharRanges)
-  : Style(Style), ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),
+  const std::vector &CharRanges)
+  : ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),
 SM(*VirtualSM), FileMgr(std::move(FileMgr)),
 VirtualSM(std::move(VirtualSM)), Diagnostics(std::move(Diagnostics)) {}
 
   // This sets up an virtual file system with file \p FileName containing \p
   // Code.
   static std::unique_ptr
-  CreateVirtualEnvironment(const FormatStyle &Style, StringRef Code,
-   StringRef FileName,
+  CreateVirtualEnvironment(StringRef Code, StringRef FileName,
ArrayRef Ranges) {
 // This is referenced by `FileMgr` and will be released by `FileMgr` when it
 // is deleted.
@@ -1501,25 +1497,20 @@
   SourceLocation End = Start.getLocWithOffset(Range.getLength());
   CharRanges.push_back(CharSourceRange::getCharRange(Start, End));
 }
-return llvm::make_unique(Style, ID, std::move(FileMgr),
+return llvm::make_unique(ID, std::move(FileMgr),
   std::move(VirtualSM),
   std::move(Diagnostics), CharRanges);
   }
 
-  FormatStyle &getFormatStyle() { return Style; }
-
-  const FormatStyle &getFormatStyle() const { return Style; }
-
   FileID getFileID() const { return ID; }
 
   StringRef getFileName() const { return FileName; }
 
   ArrayRef getCharRanges() const { return CharRanges; }
 
-  SourceManager &getSourceManager() { return SM; }
+  const SourceManager &getSourceManager() const { return SM; }
 
 private:
-  FormatStyle Style;
   FileID ID;
   StringRef FileName;
   SmallVector CharRanges;
@@ -1535,35 +1526,35 @@
 
 class TokenAnalyzer : public UnwrappedLineConsumer {
 public:
-  TokenAnalyzer(Environment &Env)
-  : Env(Env), AffectedRangeMgr(Env.getSourceManager(), Env.getCharRanges()),
+  TokenAnalyzer(const Environment &Env, const FormatStyle &Style)
+  : Style(Style), Env(Env),
+AffectedRangeMgr(Env.getSourceManager(), Env.getCharRanges()),
 UnwrappedLines(1),
 Encoding(encoding::detectEncoding(
 Env.getSourceManager().getBufferData(Env.getFileID( {
 DEBUG(llvm::dbgs() << "File encoding: "
<< (Encoding == encoding::Encoding_UTF8 ? "UTF8"
: "unknown")
<< "\n")

r267859 - Addressed reviewer's post-submission comments from http://reviews.llvm.org/D18551.

2016-04-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Apr 28 02:52:03 2016
New Revision: 267859

URL: http://llvm.org/viewvc/llvm-project?rev=267859&view=rev
Log:
Addressed reviewer's post-submission comments from 
http://reviews.llvm.org/D18551.

Summary: Make SourceManager in Environment, WhitespaceManager, and 
FormatTokenAnalyzer etc constant members.

Reviewers: djasper, klimek

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/AffectedRangeManager.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/ContinuationIndenter.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/WhitespaceManager.h

Modified: cfe/trunk/lib/Format/AffectedRangeManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.h?rev=267859&r1=267858&r2=267859&view=diff
==
--- cfe/trunk/lib/Format/AffectedRangeManager.h (original)
+++ cfe/trunk/lib/Format/AffectedRangeManager.h Thu Apr 28 02:52:03 2016
@@ -25,7 +25,7 @@ class AnnotatedLine;
 
 class AffectedRangeManager {
 public:
-  AffectedRangeManager(SourceManager &SourceMgr,
+  AffectedRangeManager(const SourceManager &SourceMgr,
const ArrayRef Ranges)
   : SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}
 
@@ -57,7 +57,7 @@ private:
   bool nonPPLineAffected(AnnotatedLine *Line,
  const AnnotatedLine *PreviousLine);
 
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   const SmallVector Ranges;
 };
 

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=267859&r1=267858&r2=267859&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Apr 28 02:52:03 2016
@@ -64,7 +64,7 @@ static bool startsNextParameter(const Fo
 
 ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
const AdditionalKeywords &Keywords,
-   SourceManager &SourceMgr,
+   const SourceManager &SourceMgr,
WhitespaceManager &Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)

Modified: cfe/trunk/lib/Format/ContinuationIndenter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.h?rev=267859&r1=267858&r2=267859&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.h (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.h Thu Apr 28 02:52:03 2016
@@ -38,7 +38,8 @@ public:
   /// column \p FirstIndent.
   ContinuationIndenter(const FormatStyle &Style,
const AdditionalKeywords &Keywords,
-   SourceManager &SourceMgr, WhitespaceManager 
&Whitespaces,
+   const SourceManager &SourceMgr,
+   WhitespaceManager &Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions);
 
@@ -137,7 +138,7 @@ private:
 
   FormatStyle Style;
   const AdditionalKeywords &Keywords;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   WhitespaceManager &Whitespaces;
   encoding::Encoding Encoding;
   bool BinPackInconclusiveFunctions;

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=267859&r1=267858&r2=267859&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr 28 02:52:03 2016
@@ -784,7 +784,7 @@ namespace {
 
 class FormatTokenLexer {
 public:
-  FormatTokenLexer(SourceManager &SourceMgr, FileID ID,
+  FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
const FormatStyle &Style, encoding::Encoding Encoding)
   : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
 LessStashed(false), Column(0), TrailingWhitespace(0),
@@ -1373,7 +1373,7 @@ private:
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   FileID ID;
   const FormatStyle &Style;
   IdentifierTable IdentTable;
@@ -1451,25 +1451,21 @@ static StringRef getLanguageName(FormatS
 
 class Environment {
 public:
-  Environment(const FormatStyle &Style, SourceManager &SM, FileID ID,
-  ArrayRef Ranges)
-  : Style(Style), ID(ID), CharRanges(Ranges.begin(), Ranges.end()), S

r267858 - Addressed review's comments.

2016-04-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Apr 28 02:51:47 2016
New Revision: 267858

URL: http://llvm.org/viewvc/llvm-project?rev=267858&view=rev
Log:
Addressed review's comments.

Modified:
cfe/trunk/lib/Format/AffectedRangeManager.h
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/AffectedRangeManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.h?rev=267858&r1=267857&r2=267858&view=diff
==
--- cfe/trunk/lib/Format/AffectedRangeManager.h (original)
+++ cfe/trunk/lib/Format/AffectedRangeManager.h Thu Apr 28 02:51:47 2016
@@ -56,6 +56,7 @@ private:
   // Returns \c true if line or one if its children is affected.
   bool nonPPLineAffected(AnnotatedLine *Line,
  const AnnotatedLine *PreviousLine);
+
   SourceManager &SourceMgr;
   const SmallVector Ranges;
 };
@@ -63,4 +64,5 @@ private:
 } // namespace format
 } // namespace clang
 
-#endif // LLVM_CLANG_LIB_FORMAT_WHITESPACEMANAGER_H
+#endif // LLVM_CLANG_LIB_FORMAT_AFFECTEDRANGEMANAGER_H
+#

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=267858&r1=267857&r2=267858&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr 28 02:51:47 2016
@@ -1460,7 +1460,7 @@ public:
   std::unique_ptr FileMgr,
   std::unique_ptr VirtualSM,
   std::unique_ptr Diagnostics,
-  std::vector CharRanges)
+  const std::vector &CharRanges)
   : Style(Style), ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),
 SM(*VirtualSM), FileMgr(std::move(FileMgr)),
 VirtualSM(std::move(VirtualSM)), Diagnostics(std::move(Diagnostics)) {}


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


r267860 - removed redundant '#'

2016-04-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Apr 28 02:52:06 2016
New Revision: 267860

URL: http://llvm.org/viewvc/llvm-project?rev=267860&view=rev
Log:
removed redundant '#'

Modified:
cfe/trunk/lib/Format/AffectedRangeManager.h

Modified: cfe/trunk/lib/Format/AffectedRangeManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.h?rev=267860&r1=267859&r2=267860&view=diff
==
--- cfe/trunk/lib/Format/AffectedRangeManager.h (original)
+++ cfe/trunk/lib/Format/AffectedRangeManager.h Thu Apr 28 02:52:06 2016
@@ -65,4 +65,3 @@ private:
 } // namespace clang
 
 #endif // LLVM_CLANG_LIB_FORMAT_AFFECTEDRANGEMANAGER_H
-#


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


Re: [PATCH] D19587: Addressed reviewer's post-submission comments from http://reviews.llvm.org/D18551.

2016-04-28 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267859: Addressed reviewer's post-submission comments from 
http://reviews.llvm. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D19587?vs=55382&id=55383#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19587

Files:
  cfe/trunk/lib/Format/AffectedRangeManager.h
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/ContinuationIndenter.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/WhitespaceManager.h

Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -64,7 +64,7 @@
 
 ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
const AdditionalKeywords &Keywords,
-   SourceManager &SourceMgr,
+   const SourceManager &SourceMgr,
WhitespaceManager &Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)
Index: cfe/trunk/lib/Format/WhitespaceManager.h
===
--- cfe/trunk/lib/Format/WhitespaceManager.h
+++ cfe/trunk/lib/Format/WhitespaceManager.h
@@ -37,7 +37,7 @@
 /// There may be multiple calls to \c breakToken for a given token.
 class WhitespaceManager {
 public:
-  WhitespaceManager(SourceManager &SourceMgr, const FormatStyle &Style,
+  WhitespaceManager(const SourceManager &SourceMgr, const FormatStyle &Style,
 bool UseCRLF)
   : SourceMgr(SourceMgr), Style(Style), UseCRLF(UseCRLF) {}
 
@@ -203,7 +203,7 @@
 unsigned Spaces, unsigned WhitespaceStartColumn);
 
   SmallVector Changes;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   tooling::Replacements Replaces;
   const FormatStyle &Style;
   bool UseCRLF;
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -784,7 +784,7 @@
 
 class FormatTokenLexer {
 public:
-  FormatTokenLexer(SourceManager &SourceMgr, FileID ID,
+  FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
const FormatStyle &Style, encoding::Encoding Encoding)
   : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
 LessStashed(false), Column(0), TrailingWhitespace(0),
@@ -1373,7 +1373,7 @@
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
-  SourceManager &SourceMgr;
+  const SourceManager &SourceMgr;
   FileID ID;
   const FormatStyle &Style;
   IdentifierTable IdentTable;
@@ -1451,25 +1451,21 @@
 
 class Environment {
 public:
-  Environment(const FormatStyle &Style, SourceManager &SM, FileID ID,
-  ArrayRef Ranges)
-  : Style(Style), ID(ID), CharRanges(Ranges.begin(), Ranges.end()), SM(SM) {
-  }
+  Environment(SourceManager &SM, FileID ID, ArrayRef Ranges)
+  : ID(ID), CharRanges(Ranges.begin(), Ranges.end()), SM(SM) {}
 
-  Environment(const FormatStyle &Style, FileID ID,
-  std::unique_ptr FileMgr,
+  Environment(FileID ID, std::unique_ptr FileMgr,
   std::unique_ptr VirtualSM,
   std::unique_ptr Diagnostics,
   const std::vector &CharRanges)
-  : Style(Style), ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),
+  : ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),
 SM(*VirtualSM), FileMgr(std::move(FileMgr)),
 VirtualSM(std::move(VirtualSM)), Diagnostics(std::move(Diagnostics)) {}
 
   // This sets up an virtual file system with file \p FileName containing \p
   // Code.
   static std::unique_ptr
-  CreateVirtualEnvironment(const FormatStyle &Style, StringRef Code,
-   StringRef FileName,
+  CreateVirtualEnvironment(StringRef Code, StringRef FileName,
ArrayRef Ranges) {
 // This is referenced by `FileMgr` and will be released by `FileMgr` when it
 // is deleted.
@@ -1501,25 +1497,20 @@
   SourceLocation End = Start.getLocWithOffset(Range.getLength());
   CharRanges.push_back(CharSourceRange::getCharRange(Start, End));
 }
-return llvm::make_unique(Style, ID, std::move(FileMgr),
+return llvm::make_unique(ID, std::move(FileMgr),
   std::move(VirtualSM),
   std::move(Diagnostics), CharRanges);
   }
 
-  FormatStyle &getFormatStyle() { return Style; }
-
-  const FormatStyle &getFormatStyle() const { return Style; }
-
   FileID getFileID() const { return ID; }
 
   StringRef getFileName() const { 

Re: [PATCH] D18265: [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature

2016-04-28 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

I see this one is accepted, but the prerequisite is not reviewed yet (after the 
update). Without that this one should not be merged into the code because it 
will not compile.


http://reviews.llvm.org/D18265



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


Re: [PATCH] D19482: [include-fixer] Add a find-all-symbols tool for include-fixer.

2016-04-28 Thread Haojian Wu via cfe-commits
hokein added a comment.

@chapuni, thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D19482



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


r267862 - [OPENMP 4.5] Codegen for 'grainsize/num_tasks' clauses of 'taskloop'

2016-04-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr 28 04:15:06 2016
New Revision: 267862

URL: http://llvm.org/viewvc/llvm-project?rev=267862&view=rev
Log:
[OPENMP 4.5] Codegen for 'grainsize/num_tasks' clauses of 'taskloop'
directive.

OpenMP 4.5 defines 'taskloop' directive and 2 additional clauses
'grainsize' and 'num_tasks' for this directive. Patch adds codegen for
these clauses.
These clauses are generated as arguments of the '__kmpc_taskloop'
libcall and are encoded the following way:

void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val, 
kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int nogroup,  int sched, 
kmp_uint64 grainsize, void *task_dup);

If 'grainsize' is specified, 'sched' argument must be set to '1' and
'grainsize' argument must be set to the value of the 'grainsize' clause.
If 'num_tasks' is specified, 'sched' argument must be set to '2' and
'grainsize' argument must be set to the value of the 'num_tasks' clause.
It is possible because these 2 clauses are mutually exclusive and can't
be used at the same time on the same directive.
If none of these clauses is specified, 'sched' argument must be set to
'0'.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/taskloop_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=267862&r1=267861&r2=267862&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Apr 28 04:15:06 2016
@@ -3777,7 +3777,8 @@ void CGOpenMPRuntime::emitTaskCall(
 
 void CGOpenMPRuntime::emitTaskLoopCall(
 CodeGenFunction &CGF, SourceLocation Loc, const OMPLoopDirective &D,
-bool Tied, llvm::PointerIntPair Final, bool 
Nogroup,
+bool Tied, llvm::PointerIntPair Final,
+llvm::PointerIntPair Schedule, bool Nogroup,
 unsigned NumberOfParts, llvm::Value *TaskFunction, QualType SharedsTy,
 Address Shareds, const Expr *IfCond, ArrayRef PrivateVars,
 ArrayRef PrivateCopies,
@@ -3825,17 +3826,19 @@ void CGOpenMPRuntime::emitTaskLoopCall(
   cast(cast(D.getStrideVariable())->getDecl());
   CGF.EmitAnyExprToMem(StVar->getInit(), StLVal.getAddress(), 
StLVal.getQuals(),
/*IsInitializer=*/true);
+  enum { NoSchedule = 0, Grainsize = 1, NumTasks = 2 };
   llvm::Value *TaskArgs[] = {
-  UpLoc,
-  ThreadID,
-  Data.NewTask,
-  IfVal,
-  LBLVal.getPointer(),
-  UBLVal.getPointer(),
-  CGF.EmitLoadOfScalar(StLVal, SourceLocation()),
+  UpLoc, ThreadID, Data.NewTask, IfVal, LBLVal.getPointer(),
+  UBLVal.getPointer(), CGF.EmitLoadOfScalar(StLVal, SourceLocation()),
   llvm::ConstantInt::getSigned(CGF.IntTy, Nogroup ? 1 : 0),
-  llvm::ConstantInt::getSigned(CGF.IntTy, /*V=*/0),
-  llvm::ConstantInt::get(CGF.Int64Ty, /*V=*/0),
+  llvm::ConstantInt::getSigned(
+  CGF.IntTy, Schedule.getPointer()
+ ? Schedule.getInt() ? NumTasks : Grainsize
+ : NoSchedule),
+  Schedule.getPointer()
+  ? CGF.Builder.CreateIntCast(Schedule.getPointer(), CGF.Int64Ty,
+  /*isSigned=*/false)
+  : llvm::ConstantInt::get(CGF.Int64Ty, /*V=*/0),
   llvm::ConstantPointerNull::get(CGF.VoidPtrTy)};
   CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_taskloop), TaskArgs);
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=267862&r1=267861&r2=267862&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Apr 28 04:15:06 2016
@@ -858,6 +858,9 @@ public:
   /// \param Final Contains either constant bool value, or llvm::Value * of i1
   /// type for final clause. If the value is true, the task forces all of its
   /// child tasks to become final and included tasks.
+  /// \param Schedule If Pointer is nullptr, no grainsize/num_tasks clauses 
were
+  /// specified. If IntVal is false - it is for grainsize clause, true - for
+  /// num_tasks clause.
   /// \param Nogroup true if nogroup clause was specified, false otherwise.
   /// \param NumberOfParts Number of parts in untied taskloops.
   /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
@@ -881,9 +884,10 @@ public:
   virtual void emitTaskLoopCall(
   CodeGenFunction &CGF, SourceLocation Loc, const OMPLoopDirective &D,
   bool Tied, llvm::PointerIntPair Final,
-  bool Nogroup, unsigned NumberOfParts, llvm::Value *TaskFunction,
-  QualType SharedsTy, Address Shareds, const Expr *IfCond,
-  ArrayRef PrivateVars, ArrayRef PrivateCopie

r267863 - [OPENMP] Simplified interface for codegen of tasks, NFC.

2016-04-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr 28 04:23:51 2016
New Revision: 267863

URL: http://llvm.org/viewvc/llvm-project?rev=267863&view=rev
Log:
[OPENMP] Simplified interface for codegen of tasks, NFC.

Reduced number of arguments in member functions of runtime support
library for task-based directives.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=267863&r1=267862&r2=267863&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Apr 28 04:23:51 2016
@@ -3361,20 +3361,16 @@ static int array_pod_sort_comparator(con
   return P1->first < P2->first ? 1 : (P2->first < P1->first ? -1 : 0);
 }
 
-CGOpenMPRuntime::TaskDataTy CGOpenMPRuntime::emitTaskInit(
-CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D,
-bool Tied, llvm::PointerIntPair Final,
-unsigned NumberOfParts, llvm::Value *TaskFunction, QualType SharedsTy,
-Address Shareds, ArrayRef PrivateVars,
-ArrayRef PrivateCopies,
-ArrayRef FirstprivateVars,
-ArrayRef FirstprivateCopies,
-ArrayRef FirstprivateInits) {
+CGOpenMPRuntime::TaskResultTy
+CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
+  const OMPExecutableDirective &D,
+  llvm::Value *TaskFunction, QualType SharedsTy,
+  Address Shareds, const OMPTaskDataTy &Data) {
   auto &C = CGM.getContext();
   llvm::SmallVector Privates;
   // Aggregate privates and sort them by the alignment.
-  auto I = PrivateCopies.begin();
-  for (auto *E : PrivateVars) {
+  auto I = Data.PrivateCopies.begin();
+  for (auto *E : Data.PrivateVars) {
 auto *VD = cast(cast(E)->getDecl());
 Privates.push_back(std::make_pair(
 C.getDeclAlign(VD),
@@ -3382,9 +3378,9 @@ CGOpenMPRuntime::TaskDataTy CGOpenMPRunt
  /*PrivateElemInit=*/nullptr)));
 ++I;
   }
-  I = FirstprivateCopies.begin();
-  auto IElemInitRef = FirstprivateInits.begin();
-  for (auto *E : FirstprivateVars) {
+  I = Data.FirstprivateCopies.begin();
+  auto IElemInitRef = Data.FirstprivateInits.begin();
+  for (auto *E : Data.FirstprivateVars) {
 auto *VD = cast(cast(E)->getDecl());
 Privates.push_back(std::make_pair(
 C.getDeclAlign(VD),
@@ -3424,8 +3420,9 @@ CGOpenMPRuntime::TaskDataTy CGOpenMPRunt
   ->getType();
   if (!Privates.empty()) {
 auto FI = std::next(KmpTaskTWithPrivatesQTyRD->field_begin());
-TaskPrivatesMap = emitTaskPrivateMappingFunction(
-CGM, Loc, PrivateVars, FirstprivateVars, FI->getType(), Privates);
+TaskPrivatesMap = emitTaskPrivateMappingFunction(CGM, Loc, 
Data.PrivateVars,
+ Data.FirstprivateVars,
+ FI->getType(), Privates);
 TaskPrivatesMap = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
 TaskPrivatesMap, TaskPrivatesMapTy);
   } else {
@@ -3447,13 +3444,13 @@ CGOpenMPRuntime::TaskDataTy CGOpenMPRunt
   // description of kmp_tasking_flags struct.
   const unsigned TiedFlag = 0x1;
   const unsigned FinalFlag = 0x2;
-  unsigned Flags = Tied ? TiedFlag : 0;
+  unsigned Flags = Data.Tied ? TiedFlag : 0;
   auto *TaskFlags =
-  Final.getPointer()
-  ? CGF.Builder.CreateSelect(Final.getPointer(),
+  Data.Final.getPointer()
+  ? CGF.Builder.CreateSelect(Data.Final.getPointer(),
  CGF.Builder.getInt32(FinalFlag),
  CGF.Builder.getInt32(/*C=*/0))
-  : CGF.Builder.getInt32(Final.getInt() ? FinalFlag : 0);
+  : CGF.Builder.getInt32(Data.Final.getInt() ? FinalFlag : 0);
   TaskFlags = CGF.Builder.CreateOr(TaskFlags, CGF.Builder.getInt32(Flags));
   auto *SharedsSize = CGM.getSize(C.getTypeSizeInChars(SharedsTy));
   llvm::Value *AllocArgs[] = {emitUpdateLocation(CGF, Loc),
@@ -3489,7 +3486,7 @@ CGOpenMPRuntime::TaskDataTy CGOpenMPRunt
 auto PrivatesBase = CGF.EmitLValueForField(Base, *FI);
 FI = cast(FI->getType()->getAsTagDecl())->field_begin();
 LValue SharedsBase;
-if (!FirstprivateVars.empty()) {
+if (!Data.FirstprivateVars.empty()) {
   SharedsBase = CGF.MakeAddrLValue(
   CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   KmpTaskSharedsPtr, CGF.ConvertTypeForMem(SharedsPtrTy)),
@@ -3569,41 +3566,35 @@ CGOpenMPRuntime::TaskDataTy CGOpenMPRunt
   CGF.EmitStoreOfScalar(CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
 DestructorFn, KmpRoutineEntryPtrTy),
 Destructor);
-  T

Re: [PATCH] D19586: Misleading Indentation check

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

In http://reviews.llvm.org/D19586#415123, @Pajesz wrote:

> Both dangling else and the other check now ignore one-line if-else 
> statements. Corrected other reviews as well.


I can not see a test case for one line if-then-else. Could you add it?


http://reviews.llvm.org/D19586



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


Re: [PATCH] D19647: [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.

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

lg.


Repository:
  rL LLVM

http://reviews.llvm.org/D19647



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


Re: [PATCH] D19648: [include-fixer] Add Yaml database integration.

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

Nice. Ship it!



Comment at: include-fixer/YamlXrefsDB.h:25
@@ +24,3 @@
+public:
+  YamlXrefsDB(const std::string &FilePath);
+

StringRef instead of std::string.


Repository:
  rL LLVM

http://reviews.llvm.org/D19648



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


r267865 - Revert "[MSVC] PR27337: allow static_cast from private base to derived for WTL"

2016-04-28 Thread Dmitry Polukhin via cfe-commits
Author: dpolukhin
Date: Thu Apr 28 04:56:22 2016
New Revision: 267865

URL: http://llvm.org/viewvc/llvm-project?rev=267865&view=rev
Log:
Revert "[MSVC] PR27337: allow static_cast from private base to derived for WTL"

This reverts commit r267534.

Removed:
cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267865&r1=267864&r2=267865&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 28 04:56:22 
2016
@@ -5764,9 +5764,6 @@ def err_static_downcast_via_virtual : Er
   "cannot cast %0 to %1 via virtual base %2">;
 def err_downcast_from_inaccessible_base : Error<
   "cannot cast %select{private|protected}2 base class %1 to %0">;
-def ext_ms_downcast_from_inaccessible_base : ExtWarn<
-  "casting from %select{private|protected}2 base class %1 to derived class %0 
is a Microsoft extension">,
-  InGroup;
 def err_upcast_to_inaccessible_base : Error<
   "cannot cast %0 to its %select{private|protected}2 base class %1">;
 def err_bad_dynamic_cast_not_ref_or_ptr : Error<

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=267865&r1=267864&r2=267865&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Apr 28 04:56:22 2016
@@ -1344,11 +1344,10 @@ TryStaticDowncast(Sema &Self, CanQualTyp
   }
 
   if (!CStyle) {
-unsigned Diag = Self.getLangOpts().MSVCCompat
-? diag::ext_ms_downcast_from_inaccessible_base
-: diag::err_downcast_from_inaccessible_base;
-switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType, DestType,
-  Paths.front(), Diag)) {
+switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
+  SrcType, DestType,
+  Paths.front(),
+diag::err_downcast_from_inaccessible_base)) {
 case Sema::AR_accessible:
 case Sema::AR_delayed: // be optimistic
 case Sema::AR_dependent:   // be optimistic

Removed: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp?rev=267864&view=auto
==
--- cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (original)
+++ cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (removed)
@@ -1,40 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
-
-// Minimal reproducer.
-class A {};
-class B : A {}; // expected-note 2 {{implicitly declared private here}}
-
-B* foo(A* p) {
-  return static_cast(p);
-#ifdef NO_MS_COMPATIBILITY
-  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
-#else
-  // expected-warning@-4 {{casting from private base class 'A' to derived 
class 'B' is a Microsoft extension}}
-#endif
-}
-
-A* bar(B* p) {
-  return static_cast(p); // expected-error {{cannot cast 'B' to its 
private base class 'A'}}
-}
-
-// from atlframe.h
-template 
-class CUpdateUI {
-public:
-  CUpdateUI() {
-T* pT = static_cast(this);
-#ifdef NO_MS_COMPATIBILITY
-// expected-error@-2 {{cannot cast private base class}}
-#else
-// expected-warning@-4 {{casting from private base class 
'CUpdateUI' to derived class 'CMDIFrame' is a Microsoft extension}}
-#endif
-  }
-};
-
-// from sample WTL/MDIDocVw (mainfrm.h
-class CMDIFrame : CUpdateUI {};
-// expected-note@-1 {{implicitly declared private here}}
-// expected-note@-2 {{in instantiation of member function}}
-
-CMDIFrame wndMain;


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


Re: [clang-tools-extra] r267828 - clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp: Appease ms targets with -fno-delayed-template-parsing.

2016-04-28 Thread Alexander Kornienko via cfe-commits
Thank you for the fix! We've actually tried adding -fdelayed-template-parsing
and -fms-compatibility on linux, and the test passed. Not sure why it
failed on Windows. Is there any other subtle difference?

On Thu, Apr 28, 2016 at 2:39 AM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Wed Apr 27 19:39:48 2016
> New Revision: 267828
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267828&view=rev
> Log:
> clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp:
> Appease ms targets with -fno-delayed-template-parsing.
>
> Modified:
>
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp?rev=267828&r1=267827&r2=267828&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
> Wed Apr 27 19:39:48 2016
> @@ -1,4 +1,4 @@
> -// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t --
> -- -std=c++98
> +// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t --
> -- -std=c++98 -fno-delayed-template-parsing
>
>  struct PositiveFieldBeforeConstructor {
>int F;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r267534 - [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-28 Thread Dmitry Polukhin via cfe-commits
Reverted in r267865.

On Wed, Apr 27, 2016 at 10:31 PM, Dmitry Polukhin  wrote:

> So it seems that there is an agreement that Clang don't need this MSVC
> "feature" so I'll revert my patch tomorrow when I get to the office.
>
> On Wed, Apr 27, 2016 at 10:09 PM, Stephan T. Lavavej <
> s...@exchange.microsoft.com> wrote:
>
>> [Richard Smith]
>> > You can find a description of the problem in http://llvm.org/PR27337
>> > Brief summary:
>> > The WTL bug is the missing 'public' on the second base class on this
>> line:
>> https://sourceforge.net/p/wtl/code/HEAD/tree/trunk/wtl/Samples/MDIDocVw/mainfrm.h#l636
>> > The C1xx bug is that it accepts a (non-C-style) cast from a base class
>> to an inaccessible derived class.
>>
>> Thanks, I've asked my boss if MS devs still maintain WTL and if so, who.
>>
>> As for C1XX, I've filed VSO#216958 "C1XX shouldn't allow static_cast to
>> bypass private inheritance" with a self-contained repro.
>>
>> STL
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267866 - [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

2016-04-28 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Thu Apr 28 05:13:18 2016
New Revision: 267866

URL: http://llvm.org/viewvc/llvm-project?rev=267866&view=rev
Log:
[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

Rework implementation of several MS pragmas that use internal stack:
vtordisp, {bss|code|const|data}_seg.
This patch:
  1. Makes #pragma vtordisp use PragmaStack class as *_seg pragmas do;
  2. Fixes "#pragma vtordisp()" behavior: it shouldn't affect stack;
  3. Saves/restores the stacks on enter/exit a C++ method body.


Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/CodeGenCXX/sections.cpp
cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=267866&r1=267865&r2=267866&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 28 05:13:18 2016
@@ -327,40 +327,21 @@ public:
   LangOptions::PragmaMSPointersToMembersKind
   MSPointerToMemberRepresentationMethod;
 
-  enum PragmaVtorDispKind {
-PVDK_Push,  ///< #pragma vtordisp(push, mode)
-PVDK_Set,   ///< #pragma vtordisp(mode)
-PVDK_Pop,   ///< #pragma vtordisp(pop)
-PVDK_Reset  ///< #pragma vtordisp()
-  };
-
-  enum PragmaMsStackAction {
-PSK_Reset,// #pragma ()
-PSK_Set,  // #pragma ("name")
-PSK_Push, // #pragma (push[, id])
-PSK_Push_Set, // #pragma (push[, id], "name")
-PSK_Pop,  // #pragma (pop[, id])
-PSK_Pop_Set,  // #pragma (pop[, id], "name")
-  };
-
-  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
-  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
-  ///
-  /// 0: Suppress all vtordisps
-  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
-  ///structors
-  /// 2: Always insert vtordisps to support RTTI on partially constructed
-  ///objects
-  ///
-  /// The stack always has at least one element in it.
-  SmallVector VtorDispModeStack;
-
   /// Stack of active SEH __finally scopes.  Can be empty.
   SmallVector CurrentSEHFinally;
 
   /// \brief Source location for newly created implicit MSInheritanceAttrs
   SourceLocation ImplicitMSInheritanceAttrLoc;
 
+  enum PragmaMsStackAction {
+PSK_Reset = 0x0,// #pragma ()
+PSK_Set   = 0x1,// #pragma (value)
+PSK_Push  = 0x2,// #pragma (push[, id])
+PSK_Pop   = 0x4,// #pragma (pop[, id])
+PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
+PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
+  };
+
   template
   struct PragmaStack {
 struct Slot {
@@ -377,18 +358,84 @@ public:
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  ValueType Value);
-explicit PragmaStack(const ValueType &Value)
-  : CurrentValue(Value) {}
+
+// MSVC seems to add artificial slots to #pragma stacks on entering a C++
+// method body to restore the stacks on exit, so it works like this:
+//
+//   struct S {
+// #pragma (push, InternalPragmaSlot, )
+// void Method {}
+// #pragma (pop, InternalPragmaSlot)
+//   };
+//
+// It works even with #pragma vtordisp, although MSVC doesn't support
+//   #pragma vtordisp(push [, id], n)
+// syntax.
+//
+// Push / pop a named sentinel slot.
+void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
+  assert((Action == PSK_Push || Action == PSK_Pop) &&
+ "Can only push / pop #pragma stack sentinels!");
+  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
+}
+
+// Constructors.
+explicit PragmaStack(const ValueType &Default)
+: DefaultValue(Default), CurrentValue(Default) {}
+
 SmallVector Stack;
+ValueType DefaultValue; // Value used for PSK_Reset action.
 ValueType CurrentValue;
 SourceLocation CurrentPragmaLocation;
   };
   // FIXME: We should serialize / deserialize these if they occur in a PCH (but
   // we shouldn't do so if they're in a module).
+
+  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
+  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
+  ///
+  /// 0: Suppress all vtordisps
+  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
+  ///structors
+  /// 2: Always insert vtordisps to support RTTI on partially constructed
+  ///objects
+  PragmaStack VtorDispStack;
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
   PragmaStack ConstSegStack;
   PragmaStack CodeSegStack;
+  // TODO:

Re: r267866 - [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

2016-04-28 Thread Diana Picus via cfe-commits
Hi,

I don't know if you've noticed, but this commit broke a lot of builds -
e.g. http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/11865.

Regards,
Diana

On 28 April 2016 at 13:13, Denis Zobnin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dzobnin
> Date: Thu Apr 28 05:13:18 2016
> New Revision: 267866
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267866&view=rev
> Log:
> [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)
>
> Rework implementation of several MS pragmas that use internal stack:
> vtordisp, {bss|code|const|data}_seg.
> This patch:
>   1. Makes #pragma vtordisp use PragmaStack class as *_seg pragmas do;
>   2. Fixes "#pragma vtordisp()" behavior: it shouldn't affect stack;
>   3. Saves/restores the stacks on enter/exit a C++ method body.
>
>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/ParsePragma.cpp
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaAttr.cpp
> cfe/trunk/test/CodeGenCXX/sections.cpp
> cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=267866&r1=267865&r2=267866&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 28 05:13:18 2016
> @@ -327,40 +327,21 @@ public:
>LangOptions::PragmaMSPointersToMembersKind
>MSPointerToMemberRepresentationMethod;
>
> -  enum PragmaVtorDispKind {
> -PVDK_Push,  ///< #pragma vtordisp(push, mode)
> -PVDK_Set,   ///< #pragma vtordisp(mode)
> -PVDK_Pop,   ///< #pragma vtordisp(pop)
> -PVDK_Reset  ///< #pragma vtordisp()
> -  };
> -
> -  enum PragmaMsStackAction {
> -PSK_Reset,// #pragma ()
> -PSK_Set,  // #pragma ("name")
> -PSK_Push, // #pragma (push[, id])
> -PSK_Push_Set, // #pragma (push[, id], "name")
> -PSK_Pop,  // #pragma (pop[, id])
> -PSK_Pop_Set,  // #pragma (pop[, id], "name")
> -  };
> -
> -  /// \brief Whether to insert vtordisps prior to virtual bases in the
> Microsoft
> -  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
> -  ///
> -  /// 0: Suppress all vtordisps
> -  /// 1: Insert vtordisps in the presence of vbase overrides and
> non-trivial
> -  ///structors
> -  /// 2: Always insert vtordisps to support RTTI on partially constructed
> -  ///objects
> -  ///
> -  /// The stack always has at least one element in it.
> -  SmallVector VtorDispModeStack;
> -
>/// Stack of active SEH __finally scopes.  Can be empty.
>SmallVector CurrentSEHFinally;
>
>/// \brief Source location for newly created implicit MSInheritanceAttrs
>SourceLocation ImplicitMSInheritanceAttrLoc;
>
> +  enum PragmaMsStackAction {
> +PSK_Reset = 0x0,// #pragma ()
> +PSK_Set   = 0x1,// #pragma (value)
> +PSK_Push  = 0x2,// #pragma (push[, id])
> +PSK_Pop   = 0x4,// #pragma (pop[, id])
> +PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
> +PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
> +  };
> +
>template
>struct PragmaStack {
>  struct Slot {
> @@ -377,18 +358,84 @@ public:
>   PragmaMsStackAction Action,
>   llvm::StringRef StackSlotLabel,
>   ValueType Value);
> -explicit PragmaStack(const ValueType &Value)
> -  : CurrentValue(Value) {}
> +
> +// MSVC seems to add artificial slots to #pragma stacks on entering a
> C++
> +// method body to restore the stacks on exit, so it works like this:
> +//
> +//   struct S {
> +// #pragma (push, InternalPragmaSlot,
> )
> +// void Method {}
> +// #pragma (pop, InternalPragmaSlot)
> +//   };
> +//
> +// It works even with #pragma vtordisp, although MSVC doesn't support
> +//   #pragma vtordisp(push [, id], n)
> +// syntax.
> +//
> +// Push / pop a named sentinel slot.
> +void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
> +  assert((Action == PSK_Push || Action == PSK_Pop) &&
> + "Can only push / pop #pragma stack sentinels!");
> +  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
> +}
> +
> +// Constructors.
> +explicit PragmaStack(const ValueType &Default)
> +: DefaultValue(Default), CurrentValue(Default) {}
> +
>  SmallVector Stack;
> +ValueType DefaultValue; // Value used for PSK_Reset action.
>  ValueType CurrentValue;
>  SourceLocation CurrentPragmaLocation;
>};
>// FIXME: We should serialize / deserialize these if they occur in a
> PCH (but
>// we shouldn't do so if they're in a module).
> +
> +  /// \brief Whether to in

[clang-tools-extra] r267868 - [include-fixer] Add an option to minimize include paths.

2016-04-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr 28 06:21:29 2016
New Revision: 267868

URL: http://llvm.org/viewvc/llvm-project?rev=267868&view=rev
Log:
[include-fixer] Add an option to minimize include paths.

This will always pick the shortest possible path based on -I options. Based
on the #include suggestion code for modules.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=267868&r1=267867&r2=267868&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu Apr 28 06:21:29 
2016
@@ -10,6 +10,7 @@
 #include "IncludeFixer.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Parse/ParseAST.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -59,7 +60,8 @@ private:
 class Action : public clang::ASTFrontendAction,
public clang::ExternalSemaSource {
 public:
-  explicit Action(XrefsDB &Xrefs) : Xrefs(Xrefs) {}
+  explicit Action(XrefsDB &Xrefs, bool MinimizeIncludePaths)
+  : Xrefs(Xrefs), MinimizeIncludePaths(MinimizeIncludePaths) {}
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &Compiler,
@@ -147,13 +149,40 @@ public:
   FirstIncludeOffset = Offset;
   }
 
+  /// Get the minimal include for a given path.
+  std::string minimizeInclude(StringRef Include,
+  clang::SourceManager &SourceManager,
+  clang::HeaderSearch &HeaderSearch) {
+if (!MinimizeIncludePaths)
+  return Include;
+
+// Get the FileEntry for the include.
+StringRef StrippedInclude = Include.trim("\"<>");
+const FileEntry *Entry =
+SourceManager.getFileManager().getFile(StrippedInclude);
+
+// If the file doesn't exist return the path from the database.
+// FIXME: This should never happen.
+if (!Entry)
+  return Include;
+
+bool IsSystem;
+std::string Suggestion =
+HeaderSearch.suggestPathToFileForDiagnostics(Entry, &IsSystem);
+
+return IsSystem ? '<' + Suggestion + '>' : '"' + Suggestion + '"';
+  }
+
   /// Generate replacements for the suggested includes.
   /// \return true if changes will be made, false otherwise.
   bool Rewrite(clang::SourceManager &SourceManager,
+   clang::HeaderSearch &HeaderSearch,
std::vector &replacements) {
 for (const auto &ToTry : Untried) {
-  DEBUG(llvm::dbgs() << "Adding include " << ToTry << "\n");
-  std::string ToAdd = "#include " + ToTry + "\n";
+  std::string ToAdd = "#include " +
+  minimizeInclude(ToTry, SourceManager, HeaderSearch) +
+  "\n";
+  DEBUG(llvm::dbgs() << "Adding " << ToAdd << "\n");
 
   if (FirstIncludeOffset == -1U)
 FirstIncludeOffset = 0;
@@ -228,6 +257,9 @@ private:
 
   /// Includes we have left to try.
   std::set Untried;
+
+  /// Whether we should use the smallest possible include path.
+  bool MinimizeIncludePaths = true;
 };
 
 void PreprocessorHooks::FileChanged(clang::SourceLocation Loc,
@@ -271,8 +303,10 @@ void PreprocessorHooks::InclusionDirecti
 } // namespace
 
 IncludeFixerActionFactory::IncludeFixerActionFactory(
-XrefsDB &Xrefs, std::vector &Replacements)
-: Xrefs(Xrefs), Replacements(Replacements) {}
+XrefsDB &Xrefs, std::vector &Replacements,
+bool MinimizeIncludePaths)
+: Xrefs(Xrefs), Replacements(Replacements),
+  MinimizeIncludePaths(MinimizeIncludePaths) {}
 
 IncludeFixerActionFactory::~IncludeFixerActionFactory() = default;
 
@@ -294,11 +328,14 @@ bool IncludeFixerActionFactory::runInvoc
   Compiler.createSourceManager(*Files);
 
   // Run the parser, gather missing includes.
-  auto ScopedToolAction = llvm::make_unique(Xrefs);
+  auto ScopedToolAction =
+  llvm::make_unique(Xrefs, MinimizeIncludePaths);
   Compiler.ExecuteAction(*ScopedToolAction);
 
   // Generate replacements.
-  ScopedToolAction->Rewrite(Compiler.getSourceManager(), Replacements);
+  ScopedToolAction->Rewrite(Compiler.getSourceManager(),
+Compiler.getPreprocessor().getHeaderSearchInfo(),
+Replacements);
 
   // Technically this should only return true if we're sure that we have a
   // parseable file. We don't know that though.

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev

Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-28 Thread Andrew V. Tischenko via cfe-commits
avt77 added inline comments.


Comment at: test/SemaCXX/dllimport.cpp:179
@@ -140,1 +178,3 @@
+template 
+int ExternVarTmplDeclInit = 1;
 

majnemer wrote:
> avt77 wrote:
> > rnk wrote:
> > > Can you check with MSVC 2015 update 2 actually does with definitions of 
> > > dllimport variable templates? I bet it doesn't export them.
> > They don't support variable templates at all:
> > 
> > error C2399: variable templates are not supported in this release
> Your compiler is too old, they are definitely supported.
> 
> > Previously a template declaration was only allowed to be a function, class, 
> > or alias. Now, in the MSVC compiler it can be a variable as well.
> 
> https://blogs.msdn.microsoft.com/vcblog/2016/02/11/compiler-improvements-in-vs-2015-update-2/
OK, I updated several additional components and now CL supports variable 
templates. I checked the issue again and got the following:

C:\_bugs>cl -c  t1.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

t1.cpp
t1.cpp(8): warning C4273: 'ExternVarTmplDeclInit': inconsistent dll linkage
t1.cpp(2): note: see previous definition of 'ExternVarTmplDeclInit'

C:\_bugs>dumpbin /directives t1.obj
Microsoft (R) COFF/PE Dumper Version 14.00.23918.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file t1.obj

File Type: COFF OBJECT

   Linker Directives
   -
   /DEFAULTLIB:LIBCMT
   /DEFAULTLIB:OLDNAMES
   /EXPORT:??$ExternVarTmplDeclInit@H@@3HA,DATA//

As you see they produce warning and change the export attribute. I suppose 
Clang should do the same, right?


Comment at: test/SemaCXX/dllimport.cpp:1137
@@ -1017,1 +1136,3 @@
+template 
+void ImportClassTmplMembers::normalDef() {}
 #ifdef GNU

avt77 wrote:
> rnk wrote:
> > I'm pretty sure MSVC considers all free function templates to be 'inline', 
> > i.e. they put them in comdats. I doubt MSVC exports these. Can you verify 
> > what it does?
> They prohibit such a definition in the latest MSVC: 
> 
> error C2491: 'ImportClassTmplMembers::normalDef': definition of dllimport 
> function not allowed
> 
> The same error I see for other definitions as well
With the latest compiler they disallow the definition of dllimport functions as 
well. I suppose Clang should do the same, right?


http://reviews.llvm.org/D18953



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


r267869 - PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-28 Thread Silviu Baranga via cfe-commits
Author: sbaranga
Date: Thu Apr 28 06:29:08 2016
New Revision: 267869

URL: http://llvm.org/viewvc/llvm-project?rev=267869&view=rev
Log:
PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

Summary:
According to the ACLE spec, "__ARM_FEATURE_FMA is defined to 1 if
the hardware floating-point architecture supports fused floating-point
multiply-accumulate".

This changes clang's behaviour from emitting this macro for v7-A and v7-R
cores to only emitting it when the target has VFPv4 (and therefore support
for the floating point multiply-accumulate instruction).

Fixes PR27216

Reviewers: t.p.northover, rengolin

Subscribers: aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/arm-neon-fma.c
cfe/trunk/test/Preprocessor/arm-acle-6.5.c
cfe/trunk/test/Sema/arm_vfma.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=267869&r1=267868&r2=267869&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr 28 06:29:08 2016
@@ -4931,7 +4931,7 @@ public:
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.

Modified: cfe/trunk/test/CodeGen/arm-neon-fma.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-neon-fma.c?rev=267869&r1=267868&r2=267869&view=diff
==
--- cfe/trunk/test/CodeGen/arm-neon-fma.c (original)
+++ cfe/trunk/test/CodeGen/arm-neon-fma.c Thu Apr 28 06:29:08 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
 // RUN:   -target-abi aapcs \
-// RUN:   -target-cpu cortex-a8 \
+// RUN:   -target-cpu cortex-a7 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s

Modified: cfe/trunk/test/Preprocessor/arm-acle-6.5.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-acle-6.5.c?rev=267869&r1=267868&r2=267869&view=diff
==
--- cfe/trunk/test/Preprocessor/arm-acle-6.5.c (original)
+++ cfe/trunk/test/Preprocessor/arm-acle-6.5.c Thu Apr 28 06:29:08 2016
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv8-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 
 // CHECK-FMA: __ARM_FEATURE_FMA 1
 

Modified: cfe/trunk/test/Sema/arm_vfma.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm_vfma.c?rev=267869&r1=267868&r2=267869&view=diff
==
--- cfe/trunk/test/Sema/arm_vfma.c (original)
+++ cfe/trunk/test/Sema/arm_vfma.c Thu Apr 28 06:29:08 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7-none-eabi -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 
 
 // expected-no-diagnostics


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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-28 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added a comment.

Thanks, r267869!

-Silviu


http://reviews.llvm.org/D18963



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


r267870 - Revert "[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)"

2016-04-28 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Thu Apr 28 06:32:10 2016
New Revision: 267870

URL: http://llvm.org/viewvc/llvm-project?rev=267870&view=rev
Log:
Revert "[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)"

This reverts commit r267866.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/CodeGenCXX/sections.cpp
cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=267870&r1=267869&r2=267870&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 28 06:32:10 2016
@@ -327,21 +327,40 @@ public:
   LangOptions::PragmaMSPointersToMembersKind
   MSPointerToMemberRepresentationMethod;
 
+  enum PragmaVtorDispKind {
+PVDK_Push,  ///< #pragma vtordisp(push, mode)
+PVDK_Set,   ///< #pragma vtordisp(mode)
+PVDK_Pop,   ///< #pragma vtordisp(pop)
+PVDK_Reset  ///< #pragma vtordisp()
+  };
+
+  enum PragmaMsStackAction {
+PSK_Reset,// #pragma ()
+PSK_Set,  // #pragma ("name")
+PSK_Push, // #pragma (push[, id])
+PSK_Push_Set, // #pragma (push[, id], "name")
+PSK_Pop,  // #pragma (pop[, id])
+PSK_Pop_Set,  // #pragma (pop[, id], "name")
+  };
+
+  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
+  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
+  ///
+  /// 0: Suppress all vtordisps
+  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
+  ///structors
+  /// 2: Always insert vtordisps to support RTTI on partially constructed
+  ///objects
+  ///
+  /// The stack always has at least one element in it.
+  SmallVector VtorDispModeStack;
+
   /// Stack of active SEH __finally scopes.  Can be empty.
   SmallVector CurrentSEHFinally;
 
   /// \brief Source location for newly created implicit MSInheritanceAttrs
   SourceLocation ImplicitMSInheritanceAttrLoc;
 
-  enum PragmaMsStackAction {
-PSK_Reset = 0x0,// #pragma ()
-PSK_Set   = 0x1,// #pragma (value)
-PSK_Push  = 0x2,// #pragma (push[, id])
-PSK_Pop   = 0x4,// #pragma (pop[, id])
-PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
-PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
-  };
-
   template
   struct PragmaStack {
 struct Slot {
@@ -358,84 +377,18 @@ public:
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  ValueType Value);
-
-// MSVC seems to add artificial slots to #pragma stacks on entering a C++
-// method body to restore the stacks on exit, so it works like this:
-//
-//   struct S {
-// #pragma (push, InternalPragmaSlot, )
-// void Method {}
-// #pragma (pop, InternalPragmaSlot)
-//   };
-//
-// It works even with #pragma vtordisp, although MSVC doesn't support
-//   #pragma vtordisp(push [, id], n)
-// syntax.
-//
-// Push / pop a named sentinel slot.
-void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
-  assert((Action == PSK_Push || Action == PSK_Pop) &&
- "Can only push / pop #pragma stack sentinels!");
-  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
-}
-
-// Constructors.
-explicit PragmaStack(const ValueType &Default)
-: DefaultValue(Default), CurrentValue(Default) {}
-
+explicit PragmaStack(const ValueType &Value)
+  : CurrentValue(Value) {}
 SmallVector Stack;
-ValueType DefaultValue; // Value used for PSK_Reset action.
 ValueType CurrentValue;
 SourceLocation CurrentPragmaLocation;
   };
   // FIXME: We should serialize / deserialize these if they occur in a PCH (but
   // we shouldn't do so if they're in a module).
-
-  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
-  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
-  ///
-  /// 0: Suppress all vtordisps
-  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
-  ///structors
-  /// 2: Always insert vtordisps to support RTTI on partially constructed
-  ///objects
-  PragmaStack VtorDispStack;
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
   PragmaStack ConstSegStack;
   PragmaStack CodeSegStack;
-  // TODO: Change implementation of #pragma pack to use PragmaStack<> approach.
-
-  // RAII object to psuh / pop sentinel slots for all MS #pragma stacks.
-  // Actions should be performed only if we enter / exit a C++ method body.
-  class PragmaStackSentinelRAII {
-  public:
-PragmaStack

Re: r267870 - Revert "[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)"

2016-04-28 Thread Aaron Ballman via cfe-commits
On Thu, Apr 28, 2016 at 7:32 AM, Denis Zobnin via cfe-commits
 wrote:
> Author: dzobnin
> Date: Thu Apr 28 06:32:10 2016
> New Revision: 267870
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267870&view=rev
> Log:
> Revert "[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)"
>
> This reverts commit r267866.

When reverting code, please state a reason why it is being reverted
(preferably with links to a broken bot if that's the reason).

~Aaron

>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/ParsePragma.cpp
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaAttr.cpp
> cfe/trunk/test/CodeGenCXX/sections.cpp
> cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=267870&r1=267869&r2=267870&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr 28 06:32:10 2016
> @@ -327,21 +327,40 @@ public:
>LangOptions::PragmaMSPointersToMembersKind
>MSPointerToMemberRepresentationMethod;
>
> +  enum PragmaVtorDispKind {
> +PVDK_Push,  ///< #pragma vtordisp(push, mode)
> +PVDK_Set,   ///< #pragma vtordisp(mode)
> +PVDK_Pop,   ///< #pragma vtordisp(pop)
> +PVDK_Reset  ///< #pragma vtordisp()
> +  };
> +
> +  enum PragmaMsStackAction {
> +PSK_Reset,// #pragma ()
> +PSK_Set,  // #pragma ("name")
> +PSK_Push, // #pragma (push[, id])
> +PSK_Push_Set, // #pragma (push[, id], "name")
> +PSK_Pop,  // #pragma (pop[, id])
> +PSK_Pop_Set,  // #pragma (pop[, id], "name")
> +  };
> +
> +  /// \brief Whether to insert vtordisps prior to virtual bases in the 
> Microsoft
> +  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
> +  ///
> +  /// 0: Suppress all vtordisps
> +  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
> +  ///structors
> +  /// 2: Always insert vtordisps to support RTTI on partially constructed
> +  ///objects
> +  ///
> +  /// The stack always has at least one element in it.
> +  SmallVector VtorDispModeStack;
> +
>/// Stack of active SEH __finally scopes.  Can be empty.
>SmallVector CurrentSEHFinally;
>
>/// \brief Source location for newly created implicit MSInheritanceAttrs
>SourceLocation ImplicitMSInheritanceAttrLoc;
>
> -  enum PragmaMsStackAction {
> -PSK_Reset = 0x0,// #pragma ()
> -PSK_Set   = 0x1,// #pragma (value)
> -PSK_Push  = 0x2,// #pragma (push[, id])
> -PSK_Pop   = 0x4,// #pragma (pop[, id])
> -PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
> -PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
> -  };
> -
>template
>struct PragmaStack {
>  struct Slot {
> @@ -358,84 +377,18 @@ public:
>   PragmaMsStackAction Action,
>   llvm::StringRef StackSlotLabel,
>   ValueType Value);
> -
> -// MSVC seems to add artificial slots to #pragma stacks on entering a C++
> -// method body to restore the stacks on exit, so it works like this:
> -//
> -//   struct S {
> -// #pragma (push, InternalPragmaSlot, )
> -// void Method {}
> -// #pragma (pop, InternalPragmaSlot)
> -//   };
> -//
> -// It works even with #pragma vtordisp, although MSVC doesn't support
> -//   #pragma vtordisp(push [, id], n)
> -// syntax.
> -//
> -// Push / pop a named sentinel slot.
> -void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
> -  assert((Action == PSK_Push || Action == PSK_Pop) &&
> - "Can only push / pop #pragma stack sentinels!");
> -  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
> -}
> -
> -// Constructors.
> -explicit PragmaStack(const ValueType &Default)
> -: DefaultValue(Default), CurrentValue(Default) {}
> -
> +explicit PragmaStack(const ValueType &Value)
> +  : CurrentValue(Value) {}
>  SmallVector Stack;
> -ValueType DefaultValue; // Value used for PSK_Reset action.
>  ValueType CurrentValue;
>  SourceLocation CurrentPragmaLocation;
>};
>// FIXME: We should serialize / deserialize these if they occur in a PCH 
> (but
>// we shouldn't do so if they're in a module).
> -
> -  /// \brief Whether to insert vtordisps prior to virtual bases in the 
> Microsoft
> -  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
> -  ///
> -  /// 0: Suppress all vtordisps
> -  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
> -  ///structors
> -  /// 2: Always insert vtordisps to support RTTI on partially constructed
> -  ///   

Re: [PATCH] D19586: Misleading Indentation check

2016-04-28 Thread Pauer Gergely via cfe-commits
Pajesz updated this revision to Diff 55389.
Pajesz marked 5 inline comments as done.
Pajesz added a comment.

Both dangling else and the other check now ignore one-line if-else statements. 
Corrected other reviews as well.


http://reviews.llvm.org/D19586

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-misleading-indentation.rst
  test/clang-tidy/readability-misleading-indentation.cpp

Index: test/clang-tidy/readability-misleading-indentation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-misleading-indentation.cpp
@@ -0,0 +1,62 @@
+// RUN: %check_clang_tidy %s readability-misleading-indentation %t
+
+void foo1() {}
+void foo2() {}
+
+int main()
+{
+   bool cond1 = true;
+   bool cond2 = true;
+
+   if (cond1)
+  if (cond2)
+ foo1();
+   else
+ foo2();  // comment
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: wrong indentation, else belongs to if(cond2) statement
+// CHECK-FIXES: {{^}}  // comment
+
+   if (cond1) {
+  if (cond2)
+ foo1();
+   }
+   else
+  foo2();  // ok, else belongs to if(cond1) statement
+
+   if (cond1)
+ if (cond2)
+foo1();
+ else
+foo2();  // ok, indentation matches to syntactical structure
+
+   if (cond1)
+  foo1();
+  foo2(); // comment
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond1)
+// CHECK-FIXES: {{^}}  // comment
+
+   if (cond2)
+  foo1();
+  foo2(); // comment
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond2)
+// CHECK-FIXES: {{^}}  // comment
+
+   if (cond1)
+   {
+  foo1();
+   }
+  foo2();  // ok
+
+   if (cond1)
+  foo1();
+   foo2();  // ok
+
+  if (cond1)
+  foo1();
+  foo2(); // comment
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond1)
+// CHECK-FIXES: {{^}}  // comment
+  foo2(); // no need for redundant warning
+
+   return 0;
+}
Index: docs/clang-tidy/checks/readability-misleading-indentation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-misleading-indentation.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - readability-misleading-indentation
+
+readability-misleading-indentation
+==
+
+Description
+
+Correct indentation helps to understand code. Mismatch of the syntactical structure and the indentation of the code may reveal serious pr
+
+The way to avoid dangling else is to always check that an "else" belongs to the "if" that begins in the same column.
+
+You can omit braces when your inner part of e.g. an "if" statement has only one statement in it. Although in that case you should begin t
+
+Examples:
+
+.. code-block:: c++
+
+  // Dangling else:
+
+  if (cond1)
+if (cond2)
+  foo1();
+  else
+foo2();  // wrong indentation: else belongs to if(cond2) statement
+
+  // Missing braces
+
+  if (cond1)
+foo1();
+foo2();  // not part of if(cond1)
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -93,6 +93,7 @@
readability-identifier-naming
readability-implicit-bool-cast
readability-inconsistent-declaration-parameter-name
+   readability-misleading-indentation
readability-named-parameter
readability-redundant-control-flow
readability-redundant-smartptr-get
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -17,6 +17,7 @@
 #include "IdentifierNamingCheck.h"
 #include "ImplicitBoolCastCheck.h"
 #include "InconsistentDeclarationParameterNameCheck.h"
+#include "MisleadingIndentationCheck.h"
 #include "NamedParameterCheck.h"
 #include "RedundantControlFlowCheck.h"
 #include "RedundantSmartptrGetCheck.h"
@@ -45,6 +46,8 @@
 "readability-implicit-bool-cast");
 CheckFactories.registerCheck(
 "readability-inconsistent-declaration-parameter-name");
+CheckFactories.registerCheck(
+"readability-misleading-indentation");
 CheckFactories.registerCheck(
 "readability-named-parameter");
 CheckFactories.registerCheck(
Index: clang-tidy/readability/MisleadingIndentationCheck.h
===
--- /dev/null
+++ clang-tidy/readability/MisleadingIndentationCheck.h
@@ -0,0 +1,38 @@
+//===--- MisleadingIndentationCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Ope

Re: [PATCH] D19647: [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.

2016-04-28 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 55398.
hokein added a comment.

Don't append absolute path to build directory.

We will get the absolute file paths in some cases, such as STL.


http://reviews.llvm.org/D19647

Files:
  include-fixer/find-all-symbols/FindAllSymbols.cpp

Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -16,6 +16,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,19 +48,37 @@
   SetContext(ND, Symbol);
 
   Symbol->Name = ND->getNameAsString();
-  SourceLocation Loc = 
Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+  const SourceManager *SM = Result.SourceManager;
+  SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
   if (!Loc.isValid()) {
 llvm::errs() << "Declaration " << ND->getNameAsString() << "("
  << ND->getDeclKindName()
  << ") has invalid declaration location.";
 return false;
   }
-  std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+  Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
   if (FilePath.empty())
 return false;
 
-  Symbol->FilePath = FilePath;
-  Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(FilePath)) {
+AbsolutePath = FilePath;
+  } else {
+auto WorkingDir = SM->getFileManager()
+  .getVirtualFileSystem()
+  ->getCurrentWorkingDirectory();
+if (!WorkingDir)
+  return false;
+AbsolutePath = *WorkingDir;
+llvm::sys::path::append(AbsolutePath, FilePath);
+  }
+
+  llvm::sys::path::remove_dots(AbsolutePath, true);
+  Symbol->FilePath = AbsolutePath.str();
   return true;
 }
 } // namespace


Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -16,6 +16,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,19 +48,37 @@
   SetContext(ND, Symbol);
 
   Symbol->Name = ND->getNameAsString();
-  SourceLocation Loc = Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+  const SourceManager *SM = Result.SourceManager;
+  SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
   if (!Loc.isValid()) {
 llvm::errs() << "Declaration " << ND->getNameAsString() << "("
  << ND->getDeclKindName()
  << ") has invalid declaration location.";
 return false;
   }
-  std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+  Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
   if (FilePath.empty())
 return false;
 
-  Symbol->FilePath = FilePath;
-  Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(FilePath)) {
+AbsolutePath = FilePath;
+  } else {
+auto WorkingDir = SM->getFileManager()
+  .getVirtualFileSystem()
+  ->getCurrentWorkingDirectory();
+if (!WorkingDir)
+  return false;
+AbsolutePath = *WorkingDir;
+llvm::sys::path::append(AbsolutePath, FilePath);
+  }
+
+  llvm::sys::path::remove_dots(AbsolutePath, true);
+  Symbol->FilePath = AbsolutePath.str();
   return true;
 }
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, thakis, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This is exactly same patch as http://reviews.llvm.org/D18596 (already reviewed 
and LGTMed by rnk), with a couple of changes to fix PR27367:

* A check for void pointer added to include/clang/AST/Type.h
* A check for void pointer added to lib/Sema/SemaOverload.cpp
* A test (from PR27367) added to test/SemaCXX/MicrosoftExtensions.cpp

Yours,
Andrey
=
Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D19654

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4791,6 +4794,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4808,7 +4815,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5031,7 +5037,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1444,6 +1444,9 @@
   (PointeeType.isNull() || !PointeeType->isFunctionType()))
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1592,6 +1592,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 add

Re: r267744 - Revert r267691, it caused PR27535.

2016-04-28 Thread Vassil Vassilev via cfe-commits

Hi Nico,
  I have a fix. What is the right way of putting it in? Shall I revert 
the "revert" and commit the fix afterwards?

Many thanks
Vassil
On 27/04/16 19:26, Nico Weber via cfe-commits wrote:

Author: nico
Date: Wed Apr 27 12:26:08 2016
New Revision: 267744

URL: http://llvm.org/viewvc/llvm-project?rev=267744&view=rev
Log:
Revert r267691, it caused PR27535.

Removed:
 cfe/trunk/test/Modules/Inputs/PR27401/
 cfe/trunk/test/Modules/pr27401.cpp
Modified:
 cfe/trunk/include/clang/AST/DeclBase.h
 cfe/trunk/include/clang/Serialization/ASTWriter.h
 cfe/trunk/lib/AST/DeclBase.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=267744&r1=267743&r2=267744&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Apr 27 12:26:08 2016
@@ -518,8 +518,8 @@ public:
bool isImplicit() const { return Implicit; }
void setImplicit(bool I = true) { Implicit = I; }
  
-  /// \brief Whether *any* (re-)declaration of the entity was used, meaning that

-  /// a definition is required.
+  /// \brief Whether this declaration was used, meaning that a definition
+  /// is required.
///
/// \param CheckUsedAttr When true, also consider the "used" attribute
/// (in addition to the "used" bit set by \c setUsed()) when determining
@@ -529,8 +529,7 @@ public:
/// \brief Set whether the declaration is used, in the sense of odr-use.
///
/// This should only be used immediately after creating a declaration.
-  /// It intentionally doesn't notify any listeners.
-  void setIsUsed() { getCanonicalDecl()->Used = true; }
+  void setIsUsed() { Used = true; }
  
/// \brief Mark the declaration used, in the sense of odr-use.

///

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=267744&r1=267743&r2=267744&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Apr 27 12:26:08 2016
@@ -565,17 +565,6 @@ public:
/// decl.
const Decl *getFirstLocalDecl(const Decl *D);
  
-  /// \brief Is this a local declaration (that is, one that will be written to

-  /// our AST file)? This is the case for declarations that are neither 
imported
-  /// from another AST file nor predefined.
-  bool IsLocalDecl(const Decl *D) {
-if (D->isFromASTFile())
-  return false;
-auto I = DeclIDs.find(D);
-return (I == DeclIDs.end() ||
-I->second >= serialization::NUM_PREDEF_DECL_IDS);
-  };
-
/// \brief Emit a reference to a declaration.
void AddDeclRef(const Decl *D, RecordDataImpl &Record);
  


Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=267744&r1=267743&r2=267744&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Apr 27 12:26:08 2016
@@ -340,29 +340,25 @@ unsigned Decl::getMaxAlignment() const {
return Align;
  }
  
-bool Decl::isUsed(bool CheckUsedAttr) const {

-  const Decl *CanonD = getCanonicalDecl();
-  if (CanonD->Used)
+bool Decl::isUsed(bool CheckUsedAttr) const {
+  if (Used)
  return true;
-
+
// Check for used attribute.
-  // Ask the most recent decl, since attributes accumulate in the redecl chain.
-  if (CheckUsedAttr && getMostRecentDecl()->hasAttr())
+  if (CheckUsedAttr && hasAttr())
  return true;
  
-  // The information may have not been deserialized yet. Force deserialization

-  // to complete the needed information.
-  return getMostRecentDecl()->getCanonicalDecl()->Used;
+  return false;
  }
  
  void Decl::markUsed(ASTContext &C) {

-  if (isUsed())
+  if (Used)
  return;
  
if (C.getASTMutationListener())

  C.getASTMutationListener()->DeclarationMarkedUsed(this);
  
-  setIsUsed();

+  Used = true;
  }
  
  bool Decl::isReferenced() const {


Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=267744&r1=267743&r2=267744&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr 27 12:26:08 2016
@@ -13011,7 +13011,17 @@ void Sema::MarkFunctionReferenced(Source
UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
}
  
-  Func->markUsed(Context);

+ 

r267872 - [OPENMP 4.5] Initial codegen for 'taskloop simd' directive.

2016-04-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr 28 07:14:51 2016
New Revision: 267872

URL: http://llvm.org/viewvc/llvm-project?rev=267872&view=rev
Log:
[OPENMP 4.5] Initial codegen for 'taskloop simd' directive.

OpenMP 4.5 defines 'taskloop simd' directive, which is combined
directive for 'taskloop' and 'simd' directives. Patch adds initial
codegen support for this directive and its 2 basic clauses 'safelen' and
'simdlen'.

Added:
cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=267872&r1=267871&r2=267872&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Apr 28 07:14:51 2016
@@ -3383,6 +3383,9 @@ void CodeGenFunction::EmitOMPTaskLoopBas
   CGF.incrementProfileCounter(&S);
 }
 
+if (isOpenMPSimdDirective(S.getDirectiveKind()))
+  CGF.EmitOMPSimdInit(S);
+
 OMPPrivateScope LoopScope(CGF);
 // Emit helper vars inits.
 enum { LowerBound = 5, UpperBound, Stride, LastIter };
@@ -3449,12 +3452,5 @@ void CodeGenFunction::EmitOMPTaskLoopDir
 
 void CodeGenFunction::EmitOMPTaskLoopSimdDirective(
 const OMPTaskLoopSimdDirective &S) {
-  // emit the code inside the construct for now
-  OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
-  CGM.getOpenMPRuntime().emitInlinedDirective(
-  *this, OMPD_taskloop_simd, [&S](CodeGenFunction &CGF, PrePostActionTy &) 
{
-OMPLoopScope PreInitScope(CGF, S);
-CGF.EmitStmt(
-cast(S.getAssociatedStmt())->getCapturedStmt());
-  });
+  EmitOMPTaskLoopBasedDirective(S);
 }

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=267872&r1=267871&r2=267872&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 28 07:14:51 2016
@@ -1720,7 +1720,8 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
  Params);
 break;
   }
-  case OMPD_taskloop: {
+  case OMPD_taskloop:
+  case OMPD_taskloop_simd: {
 QualType KmpInt32Ty =
 Context.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
 QualType KmpUInt64Ty =
@@ -1754,14 +1755,6 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
 Context, AlwaysInlineAttr::Keyword_forceinline, SourceRange()));
 break;
   }
-  case OMPD_taskloop_simd: {
-Sema::CapturedParamNameType Params[] = {
-std::make_pair(StringRef(), QualType()) // __context with shared vars
-};
-ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
- Params);
-break;
-  }
   case OMPD_distribute: {
 Sema::CapturedParamNameType Params[] = {
 std::make_pair(StringRef(), QualType()) // __context with shared vars

Added: cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp?rev=267872&view=auto
==
--- cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp Thu Apr 28 07:14:51 2016
@@ -0,0 +1,211 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck %s
+// expected-no-diagnostics
+// REQUIRES: x86-registered-target
+#ifndef HEADER
+#define HEADER
+
+// CHECK-LABEL: @main
+int main(int argc, char **argv) {
+// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* 
[[DEFLOC:@.+]])
+// CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* 
[[DEFLOC]], i32 [[GTID]], i32 1, i64 64, i64 1, i32 (i32, i8*)* bitcast (i32 
(i32, [[TDP_TY:%.+]]*)* [[TASK1:@.+]] to i32 (i32, i8*)*))
+// CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*
+// CHECK: [[TASK_DATA:%.+]] = getelementptr inbounds [[TDP_TY]], [[TDP_TY]]* 
[[TASK]], i32 0, i32 0
+// CHECK: getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* [[TASK_DATA]], i32 
0, i32 3
+// CHECK: store i32 (i32, i8*)* null, i32 (i32, i8*)** %{{.+}}
+// CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* 
[[TASK_DATA]], i32 0, i32 4
+// CHECK: store i64 0, i64* [[DOWN]],
+// CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* 
[[TASK_DATA]], i32 0, i32 5
+// CHECK: store i64 9, i64* [[UP]],
+// CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* 
[[TA

r267871 - Revert r267784, r267824 and r267830.

2016-04-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr 28 07:14:47 2016
New Revision: 267871

URL: http://llvm.org/viewvc/llvm-project?rev=267871&view=rev
Log:
Revert r267784, r267824 and r267830.

It makes compiler-rt tests fail if the gold plugin is enabled.

Revert "Rework interface for bitset-using features to use a notion of LTO 
visibility."
Revert "Driver: only produce CFI -fvisibility= error when compiling."
Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would 
be non-cfi."

Added:
cfe/trunk/runtime/vtables_blacklist.txt
cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
Removed:
cfe/trunk/docs/LTOVisibility.rst
cfe/trunk/test/CodeGenCXX/bitset-inference.cpp
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/SemaCXX/attr-lto-visibility-public.cpp
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/docs/index.rst
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/runtime/CMakeLists.txt
cfe/trunk/test/CodeGenCXX/bitsets.cpp
cfe/trunk/test/CodeGenCXX/cfi-cast.cpp
cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp
cfe/trunk/test/CodeGenCXX/cfi-ms-rtti.cpp
cfe/trunk/test/CodeGenCXX/cfi-nvcall.cpp
cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
cfe/trunk/test/Driver/cl-runtime-flags.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/whole-program-vtables.c
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=267871&r1=267870&r2=267871&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Thu Apr 28 07:14:47 2016
@@ -25,25 +25,13 @@ As currently implemented, all schemes re
 so it is required to specify ``-flto``, and the linker used must support LTO,
 for example via the `gold plugin`_.
 
-To allow the checks to be implemented efficiently, the program must
-be structured such that certain object files are compiled with CFI
+To allow the checks to be implemented efficiently, the program must be
+structured such that certain object files are compiled with CFI
 enabled, and are statically linked into the program. This may preclude
-the use of shared libraries in some cases.
-
-The compiler will only produce CFI checks for a class if it can infer hidden
-LTO visibility for that class. LTO visibility is a property of a class that
-is inferred from flags and attributes. For more details, see the documentation
-for :doc:`LTO visibility `.
-
-The ``-fsanitize=cfi-{vcall,nvcall,derived-cast,unrelated-cast}`` flags
-require that a ``-fvisibility=`` flag also be specified. This is because the
-default visibility setting is ``-fvisibility=default``, which would disable
-CFI checks for classes without visibility attributes. Most users will want
-to specify ``-fvisibility=hidden``, which enables CFI checks for such classes.
-
-Experimental support for :ref:`cross-DSO control flow integrity
-` exists that does not require classes to have hidden LTO
-visibility. This cross-DSO support has unstable ABI at this time.
+the use of shared libraries in some cases. Experimental support for
+:ref:`cross-DSO control flow integrity ` exists that
+does not have these requirements. This cross-DSO support has unstable
+ABI at this time.
 
 .. _gold plugin: http://llvm.org/docs/GoldPlugin.html
 
@@ -245,6 +233,11 @@ A :doc:`SanitizerSpecialCaseList` can be
 source files, functions and types using the ``src``, ``fun`` and ``type``
 entity types.
 
+In addition, if a type has a ``uuid`` attribute and the blacklist contains
+the type entry ``attr:uuid``, CFI checks are suppressed for that type. This
+allows all COM types to be easily blacklisted, which is useful as COM types
+are typically defined outside of the linked program.
+
 .. code-block:: bash
 
 # Suppress checking for code in a file.
@@ -254,6 +247,8 @@ entity types.
 fun:*MyFooBar*
 # Ignore all types in the standard library.
 type:std::*
+# Ignore all types with a uuid attribute.
+type:attr:uuid
 
 .. _cfi-cross-dso:
 
@@ -265,11 +260,6 @@ flow integrity mode, which allows all CF
 apply across DSO boundaries. As in the regular CFI, each DSO must be
 built with ``-flto``

Re: [PATCH] D14274: Add alloc_size attribute to clang

2016-04-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:753
@@ +752,3 @@
+  let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
+  let TemplateDependent = 1;
+  let Documentation = [AllocSizeDocs];

I don't see any C++ tests involving templates; can you add some?


Comment at: test/SemaCXX/constant-expression-cxx11.cpp:1171
@@ -1170,3 +1170,3 @@
   int l : n3; // expected-error {{constant expression}} expected-note {{read 
of non-const variable}}
-  int m : t.n; // expected-error {{constant expression}} expected-note {{read 
of non-constexpr variable}}
+  int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}}
 };

This change seems out of place for a test that doesn't use alloc_size anywhere. 
Can you explain why this test has changed?


http://reviews.llvm.org/D14274



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


r267876 - [Clang][BuiltIn][AVX512] Adding intrinsics fot align{d|q} and palignr instruction set

2016-04-28 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Apr 28 07:47:30 2016
New Revision: 267876

URL: http://llvm.org/viewvc/llvm-project?rev=267876&view=rev
Log:
[Clang][BuiltIn][AVX512] Adding intrinsics fot align{d|q} and palignr 
instruction set

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=267876&r1=267875&r2=267876&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Apr 28 07:47:30 2016
@@ -1058,6 +1058,10 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var
 TARGET_BUILTIN(__builtin_ia32_vpermt2varpd512_mask, "V8dV8LLiV8dV8dUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_alignq512_mask, "V8LLiV8LLiV8LLiIiV8LLiUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_alignd512_mask, "V16iV16iV16iIiV16iUs", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignd128_mask, "V4iV4iV4iIiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignd256_mask, "V8iV8iV8iIiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignq128_mask, 
"V2LLiV2LLiV2LLiIiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignq256_mask, 
"V4LLiV4LLiV4LLiIiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIiV4dUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIiV4fUc", "", 
"avx512f")
 
@@ -2207,6 +2211,10 @@ TARGET_BUILTIN(__builtin_ia32_movntdq512
 TARGET_BUILTIN(__builtin_ia32_movntdqa512, "V8LLiV8LLi*","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_movntpd512, "vd*V8d","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_movntps512, "vf*V16f","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_palignr512_mask, 
"V64cV64cV64ciV64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_palignr128_mask, 
"V16cV16cV16ciV16cUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_palignr256_mask, 
"V32cV32cV32ciV32cUi","","avx512bw,avx512vl")
+
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=267876&r1=267875&r2=267876&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Thu Apr 28 07:47:30 2016
@@ -2168,6 +2168,29 @@ _mm512_mask_permutexvar_epi16 (__m512i _
  (__mmask32) __M);
 }
 
+#define _mm512_alignr_epi8( __A, __B, __N) __extension__ ({\
+__builtin_ia32_palignr512_mask ((__v8di) __A,\
+ (__v8di) __B ,__N * 8,\
+ (__v8di) _mm512_undefined_pd (),\
+ (__mmask64) -1);\
+})
+
+#define _mm512_mask_alignr_epi8( __W, __U, __A, __B, __N) __extension__({\
+__builtin_ia32_palignr512_mask ((__v8di) __A,\
+ (__v8di) __B,\
+ __N * 8,\
+ (__v8di) __W,\
+ (__mmask64) __U);\
+})
+
+#define _mm512_maskz_alignr_epi8( __U, __A, __B, __N) __extension__({\
+__builtin_ia32_palignr512_mask ((__v8di) __A,\
+ (__v8di) __B,\
+ __N * 8,\
+ (__v8di) _mm512_setzero_si512 (),\
+ (__mmask64) __U);\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=267876&r1=267875&r2=267876&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Apr 28 07:47:30 2016
@@ -2550,12 +2550,40 @@ _mm512_permutex2var_ps(__m512 __A, __m51
  (I), (__v8di)_mm512_setzero_si512(), \
  (__mmask8)-1); })
 
+#define _mm512_mask_alignr_epi64( __W,  __U,  __A, __B, __imm) __extension__({\
+  (__m512i)__builtin_ia32_alignq512_mask ((__v8di) __A,\
+ (__v8di) __B, __imm,\
+ (__v8di) __W,\
+ (__mmask8) __U);\
+})
+
+#define _mm512_maskz_alignr_epi64( __U,  __A,  __B, __imm) __extension__({\
+  (__m512i)__builtin_ia32_alignq512_mask ((__v8di) __A,\
+ (__v8di) __B, __imm,\
+ (__v8di) _mm512_setze

Re: [PATCH] D19403: Add loop pragma for Loop Distribution

2016-04-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: docs/LanguageExtensions.rst:2161
@@ +2160,3 @@
+
+  #pragma clang loop distribute(enable)
+  for(...) {

It would be nice to use a more compelling example than an empty for loop. Also, 
it would be helpful if the user understood why they wouldn't use this pragma 
for every loop (or why it doesn't happen by default).


http://reviews.llvm.org/D19403



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


Re: r267744 - Revert r267691, it caused PR27535.

2016-04-28 Thread Nico Weber via cfe-commits
I'd reland with the fix, and with an additional test that catches the
problem this introduced.
On Apr 28, 2016 8:16 AM, "Vassil Vassilev via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Hi Nico,
>   I have a fix. What is the right way of putting it in? Shall I revert the
> "revert" and commit the fix afterwards?
> Many thanks
> Vassil
> On 27/04/16 19:26, Nico Weber via cfe-commits wrote:
>
>> Author: nico
>> Date: Wed Apr 27 12:26:08 2016
>> New Revision: 267744
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267744&view=rev
>> Log:
>> Revert r267691, it caused PR27535.
>>
>> Removed:
>>  cfe/trunk/test/Modules/Inputs/PR27401/
>>  cfe/trunk/test/Modules/pr27401.cpp
>> Modified:
>>  cfe/trunk/include/clang/AST/DeclBase.h
>>  cfe/trunk/include/clang/Serialization/ASTWriter.h
>>  cfe/trunk/lib/AST/DeclBase.cpp
>>  cfe/trunk/lib/Sema/SemaExpr.cpp
>>  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>>  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=267744&r1=267743&r2=267744&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Wed Apr 27 12:26:08 2016
>> @@ -518,8 +518,8 @@ public:
>> bool isImplicit() const { return Implicit; }
>> void setImplicit(bool I = true) { Implicit = I; }
>>   -  /// \brief Whether *any* (re-)declaration of the entity was used,
>> meaning that
>> -  /// a definition is required.
>> +  /// \brief Whether this declaration was used, meaning that a definition
>> +  /// is required.
>> ///
>> /// \param CheckUsedAttr When true, also consider the "used" attribute
>> /// (in addition to the "used" bit set by \c setUsed()) when
>> determining
>> @@ -529,8 +529,7 @@ public:
>> /// \brief Set whether the declaration is used, in the sense of
>> odr-use.
>> ///
>> /// This should only be used immediately after creating a declaration.
>> -  /// It intentionally doesn't notify any listeners.
>> -  void setIsUsed() { getCanonicalDecl()->Used = true; }
>> +  void setIsUsed() { Used = true; }
>>   /// \brief Mark the declaration used, in the sense of odr-use.
>> ///
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=267744&r1=267743&r2=267744&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Apr 27 12:26:08
>> 2016
>> @@ -565,17 +565,6 @@ public:
>> /// decl.
>> const Decl *getFirstLocalDecl(const Decl *D);
>>   -  /// \brief Is this a local declaration (that is, one that will be
>> written to
>> -  /// our AST file)? This is the case for declarations that are neither
>> imported
>> -  /// from another AST file nor predefined.
>> -  bool IsLocalDecl(const Decl *D) {
>> -if (D->isFromASTFile())
>> -  return false;
>> -auto I = DeclIDs.find(D);
>> -return (I == DeclIDs.end() ||
>> -I->second >= serialization::NUM_PREDEF_DECL_IDS);
>> -  };
>> -
>> /// \brief Emit a reference to a declaration.
>> void AddDeclRef(const Decl *D, RecordDataImpl &Record);
>>
>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=267744&r1=267743&r2=267744&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclBase.cpp Wed Apr 27 12:26:08 2016
>> @@ -340,29 +340,25 @@ unsigned Decl::getMaxAlignment() const {
>> return Align;
>>   }
>>   -bool Decl::isUsed(bool CheckUsedAttr) const {
>> -  const Decl *CanonD = getCanonicalDecl();
>> -  if (CanonD->Used)
>> +bool Decl::isUsed(bool CheckUsedAttr) const {
>> +  if (Used)
>>   return true;
>> -
>> +
>> // Check for used attribute.
>> -  // Ask the most recent decl, since attributes accumulate in the redecl
>> chain.
>> -  if (CheckUsedAttr && getMostRecentDecl()->hasAttr())
>> +  if (CheckUsedAttr && hasAttr())
>>   return true;
>>   -  // The information may have not been deserialized yet. Force
>> deserialization
>> -  // to complete the needed information.
>> -  return getMostRecentDecl()->getCanonicalDecl()->Used;
>> +  return false;
>>   }
>> void Decl::markUsed(ASTContext &C) {
>> -  if (isUsed())
>> +  if (Used)
>>   return;
>>   if (C.getASTMutationListener())
>>   C.getASTMutationListener()->DeclarationMarkedUsed(this);
>>   -  setIsUsed();
>> +  Used = true;
>>   }
>> bool Decl::isReferenced() const {
>>
>> Mod

r267877 - Fix spuriously dematerializing reference bug. Fixes PR26612.

2016-04-28 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Apr 28 08:37:45 2016
New Revision: 267877

URL: http://llvm.org/viewvc/llvm-project?rev=267877&view=rev
Log:
Fix spuriously dematerializing reference bug. Fixes PR26612.

Modified:
cfe/trunk/docs/CMakeLists.txt

Modified: cfe/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CMakeLists.txt?rev=267877&r1=267876&r2=267877&view=diff
==
--- cfe/trunk/docs/CMakeLists.txt (original)
+++ cfe/trunk/docs/CMakeLists.txt Thu Apr 28 08:37:45 2016
@@ -95,8 +95,10 @@ if (LLVM_ENABLE_SPHINX)
 include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang)
-  configure_file(LibASTMatchersReference.html
-"${CMAKE_CURRENT_BINARY_DIR}/html/LibASTMatchersReference.html" 
COPYONLY)
+  add_custom_command(TARGET docs-clang-html POST_BUILD
+COMMAND ${CMAKE_COMMAND} -E copy
+LibASTMatchersReference.html
+"${CMAKE_CURRENT_BINARY_DIR}/html/LibASTMatchersReference.html")
 endif()
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man clang)


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


[PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-04-28 Thread Andrey Turetskiy via cfe-commits
aturetsk created this revision.
aturetsk added reviewers: rsmith, echristo.
aturetsk added subscribers: cfe-commits, zinovy.nis.
Herald added a subscriber: joker.eph.

Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87.
-m[no-]80387 options is added for compatibility with GCC.

http://reviews.llvm.org/D19658

Files:
  include/clang/Driver/Options.td

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1361,6 +1361,8 @@
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
+def mno_x87 : Flag<["-"], "mno-x87">, Group;
+def mno_80387 : Flag<["-"], "mno-80387">, Alias;
 def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
 def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
@@ -1527,6 +1529,8 @@
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>;
+def mx87 : Flag<["-"], "mx87">, Group;
+def m80387 : Flag<["-"], "m80387">, Alias;
 def msse2 : Flag<["-"], "msse2">, Group;
 def msse3 : Flag<["-"], "msse3">, Group;
 def msse4a : Flag<["-"], "msse4a">, Group;


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1361,6 +1361,8 @@
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
+def mno_x87 : Flag<["-"], "mno-x87">, Group;
+def mno_80387 : Flag<["-"], "mno-80387">, Alias;
 def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
 def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
@@ -1527,6 +1529,8 @@
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>;
+def mx87 : Flag<["-"], "mx87">, Group;
+def m80387 : Flag<["-"], "m80387">, Alias;
 def msse2 : Flag<["-"], "msse2">, Group;
 def msse3 : Flag<["-"], "msse3">, Group;
 def msse4a : Flag<["-"], "msse4a">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267879 - [SystemZ] Support Swift calling convention

2016-04-28 Thread Bryan Chan via cfe-commits
Author: bryanpkc
Date: Thu Apr 28 08:56:43 2016
New Revision: 267879

URL: http://llvm.org/viewvc/llvm-project?rev=267879&view=rev
Log:
[SystemZ] Support Swift calling convention

Summary:
Port rL265324 to SystemZ to allow using the 'swiftcall' attribute on that 
architecture.

Depends on D19414.

Reviewers: kbarton, rjmccall, uweigand

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=267879&r1=267878&r2=267879&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr 28 08:56:43 2016
@@ -6548,6 +6548,16 @@ public:
 .Default(false);
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_C:
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
+
   StringRef getABI() const override {
 if (HasVector)
   return "vector";

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267879&r1=267878&r2=267879&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Apr 28 08:56:43 2016
@@ -5713,12 +5713,12 @@ void NVPTXTargetCodeGenInfo::addNVVMMeta
 
 namespace {
 
-class SystemZABIInfo : public ABIInfo {
+class SystemZABIInfo : public SwiftABIInfo {
   bool HasVector;
 
 public:
   SystemZABIInfo(CodeGenTypes &CGT, bool HV)
-: ABIInfo(CGT), HasVector(HV) {}
+: SwiftABIInfo(CGT), HasVector(HV) {}
 
   bool isPromotableIntegerType(QualType Ty) const;
   bool isCompoundType(QualType Ty) const;
@@ -5738,6 +5738,12 @@ public:
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
+ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {


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


Re: [PATCH] D19432: [SystemZ] Support Swift calling convention

2016-04-28 Thread Bryan Chan via cfe-commits
bryanpkc added a comment.

Thank you for the reviews.


http://reviews.llvm.org/D19432



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


r267880 - ARMv7k: define __ARM_PCS_VFP since we're hard-float.

2016-04-28 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Apr 28 08:59:55 2016
New Revision: 267880

URL: http://llvm.org/viewvc/llvm-project?rev=267880&view=rev
Log:
ARMv7k: define __ARM_PCS_VFP since we're hard-float.

It's a little debateable because we're not truly AAPCS, so I'm
certainly not going to define __ARM_PCS, but __ARM_PCS_VFP seems to be
really an "hard-float" define, which is a useful thing to have.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=267880&r1=267879&r2=267880&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr 28 08:59:55 2016
@@ -4948,11 +4948,12 @@ public:
   if (!getTriple().isOSDarwin() && !getTriple().isOSWindows())
 Builder.defineMacro("__ARM_EABI__");
   Builder.defineMacro("__ARM_PCS", "1");
-
-  if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp")
-Builder.defineMacro("__ARM_PCS_VFP", "1");
 }
 
+if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp" ||
+ABI == "aapcs16")
+  Builder.defineMacro("__ARM_PCS_VFP", "1");
+
 if (SoftFloat)
   Builder.defineMacro("__SOFTFP__");
 


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


r267881 - Add accidentally dropped test to r267880.

2016-04-28 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Apr 28 09:01:49 2016
New Revision: 267881

URL: http://llvm.org/viewvc/llvm-project?rev=267881&view=rev
Log:
Add accidentally dropped test to r267880.

Forgot "git add".

Modified:
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=267881&r1=267880&r2=267881&view=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Thu Apr 28 09:01:49 2016
@@ -212,6 +212,16 @@
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
+// Test whether predefines are as expected when targeting cortex-a7.
+// RUN: %clang -target x86_64-apple-darwin -arch armv7k -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV7K %s
+// ARMV7K:#define __ARM_ARCH 7
+// ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_FEATURE_DSP 1
+// ARMV7K:#define __ARM_FP 0xE
+// ARMV7K:#define __ARM_PCS_VFP 1
+
+
 // Test whether predefines are as expected when targeting cortex-a8.
 // RUN: %clang -target armv7 -mcpu=cortex-a8 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=A8 %s
 // RUN: %clang -target armv7 -mthumb -mcpu=cortex-a8 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=A8 %s


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


Re: [PATCH] D19648: [include-fixer] Add Yaml database integration.

2016-04-28 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 55412.
hokein added a comment.

Fix a nit.


http://reviews.llvm.org/D19648

Files:
  include-fixer/CMakeLists.txt
  include-fixer/YamlXrefsDB.cpp
  include-fixer/YamlXrefsDB.h
  include-fixer/tool/ClangIncludeFixer.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/yamldb.cpp

Index: test/include-fixer/yamldb.cpp
===
--- /dev/null
+++ test/include-fixer/yamldb.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp --
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK: #include "foo.h"
+// CHECK: b::a::foo f;
+
+b::a::foo f;
Index: test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- /dev/null
+++ test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -0,0 +1,11 @@
+---
+Name:   foo
+Contexts:
+  - ContextType: Namespace
+ContextName: a
+  - ContextType: Namespace
+ContextName: b
+FilePath:foo.h
+LineNumber:  1
+Type:Class
+...
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -9,24 +9,29 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "YamlXrefsDB.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+
 using namespace clang;
 using namespace llvm;
 
 namespace {
 cl::OptionCategory IncludeFixerCategory("Tool options");
 
 enum DatabaseFormatTy {
   fixed, //< Hard-coded mapping.
+  yaml,  //< Yaml database created by find-all-symbols.
 };
 
 cl::opt DatabaseFormat(
 "db", cl::desc("Specify input format"),
-cl::values(clEnumVal(fixed, "Hard-coded mapping"), clEnumValEnd),
+cl::values(clEnumVal(fixed, "Hard-coded mapping"),
+   clEnumVal(yaml, "Yaml database created by find-all-symbols"),
+   clEnumValEnd),
 cl::init(fixed), cl::cat(IncludeFixerCategory));
 
 cl::opt Input("input",
@@ -62,6 +67,10 @@
 llvm::make_unique(std::move(XrefsMap));
 break;
   }
+  case yaml: {
+XrefsDB = llvm::make_unique(Input);
+break;
+  }
   }
 
   // Now run our tool.
Index: include-fixer/YamlXrefsDB.h
===
--- /dev/null
+++ include-fixer/YamlXrefsDB.h
@@ -0,0 +1,35 @@
+//===-- YamlXrefsDB.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+
+#include "XrefsDB.h"
+#include "find-all-symbols/SymbolInfo.h"
+#include 
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+/// Yaml format database.
+class YamlXrefsDB : public XrefsDB {
+public:
+  YamlXrefsDB(llvm::StringRef FilePath);
+
+  std::vector search(llvm::StringRef Identifier) override;
+
+private:
+  std::vector Symbols;
+};
+
+} // namespace include_fixer
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
Index: include-fixer/YamlXrefsDB.cpp
===
--- /dev/null
+++ include-fixer/YamlXrefsDB.cpp
@@ -0,0 +1,64 @@
+//===-- YamlXrefsDB.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "YamlXrefsDB.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
+  int ReadFD = 0;
+  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
+return;
+  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+  if (!Buffer)
+return;
+  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer());
+}
+
+std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {
+  llvm::SmallVector Names;
+  std::vector Results;
+
+  // The identifier may be fully qualified, so split it and get all the context
+  // names.
+  Identifier.split(Names, "::");
+  for (const auto &Symbol : Symbols

Re: [PATCH] D19648: [include-fixer] Add Yaml database integration.

2016-04-28 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D19648



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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-28 Thread Vladimir Yakovlev via cfe-commits
vbyakovl added a comment.

@rsmith ping


http://reviews.llvm.org/D18823



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


r267882 - Reland r267691 fixing PR27535.

2016-04-28 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Apr 28 09:13:28 2016
New Revision: 267882

URL: http://llvm.org/viewvc/llvm-project?rev=267882&view=rev
Log:
Reland r267691 fixing PR27535.

Added:
cfe/trunk/test/Modules/Inputs/PR27401/
cfe/trunk/test/Modules/Inputs/PR27401/a.h
cfe/trunk/test/Modules/Inputs/PR27401/b.h
cfe/trunk/test/Modules/Inputs/PR27401/module.modulemap
cfe/trunk/test/Modules/pr27401.cpp
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGen/attr-used.c

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=267882&r1=267881&r2=267882&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Apr 28 09:13:28 2016
@@ -518,8 +518,8 @@ public:
   bool isImplicit() const { return Implicit; }
   void setImplicit(bool I = true) { Implicit = I; }
 
-  /// \brief Whether this declaration was used, meaning that a definition
-  /// is required.
+  /// \brief Whether *any* (re-)declaration of the entity was used, meaning 
that
+  /// a definition is required.
   ///
   /// \param CheckUsedAttr When true, also consider the "used" attribute
   /// (in addition to the "used" bit set by \c setUsed()) when determining
@@ -529,7 +529,8 @@ public:
   /// \brief Set whether the declaration is used, in the sense of odr-use.
   ///
   /// This should only be used immediately after creating a declaration.
-  void setIsUsed() { Used = true; }
+  /// It intentionally doesn't notify any listeners.
+  void setIsUsed() { getCanonicalDecl()->Used = true; }
 
   /// \brief Mark the declaration used, in the sense of odr-use.
   ///

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=267882&r1=267881&r2=267882&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Apr 28 09:13:28 2016
@@ -565,6 +565,17 @@ public:
   /// decl.
   const Decl *getFirstLocalDecl(const Decl *D);
 
+  /// \brief Is this a local declaration (that is, one that will be written to
+  /// our AST file)? This is the case for declarations that are neither 
imported
+  /// from another AST file nor predefined.
+  bool IsLocalDecl(const Decl *D) {
+if (D->isFromASTFile())
+  return false;
+auto I = DeclIDs.find(D);
+return (I == DeclIDs.end() ||
+I->second >= serialization::NUM_PREDEF_DECL_IDS);
+  };
+
   /// \brief Emit a reference to a declaration.
   void AddDeclRef(const Decl *D, RecordDataImpl &Record);
 

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=267882&r1=267881&r2=267882&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Apr 28 09:13:28 2016
@@ -340,25 +340,29 @@ unsigned Decl::getMaxAlignment() const {
   return Align;
 }
 
-bool Decl::isUsed(bool CheckUsedAttr) const { 
-  if (Used)
+bool Decl::isUsed(bool CheckUsedAttr) const {
+  const Decl *CanonD = getCanonicalDecl();
+  if (CanonD->Used)
 return true;
-  
+
   // Check for used attribute.
-  if (CheckUsedAttr && hasAttr())
+  // Ask the most recent decl, since attributes accumulate in the redecl chain.
+  if (CheckUsedAttr && getMostRecentDecl()->hasAttr())
 return true;
 
-  return false; 
+  // The information may have not been deserialized yet. Force deserialization
+  // to complete the needed information.
+  return getMostRecentDecl()->getCanonicalDecl()->Used;
 }
 
 void Decl::markUsed(ASTContext &C) {
-  if (Used)
+  if (isUsed(false))
 return;
 
   if (C.getASTMutationListener())
 C.getASTMutationListener()->DeclarationMarkedUsed(this);
 
-  Used = true;
+  setIsUsed();
 }
 
 bool Decl::isReferenced() const { 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=267882&r1=267881&r2=267882&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr 28 09:13:28 2016
@@ -13011,17 +13011,7 @@ void Sema::MarkFunctionReferenced(Source
   UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
   }
 
-  // Normally the most current decl is marked used while processing the use and
-  // an

Re: r267744 - Revert r267691, it caused PR27535.

2016-04-28 Thread Vassil Vassilev via cfe-commits

r267882.
On 28/04/16 15:23, Nico Weber wrote:


I'd reland with the fix, and with an additional test that catches the 
problem this introduced.


On Apr 28, 2016 8:16 AM, "Vassil Vassilev via cfe-commits" 
mailto:cfe-commits@lists.llvm.org>> wrote:


Hi Nico,
  I have a fix. What is the right way of putting it in? Shall I
revert the "revert" and commit the fix afterwards?
Many thanks
Vassil
On 27/04/16 19:26, Nico Weber via cfe-commits wrote:

Author: nico
Date: Wed Apr 27 12:26:08 2016
New Revision: 267744

URL: http://llvm.org/viewvc/llvm-project?rev=267744&view=rev
Log:
Revert r267691, it caused PR27535.

Removed:
 cfe/trunk/test/Modules/Inputs/PR27401/
 cfe/trunk/test/Modules/pr27401.cpp
Modified:
 cfe/trunk/include/clang/AST/DeclBase.h
 cfe/trunk/include/clang/Serialization/ASTWriter.h
 cfe/trunk/lib/AST/DeclBase.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=267744&r1=267743&r2=267744&view=diff

==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Apr 27 12:26:08
2016
@@ -518,8 +518,8 @@ public:
bool isImplicit() const { return Implicit; }
void setImplicit(bool I = true) { Implicit = I; }
  -  /// \brief Whether *any* (re-)declaration of the entity
was used, meaning that
-  /// a definition is required.
+  /// \brief Whether this declaration was used, meaning that
a definition
+  /// is required.
///
/// \param CheckUsedAttr When true, also consider the
"used" attribute
/// (in addition to the "used" bit set by \c setUsed())
when determining
@@ -529,8 +529,7 @@ public:
/// \brief Set whether the declaration is used, in the
sense of odr-use.
///
/// This should only be used immediately after creating a
declaration.
-  /// It intentionally doesn't notify any listeners.
-  void setIsUsed() { getCanonicalDecl()->Used = true; }
+  void setIsUsed() { Used = true; }
  /// \brief Mark the declaration used, in the sense of
odr-use.
///

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=267744&r1=267743&r2=267744&view=diff

==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Apr
27 12:26:08 2016
@@ -565,17 +565,6 @@ public:
/// decl.
const Decl *getFirstLocalDecl(const Decl *D);
  -  /// \brief Is this a local declaration (that is, one that
will be written to
-  /// our AST file)? This is the case for declarations that
are neither imported
-  /// from another AST file nor predefined.
-  bool IsLocalDecl(const Decl *D) {
-if (D->isFromASTFile())
-  return false;
-auto I = DeclIDs.find(D);
-return (I == DeclIDs.end() ||
-I->second >= serialization::NUM_PREDEF_DECL_IDS);
-  };
-
/// \brief Emit a reference to a declaration.
void AddDeclRef(const Decl *D, RecordDataImpl &Record);

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=267744&r1=267743&r2=267744&view=diff

==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Apr 27 12:26:08 2016
@@ -340,29 +340,25 @@ unsigned Decl::getMaxAlignment() const {
return Align;
  }
  -bool Decl::isUsed(bool CheckUsedAttr) const {
-  const Decl *CanonD = getCanonicalDecl();
-  if (CanonD->Used)
+bool Decl::isUsed(bool CheckUsedAttr) const {
+  if (Used)
  return true;
-
+
// Check for used attribute.
-  // Ask the most recent decl, since attributes accumulate in
the redecl chain.
-  if (CheckUsedAttr && getMostRecentDecl()->hasAttr())
+  if (CheckUsedAttr

r267883 - Fix build.

2016-04-28 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Apr 28 09:28:19 2016
New Revision: 267883

URL: http://llvm.org/viewvc/llvm-project?rev=267883&view=rev
Log:
Fix build.

Modified:
cfe/trunk/docs/CMakeLists.txt

Modified: cfe/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CMakeLists.txt?rev=267883&r1=267882&r2=267883&view=diff
==
--- cfe/trunk/docs/CMakeLists.txt (original)
+++ cfe/trunk/docs/CMakeLists.txt Thu Apr 28 09:28:19 2016
@@ -97,7 +97,7 @@ if (LLVM_ENABLE_SPHINX)
   add_sphinx_target(html clang)
   add_custom_command(TARGET docs-clang-html POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E copy
-LibASTMatchersReference.html
+"${CMAKE_CURRENT_SOURCE_DIR}/LibASTMatchersReference.html"
 "${CMAKE_CURRENT_BINARY_DIR}/html/LibASTMatchersReference.html")
 endif()
 if (${SPHINX_OUTPUT_MAN})


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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-28 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/AffectedRangeManager.cpp:103
@@ -102,1 +102,3 @@
 AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+  assert(Line && "does not contain any line");
+

klimek wrote:
> Perhaps we should change this to take a Line& instead? Daniel, thoughts?
Yeah, that makes sense to me.


Comment at: lib/Format/AffectedRangeManager.cpp:111
@@ -108,2 +110,3 @@
 
+  assert(Line->First && "does not have a first token");
   // Stores whether one of the line's tokens is directly affected.

Here, we should probably just return false.


http://reviews.llvm.org/D19385



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


[PATCH] D19662: [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

2016-04-28 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
yaxunl added subscribers: cfe-commits, tstellarAMD.

When comparing unqualified types, canonical types should be used, otherwise 
equivalent types may be treated as different type.

For example,

typedef int int_t;
generic int* a;
global int_t* b;

`0 ? a : b` should have type generic int*. However due to this bug, int_t and 
int are treated as different types, which causes the type of `0 ? a : b` to 
have type generic void*.

This patch fixes it. 

http://reviews.llvm.org/D19662

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenOpenCL/address-spaces-conversions.cl

Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -49,7 +49,7 @@
   generic int *var_gen2;
   generic float *var_gen_f;
   generic void *var_gen_v;
-
+  
   var_gen = var_gen ? var_gen : var_gen2; // operands of the same addr spaces 
and the same type
   // CHECK: icmp
   // CHECK-NOT: addrspacecast
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping 
addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr 
space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))


Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -49,7 +49,7 @@
   generic int *var_gen2;
   generic float *var_gen_f;
   generic void *var_gen_v;
-
+  
   var_gen = var_gen ? var_gen : var_gen2; // operands of the same addr spaces and the same type
   // CHECK: icmp
   // CHECK-NOT: addrspacecast
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.


Comment at: test/Modules/getSourceDescriptor-crash.cpp:1
@@ +1,2 @@
+// RUN: %clang -I %S/Inputs/getSourceDescriptor-crash -c -g 
-fimplicit-module-maps %s
+

Should run %clang_cc1 not the driver.



http://reviews.llvm.org/D19048



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


Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Adrian Prantl via cfe-commits

> On Apr 27, 2016, at 7:27 PM, Douglas Yung  wrote:
> 
> dyung added a comment.
> 
> In http://reviews.llvm.org/D19048#414568, @aprantl wrote:
> 
>> Thanks!
>> 
>> Is there anything meaningful that could be CHECKed here?
>> Usually a crash means that we previously had a code path without test 
>> coverage.
> 
> 
> This was definitely a code path without test coverage.
> 
> When you ask whether there is anything meaningful that could be checked here, 
> are you asking whether we can change the test from testing only that the 
> compilation succeeds to checking something that the compiler produces? If so, 
> I could change the test to produce llvm assembly (-S -emit-llvm) instead, and 
> then perhaps check for the presence of a DIModule within the output. Would 
> that make a better test?

Yes, please!

> 
> 
> http://reviews.llvm.org/D19048
> 
> 
> 

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


[PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

2016-04-28 Thread silviu.bara...@arm.com via cfe-commits
sbaranga created this revision.
sbaranga added a reviewer: rengolin.
sbaranga added subscribers: t.p.northover, cfe-commits.
Herald added subscribers: rengolin, aemerson.

Conversions between float and half are only available when the
taraget has the half-precision extension. Guard these intrinsics
so that they don't cause crashes in the backend.

Fixes PR27550.

http://reviews.llvm.org/D19665

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/arm-negative-fp16.c

Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -704,8 +704,12 @@
 

 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+  def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+  def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", 
OP_VCVT_NA_HI_F16>;
+  def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", 
OP_VCVT_EX_HI_F32>;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
@@ -981,8 +985,6 @@
 def VCVT_U64 : SInst<"vcvt_u64", "ud",  "dQd">;
 def VCVT_F64 : SInst<"vcvt_f64", "Fd",  "lUlQlQUl">;
 
-def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", 
OP_VCVT_NA_HI_F16>;
-def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
 def VCVT_HIGH_F32_F64 : SOpInst<"vcvt_high_f32", "qfj", "d", 
OP_VCVT_NA_HI_F32>;
 def VCVT_HIGH_F64_F32 : SOpInst<"vcvt_high_f64", "wj", "f", OP_VCVT_EX_HI_F64>;
 
Index: test/CodeGen/arm-negative-fp16.c
===
--- /dev/null
+++ test/CodeGen/arm-negative-fp16.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon 
-target-feature -fp16 -fsyntax-only -verify
+
+#include 
+
+float16x4_t test_vcvt_f16_f32(float32x4_t a) {
+  return vcvt_f16_f32(a); // expected-warning{{implicit declaration of 
function 'vcvt_f16_f32'}}  expected-error{{returning 'int' from a function with 
incompatible result type 'float16x4_t'}}
+}
+
+float32x4_t test_vcvt_f32_f16(float16x4_t a) {
+  return vcvt_f32_f16(a); // expected-warning{{implicit declaration of 
function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with 
incompatible result type 'float32x4_t'}}
+}
+
+float32x4_t test_vcvt_high_f32_f16(float16x8_t a) {
+  return vcvt_high_f32_f16(a); // expected-warning{{implicit declaration of 
function 'vcvt_high_f32_f16'}} expected-error{{returning 'int' from a function 
with incompatible result type 'float32x4_t'}}
+}
+float16x8_t test_vcvt_high_f16_f32(float16x4_t a, float32x4_t b) {
+  return vcvt_high_f16_f32(a, b); // expected-warning{{implicit declaration of 
function 'vcvt_high_f16_f32'}} expected-error{{returning 'int' from a function 
with incompatible result type 'float16x8_t'}}
+}


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -704,8 +704,12 @@
 
 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+  def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+  def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", OP_VCVT_NA_HI_F16>;
+  def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
@@ -981,8 +985,6 @@
 def VCVT_U64 : SInst<"vcvt_u64", "ud",  "dQd">;
 def VCVT_F64 : SInst<"vcvt_f64", "Fd",  "lUlQlQUl">;
 
-def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", OP_VCVT_NA_HI_F16>;
-def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
 def VCVT_HIGH_F32_F64 : SOpInst<"vcvt_high_f32", "qfj", "d", OP_VCVT_NA_HI_F32>;
 def VCVT_HIGH_F64_F32 : SOpInst<"vcvt_high_f64", "wj", "f", OP_VCVT_EX_HI_F64>;
 
Index: test/CodeGen/arm-negative-fp16.c
===
--- /dev/null
+++ test/CodeGen/arm-negative-fp16.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon -target-feature -fp16 -fsyntax-only -verify
+
+#include 
+
+float16x4_t test_vcvt_f16_f32(float32x4_t a) {
+  return vcvt_f16_f32(a); // expected-warning{{implicit declaration of function 'vcvt_f16_f32'}}  expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float32x

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55425.
rmaprath added a comment.

Addressing review comments by @mclow.lists:

- Switched to `_LIBCPP_ALWAYS_INLINE` from `_LIBCPP_INLINE_VISIBILITY` for all 
`__os_xxx` functions.

I've left the remaining points (naming of `__os_support` header and 
initialization of internal mutex / condition_variable instances) untouched 
pending further discussion.

/ Asiri


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__os_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __os_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +64,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __os_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,91 +21,71 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__os_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __os_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
-if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
+int ec = __os_mutex_init(&__m_, true);
 if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __os_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __os_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +145,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__os_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +163,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __os_thread_id_compare(id, __id_) == 0))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +197,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +227,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+unique_lock lk(mut)

[PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added a reviewer: rsmith.
filcab added a subscriber: cfe-commits.

This option allows the user to control how much of the file name is
emitted by UBSan. Tuning this option allows one to save space in the
resulting binary, which is helpful for restricted execution
environments.

With a positive N, UBSan skips the first N path components.
With a negative N, UBSan only keeps the last N path components.

http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fubsan-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fubsan-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+// We can't easily check stripping one or two levels.
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fubsan-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// We have an optional space in the regex in the next line because the }} eagerly closes the regex
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -783,6 +783,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip =
+  getLastArgIntValue(Args, OPT_fubsan_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5621,6 +5621,9 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fubsan_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/

Re: [PATCH] D19403: Add loop pragma for Loop Distribution

2016-04-28 Thread Adam Nemet via cfe-commits
anemet added inline comments.


Comment at: docs/LanguageExtensions.rst:2161
@@ +2160,3 @@
+
+  #pragma clang loop distribute(enable)
+  for(...) {

aaron.ballman wrote:
> It would be nice to use a more compelling example than an empty for loop. 
> Also, it would be helpful if the user understood why they wouldn't use this 
> pragma for every loop (or why it doesn't happen by default).
Sure, I just followed the vectorizer example but you're right this needs more 
context.  Let me update the patch.

Thanks for the review!


http://reviews.llvm.org/D19403



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


Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-04-28 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.
bruno added a reviewer: bruno.
bruno added a comment.

Hi Andrey,

What about the code / tests that check for this flags?


http://reviews.llvm.org/D19658



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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2016-04-28 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


[PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab created this revision.
filcab added reviewers: kcc, samsonov, rsmith.
filcab added a subscriber: cfe-commits.

This patch makes the type_mismatch static data 7 bytes smaller (and it ends up
being 16 bytes smaller due to alignment restrictions, at least on some x86-64
environments).

Currently, I have no binary compatibility for using an older object file
(compiled before this change) with a newer clang. Depending on the compiler-rt
code review, this patch might be updated to better signal to the library that
this object has this new binary format.

http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp

Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-28 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


Re: [PATCH] D19662: [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

2016-04-28 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/CodeGenOpenCL/address-spaces-conversions.cl:52
@@ -51,3 +51,3 @@
   generic void *var_gen_v;
-
+  
   var_gen = var_gen ? var_gen : var_gen2; // operands of the same addr spaces 
and the same type

Inserting a whitespace here?


http://reviews.llvm.org/D19662



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-28 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/AST/MicrosoftMangle.cpp:1446-1451
@@ -1445,5 +1445,8 @@
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }

Have you tested `__restrict` with `__unaligned` on MSVC?  I don't see a test 
for it here.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1585
@@ -1579,3 +1582,5 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';

It would be good to see what MSVC does with:

```
template 
T f(T t) { return t; }
```

Where `T` is instantiated with `int *` and `int __unaligned *`.


Comment at: lib/Sema/SemaType.cpp:1787
@@ -1787,1 +1786,3 @@
+  // TQ_unaligned;
+  unsigned CVR = CVRAU & ~DeclSpec::TQ_atomic & ~DeclSpec::TQ_unaligned;
 

This would probably be easier to read if written as:
  unsigned CVR = CVRAU & ~(DeclSpec::TQ_atomic | DeclSpec::TQ_unaligned);


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-04-28 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

Is there an associated patch on the consuming side for this data?


http://reviews.llvm.org/D19667



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D19412#414374, @rmaprath wrote:

> > On a bikeshed note: is `<__os_support>` the right name? Or should it be 
> > something like `<__thread>`  or `<__threading_support>`?
>
>
> I went with `__os_support`  in case if we'd want to group further external 
> dependencies (like, for example, if some non-c POSIX calls are used in the 
> upcoming `filesystem` library). I can revert back to `__threading_support` if 
> that's preferred.
>
> Thanks.
>
> / Asiri


I don't particularly care for <__os_support> either.  Either of <__thread> or 
<__threading_support> are fine with me.

Note that there are already other OS specific calls that libcxx has to handle.  
A lot of the locale code wants to use BSD style foo_l functions that are 
present on Linux.  I prefer to keep the locale code independent of the 
threading code, as the two don't overlap much.

For filesystem related items, I would expect those to go under <__filesystem> 
or <__filesystem_support>, or something similar.


http://reviews.llvm.org/D19412



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


r267903 - Re-apply r267784, r267824 and r267830.

2016-04-28 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Apr 28 12:09:37 2016
New Revision: 267903

URL: http://llvm.org/viewvc/llvm-project?rev=267903&view=rev
Log:
Re-apply r267784, r267824 and r267830.

I have updated the compiler-rt tests.

Added:
cfe/trunk/docs/LTOVisibility.rst
cfe/trunk/test/CodeGenCXX/bitset-inference.cpp
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/SemaCXX/attr-lto-visibility-public.cpp
Removed:
cfe/trunk/runtime/vtables_blacklist.txt
cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/docs/index.rst
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/runtime/CMakeLists.txt
cfe/trunk/test/CodeGenCXX/bitsets.cpp
cfe/trunk/test/CodeGenCXX/cfi-cast.cpp
cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp
cfe/trunk/test/CodeGenCXX/cfi-ms-rtti.cpp
cfe/trunk/test/CodeGenCXX/cfi-nvcall.cpp
cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
cfe/trunk/test/Driver/cl-runtime-flags.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/whole-program-vtables.c
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=267903&r1=267902&r2=267903&view=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Thu Apr 28 12:09:37 2016
@@ -25,13 +25,25 @@ As currently implemented, all schemes re
 so it is required to specify ``-flto``, and the linker used must support LTO,
 for example via the `gold plugin`_.
 
-To allow the checks to be implemented efficiently, the program must be
-structured such that certain object files are compiled with CFI
+To allow the checks to be implemented efficiently, the program must
+be structured such that certain object files are compiled with CFI
 enabled, and are statically linked into the program. This may preclude
-the use of shared libraries in some cases. Experimental support for
-:ref:`cross-DSO control flow integrity ` exists that
-does not have these requirements. This cross-DSO support has unstable
-ABI at this time.
+the use of shared libraries in some cases.
+
+The compiler will only produce CFI checks for a class if it can infer hidden
+LTO visibility for that class. LTO visibility is a property of a class that
+is inferred from flags and attributes. For more details, see the documentation
+for :doc:`LTO visibility `.
+
+The ``-fsanitize=cfi-{vcall,nvcall,derived-cast,unrelated-cast}`` flags
+require that a ``-fvisibility=`` flag also be specified. This is because the
+default visibility setting is ``-fvisibility=default``, which would disable
+CFI checks for classes without visibility attributes. Most users will want
+to specify ``-fvisibility=hidden``, which enables CFI checks for such classes.
+
+Experimental support for :ref:`cross-DSO control flow integrity
+` exists that does not require classes to have hidden LTO
+visibility. This cross-DSO support has unstable ABI at this time.
 
 .. _gold plugin: http://llvm.org/docs/GoldPlugin.html
 
@@ -233,11 +245,6 @@ A :doc:`SanitizerSpecialCaseList` can be
 source files, functions and types using the ``src``, ``fun`` and ``type``
 entity types.
 
-In addition, if a type has a ``uuid`` attribute and the blacklist contains
-the type entry ``attr:uuid``, CFI checks are suppressed for that type. This
-allows all COM types to be easily blacklisted, which is useful as COM types
-are typically defined outside of the linked program.
-
 .. code-block:: bash
 
 # Suppress checking for code in a file.
@@ -247,8 +254,6 @@ are typically defined outside of the lin
 fun:*MyFooBar*
 # Ignore all types in the standard library.
 type:std::*
-# Ignore all types with a uuid attribute.
-type:attr:uuid
 
 .. _cfi-cross-dso:
 
@@ -260,6 +265,11 @@ flow integrity mode, which allows all CF
 apply across DSO boundaries. As in the regular CFI, each DSO must be
 built with ``-flto``.
 
+Normally, CFI checks will only be performed for classes that have hidden LTO
+visibility. With this flag enabled, the compiler will emit cross-DSO CFI
+checks for all classes, except for those which appear in the CFI blacklist
+or which use a `

Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-04-28 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Could you export a full diff please? There are too many small bits here to 
review! Thanks!



Comment at: test/SemaOpenCL/extensions.cl:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
+

Could we perhaps have two targets in this test - one that supports the 
extension and one that doesn't to test the rest of your patch?


http://reviews.llvm.org/D19484



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


Re: [PATCH] D16298: Improve test coverage of -Wdouble-promotion

2016-04-28 Thread Robert Lougher via cfe-commits
rob.lougher added a comment.

Ping.


http://reviews.llvm.org/D16298



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


Re: [PATCH] D19662: [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

2016-04-28 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 55438.
yaxunl added a comment.

Removed accidentally inserted blanks.


http://reviews.llvm.org/D19662

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenOpenCL/address-spaces-conversions.cl

Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping 
addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr 
space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))


Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Apr 28 12:21:56 2016
New Revision: 267904

URL: http://llvm.org/viewvc/llvm-project?rev=267904&view=rev
Log:
Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.
The LLVM Verifier expects all inlinable calls in debuggable functions to
have a location.

rdar://problem/25818489

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/instrument-functions.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
@@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
 /// instrumentation function with the current function and the call site, if
 /// function instrumentation is enabled.
 void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
+  auto NL = ApplyDebugLocation::CreateArtificial(*this);
   // void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site);
   llvm::PointerType *PointerTy = Int8PtrTy;
   llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };

Modified: cfe/trunk/test/CodeGen/instrument-functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff
==
--- cfe/trunk/test/CodeGen/instrument-functions.c (original)
+++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s 
-finstrument-functions | FileCheck %s
 
 // CHECK: @test1
 int test1(int x) {
-// CHECK: __cyg_profile_func_enter
-// CHECK: __cyg_profile_func_exit
+// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
+// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
 // CHECK: ret
   return x;
 }


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


Re: [PATCH] D19662: [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

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

LGTM!


http://reviews.llvm.org/D19662



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


r267906 - [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

2016-04-28 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Apr 28 12:34:57 2016
New Revision: 267906

URL: http://llvm.org/viewvc/llvm-project?rev=267906&view=rev
Log:
[OpenCL] Fix bug in mergeTypes which causes equivalent types treated as 
different.

When comparing unqualified types, canonical types should be used, otherwise 
equivalent types may be treated as different type.

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=267906&r1=267905&r2=267906&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Apr 28 12:34:57 2016
@@ -7618,7 +7618,7 @@ QualType ASTContext::mergeTypes(QualType
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))

Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl?rev=267906&r1=267905&r2=267906&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl Thu Apr 28 
12:34:57 2016
@@ -63,7 +63,16 @@ void test_ternary(void) {
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping 
addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr 
space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*


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


Re: [PATCH] D19403: Add loop pragma for Loop Distribution

2016-04-28 Thread Adam Nemet via cfe-commits
anemet updated this revision to Diff 55439.
anemet added a comment.

Added more context to the documentation per Aaron's comments.


http://reviews.llvm.org/D19403

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenCXX/pragma-loop.cpp
  test/Misc/ast-print-pragmas.cpp
  test/PCH/pragma-loop.cpp
  test/Parser/pragma-loop-safety.cpp
  test/Parser/pragma-loop.cpp

Index: test/Parser/pragma-loop.cpp
===
--- test/Parser/pragma-loop.cpp
+++ test/Parser/pragma-loop.cpp
@@ -116,25 +116,38 @@
 VList[j] = List[j];
   }
 
+#pragma clang loop distribute(enable)
+  for (int j : VList) {
+VList[j] = List[j];
+  }
+
+#pragma clang loop distribute(disable)
+  for (int j : VList) {
+VList[j] = List[j];
+  }
+
   test_nontype_template_param<4, 8>(List, Length);
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
+/* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
+/* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll_count(4
 
 /* expected-error {{missing argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop vectorize()
 /* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop interleave_count()
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, or unroll_count}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -187,6 +200,7 @@
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop vectorize(badidentifier)
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(badidentifier)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
+/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(badidentifier)
   while (i-7 < Length) {
 List[i] = i;
   }
@@ -196,6 +210,7 @@
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(()
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(*)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(=)
+/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(+)
 /* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^)
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop interleave_count(/)
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop unroll_count(==)
@@ -232,6 +247,8 @@
 #pragma clang loop interleave(disable)
 /* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(full)'}} */ #pragma clang loop unroll(full)
 #pragma clang loop unroll(disable)
+/* expected-error {{duplicate directives 'distribute(disable)' and 'distribute(enable)'}} */ #pragma clang loop distribute(enable)
+#pragma clang loop distribute(disable)
   while (i-9 < Length) {
 List[i] = i;
   }
Index: test/Parser/pragma-loop-safety.cpp
===
--- test/Parser/pragma-loop-safety.cpp
+++ test/Parser/pragma-loop-safety.cpp
@@ -16,6 +16,7 @@
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(assume_s

Re: [PATCH] D19662: [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different.

2016-04-28 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267906: [OpenCL] Fix bug in mergeTypes which causes 
equivalent types treated as… (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D19662?vs=55438&id=55440#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19662

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl

Index: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping 
addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 
addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr 
space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))


Index: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -63,7 +63,16 @@
   // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
   // CHECK: phi
   // CHECK: store
-  
+
+  typedef int int_t;
+  global int_t *var_glob_typedef;
+  var_gen = var_gen ? var_gen : var_glob_typedef; // operands of overlapping addr spaces and equivalent types
+  // CHECK: icmp
+  // CHECK-NOT: bitcast
+  // CHECK: %{{.+}} = addrspacecast i32 addrspace(1)* %{{.+}} to i32 addrspace(4)*
+  // CHECK: phi
+  // CHECK: store
+ 
   var_gen_v = var_gen ? var_gen : var_gen_f; // operands of the same addr space and different types
   // CHECK: icmp
   // CHECK: %{{.+}} = bitcast i32 addrspace(4)* %{{.+}} to i8 addrspace(4)*
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -7618,7 +7618,7 @@
   Qualifiers RQuals = RHSCan.getLocalQualifiers();
   if (LQuals != RQuals) {
 if (getLangOpts().OpenCL) {
-  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() ||
   LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())
 return QualType();
   if (LQuals.isAddressSpaceSupersetOf(RQuals))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-04-28 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

http://reviews.llvm.org/D19668 is the compiler-rt side of the patch.


http://reviews.llvm.org/D19667



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


[PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added a reviewer: sbenza.
alexfh added subscribers: cfe-commits, flx, michael_miller.

Variables with static storage duration are zero-initialized per
[stmt.dcl]p4 and [basic.start.init]p2.

http://reviews.llvm.org/D19672

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -175,17 +175,14 @@
   ComplexNonTrivialType T;
 }
 
-struct PositiveStaticMember {
+struct NegativeStaticMember {
   static NonTrivialType X;
   static NonTrivialType Y;
   static constexpr NonTrivialType Z{};
 };
 
-NonTrivialType PositiveStaticMember::X;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 'X'
-// CHECK-FIXES: NonTrivialType PositiveStaticMember::X{};
-
-NonTrivialType PositiveStaticMember::Y{};
+NonTrivialType NegativeStaticMember::X;
+NonTrivialType NegativeStaticMember::Y{};
 
 struct PositiveMultipleConstructors {
   PositiveMultipleConstructors() {}
@@ -242,9 +239,7 @@
   int F;
 };
 
-static InheritedAggregate PositiveGlobal;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 
'PositiveGlobal'
-// CHECK-FIXES: InheritedAggregate PositiveGlobal{};
+static InheritedAggregate NegativeGlobal;
 
 enum TestEnum {
   A,
@@ -280,6 +275,11 @@
 }
 }
 
+static void NegativeStaticVariable() {
+  static NegativeCStruct S;
+  (void)S;
+}
+
 union NegativeUnionInClass {
   NegativeUnionInClass() {} // No message as a union can only initialize one 
member.
   int X = 0;
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
@@ -19,10 +19,10 @@
 account but generates false positives for fields initialized in
 methods invoked in the constructor body.
 
-The check also flags variables of record types without a user-provided
-constructor that are not initialized. The suggested fix is to zero
-initialize the variable via {} for C++11 and beyond or = {} for older
-versions.
+The check also flags variables with automatic storage duration that have record
+types without a user-provided constructor and are not initialized. The 
suggested
+fix is to zero initialize the variable via ``{}`` for C++11 and beyond or ``=
+{}`` for older language versions.
 
 IgnoreArrays option
 ---
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -281,6 +281,7 @@
isDefaultConstructor(), 
unless(isUserProvided());
   Finder->addMatcher(
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),
  isTriviallyDefaultConstructible(
   .bind("var"),


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -175,17 +175,14 @@
   ComplexNonTrivialType T;
 }
 
-struct PositiveStaticMember {
+struct NegativeStaticMember {
   static NonTrivialType X;
   static NonTrivialType Y;
   static constexpr NonTrivialType Z{};
 };
 
-NonTrivialType PositiveStaticMember::X;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 'X'
-// CHECK-FIXES: NonTrivialType PositiveStaticMember::X{};
-
-NonTrivialType PositiveStaticMember::Y{};
+NonTrivialType NegativeStaticMember::X;
+NonTrivialType NegativeStaticMember::Y{};
 
 struct PositiveMultipleConstructors {
   PositiveMultipleConstructors() {}
@@ -242,9 +239,7 @@
   int F;
 };
 
-static InheritedAggregate PositiveGlobal;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: uninitialized record type: 'PositiveGlobal'
-// CHECK-FIXES: InheritedAggregate PositiveGlobal{};
+static InheritedAggregate NegativeGlobal;
 
 enum TestEnum {
   A,
@@ -280,6 +275,11 @@
 }
 }
 
+static void NegativeStaticVariable() {
+  static NegativeCStruct S;
+  (void)S;
+}
+
 union NegativeUnionInClass {
   NegativeUnionInClass() {} // No message as a union can only initialize one member.
   int X = 0;
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- docs/clang-tidy/checks

Re: [PATCH] D19403: Add loop pragma for Loop Distribution

2016-04-28 Thread Adam Nemet via cfe-commits
anemet updated this revision to Diff 55445.
anemet added a comment.

A little tweak to the example to make it clear that 'i' is the induction
variable


http://reviews.llvm.org/D19403

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenCXX/pragma-loop.cpp
  test/Misc/ast-print-pragmas.cpp
  test/PCH/pragma-loop.cpp
  test/Parser/pragma-loop-safety.cpp
  test/Parser/pragma-loop.cpp

Index: test/Parser/pragma-loop.cpp
===
--- test/Parser/pragma-loop.cpp
+++ test/Parser/pragma-loop.cpp
@@ -116,25 +116,38 @@
 VList[j] = List[j];
   }
 
+#pragma clang loop distribute(enable)
+  for (int j : VList) {
+VList[j] = List[j];
+  }
+
+#pragma clang loop distribute(disable)
+  for (int j : VList) {
+VList[j] = List[j];
+  }
+
   test_nontype_template_param<4, 8>(List, Length);
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
+/* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
+/* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll_count(4
 
 /* expected-error {{missing argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop vectorize()
 /* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop interleave_count()
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, or unroll_count}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -187,6 +200,7 @@
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop vectorize(badidentifier)
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(badidentifier)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
+/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(badidentifier)
   while (i-7 < Length) {
 List[i] = i;
   }
@@ -196,6 +210,7 @@
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(()
 /* expected-error {{invalid argument; expected 'enable', 'assume_safety' or 'disable'}} */ #pragma clang loop interleave(*)
 /* expected-error {{invalid argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll(=)
+/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute(+)
 /* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^)
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop interleave_count(/)
 /* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop unroll_count(==)
@@ -232,6 +247,8 @@
 #pragma clang loop interleave(disable)
 /* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(full)'}} */ #pragma clang loop unroll(full)
 #pragma clang loop unroll(disable)
+/* expected-error {{duplicate directives 'distribute(disable)' and 'distribute(enable)'}} */ #pragma clang loop distribute(enable)
+#pragma clang loop distribute(disable)
   while (i-9 < Length) {
 List[i] = i;
   }
Index: test/Parser/pragma-loop-safety.cpp
===
--- test/Parser/pragma-loop-safety.cpp
+++ test/Parser/pragma-loop-safety.cpp
@@ -16,6 +16,7 @@
 /* expected-error {{expected ')'}} */ #pragma clang loop

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55443.
rmaprath added a comment.

Renamed `__os_support` to `__threading_support` as suggested by @mclow.lists 
and @bcraig. I've left the namespace name `__libcpp_os_support` untouched, can 
change it to `__libcpp_threading_support` if the latter is preferred.

Thanks!

/ Asiri


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __os_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +64,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __os_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,91 +21,71 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__os_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __os_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
-if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
+int ec = __os_mutex_init(&__m_, true);
 if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __os_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __os_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +145,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__os_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +163,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __os_thread_id_compare(id, __id_) == 0))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +197,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +227,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+unique_lock lk(mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+cv.w

r267909 - Make the test exercise all paths modified in r267746.

2016-04-28 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Apr 28 12:52:28 2016
New Revision: 267909

URL: http://llvm.org/viewvc/llvm-project?rev=267909&view=rev
Log:
Make the test exercise all paths modified in r267746.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-nodebug.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-nodebug.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-nodebug.cpp?rev=267909&r1=267908&r2=267909&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-nodebug.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-nodebug.cpp Thu Apr 28 12:52:28 2016
@@ -27,12 +27,18 @@ NODEBUG S1 global_struct = { 2, 3 };
 // NOINFO-NOT:  !DIGlobalVariable(name: "global_struct"
 
 // Static data members. Const member needs a use.
+// Also the class as a whole needs a use, so that we produce debug info for
+// the entire class (iterating over the members, demonstrably skipping those
+// with 'nodebug').
 struct S2 {
   NODEBUG static int static_member;
   NODEBUG static const int static_const_member = 4;
 };
 int S2::static_member = 5;
-void func3() { func1(S2::static_const_member); }
+void func3() {
+  S2 junk;
+  func1(S2::static_const_member);
+}
 // YESINFO-DAG: !DIGlobalVariable(name: "static_member"
 // NOINFO-NOT:  !DIGlobalVariable(name: "static_member"
 // YESINFO-DAG: !DIDerivedType({{.*}} name: "static_const_member"


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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  You'll still need to wait for one of the other reviewers though 
(probably @mclow.lists )


http://reviews.llvm.org/D19412



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


Re: [PATCH] D16298: Improve test coverage of -Wdouble-promotion

2016-04-28 Thread George Burgess IV via cfe-commits
george.burgess.iv added a subscriber: george.burgess.iv.
george.burgess.iv accepted this revision.
george.burgess.iv added a reviewer: george.burgess.iv.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.

Hey -- I'm really sorry about the latency on this; I recently (within the last 
month) discovered that I don't actually receive an email for reviews sent to 
gbiv, so I had to make a filter specifically to catch things like this. As a 
result, this is the first time I'm seeing that I'm a reviewer for this. :(

Sorry again, and LGTM.


http://reviews.llvm.org/D16298



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


r267914 - Fix use of uninitialized value exposed by r267802. Accessors of an invalid

2016-04-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 28 13:26:32 2016
New Revision: 267914

URL: http://llvm.org/viewvc/llvm-project?rev=267914&view=rev
Log:
Fix use of uninitialized value exposed by r267802. Accessors of an invalid
PresumedLoc should not be called.

Modified:
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=267914&r1=267913&r2=267914&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Thu Apr 28 13:26:32 2016
@@ -373,22 +373,22 @@ public:
   /// \brief Return the presumed filename of this location.
   ///
   /// This can be affected by \#line etc.
-  const char *getFilename() const { return Filename; }
+  const char *getFilename() const { assert(isValid()); return Filename; }
 
   /// \brief Return the presumed line number of this location.
   ///
   /// This can be affected by \#line etc.
-  unsigned getLine() const { return Line; }
+  unsigned getLine() const { assert(isValid()); return Line; }
 
   /// \brief Return the presumed column number of this location.
   ///
   /// This cannot be affected by \#line, but is packaged here for convenience.
-  unsigned getColumn() const { return Col; }
+  unsigned getColumn() const { assert(isValid()); return Col; }
 
   /// \brief Return the presumed include location of this location.
   ///
   /// This can be affected by GNU linemarker directives.
-  SourceLocation getIncludeLoc() const { return IncludeLoc; }
+  SourceLocation getIncludeLoc() const { assert(isValid()); return IncludeLoc; 
}
 };
 
 

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=267914&r1=267913&r2=267914&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Apr 28 13:26:32 2016
@@ -1160,7 +1160,8 @@ unsigned SourceManager::getColumnNumber(
 
 // isInvalid - Return the result of calling loc.isInvalid(), and
 // if Invalid is not null, set its value to same.
-static bool isInvalid(SourceLocation Loc, bool *Invalid) {
+template
+static bool isInvalid(LocType Loc, bool *Invalid) {
   bool MyInvalid = Loc.isInvalid();
   if (Invalid)
 *Invalid = MyInvalid;
@@ -1183,8 +1184,9 @@ unsigned SourceManager::getExpansionColu
 
 unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc,
 bool *Invalid) const {
-  if (isInvalid(Loc, Invalid)) return 0;
-  return getPresumedLoc(Loc).getColumn();
+  PresumedLoc PLoc = getPresumedLoc(Loc);
+  if (isInvalid(PLoc, Invalid)) return 0;
+  return PLoc.getColumn();
 }
 
 #ifdef __SSE2__

Modified: cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp?rev=267914&r1=267913&r2=267914&view=diff
==
--- cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp Thu Apr 28 13:26:32 2016
@@ -167,7 +167,8 @@ void DiagnosticRenderer::emitIncludeStac
   PresumedLoc PLoc,
   DiagnosticsEngine::Level Level,
   const SourceManager &SM) {
-  SourceLocation IncludeLoc = PLoc.getIncludeLoc();
+  SourceLocation IncludeLoc =
+  PLoc.isInvalid() ? SourceLocation() : PLoc.getIncludeLoc();
 
   // Skip redundant include stacks altogether.
   if (LastIncludeLoc == IncludeLoc)

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=267914&r1=267913&r2=267914&view=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Thu Apr 28 13:26:32 2016
@@ -883,7 +883,7 @@ void TextDiagnostic::emitDiagnosticLoc(S
 void TextDiagnostic::emitIncludeLocation(SourceLocation Loc,
  PresumedLoc PLoc,
  const SourceManager &SM) {
-  if (DiagOpts->ShowLocation && PLoc.getFilename())
+  if (DiagOpts->ShowLocation && PLoc.isValid())
 OS << "In file included from " << PLoc.getFilename() << ':'
<< PLoc.getLine() << ":\n";
   else
@@ -893,7 +893,7 @@ void TextDiagnostic::emitIncludeLocation
 void TextDiagnostic::emitImportLocation(SourceLocation Loc, PresumedLoc PLoc,
   

Re: [PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

2016-04-28 Thread Tim Northover via cfe-commits
t.p.northover added a comment.

Couple of issues, as far as I can see:



Comment at: include/clang/Basic/arm_neon.td:710-711
@@ +709,4 @@
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+  def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", 
OP_VCVT_NA_HI_F16>;
+  def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", 
OP_VCVT_EX_HI_F32>;
+}

I think these _high variants are supposed to be AArch64-only.


Comment at: test/CodeGen/arm-negative-fp16.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon 
-target-feature -fp16 -fsyntax-only -verify
+

This is a Sema test.


http://reviews.llvm.org/D19665



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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-04-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Driver/Options.td:1102
@@ -1101,1 +1101,3 @@
 def Wlarge_by_value_copy_EQ : Joined<["-"], "Wlarge-by-value-copy=">, 
Flags<[CC1Option]>;
+def fubsan_strip_path_components_EQ : Joined<["-"], 
"fubsan-strip-path-components=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,

This should be spelled `-fsanitize-undefined-strip-path-components=` or similar 
to match the other `-fsanitize-...` options.


Comment at: lib/CodeGen/CGExpr.cpp:2400-2402
@@ -2371,1 +2399,5 @@
+
+// We're calling .data() to get the full string from this component 
onwards.
+// Not just the current component.
+auto FilenameGV = CGM.GetAddrOfConstantCString(FilenameString.data(), 
".src");
 CGM.getSanitizerMetadata()->disableSanitizerForGlobal(

This is a fragile way to compute the resulting string: you're relying on 
`PLoc.getFilename()` returning a nul-terminated string; this code would fail if 
`PLoc.getFilename()` started (very reasonably) returning a `StringRef`. Also, 
`*I` on a path iterator doesn't necessarily produce a `StringRef` whose 
contents are taken from the path being iterated (particularly for paths ending 
in a `/`, which can't happen here, but there seem to be no guarantees that this 
doesn't happen in other cases too).

In the forward iteration case, you can use `FilenameString.substr(I - 
path::begin(FilenameString))` to get a correct `StringRef` denoting the 
relevant piece of the path. The path reverse iterators don't have an 
`operator-` but one could presumably be added.


http://reviews.llvm.org/D19666



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-28 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 55453.
ahatanak added a comment.

Use ParseScopeFlags to clear the TemplateParamScope rather than calling 
setFlags directly.

I tried calling Init(AnyParent, F) is Scope::setFlags, but it caused a lot of 
test cases to fail, which I'm currently investigating.


http://reviews.llvm.org/D19175

Files:
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  test/SemaCXX/vartemplate-lambda.cpp

Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- /dev/null
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
+template auto fn1 = [](auto a) { return a + T(1); };
+
+template 
+int foo2() {
+  X a = 0x61;
+  fn1(a);
+  return 0;
+}
+
+int main() {
+  foo2();
+}
Index: test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
===
--- test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -195,7 +195,7 @@
 namespace default_args {
 #ifdef CPP11ONLY
 namespace lambdas {
-template //expected-error 2{{constant 
expression}} expected-note{{constant expression}}
+template //expected-error {{constant expression}}
 int f();
 }
 #endif // CPP11ONLY
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3907,9 +3907,14 @@
   PushExpressionEvaluationContext(Sema::PotentiallyEvaluated, OldVar);
 
 // Instantiate the initializer.
-ExprResult Init =
-SubstInitializer(OldVar->getInit(), TemplateArgs,
- OldVar->getInitStyle() == VarDecl::CallInit);
+ExprResult Init;
+
+{
+  ContextRAII SwitchContext(*this, Var->getDeclContext());
+  Init = SubstInitializer(OldVar->getInit(), TemplateArgs,
+  OldVar->getInitStyle() == VarDecl::CallInit);
+}
+
 if (!Init.isInvalid()) {
   bool TypeMayContainAuto = true;
   Expr *InitExpr = Init.get();
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -814,8 +814,8 @@
   // The lambda-expression's closure type might be dependent even if its
   // semantic context isn't, if it appears within a default argument of a
   // function template.
-  if (Scope *TmplScope = CurScope->getTemplateParamParent())
-if (!TmplScope->decl_empty())
+  if (auto *TmplScope = CurScope->getTemplateParamParent())
+if (TmplScope->isTemplateParamScope())
   KnownDependent = true;
 
   // Determine the signature of the call operator.
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -147,6 +147,9 @@
 }
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
+  unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
+  ParseScopeFlags TemplateScopeFlags(this, NewFlags, isSpecialization);
+
   // Parse the actual template declaration.
   return ParseSingleDeclarationAfterTemplate(Context,
  ParsedTemplateInfo(&ParamLists,


Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- /dev/null
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
+template auto fn1 = [](auto a) { return a + T(1); };
+
+template 
+int foo2() {
+  X a = 0x61;
+  fn1(a);
+  return 0;
+}
+
+int main() {
+  foo2();
+}
Index: test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
===
--- test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -195,7 +195,7 @@
 namespace default_args {
 #ifdef CPP11ONLY
 namespace lambdas {
-template //expected-error 2{{constant expression}} expected-note{{constant expression}}
+template //expected-error {{constant expression}}
 int f();
 }
 #endif // CPP11ONLY
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3907,9 +3907,14 @@
   PushExpressionEvaluationContext(Sema::PotentiallyEvaluated, OldVar);
 
 // Instantiate the initializer.
-ExprResult Init =
-SubstInitializer(OldVar->getInit(), TemplateArgs,
- OldVar-

Re: [PATCH] D18136: boost-use-to-string check

2016-04-28 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 with a couple of nits. Please submit this as a single patch, there's 
no need to add an empty "boost" module separately.



Comment at: clang-tidy/boost/UseToStringCheck.cpp:38
@@ +37,3 @@
+  argumentCountIs(1), unless(isInTemplateInstantiation()))
+  .bind("to_string"),
+  this);

clang-format?


Comment at: clang-tidy/boost/UseToStringCheck.h:19
@@ +18,3 @@
+
+/// Matches calls to boost::lexical_cast and
+/// boost::lexical_cast and replaces it with to_string and

1. Please enclose inline code snippets in backquotes.
2. s/Matches/Finds/ or Flags
3. s/and replaces it/and replaces them
4. s/to_string/std::to_string/, same for to_wstring.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

We should add a test that this still diagnoses variables with dynamic storage 
duration. Alternatively, this could be 
`unless(anyOf(hasStaticStorageDuration(), hasThreadStorageDuration()))`


http://reviews.llvm.org/D19672



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

aaron.ballman wrote:
> We should add a test that this still diagnoses variables with dynamic storage 
> duration. Alternatively, this could be 
> `unless(anyOf(hasStaticStorageDuration(), hasThreadStorageDuration()))`
I don't think it ever diagnosed on the dynamic storage duration, since it 
doesn't match `cxxNewExpr` ;)


http://reviews.llvm.org/D19672



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Michael Miller via cfe-commits
michael_miller added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

alexfh wrote:
> aaron.ballman wrote:
> > We should add a test that this still diagnoses variables with dynamic 
> > storage duration. Alternatively, this could be 
> > `unless(anyOf(hasStaticStorageDuration(), hasThreadStorageDuration()))`
> I don't think it ever diagnosed on the dynamic storage duration, since it 
> doesn't match `cxxNewExpr` ;)
Perhaps unrelated but a new expression without the parens wouldn't 
value-initialize a record type with a default constructor and potentially be a 
problematic. Maybe we should be checking cxxNewExpr.


http://reviews.llvm.org/D19672



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

michael_miller wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > We should add a test that this still diagnoses variables with dynamic 
> > > storage duration. Alternatively, this could be 
> > > `unless(anyOf(hasStaticStorageDuration(), hasThreadStorageDuration()))`
> > I don't think it ever diagnosed on the dynamic storage duration, since it 
> > doesn't match `cxxNewExpr` ;)
> Perhaps unrelated but a new expression without the parens wouldn't 
> value-initialize a record type with a default constructor and potentially be 
> a problematic. Maybe we should be checking cxxNewExpr.
Shouldn't it have diagnosed:
```
struct s {
  int *i;
  s() {}
};
```
?


http://reviews.llvm.org/D19672



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


[PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel created this revision.
hfinkel added reviewers: rsmith, chandlerc, rcox2, jmolloy, anemet, 
silviu.baranga, mzolotukhin, spatel, rengolin, delena, Carrot, congh, echristo.
hfinkel added a subscriber: cfe-commits.
Herald added subscribers: joker.eph, mcrosier.

This patch implements support for annotated-source optimization reports (a.k.a. 
"listing" files). Aside from optimizer improvements, this is a top feature 
request from my performance-engineering team. Most HPC-relevant compilers have 
some kind of capability along these lines. The DiagnosticInfo infrastructure at 
the IR level was designed specifically to support the development of this kind 
of feature, by allowing diagnostic messages to be subclass carrying arbitrary 
additional payload, although in terms of optimizer feedback, we currently only 
use this with -Rpass and friends. -Rpass and related options are very useful, 
but they can generate a lot of output, and that output lacks significant 
context, making it hard to see if the compiler is really doing what the user 
expects.

For this optimizer report, I focused on making the output as succinct as 
possible while providing information on inlining and loop transformations. The 
goal here is that the source code should still be easily readable in the 
report. My primary inspiration here is the reports generated by Cray's tools 
(http://docs.cray.com/books/S-2496-4101/html-S-2496-4101/z1112823641oswald.html).
 These reports are highly regarded within the HPC community. Intel's compiler, 
for example, also has an optimization-report capability 
(https://software.intel.com/sites/default/files/managed/55/b1/new-compiler-optimization-reports.pdf).

  $ cat /tmp/v.c
  void bar();
  void foo() { bar(); }
  
  void Test(int *res, int *c, int *d, int *p, int n) {
int i;
  
  #pragma clang loop vectorize(assume_safety)
for (i = 0; i < 1600; i++) {
  res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
}
  
for (i = 0; i < 16; i++) {
  res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
}
  
foo();
  
foo(); bar(); foo();
  }

The patch -flisting and -flisting=filename. For the first form, where the file 
name is not explicitly specified, the file name is computed automatically just 
as we do for split-debug output files.

$ clang -O3 -o /tmp/v.o -c /tmp/v.c -flisting
$ cat /tmp/v.lst
  < /tmp/v.c
   1 | void bar();
   2 | void foo() { bar(); }
   3 | 
   4 | void Test(int *res, int *c, int *d, int *p, int n) {
   5 |   int i;
   6 | 
   7 | #pragma clang loop vectorize(assume_safety)
   8   V |   for (i = 0; i < 1600; i++) {
   9 | res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
  10 |   }
  11 | 
  12 |   for (i = 0; i < 16; i++) {
  13  U  | res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
  14 |   }
  15 | 
  16 I   |   foo();
  17 | 
  18 |   foo(); bar(); foo();
 I   |   ^
 I   | ^
  19 | }
  20 | 

Each source line gets a prefix giving the line number, and a few columns for 
important optimizations: inlining, loop unrolling and loop vectorization. An 
'I' is printed next to a line where a function was inlined, a 'U' next to an 
unrolled loop, and 'V' next to a vectorized loop. These are printing on the 
relevant code line when that seems unambiguous, or on subsequent lines when 
multiple potential options exist (messages, both positive and negative, from 
the same optimization with different column numbers are taken to indicate 
potential ambiguity). When on subsequent lines, a '^' is output in the relevant 
column. The fact that the 'U' is on the wrong line is also a problem with 
-Rpass=loop-unroll and may be something we can fix in the backend.

Annotated source for all relevant input files are put into the listing file 
(each starting with '<' and then the file name).

To see what this looks like for C++ code, here's a small excerpt from 
CodeGenAction.cpp:

  340 |   // If the SMDiagnostic has an inline asm source location, 
translate it.
  341 I   |   FullSourceLoc Loc;
  342 |   if (D.getLoc() != SMLoc())
  I   |   ^
  I   |  ^
  I   | ^
  343 | Loc = ConvertBackendLocation(D, Context->getSourceManager());
  I   |   ^
  I   | ^
  344 | 
  345 |   unsigned DiagID;
  346 I   |   switch (D.getKind()) {

There's obvious bikeshedding to do here, and I'm quite open to suggestions. My 
engineering team often calls these things "listing files", and other tools 
often name this files with lst as an extension, thus the naming in the patch. 
Intel's option is -opt-report-file=filename.

After some backend enhancements (to turn the relevant remark types into proper 
subclasses), I'd like to extend this to also print the vectorization factor, 
interleaving factor and unrolling factor when relevant. After these 
enhancements, I'd l imagine the loop 

Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Douglas Yung via cfe-commits
dyung updated this revision to Diff 55457.
dyung added a comment.

Modified the test to emit llvm assembly and check for the presence of a 
DIModule in the output.


http://reviews.llvm.org/D19048

Files:
  test/Modules/Inputs/getSourceDescriptor-crash/h1.h
  test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
  test/Modules/getSourceDescriptor-crash.cpp

Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm -g 
-fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIModule
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once


Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm -g -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIModule
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread David Blaikie via cfe-commits
Should these have no/artificial location? It seems like perhaps they should
have the same location as the scope they're for? (well, the beginning or
end of that scope, respectively, etc)

On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Apr 28 12:21:56 2016
> New Revision: 267904
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267904&view=rev
> Log:
> Debug info: Apply an artificial debug location to __cyg_profile_func.*
> calls.
> The LLVM Verifier expects all inlinable calls in debuggable functions to
> have a location.
>
> rdar://problem/25818489
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/test/CodeGen/instrument-functions.c
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
> @@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
>  /// instrumentation function with the current function and the call site,
> if
>  /// function instrumentation is enabled.
>  void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
> +  auto NL = ApplyDebugLocation::CreateArtificial(*this);
>// void __cyg_profile_func_{enter,exit} (void *this_fn, void
> *call_site);
>llvm::PointerType *PointerTy = Int8PtrTy;
>llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
>
> Modified: cfe/trunk/test/CodeGen/instrument-functions.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/instrument-functions.c (original)
> +++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016
> @@ -1,9 +1,9 @@
> -// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions |
> FileCheck %s
> +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s
> -finstrument-functions | FileCheck %s
>
>  // CHECK: @test1
>  int test1(int x) {
> -// CHECK: __cyg_profile_func_enter
> -// CHECK: __cyg_profile_func_exit
> +// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
> +// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
>  // CHECK: ret
>return x;
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

2016-04-28 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.

Method Pool in modules: we make sure that if a module contains an entry for a 
selector, the entry should be complete, containing
 everything introduced by that module and all modules it imports.

Before writing out the method pool of a module, we sync up the out of date 
selectors by pulling in methods for the selectors from all modules it imports.

In ReadMethodPool, after pulling in the method pool entry for module A, this 
lets us skip the modules that module A imports.

http://reviews.llvm.org/D19679

Files:
  include/clang/Sema/ExternalSemaSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTReader.h
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/MethodPoolCombined1.h
  test/Modules/Inputs/MethodPoolCombined2.h
  test/Modules/Inputs/MethodPoolString1.h
  test/Modules/Inputs/MethodPoolString2.h
  test/Modules/Inputs/module.map
  test/Modules/method_pool_write.m

Index: test/Modules/method_pool_write.m
===
--- /dev/null
+++ test/Modules/method_pool_write.m
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -verify
+// expected-no-diagnostics
+
+@import MethodPoolCombined;
+@import MethodPoolString2;
+
+void message_kindof_object(__kindof S2 *kindof_S2) {
+  [kindof_S2 stringValue];
+}
+
Index: test/Modules/Inputs/MethodPoolString2.h
===
--- /dev/null
+++ test/Modules/Inputs/MethodPoolString2.h
@@ -0,0 +1,4 @@
+
+@interface S2
+- (int)stringValue;
+@end
Index: test/Modules/Inputs/MethodPoolString1.h
===
--- /dev/null
+++ test/Modules/Inputs/MethodPoolString1.h
@@ -0,0 +1,4 @@
+
+@interface S1
+- (int)stringValue;
+@end
Index: test/Modules/Inputs/MethodPoolCombined2.h
===
--- /dev/null
+++ test/Modules/Inputs/MethodPoolCombined2.h
@@ -0,0 +1 @@
+@import MethodPoolString2;
Index: test/Modules/Inputs/MethodPoolCombined1.h
===
--- /dev/null
+++ test/Modules/Inputs/MethodPoolCombined1.h
@@ -0,0 +1,6 @@
+
+@import MethodPoolString1;
+@interface A
+- (int)stringValue;
+@end
+
Index: test/Modules/Inputs/module.map
===
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -393,3 +393,20 @@
 header "elaborated-type-structs.h"
   }
 }
+
+// We import a module, then declare a method with selector stringValue in
+// MethodPoolCombined1.h. In MethodPoolCombined2.h, we import another module
+// that also contains a method for selector stringValue. We make sure that
+// the method pool entry for stringValue in this module is complete.
+module MethodPoolCombined {
+  header "MethodPoolCombined1.h"
+  header "MethodPoolCombined2.h"
+}
+
+module MethodPoolString1 {
+  header "MethodPoolString1.h"
+}
+
+module MethodPoolString2 {
+  header "MethodPoolString2.h"
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4387,6 +4387,13 @@
 }
   }
 
+  // For method pool in the module, if it contains an entry for a selector,
+  // the entry should be complete, containing everything introduced by that
+  // module and all modules it imports. It's possible that the entry is out of
+  // date, so we need to pull in the new content here.
+  for (auto &SelectorAndID : SelectorIDs)
+SemaRef.updateOutOfDateSelector(SelectorAndID.first);
+
   // Form the record of special types.
   RecordData SpecialTypes;
   AddTypeRef(Context.getRawCFConstantStringType(), SpecialTypes);
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3606,6 +3606,9 @@
  Id != IdEnd; ++Id)
   Id->second->setOutOfDate(true);
   }
+  // Mark selectors as out of date.
+  for (auto Sel : SelectorGeneration)
+SelectorOutOfDate[Sel.first] = true;
   
   // Resolve any unresolved module exports.
   for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
@@ -7139,6 +7142,7 @@
   unsigned &Generation = SelectorGeneration[Sel];
   unsigned PriorGeneration = Generation;
   Generation = getGeneration();
+  SelectorOutOfDate[Sel] = false;
   
   // Search for methods defined with this selector.
   ++NumMethodPoolLookups;
@@ -7170,6 +7174,11 @@
   addMethodsToPool(S, Visitor.getFactoryMethods(), 

Re: [PATCH] D19048: Test for a module related crash in CGDebugInfo.cpp

2016-04-28 Thread Douglas Yung via cfe-commits
dyung updated this revision to Diff 55460.
dyung added a comment.

Change test to not use the driver.


http://reviews.llvm.org/D19048

Files:
  test/Modules/Inputs/getSourceDescriptor-crash/h1.h
  test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
  test/Modules/getSourceDescriptor-crash.cpp

Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm 
-debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIModule2
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once


Index: test/Modules/getSourceDescriptor-crash.cpp
===
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -I %S/Inputs/getSourceDescriptor-crash -S -emit-llvm -debug-info-kind=limited -fimplicit-module-maps %s -o - | FileCheck %s
+
+#include "h1.h"
+#include "h1.h"
+
+// CHECK: DIModule2
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+   header "h1.h"
+}
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19403: Add loop pragma for Loop Distribution

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

LGTM, but you should wait in case @rsmith has feedback.


http://reviews.llvm.org/D19403



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


r267924 - [analyzer] Add path note for localizability checker.

2016-04-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Apr 28 14:44:40 2016
New Revision: 267924

URL: http://llvm.org/viewvc/llvm-project?rev=267924&view=rev
Log:
[analyzer] Add path note for localizability checker.

Add a path note indicating the location of the non-localized string
literal in NonLocalizedStringChecker.

rdar://problem/25981525

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/test/Analysis/localization.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=267924&r1=267923&r2=267924&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Thu Apr 28 
14:44:40 2016
@@ -111,6 +111,30 @@ NonLocalizedStringChecker::NonLocalizedS
"Localizability Issue (Apple)"));
 }
 
+namespace {
+class NonLocalizedStringBRVisitor final
+: public BugReporterVisitorImpl {
+
+  const MemRegion *NonLocalizedString;
+  bool Satisfied;
+
+public:
+  NonLocalizedStringBRVisitor(const MemRegion *NonLocalizedString)
+  : NonLocalizedString(NonLocalizedString), Satisfied(false) {
+assert(NonLocalizedString);
+  }
+
+  PathDiagnosticPiece *VisitNode(const ExplodedNode *Succ,
+ const ExplodedNode *Pred,
+ BugReporterContext &BRC,
+ BugReport &BR) override;
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override {
+ID.Add(NonLocalizedString);
+  }
+};
+} // End anonymous namespace.
+
 #define NEW_RECEIVER(receiver) 
\
   llvm::DenseMap &receiver##M = 
\
   UIMethods.insert({&Ctx.Idents.get(#receiver),
\
@@ -676,6 +700,11 @@ void NonLocalizedStringChecker::reportLo
 R->addRange(M.getSourceRange());
   }
   R->markInteresting(S);
+
+  const MemRegion *StringRegion = S.getAsRegion();
+  if (StringRegion)
+
R->addVisitor(llvm::make_unique(StringRegion));
+
   C.emitReport(std::move(R));
 }
 
@@ -866,6 +895,41 @@ void NonLocalizedStringChecker::checkPos
   setNonLocalizedState(sv, C);
 }
 
+PathDiagnosticPiece *
+NonLocalizedStringBRVisitor::VisitNode(const ExplodedNode *Succ,
+   const ExplodedNode *Pred,
+   BugReporterContext &BRC, BugReport &BR) 
{
+  if (Satisfied)
+return nullptr;
+
+  Optional Point = Succ->getLocation().getAs();
+  if (!Point.hasValue())
+return nullptr;
+
+  auto *LiteralExpr = dyn_cast(Point->getStmt());
+  if (!LiteralExpr)
+return nullptr;
+
+  ProgramStateRef State = Succ->getState();
+  SVal LiteralSVal = State->getSVal(LiteralExpr, Succ->getLocationContext());
+  if (LiteralSVal.getAsRegion() != NonLocalizedString)
+return nullptr;
+
+  Satisfied = true;
+
+  PathDiagnosticLocation L =
+  PathDiagnosticLocation::create(*Point, BRC.getSourceManager());
+
+  if (!L.isValid() || !L.asLocation().isValid())
+return nullptr;
+
+  auto *Piece = new PathDiagnosticEventPiece(L,
+  "Non-localized string literal here");
+  Piece->addRange(LiteralExpr->getSourceRange());
+
+  return Piece;
+}
+
 namespace {
 class EmptyLocalizationContextChecker
 : public Checker> {

Modified: cfe/trunk/test/Analysis/localization.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/localization.m?rev=267924&r1=267923&r2=267924&view=diff
==
--- cfe/trunk/test/Analysis/localization.m (original)
+++ cfe/trunk/test/Analysis/localization.m Thu Apr 28 14:44:40 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region 
-analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker 
-analyzer-checker=alpha.osx.cocoa.localizability.PluralMisuseChecker -verify  %s
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region 
-analyzer-output=text 
-analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker 
-analyzer-checker=alpha.osx.cocoa.localizability.PluralMisuseChecker -verify  %s
 
 // The larger set of tests in located in localization.m. These are tests
 // specific for non-aggressive reporting.
@@ -61,11 +61,26 @@ NSString *KHLocalizedString(NSString* ke
   UILabel *testLabel = [[UILabel alloc] init];
   NSString *bar = NSLocalizedString(@"Hello", @"Comment");
 
-  if (random()) {
-bar = @"Unlocalized string";
+  if (random()) { // expected-note {{Taking true branch}}
+bar = @"Unlocalized string"; // expected-note {{Non-localized string 
literal here}}
   }
 
-  [testLabel setText:bar]; // expected-warning {{User-facing text should use 
localized string macro}}
+  [testLabel setText:bar]; // expected-warni

Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread Adrian Prantl via cfe-commits

> On Apr 28, 2016, at 12:34 PM, David Blaikie  wrote:
> 
> Should these have no/artificial location? It seems like perhaps they should 
> have the same location as the scope they're for? (well, the beginning or end 
> of that scope, respectively, etc)

While there is usually a single source location for the beginning of the 
function, there can be more than one such location for the end of the function, 
so I don’t think this is generally possible. The artificial location 
unambiguously marks the function call as something that does not appear in 
source code. For a (terrible) example (given the nature of these function calls 
:-p) if you look at a profile you wouldn’t want these function calls to be 
misattributed to any line in the source code.

-- adrian

> 
> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Apr 28 12:21:56 2016
> New Revision: 267904
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=267904&view=rev 
> 
> Log:
> Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.
> The LLVM Verifier expects all inlinable calls in debuggable functions to
> have a location.
> 
> rdar://problem/25818489
> 
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/test/CodeGen/instrument-functions.c
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
> @@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
>  /// instrumentation function with the current function and the call site, if
>  /// function instrumentation is enabled.
>  void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
> +  auto NL = ApplyDebugLocation::CreateArtificial(*this);
>// void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site);
>llvm::PointerType *PointerTy = Int8PtrTy;
>llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
> 
> Modified: cfe/trunk/test/CodeGen/instrument-functions.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff
>  
> 
> ==
> --- cfe/trunk/test/CodeGen/instrument-functions.c (original)
> +++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016
> @@ -1,9 +1,9 @@
> -// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck 
> %s
> +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s 
> -finstrument-functions | FileCheck %s
> 
>  // CHECK: @test1
>  int test1(int x) {
> -// CHECK: __cyg_profile_func_enter
> -// CHECK: __cyg_profile_func_exit
> +// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
> +// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
>  // CHECK: ret
>return x;
>  }
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
> 

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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread John McCall via cfe-commits
rjmccall added a comment.

I see what you're going for with "listing file", but I like ICC's option name 
much better, or at least something along those lines.


http://reviews.llvm.org/D19678



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


Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-28 Thread David Blaikie via cfe-commits
On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl  wrote:

>
> On Apr 28, 2016, at 12:34 PM, David Blaikie  wrote:
>
> Should these have no/artificial location? It seems like perhaps they
> should have the same location as the scope they're for? (well, the
> beginning or end of that scope, respectively, etc)
>
>
> While there is usually a single source location for the beginning of the
> function, there can be more than one such location for the end of the
> function, so I don’t think this is generally possible.
>

Seems to me like it would be - declare a variable with a non-trivial dtor
at the start of the function. Whichever line the dtor call is attributed
to, that's the end of the function. (I think we use the } for this, or
perhaps the final return statement if there is one and only one - I forget
the specifics)


> The artificial location unambiguously marks the function call as something
> that does not appear in source code. For a (terrible) example (given the
> nature of these function calls :-p) if you look at a profile you wouldn’t
> want these function calls to be misattributed to any line in the source
> code.
>

I'm not quite sure what the ramifications of that would be/why that would
be bad (or good) - could you explain further?

- Dave


>
> -- adrian
>
>
> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Thu Apr 28 12:21:56 2016
>> New Revision: 267904
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267904&view=rev
>> Log:
>> Debug info: Apply an artificial debug location to __cyg_profile_func.*
>> calls.
>> The LLVM Verifier expects all inlinable calls in debuggable functions to
>> have a location.
>>
>> rdar://problem/25818489
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> cfe/trunk/test/CodeGen/instrument-functions.c
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
>> @@ -401,6 +401,7 @@ bool CodeGenFunction::ShouldInstrumentFu
>>  /// instrumentation function with the current function and the call
>> site, if
>>  /// function instrumentation is enabled.
>>  void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
>> +  auto NL = ApplyDebugLocation::CreateArtificial(*this);
>>// void __cyg_profile_func_{enter,exit} (void *this_fn, void
>> *call_site);
>>llvm::PointerType *PointerTy = Int8PtrTy;
>>llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
>>
>> Modified: cfe/trunk/test/CodeGen/instrument-functions.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=267904&r1=267903&r2=267904&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGen/instrument-functions.c (original)
>> +++ cfe/trunk/test/CodeGen/instrument-functions.c Thu Apr 28 12:21:56 2016
>> @@ -1,9 +1,9 @@
>> -// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions |
>> FileCheck %s
>> +// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s
>> -finstrument-functions | FileCheck %s
>>
>>  // CHECK: @test1
>>  int test1(int x) {
>> -// CHECK: __cyg_profile_func_enter
>> -// CHECK: __cyg_profile_func_exit
>> +// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
>> +// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
>>  // CHECK: ret
>>return x;
>>  }
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-28 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

The patch looks good for the most part. Nit picking I would rather have 
`__libcpp_thread_foo` instead of `__libcpp_os_support::__os_thread_foo`. IMO 
the namespace is undeeded.
@mclow.lists can you weigh in on this?



Comment at: include/__mutex_base:43
@@ -43,3 +42,3 @@
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
+constexpr mutex() _NOEXCEPT : __m_(__OS_MUTEX_INITIALIZER) {}
 #else

Similar to the reason we choose `__libcpp_mutex` these macros should have a 
`_LIBCPP` prefix as well instead of an `_OS` one.




Comment at: include/__mutex_base:285
@@ -284,3 +284,3 @@
 #else
-condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
+condition_variable() {__cv_ = (__libcpp_condvar)__OS_COND_INITIALIZER;}
 #endif

Shouldn't this be `__cond_var_type`?


http://reviews.llvm.org/D19412



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

aaron.ballman wrote:
> michael_miller wrote:
> > alexfh wrote:
> > > aaron.ballman wrote:
> > > > We should add a test that this still diagnoses variables with dynamic 
> > > > storage duration. Alternatively, this could be 
> > > > `unless(anyOf(hasStaticStorageDuration(), hasThreadStorageDuration()))`
> > > I don't think it ever diagnosed on the dynamic storage duration, since it 
> > > doesn't match `cxxNewExpr` ;)
> > Perhaps unrelated but a new expression without the parens wouldn't 
> > value-initialize a record type with a default constructor and potentially 
> > be a problematic. Maybe we should be checking cxxNewExpr.
> Shouldn't it have diagnosed:
> ```
> struct s {
>   int *i;
>   s() {}
> };
> ```
> ?
This code does not introduce an object with dynamic storage duration. Variable 
`i` is just a member variable, and the fact that it's a pointer doesn't change 
much. The check used to warn in this case and continues to do so:

  /tmp/q.cc:3:3: warning: constructor does not initialize these fields: i 
[cppcoreguidelines-pro-type-member-init]
s() {}
^
: i()

To resolve the confusion:

[basic.stc]p2
| Static, thread, and automatic storage durations are associated with objects 
introduced by declarations (3.1) and implicitly created by the implementation 
(12.2). The dynamic storage duration is associated with objects created with 
operator new (5.3.4).


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

alexfh wrote:
> aaron.ballman wrote:
> > michael_miller wrote:
> > > alexfh wrote:
> > > > aaron.ballman wrote:
> > > > > We should add a test that this still diagnoses variables with dynamic 
> > > > > storage duration. Alternatively, this could be 
> > > > > `unless(anyOf(hasStaticStorageDuration(), 
> > > > > hasThreadStorageDuration()))`
> > > > I don't think it ever diagnosed on the dynamic storage duration, since 
> > > > it doesn't match `cxxNewExpr` ;)
> > > Perhaps unrelated but a new expression without the parens wouldn't 
> > > value-initialize a record type with a default constructor and potentially 
> > > be a problematic. Maybe we should be checking cxxNewExpr.
> > Shouldn't it have diagnosed:
> > ```
> > struct s {
> >   int *i;
> >   s() {}
> > };
> > ```
> > ?
> This code does not introduce an object with dynamic storage duration. 
> Variable `i` is just a member variable, and the fact that it's a pointer 
> doesn't change much. The check used to warn in this case and continues to do 
> so:
> 
>   /tmp/q.cc:3:3: warning: constructor does not initialize these fields: i 
> [cppcoreguidelines-pro-type-member-init]
> s() {}
> ^
> : i()
> 
> To resolve the confusion:
> 
> [basic.stc]p2
> | Static, thread, and automatic storage durations are associated with objects 
> introduced by declarations (3.1) and implicitly created by the implementation 
> (12.2). The dynamic storage duration is associated with objects created with 
> operator new (5.3.4).
Michael, we should be checking `cxxNewExpr`, but I would leave this to you or 
someone else. In this patch I'm just trying to make the check less noisy.


http://reviews.llvm.org/D19672



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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-04-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

> My primary inspiration here is the reports generated by Cray's tools 
> (http://docs.cray.com/books/S-2496-4101/html-S-2496-4101/z1112823641oswald.html).


http://docs.cray.com/books/S-2315-52/html-S-2315-52/fixedds0jdeh38.html is a 
better link.


http://reviews.llvm.org/D19678



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


Re: [PATCH] D19672: [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables

2016-04-28 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
This revision is now accepted and ready to land.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:284
@@ -283,2 +283,3 @@
   varDecl(isDefinition(), HasDefaultConstructor,
+  hasAutomaticStorageDuration(),
   hasType(recordDecl(has(fieldDecl()),

alexfh wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > michael_miller wrote:
> > > > alexfh wrote:
> > > > > aaron.ballman wrote:
> > > > > > We should add a test that this still diagnoses variables with 
> > > > > > dynamic storage duration. Alternatively, this could be 
> > > > > > `unless(anyOf(hasStaticStorageDuration(), 
> > > > > > hasThreadStorageDuration()))`
> > > > > I don't think it ever diagnosed on the dynamic storage duration, 
> > > > > since it doesn't match `cxxNewExpr` ;)
> > > > Perhaps unrelated but a new expression without the parens wouldn't 
> > > > value-initialize a record type with a default constructor and 
> > > > potentially be a problematic. Maybe we should be checking cxxNewExpr.
> > > Shouldn't it have diagnosed:
> > > ```
> > > struct s {
> > >   int *i;
> > >   s() {}
> > > };
> > > ```
> > > ?
> > This code does not introduce an object with dynamic storage duration. 
> > Variable `i` is just a member variable, and the fact that it's a pointer 
> > doesn't change much. The check used to warn in this case and continues to 
> > do so:
> > 
> >   /tmp/q.cc:3:3: warning: constructor does not initialize these fields: i 
> > [cppcoreguidelines-pro-type-member-init]
> > s() {}
> > ^
> > : i()
> > 
> > To resolve the confusion:
> > 
> > [basic.stc]p2
> > | Static, thread, and automatic storage durations are associated with 
> > objects introduced by declarations (3.1) and implicitly created by the 
> > implementation (12.2). The dynamic storage duration is associated with 
> > objects created with operator new (5.3.4).
> Michael, we should be checking `cxxNewExpr`, but I would leave this to you or 
> someone else. In this patch I'm just trying to make the check less noisy.
Ah, that's a very valid point.


http://reviews.llvm.org/D19672



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


  1   2   3   >