[PATCH] D40007: [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt

2017-11-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.

Currently the -fdebug-pass-manager flag for clang doesn't enable the debug 
logging in the analysis managers. This is different than what the switch does 
when passed to opt.


https://reviews.llvm.org/D40007

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -867,10 +867,10 @@
 
   PassBuilder PB(TM.get(), PGOOpt);
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
+  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
+  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
+  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -867,10 +867,10 @@
 
   PassBuilder PB(TM.get(), PGOOpt);
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
+  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
+  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
+  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40007: [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt

2017-11-14 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM, nice catch!

Maybe update one of the new PM tests to check that this debug printing is 
available? =D


https://reviews.llvm.org/D40007



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


r318140 - [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt

2017-11-14 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Nov 14 00:48:28 2017
New Revision: 318140

URL: http://llvm.org/viewvc/llvm-project?rev=318140&view=rev
Log:
[NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis 
managers to match what we do in opt

Summary: Currently the -fdebug-pass-manager flag for clang doesn't enable the 
debug logging in the analysis managers. This is different than what the switch 
does when passed to opt.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=318140&r1=318139&r2=318140&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Nov 14 00:48:28 2017
@@ -867,10 +867,10 @@ void EmitAssemblyHelper::EmitAssemblyWit
 
   PassBuilder PB(TM.get(), PGOOpt);
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
+  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
+  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
+  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });


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


[PATCH] D40007: [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt

2017-11-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318140: [NewPassManager] Pass the -fdebug-pass-manager flag 
setting into the Analysis… (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D40007?vs=122788&id=122792#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40007

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -867,10 +867,10 @@
 
   PassBuilder PB(TM.get(), PGOOpt);
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
+  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
+  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
+  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -867,10 +867,10 @@
 
   PassBuilder PB(TM.get(), PGOOpt);
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
+  FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
+  CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);
+  ModuleAnalysisManager MAM(CodeGenOpts.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39829: add new check for property declaration

2017-11-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:89
+  assert(MatchedDecl->getName().size() > 0);
+  // Skip the check of lowerCamelCase if the name has prefix of special 
acronyms
+  if (startsWithSpecialAcronyms(MatchedDecl->getName(), SpecialAcronyms)) {

benhamilton wrote:
> For the acronyms, this means we will allow properties with names like:
> 
>   URLfoo_bar_blech
> 
> when we do not want that to be legal.
> 
> Instead, let's generate the regular expression we pass to `matchesName()` 
> from the options. I will provide a suggestion shortly.
> 
Good catch.


Repository:
  rL LLVM

https://reviews.llvm.org/D39829



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


[PATCH] D39900: Refactor ContinuationIndenter's breakProtrudingToken logic into slightly moreorthogonal pieces.

2017-11-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D39900#921885, @krasimir wrote:

> Maybe we should further refactor `getRawStringStyle` into 
> `llvm::Optional> getRawStringStyleAndDelimiter` 
> and that would nicely take care of the duplicated effort?


I thought about that, too, but I'm still convinced the right solution if we 
really care about the runtime is to cache the result in FormatToken itself.


https://reviews.llvm.org/D39900



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


r318141 - Refactor ContinuationIndenter's breakProtrudingToken logic.

2017-11-14 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Nov 14 01:19:53 2017
New Revision: 318141

URL: http://llvm.org/viewvc/llvm-project?rev=318141&view=rev
Log:
Refactor ContinuationIndenter's breakProtrudingToken logic.

Create more orthogonal pieces. The restructuring made it easy to try out
several alternatives to D33589, and while none of the alternatives
turned out to be the right solution, the underlying simplification of
the structure is helpful.

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

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/ContinuationIndenter.h
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestComments.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=318141&r1=318140&r2=318141&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Tue Nov 14 01:19:53 2017
@@ -749,6 +749,7 @@ BreakableLineCommentSection::BreakableLi
 Prefix.resize(Lines.size());
 OriginalPrefix.resize(Lines.size());
 for (size_t i = FirstLineIndex, e = Lines.size(); i < e; ++i) {
+  Lines[i] = Lines[i].ltrim(Blanks);
   // We need to trim the blanks in case this is not the first line in a
   // multiline comment. Then the indent is included in Lines[i].
   StringRef IndentPrefix =

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=318141&r1=318140&r2=318141&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Nov 14 01:19:53 2017
@@ -1008,8 +1008,8 @@ unsigned ContinuationIndenter::moveState
 
   moveStatePastFakeLParens(State, Newline);
   moveStatePastScopeCloser(State);
-  bool CanBreakProtrudingToken = !State.Stack.back().NoLineBreak &&
- !State.Stack.back().NoLineBreakInOperand;
+  bool AllowBreak = !State.Stack.back().NoLineBreak &&
+!State.Stack.back().NoLineBreakInOperand;
   moveStatePastScopeOpener(State, Newline);
   moveStatePastFakeRParens(State);
 
@@ -1023,13 +1023,9 @@ unsigned ContinuationIndenter::moveState
 
   State.Column += Current.ColumnWidth;
   State.NextToken = State.NextToken->Next;
-  unsigned Penalty = 0;
-  if (CanBreakProtrudingToken)
-Penalty = breakProtrudingToken(Current, State, DryRun);
-  if (State.Column > getColumnLimit(State)) {
-unsigned ExcessCharacters = State.Column - getColumnLimit(State);
-Penalty += Style.PenaltyExcessCharacter * ExcessCharacters;
-  }
+
+  unsigned Penalty =
+  handleEndOfLine(Current, State, DryRun, AllowBreak);
 
   if (Current.Role)
 Current.Role->formatFromToken(State, this, DryRun);
@@ -1282,8 +1278,10 @@ static unsigned getLastLineEndColumn(Str
 }
 
 unsigned ContinuationIndenter::reformatRawStringLiteral(
-const FormatToken &Current, unsigned StartColumn, LineState &State,
-StringRef Delimiter, const FormatStyle &RawStringStyle, bool DryRun) {
+const FormatToken &Current, LineState &State,
+const FormatStyle &RawStringStyle, bool DryRun) {
+  unsigned StartColumn = State.Column - Current.ColumnWidth;
+  auto Delimiter = *getRawStringDelimiter(Current.TokenText);
   // The text of a raw string is between the leading 'R"delimiter(' and the
   // trailing 'delimiter)"'.
   unsigned PrefixSize = 3 + Delimiter.size();
@@ -1353,9 +1351,6 @@ unsigned ContinuationIndenter::reformatR
 
 unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
  LineState &State) {
-  if (!Current.IsMultiline)
-return 0;
-
   // Break before further function parameters on all levels.
   for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
 State.Stack[i].BreakBeforeParameter = true;
@@ -1370,42 +1365,56 @@ unsigned ContinuationIndenter::addMultil
   return 0;
 }
 
-unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
-LineState &State,
-bool DryRun) {
+unsigned ContinuationIndenter::handleEndOfLine(const FormatToken &Current,
+   LineState &State, bool DryRun,
+   bool AllowBreak) {
+  unsigned Penalty = 0;
   // Compute the raw string style to use in case this is a raw string literal
   // that can be reformatted.
-  llvm::Optional Delimiter = None;
-  llvm::Optional RawStringStyle = None;
-  if (Current.isStringLiteral())
-Delimiter = getRawStringDelimiter(Current.TokenText);
-  if (Delimiter)
-

[PATCH] D39900: Refactor ContinuationIndenter's breakProtrudingToken logic into slightly moreorthogonal pieces.

2017-11-14 Thread Manuel Klimek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318141: Refactor ContinuationIndenter's breakProtrudingToken 
logic. (authored by klimek).

Repository:
  rL LLVM

https://reviews.llvm.org/D39900

Files:
  cfe/trunk/lib/Format/BreakableToken.cpp
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/ContinuationIndenter.h
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestComments.cpp

Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -749,6 +749,7 @@
 Prefix.resize(Lines.size());
 OriginalPrefix.resize(Lines.size());
 for (size_t i = FirstLineIndex, e = Lines.size(); i < e; ++i) {
+  Lines[i] = Lines[i].ltrim(Blanks);
   // We need to trim the blanks in case this is not the first line in a
   // multiline comment. Then the indent is included in Lines[i].
   StringRef IndentPrefix =
Index: cfe/trunk/lib/Format/ContinuationIndenter.h
===
--- cfe/trunk/lib/Format/ContinuationIndenter.h
+++ cfe/trunk/lib/Format/ContinuationIndenter.h
@@ -29,6 +29,7 @@
 namespace format {
 
 class AnnotatedLine;
+class BreakableToken;
 struct FormatToken;
 struct LineState;
 struct ParenState;
@@ -105,11 +106,20 @@
   /// 
   /// \returns An extra penalty induced by reformatting the token.
   unsigned reformatRawStringLiteral(const FormatToken &Current,
-unsigned StartColumn, LineState &State,
-StringRef Delimiter,
+LineState &State,
 const FormatStyle &RawStringStyle,
 bool DryRun);
 
+  /// \brief If the current token is at the end of the current line, handle
+  /// the transition to the next line.
+  unsigned handleEndOfLine(const FormatToken &Current, LineState &State,
+   bool DryRun, bool AllowBreak);
+
+  /// \brief If \p Current is a raw string that is configured to be reformatted,
+  /// return the style to be used.
+  llvm::Optional getRawStringStyle(const FormatToken &Current,
+const LineState &State);
+
   /// \brief If the current token sticks out over the end of the line, break
   /// it if possible.
   ///
@@ -120,7 +130,13 @@
   /// penalty for the column limit violation in the last line (and in single
   /// line tokens) is handled in \c addNextStateToQueue.
   unsigned breakProtrudingToken(const FormatToken &Current, LineState &State,
-bool DryRun);
+bool AllowBreak, bool DryRun);
+
+  /// \brief Returns the \c BreakableToken starting at \p Current, or nullptr
+  /// if the current token cannot be broken.
+  std::unique_ptr
+  createBreakableToken(const FormatToken &Current, LineState &State,
+   bool AllowBreak);
 
   /// \brief Appends the next token to \p State and updates information
   /// necessary for indentation.
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1008,8 +1008,8 @@
 
   moveStatePastFakeLParens(State, Newline);
   moveStatePastScopeCloser(State);
-  bool CanBreakProtrudingToken = !State.Stack.back().NoLineBreak &&
- !State.Stack.back().NoLineBreakInOperand;
+  bool AllowBreak = !State.Stack.back().NoLineBreak &&
+!State.Stack.back().NoLineBreakInOperand;
   moveStatePastScopeOpener(State, Newline);
   moveStatePastFakeRParens(State);
 
@@ -1023,13 +1023,9 @@
 
   State.Column += Current.ColumnWidth;
   State.NextToken = State.NextToken->Next;
-  unsigned Penalty = 0;
-  if (CanBreakProtrudingToken)
-Penalty = breakProtrudingToken(Current, State, DryRun);
-  if (State.Column > getColumnLimit(State)) {
-unsigned ExcessCharacters = State.Column - getColumnLimit(State);
-Penalty += Style.PenaltyExcessCharacter * ExcessCharacters;
-  }
+
+  unsigned Penalty =
+  handleEndOfLine(Current, State, DryRun, AllowBreak);
 
   if (Current.Role)
 Current.Role->formatFromToken(State, this, DryRun);
@@ -1282,8 +1278,10 @@
 }
 
 unsigned ContinuationIndenter::reformatRawStringLiteral(
-const FormatToken &Current, unsigned StartColumn, LineState &State,
-StringRef Delimiter, const FormatStyle &RawStringStyle, bool DryRun) {
+const FormatToken &Current, LineState &State,
+const FormatStyle &RawStringStyle, bool DryRun) {
+  unsigned StartColumn = State.Column - Current.ColumnWidth;
+  auto Delimiter = *getRawStringDelimiter(Current.TokenText);
   // The text of a raw string is between

r318142 - [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-11-14 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Tue Nov 14 01:34:39 2017
New Revision: 318142

URL: http://llvm.org/viewvc/llvm-project?rev=318142&view=rev
Log:
[libclang] Allow crash recovery with LIBCLANG_NOTHREADS

Enabled crash recovery for some libclang operations on a calling thread even
when LIBCLANG_NOTHREAD is specified.

Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not
set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its
call sites.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=318142&r1=318141&r2=318142&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Nov 14 01:34:39 2017
@@ -3508,11 +3508,6 @@ enum CXErrorCode clang_parseTranslationU
 llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU);
   };
 
-  if (getenv("LIBCLANG_NOTHREADS")) {
-ParseTranslationUnitImpl();
-return result;
-  }
-
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, ParseTranslationUnitImpl)) {
@@ -3921,8 +3916,7 @@ int clang_saveTranslationUnit(CXTranslat
 result = clang_saveTranslationUnit_Impl(TU, FileName, options);
   };
 
-  if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred() ||
-  getenv("LIBCLANG_NOTHREADS")) {
+  if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred()) {
 SaveTranslationUnitImpl();
 
 if (getenv("LIBCLANG_RESOURCE_USAGE"))
@@ -4045,11 +4039,6 @@ int clang_reparseTranslationUnit(CXTrans
 TU, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options);
   };
 
-  if (getenv("LIBCLANG_NOTHREADS")) {
-ReparseTranslationUnitImpl();
-return result;
-  }
-
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, ReparseTranslationUnitImpl)) {
@@ -8164,7 +8153,7 @@ bool RunSafely(llvm::CrashRecoveryContex
unsigned Size) {
   if (!Size)
 Size = GetSafetyThreadStackSize();
-  if (Size)
+  if (Size && !getenv("LIBCLANG_NOTHREADS"))
 return CRC.RunSafelyOnThread(Fn, Size);
   return CRC.RunSafely(Fn);
 }

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=318142&r1=318141&r2=318142&view=diff
==
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Tue Nov 14 01:34:39 2017
@@ -806,11 +806,6 @@ CXCodeCompleteResults *clang_codeComplet
 llvm::makeArrayRef(unsaved_files, num_unsaved_files), options);
   };
 
-  if (getenv("LIBCLANG_NOTHREADS")) {
-CodeCompleteAtImpl();
-return result;
-  }
-
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, CodeCompleteAtImpl)) {

Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=318142&r1=318141&r2=318142&view=diff
==
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Tue Nov 14 01:34:39 2017
@@ -880,11 +880,6 @@ int clang_indexSourceFileFullArgv(
 TU_options);
   };
 
-  if (getenv("LIBCLANG_NOTHREADS")) {
-IndexSourceFileImpl();
-return result;
-  }
-
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, IndexSourceFileImpl)) {
@@ -934,11 +929,6 @@ int clang_indexTranslationUnit(CXIndexAc
 index_options, TU);
   };
 
-  if (getenv("LIBCLANG_NOTHREADS")) {
-IndexTranslationUnitImpl();
-return result;
-  }
-
   llvm::CrashRecoveryContext CRC;
 
   if (!RunSafely(CRC, IndexTranslationUnitImpl)) {


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


[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-11-14 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv closed this revision.
erikjv added a comment.

Committed as r318142.


https://reviews.llvm.org/D37554



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-11-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D33589#920160, @Typz wrote:

> ping ?


I'm working on understanding this better :) I've refactored the code a bit so I 
could fully understand the problem, which I now do (sorry for this taking a 
while, but it took me multiple hours to work through this). I'm now convinced 
that you're right that we need the reflow/breaking logic to make the decision 
about the trade-offs, as we need the penalty for the potentially reflown code, 
as opposed to the penalty for the code if we do nothing.
Given that, my current gut feeling is that we'll want to go a bit further in 
that direction and make the change more local in breakProtrudingToken. I'll 
give that a spin and report back with what I find.


https://reviews.llvm.org/D33589



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


[PATCH] D39537: Rename identifiers named `__output`

2017-11-14 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318144: Rename identifiers named `__output` (authored by 
arichardson).

Repository:
  rL LLVM

https://reviews.llvm.org/D39537

Files:
  libcxx/trunk/include/algorithm
  libcxx/trunk/include/experimental/algorithm
  libcxx/trunk/include/experimental/iterator
  libcxx/trunk/include/regex
  libcxx/trunk/test/support/nasty_macros.hpp

Index: libcxx/trunk/include/experimental/iterator
===
--- libcxx/trunk/include/experimental/iterator
+++ libcxx/trunk/include/experimental/iterator
@@ -75,28 +75,28 @@
 typedef void reference;
 
 ostream_joiner(ostream_type& __os, _Delim&& __d)
-: __output(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
+: __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
 
 ostream_joiner(ostream_type& __os, const _Delim& __d)
-: __output(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
+: __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
 
 
 template
 ostream_joiner& operator=(const _Tp& __v)
 {
 if (!__first)
-*__output << __delim;
+*__output_iter << __delim;
 __first = false;
-*__output << __v;
+*__output_iter << __v;
 return *this;
 }
 
 ostream_joiner& operator*() _NOEXCEPT { return *this; }
 ostream_joiner& operator++()_NOEXCEPT { return *this; }
 ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
 
 private:
-ostream_type*   __output;
+ostream_type*   __output_iter;
 _Delim  __delim;
 bool__first;
 };
Index: libcxx/trunk/include/experimental/algorithm
===
--- libcxx/trunk/include/experimental/algorithm
+++ libcxx/trunk/include/experimental/algorithm
@@ -61,9 +61,9 @@
   class _UniformRandomNumberGenerator>
 inline _LIBCPP_INLINE_VISIBILITY
 _SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
-   _SampleIterator __output, _Distance __n,
+   _SampleIterator __output_iter, _Distance __n,
_UniformRandomNumberGenerator &&__g) {
-  return _VSTD::__sample(__first, __last, __output, __n, __g);
+  return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
 }
 
 _LIBCPP_END_NAMESPACE_LFTS
Index: libcxx/trunk/include/algorithm
===
--- libcxx/trunk/include/algorithm
+++ libcxx/trunk/include/algorithm
@@ -3210,48 +3210,48 @@
   class _UniformRandomNumberGenerator>
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator __output_iter,
  _Distance __n,
  _UniformRandomNumberGenerator & __g,
  input_iterator_tag) {
 
   _Distance __k = 0;
   for (; __first != __last && __k < __n; ++__first, (void)++__k)
-__output[__k] = *__first;
+__output_iter[__k] = *__first;
   _Distance __sz = __k;
   for (; __first != __last; ++__first, (void)++__k) {
 _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
 if (__r < __sz)
-  __output[__r] = *__first;
+  __output_iter[__r] = *__first;
   }
-  return __output + _VSTD::min(__n, __k);
+  return __output_iter + _VSTD::min(__n, __k);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator __output_iter,
  _Distance __n,
  _UniformRandomNumberGenerator& __g,
  forward_iterator_tag) {
   _Distance __unsampled_sz = _VSTD::distance(__first, __last);
   for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
 _Distance __r =
 _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
 if (__r < __n) {
-  *__output++ = *__first;
+  *__output_iter++ = *__first;
   --__n;
 }
   }
-  return __output;
+  return __output_iter;
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator __output_iter,
  _Distance __n, _UniformRandomNumberGenerator& __g) {
   typedef typename iterator_traits<_PopulationIterator>::iterator_category
 _PopCategory;
@@ -3263,18 +3263,18 @@

[PATCH] D39129: [OpenCL] Fix generation of constant address space sampler in function scope

2017-11-14 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In https://reviews.llvm.org/D39129#923235, @Anastasia wrote:

> In https://reviews.llvm.org/D39129#902848, @bader wrote:
>
> > @Anastasia, during the discussion of similar fix 
> > (https://reviews.llvm.org/D34342).
> >
> > I found another bug in the CodeGen library. Do you have time to fix it too?
> >  Here is the reproducer from the old review request:
> >
> >   int get_sampler_initializer(void);
> >   kernel void foo() {
> > const sampler_t const_smp_func_init = get_sampler_initializer();
> >   }
> >
>
>
> I am getting an error currently: `error: internal error: could not emit 
> constant value "abstractly"`. It seems very weird and also doesn't seem to be 
> related to constant AS change.  I think this should be allowed to compile 
> though? I can try to investigate but since I don't know the time frame yet 
> and it doesn't seem to be related to constant AS I would prefer to do it as a 
> separate change.


I'm fine with fixing this test case later, but I assume that patch posted 
https://reviews.llvm.org/D34342 covers more cases. Is this version able to 
handle samples declared as `const sampler_t const_smp`?
Are you okay if I commit https://reviews.llvm.org/D34342 instead?


https://reviews.llvm.org/D39129



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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-11-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping @joerg


https://reviews.llvm.org/D38680



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


r318147 - [ASTImporter] TypeAliasTemplate and PackExpansion importing capability

2017-11-14 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Nov 14 03:30:38 2017
New Revision: 318147

URL: http://llvm.org/viewvc/llvm-project?rev=318147&view=rev
Log:
[ASTImporter] TypeAliasTemplate and PackExpansion importing capability

Patch by: Zoltan Gera!

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=318147&r1=318146&r2=318147&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Nov 14 03:30:38 2017
@@ -77,6 +77,7 @@ namespace clang {
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType 
*T);
 QualType VisitElaboratedType(const ElaboratedType *T);
 // FIXME: DependentNameType
+QualType VisitPackExpansionType(const PackExpansionType *T);
 // FIXME: DependentTemplateSpecializationType
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 QualType VisitObjCObjectType(const ObjCObjectType *T);
@@ -149,6 +150,7 @@ namespace clang {
 Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
 Decl *VisitTypedefDecl(TypedefDecl *D);
 Decl *VisitTypeAliasDecl(TypeAliasDecl *D);
+Decl *VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
 Decl *VisitLabelDecl(LabelDecl *D);
 Decl *VisitEnumDecl(EnumDecl *D);
 Decl *VisitRecordDecl(RecordDecl *D);
@@ -265,6 +267,7 @@ namespace clang {
 Expr *VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
 Expr *VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *CE);
 Expr *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E);
+Expr *VisitPackExpansionExpr(PackExpansionExpr *E);
 Expr *VisitCXXNewExpr(CXXNewExpr *CE);
 Expr *VisitCXXDeleteExpr(CXXDeleteExpr *E);
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
@@ -767,6 +770,15 @@ QualType ASTNodeImporter::VisitElaborate
ToQualifier, ToNamedType);
 }
 
+QualType ASTNodeImporter::VisitPackExpansionType(const PackExpansionType *T) {
+  QualType Pattern = Importer.Import(T->getPattern());
+  if (Pattern.isNull())
+return QualType();
+
+  return Importer.getToContext().getPackExpansionType(Pattern,
+  T->getNumExpansions());
+}
+
 QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
   ObjCInterfaceDecl *Class
 = dyn_cast_or_null(Importer.Import(T->getDecl()));
@@ -1487,6 +1499,63 @@ Decl *ASTNodeImporter::VisitTypeAliasDec
   return VisitTypedefNameDecl(D, /*IsAlias=*/true);
 }
 
+Decl *ASTNodeImporter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
+  // Import the major distinguishing characteristics of this typedef.
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToD;
+  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+return nullptr;
+  if (ToD)
+return ToD;
+
+  // If this typedef is not in block scope, determine whether we've
+  // seen a typedef with the same name (that we can merge with) or any
+  // other entity by that name (which name lookup could conflict with).
+  if (!DC->isFunctionOrMethod()) {
+SmallVector ConflictingDecls;
+unsigned IDNS = Decl::IDNS_Ordinary;
+SmallVector FoundDecls;
+DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
+for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
+  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
+continue;
+  if (auto *FoundAlias =
+dyn_cast(FoundDecls[I]))
+  return Importer.Imported(D, FoundAlias);
+  ConflictingDecls.push_back(FoundDecls[I]);
+}
+
+if (!ConflictingDecls.empty()) {
+  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+ ConflictingDecls.data(),
+ ConflictingDecls.size());
+  if (!Name)
+return nullptr;
+}
+  }
+
+  TemplateParameterList *Params = ImportTemplateParameterList(
+D->getTemplateParameters());
+  if (!Params)
+return nullptr;
+
+  NamedDecl *TemplDecl = cast_or_null(
+Importer.Import(D->getTemplatedDecl()));
+  if (!TemplDecl)
+return nullptr;
+
+  TypeAliasTemplateDecl *ToAlias = TypeAliasTemplateDecl::Create(
+Importer.getToContext(), DC, Loc, Name, Params, TemplDecl);
+
+  ToAlias->setAccess(D->getAccess());
+  ToAlias->setLexicalDeclContext(LexicalDC);
+  Importer.Imported(D, ToAlias);
+  LexicalDC->addDeclInternal(ToAlias);
+  return ToD;
+}
+
 Decl *ASTNodeImporter::VisitLabelDecl(LabelDecl *D) {
   // Import the major distinguishing characteristics of this label.
   DeclContext *DC, *LexicalDC;
@@ -5180,6 +5249,20 @@ ASTNodeImporter::VisitMaterializeTempora
   retur

[PATCH] D40016: Use ImplicitConversionSequence::setAsIdentityConversion(QualType). NFC

2017-11-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.

Slightly reduces the amount of duplicated code.


https://reviews.llvm.org/D40016

Files:
  lib/Sema/SemaOverload.cpp


Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4752,10 +4752,7 @@
 InitializedEntity::InitializeParameter(S.Context, ToType,
/*Consumed=*/false);
   if (S.CanPerformCopyInitialization(Entity, From)) {
-Result.setStandard();
-Result.Standard.setAsIdentityConversion();
-Result.Standard.setFromType(ToType);
-Result.Standard.setAllToTypes(ToType);
+Result.setAsIdentityConversion(ToType);
 return Result;
   }
 }
@@ -4805,10 +4802,7 @@
 // For an empty list, we won't have computed any conversion sequence.
 // Introduce the identity conversion sequence.
 if (From->getNumInits() == 0) {
-  Result.setStandard();
-  Result.Standard.setAsIdentityConversion();
-  Result.Standard.setFromType(ToType);
-  Result.Standard.setAllToTypes(ToType);
+  Result.setAsIdentityConversion(ToType);
 }
 
 Result.setStdInitializerListElement(toStdInitializerList);
@@ -4946,10 +4940,7 @@
 //- if the initializer list has no elements, the implicit conversion
 //  sequence is the identity conversion.
 else if (NumInits == 0) {
-  Result.setStandard();
-  Result.Standard.setAsIdentityConversion();
-  Result.Standard.setFromType(ToType);
-  Result.Standard.setAllToTypes(ToType);
+  Result.setAsIdentityConversion(ToType);
 }
 return Result;
   }


Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -4752,10 +4752,7 @@
 InitializedEntity::InitializeParameter(S.Context, ToType,
/*Consumed=*/false);
   if (S.CanPerformCopyInitialization(Entity, From)) {
-Result.setStandard();
-Result.Standard.setAsIdentityConversion();
-Result.Standard.setFromType(ToType);
-Result.Standard.setAllToTypes(ToType);
+Result.setAsIdentityConversion(ToType);
 return Result;
   }
 }
@@ -4805,10 +4802,7 @@
 // For an empty list, we won't have computed any conversion sequence.
 // Introduce the identity conversion sequence.
 if (From->getNumInits() == 0) {
-  Result.setStandard();
-  Result.Standard.setAsIdentityConversion();
-  Result.Standard.setFromType(ToType);
-  Result.Standard.setAllToTypes(ToType);
+  Result.setAsIdentityConversion(ToType);
 }
 
 Result.setStdInitializerListElement(toStdInitializerList);
@@ -4946,10 +4940,7 @@
 //- if the initializer list has no elements, the implicit conversion
 //  sequence is the identity conversion.
 else if (NumInits == 0) {
-  Result.setStandard();
-  Result.Standard.setAsIdentityConversion();
-  Result.Standard.setFromType(ToType);
-  Result.Standard.setAllToTypes(ToType);
+  Result.setAsIdentityConversion(ToType);
 }
 return Result;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318150 - Make DiagnosticIDs::getAllDiagnostics static. NFC.

2017-11-14 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Nov 14 04:14:49 2017
New Revision: 318150

URL: http://llvm.org/viewvc/llvm-project?rev=318150&view=rev
Log:
Make DiagnosticIDs::getAllDiagnostics static. NFC.

Patch by: Andras Leitereg!

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=318150&r1=318149&r2=318150&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Tue Nov 14 04:14:49 2017
@@ -296,8 +296,8 @@ public:
  SmallVectorImpl &Diags) const;
 
   /// \brief Get the set of all diagnostic IDs.
-  void getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const;
+  static void getAllDiagnostics(diag::Flavor Flavor,
+SmallVectorImpl &Diags);
 
   /// \brief Get the diagnostic option with the closest edit distance to the
   /// given group name.

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=318150&r1=318149&r2=318150&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Tue Nov 14 04:14:49 2017
@@ -364,7 +364,7 @@ void DiagnosticsEngine::setSeverityForAl
   SourceLocation Loc) {
   // Get all the diagnostics.
   SmallVector AllDiags;
-  Diags->getAllDiagnostics(Flavor, AllDiags);
+  DiagnosticIDs::getAllDiagnostics(Flavor, AllDiags);
 
   // Set the mapping.
   for (diag::kind Diag : AllDiags)

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=318150&r1=318149&r2=318150&view=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Tue Nov 14 04:14:49 2017
@@ -583,7 +583,7 @@ DiagnosticIDs::getDiagnosticsInGroup(dia
 }
 
 void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const 
{
+  SmallVectorImpl &Diags) {
   for (unsigned i = 0; i != StaticDiagInfoSize; ++i)
 if (StaticDiagInfo[i].getFlavor() == Flavor)
   Diags.push_back(StaticDiagInfo[i].DiagID);


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


[PATCH] D39372: Make DiagnosticIDs::getAllDiagnostics static.

2017-11-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318150: Make DiagnosticIDs::getAllDiagnostics static. NFC. 
(authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D39372?vs=121104&id=122822#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39372

Files:
  cfe/trunk/include/clang/Basic/DiagnosticIDs.h
  cfe/trunk/lib/Basic/Diagnostic.cpp
  cfe/trunk/lib/Basic/DiagnosticIDs.cpp


Index: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
===
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h
@@ -296,8 +296,8 @@
  SmallVectorImpl &Diags) const;
 
   /// \brief Get the set of all diagnostic IDs.
-  void getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const;
+  static void getAllDiagnostics(diag::Flavor Flavor,
+SmallVectorImpl &Diags);
 
   /// \brief Get the diagnostic option with the closest edit distance to the
   /// given group name.
Index: cfe/trunk/lib/Basic/Diagnostic.cpp
===
--- cfe/trunk/lib/Basic/Diagnostic.cpp
+++ cfe/trunk/lib/Basic/Diagnostic.cpp
@@ -364,7 +364,7 @@
   SourceLocation Loc) {
   // Get all the diagnostics.
   SmallVector AllDiags;
-  Diags->getAllDiagnostics(Flavor, AllDiags);
+  DiagnosticIDs::getAllDiagnostics(Flavor, AllDiags);
 
   // Set the mapping.
   for (diag::kind Diag : AllDiags)
Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
===
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp
@@ -583,7 +583,7 @@
 }
 
 void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const 
{
+  SmallVectorImpl &Diags) {
   for (unsigned i = 0; i != StaticDiagInfoSize; ++i)
 if (StaticDiagInfo[i].getFlavor() == Flavor)
   Diags.push_back(StaticDiagInfo[i].DiagID);


Index: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
===
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h
@@ -296,8 +296,8 @@
  SmallVectorImpl &Diags) const;
 
   /// \brief Get the set of all diagnostic IDs.
-  void getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const;
+  static void getAllDiagnostics(diag::Flavor Flavor,
+SmallVectorImpl &Diags);
 
   /// \brief Get the diagnostic option with the closest edit distance to the
   /// given group name.
Index: cfe/trunk/lib/Basic/Diagnostic.cpp
===
--- cfe/trunk/lib/Basic/Diagnostic.cpp
+++ cfe/trunk/lib/Basic/Diagnostic.cpp
@@ -364,7 +364,7 @@
   SourceLocation Loc) {
   // Get all the diagnostics.
   SmallVector AllDiags;
-  Diags->getAllDiagnostics(Flavor, AllDiags);
+  DiagnosticIDs::getAllDiagnostics(Flavor, AllDiags);
 
   // Set the mapping.
   for (diag::kind Diag : AllDiags)
Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
===
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp
@@ -583,7 +583,7 @@
 }
 
 void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
- SmallVectorImpl &Diags) const {
+  SmallVectorImpl &Diags) {
   for (unsigned i = 0; i != StaticDiagInfoSize; ++i)
 if (StaticDiagInfo[i].getFlavor() == Flavor)
   Diags.push_back(StaticDiagInfo[i].DiagID);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39049: [analyzer] Fix wrong calculation of offset in ArrayBoundsV2

2017-11-14 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D39049#910482, @NoQ wrote:

>   // TODO: once the constraint manager is smart enough to handle non 
> simplified
>   // symbolic expressions remove this function. Note that this can not be 
> used in
>   // the constraint manager as is, since this does not handle overflows. It is
>   // safe to assume, however, that memory offsets will not overflow.
>
>
> Wasn't safe enough, i guess.


I agree, we should remove/alter this part of the comment since it is not true.

@danielmarjamaki 
Could you do a similar analysis that I did above to check why does this not 
work for the multidimensional case? (I.e.: checking what constraints are 
generated and what the analyzer does with them.)


Repository:
  rL LLVM

https://reviews.llvm.org/D39049



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-11-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Ping.

In https://reviews.llvm.org/D36836#889375, @aaron.ballman wrote:

> Adding @dberlin for licensing discussion questions.


@dberlin ping? I'm wondering if you had the chance to look at this? :)


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[libcxx] r318144 - Rename identifiers named `__output`

2017-11-14 Thread Alexander Richardson via cfe-commits
Author: arichardson
Date: Tue Nov 14 03:14:25 2017
New Revision: 318144

URL: http://llvm.org/viewvc/llvm-project?rev=318144&view=rev
Log:
Rename identifiers named `__output`

Summary:
In the CHERI clang compiler __output and __input are keywords and therefore
we can't compile libc++ with our compiler.

Reviewers: mclow.lists, EricWF, theraven

Reviewed By: EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/experimental/algorithm
libcxx/trunk/include/experimental/iterator
libcxx/trunk/include/regex
libcxx/trunk/test/support/nasty_macros.hpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=318144&r1=318143&r2=318144&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Nov 14 03:14:25 2017
@@ -3210,28 +3210,28 @@ template 
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator 
__output_iter,
  _Distance __n,
  _UniformRandomNumberGenerator & __g,
  input_iterator_tag) {
 
   _Distance __k = 0;
   for (; __first != __last && __k < __n; ++__first, (void)++__k)
-__output[__k] = *__first;
+__output_iter[__k] = *__first;
   _Distance __sz = __k;
   for (; __first != __last; ++__first, (void)++__k) {
 _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
 if (__r < __sz)
-  __output[__r] = *__first;
+  __output_iter[__r] = *__first;
   }
-  return __output + _VSTD::min(__n, __k);
+  return __output_iter + _VSTD::min(__n, __k);
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator 
__output_iter,
  _Distance __n,
  _UniformRandomNumberGenerator& __g,
  forward_iterator_tag) {
@@ -3240,18 +3240,18 @@ _SampleIterator __sample(_PopulationIter
 _Distance __r =
 _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
 if (__r < __n) {
-  *__output++ = *__first;
+  *__output_iter++ = *__first;
   --__n;
 }
   }
-  return __output;
+  return __output_iter;
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 _SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output,
+ _PopulationIterator __last, _SampleIterator 
__output_iter,
  _Distance __n, _UniformRandomNumberGenerator& __g) {
   typedef typename iterator_traits<_PopulationIterator>::iterator_category
 _PopCategory;
@@ -3263,7 +3263,7 @@ _SampleIterator __sample(_PopulationIter
   typedef typename common_type<_Distance, _Difference>::type _CommonType;
   _LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
   return _VSTD::__sample(
-  __first, __last, __output, _CommonType(__n),
+  __first, __last, __output_iter, _CommonType(__n),
   __g, _PopCategory());
 }
 
@@ -3272,9 +3272,9 @@ template 
 inline _LIBCPP_INLINE_VISIBILITY
 _SampleIterator sample(_PopulationIterator __first,
-   _PopulationIterator __last, _SampleIterator __output,
+   _PopulationIterator __last, _SampleIterator 
__output_iter,
_Distance __n, _UniformRandomNumberGenerator&& __g) {
-return _VSTD::__sample(__first, __last, __output, __n, __g);
+return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
 }
 #endif // _LIBCPP_STD_VER > 14
 

Modified: libcxx/trunk/include/experimental/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/algorithm?rev=318144&r1=318143&r2=318144&view=diff
==
--- libcxx/trunk/include/experimental/algorithm (original)
+++ libcxx/trunk/include/experimental/algorithm Tue Nov 14 03:14:25 2017
@@ -61,9 +61,9 @@ template 
 inline _LIBCPP_INLINE_VISIBILITY
 _SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
-   _SampleIterator __output, _Distance __n,
+   _SampleIterator __output_iter, _Distance __n,
_UniformRandomNumberGenerator &&__g) {
-  return _VSTD::__sample(__first, __last, __output, __n, __g);
+  return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
 }
 
 _LIBCPP_END_NAMESPACE_LFTS

Modified: libcxx/trunk/include/experimental/iterator
URL: 
http://

Clang-format: add finer-grained options for putting all arguments on one line.

2017-11-14 Thread Russell McClellan via cfe-commits
Attached is a patch that adds two new options,
AllowAllArgumentsOnNextLine and
AllowAllConstructorInitializersOnNextLine.  These mirror the existing
AllowAllParametersOfDeclarationOnNextLine and allow me to support an
internal style guide where I work.  I think this would be generally
useful, some have asked for it on stackoverflow:

https://stackoverflow.com/questions/30057534/clang-format-binpackarguments-not-working-as-expected

https://stackoverflow.com/questions/38635106/clang-format-how-to-prevent-all-function-arguments-on-next-line

Thanks for your consideration, and let me know if there's anything I
can do to improve the patch; I'm a first-time contributor.

Thanks,
-Russell


format-allownextline.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb created this revision.
Herald added subscribers: jordy.potman.lists, rbar, arichardson.

RISCVABIInfo is implemented in terms of XLen, supporting both RV32 and RV64. 
Unfortunately we need to count argument registers in the frontend in order to 
determine when to emit signext and zeroext attributes. Integer scalars are 
extended according to their type up to 32-bits and then sign-extended to XLen 
when passed in registers, but are anyext when passed on the stack. This patch 
only implements the base integer (soft float) ABIs.

For more information on the RISC-V ABI, see the ABI doc 
, my 
golden model , and the 
LLVM RISC-V calling convention patch  
(specifically the comment documenting frontend expectations).

It was necessary to modify CodeGenModule::ConstructAttributeList to ensure that 
signext is emitted for int32_t/uint32_t return values. Mips is the only other 
implementer of shouldSignExtUnsignedType but is unaffected, as unlike 
classifyArgumentType, classifyReturnType will not extend i32 values (@sdardis: 
is this a bug?).

@chandlerc, if you could help nominate appropriate reviewers I would appreciate 
it. I've CCed in those who are doing work on/with RISC-V LLVM and are well 
placed to review whether the RISC-V ABI and calling convention is implemented 
faithfully.


https://reviews.llvm.org/D40023

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/riscv32-abi.c
  test/CodeGen/riscv64-abi.c
  test/Driver/riscv32-toolchain.c
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 8
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: define zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define signext i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define signext i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i64 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define signext i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i64 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i64 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/Driver/riscv32-toolchain.c
===
--- test/Driver/riscv32-toolchain.c
+++ test/Driver/riscv32-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 4
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i32 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i32 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i32 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/CodeGen/riscv64-abi.c
===
--- /dev/null
+++ test/CodeGen/riscv64-abi.c
@@ -0,0 +1,372 @@
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL:

[PATCH] D40024: Fix skipping of flags in getClangStripDependencyFileAdjuster

2017-11-14 Thread Dave Lee via Phabricator via cfe-commits
kastiglione created this revision.

The ArgumentsAdjuster returned from `getClangStripDependencyFileAdjuster` will
skip dependency flags, and also their associated values for those flags that
take an argument. This change corrects the handling of the `-MD` and `-MMD`
flags, which do not take an argument.


https://reviews.llvm.org/D40024

Files:
  lib/Tooling/ArgumentsAdjusters.cpp


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -61,11 +61,9 @@
   if (!Arg.startswith("-M"))
 AdjustedArgs.push_back(Args[i]);
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -61,11 +61,9 @@
   if (!Arg.startswith("-M"))
 AdjustedArgs.push_back(Args[i]);
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40024: Fix skipping of flags in getClangStripDependencyFileAdjuster

2017-11-14 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 122829.
kastiglione added a comment.

Add a continue;


https://reviews.llvm.org/D40024

Files:
  lib/Tooling/ArgumentsAdjusters.cpp


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -58,14 +58,14 @@
   StringRef Arg = Args[i];
   // All dependency-file options begin with -M. These include -MM,
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M"))
+  if (!Arg.startswith("-M")) {
 AdjustedArgs.push_back(Args[i]);
+continue;
+  }
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };


Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -58,14 +58,14 @@
   StringRef Arg = Args[i];
   // All dependency-file options begin with -M. These include -MM,
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M"))
+  if (!Arg.startswith("-M")) {
 AdjustedArgs.push_back(Args[i]);
+continue;
+  }
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39948: Make isDefinition matcher support ObjCMethodDecl

2017-11-14 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 122830.
kastiglione added a comment.

Update isDefinition comment docs to reflect addition of ObjCMethodDecl


https://reviews.llvm.org/D39948

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

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1315,6 +1315,14 @@
 cxxMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
   EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
+
+  DeclarationMatcher DefinitionOfObjCMethodA =
+objcMethodDecl(hasName("a"), isDefinition());
+  EXPECT_TRUE(matchesObjC("@interface A @end "
+  "@implementation A; -(void)a {} @end",
+  DefinitionOfObjCMethodA));
+  EXPECT_TRUE(notMatchesObjC("@interface A; - (void)a; @end",
+ DefinitionOfObjCMethodA));
 }
 
 TEST(Matcher, HandlesNullQualTypes) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4201,11 +4201,19 @@
 ///   extern int vb;  // Doesn't match, as it doesn't define the variable.
 ///   void fa() {}
 ///   void fb();  // Doesn't match, as it has no body.
+///   @interface X
+///   - (void)ma; // Doesn't match, interface is declaration.
+///   @end
+///   @implementation X
+///   - (void)ma {}
+///   @end
 /// \endcode
 ///
-/// Usable as: Matcher, Matcher, Matcher
+/// Usable as: Matcher, Matcher, Matcher,
+///   Matcher
 AST_POLYMORPHIC_MATCHER(isDefinition,
 AST_POLYMORPHIC_SUPPORTED_TYPES(TagDecl, VarDecl,
+ObjCMethodDecl,
 FunctionDecl)) {
   return Node.isThisDeclarationADefinition();
 }
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2746,16 +2746,22 @@
 
 
 
-MatcherFunctionDecl>isDefinition
-Matches if a declaration has a body attached.
+MatcherFunctionDecl>isDefinition
+Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
   class B;  Doesn't match, as it has no body.
   int va;
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
 Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
 
@@ -3154,6 +3160,27 @@
 
 
 
+MatcherObjCMethodDecl>isDefinition
+Matches if a declaration has a body attached.
+
+Example matches A, va, fa
+  class A {};
+  class B;  Doesn't match, as it has no body.
+  int va;
+  extern int vb;  Doesn't match, as it doesn't define the variable.
+  void fa() {}
+  void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
+
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched type is represented by the given string.
 
@@ -3433,6 +3460,12 @@
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
 Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
 
@@ -3696,6 +3729,12 @@
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma

[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: lib/Driver/ToolChains/RISCV.cpp:86
+CmdArgs.push_back("-lc");
+CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");

apazos wrote:
> mgrang wrote:
> > How about if our sysroot is linux (as opposed to elf)? There won't be any 
> > libgloss.a, right? Also there won't be a crt0.o (instead there will be 
> > crt1.o).
> Supporting linux target is desirable early on because most of us will be 
> using Qemu for running tests.
Linux targets are not currently supported, as they require the ilp32d or lp64d 
(hard double precision) ABI. The only fiddly part is actually in the Clang 
frontend, handling structs composed of two reals or one integer + one real. 
This is obviously high up on the todo list.


https://reviews.llvm.org/D39963



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


[PATCH] D39948: Make isDefinition matcher support ObjCMethodDecl

2017-11-14 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 122831.
kastiglione added a comment.

Regenerate AST Matcher docs


https://reviews.llvm.org/D39948

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

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1315,6 +1315,14 @@
 cxxMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
   EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
+
+  DeclarationMatcher DefinitionOfObjCMethodA =
+objcMethodDecl(hasName("a"), isDefinition());
+  EXPECT_TRUE(matchesObjC("@interface A @end "
+  "@implementation A; -(void)a {} @end",
+  DefinitionOfObjCMethodA));
+  EXPECT_TRUE(notMatchesObjC("@interface A; - (void)a; @end",
+ DefinitionOfObjCMethodA));
 }
 
 TEST(Matcher, HandlesNullQualTypes) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4201,11 +4201,19 @@
 ///   extern int vb;  // Doesn't match, as it doesn't define the variable.
 ///   void fa() {}
 ///   void fb();  // Doesn't match, as it has no body.
+///   @interface X
+///   - (void)ma; // Doesn't match, interface is declaration.
+///   @end
+///   @implementation X
+///   - (void)ma {}
+///   @end
 /// \endcode
 ///
-/// Usable as: Matcher, Matcher, Matcher
+/// Usable as: Matcher, Matcher, Matcher,
+///   Matcher
 AST_POLYMORPHIC_MATCHER(isDefinition,
 AST_POLYMORPHIC_SUPPORTED_TYPES(TagDecl, VarDecl,
+ObjCMethodDecl,
 FunctionDecl)) {
   return Node.isThisDeclarationADefinition();
 }
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2746,18 +2746,25 @@
 
 
 
-MatcherFunctionDecl>isDefinition
-Matches if a declaration has a body attached.
+MatcherFunctionDecl>isDefinition
+Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
   class B;  Doesn't match, as it has no body.
   int va;
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
 
 
 
@@ -3154,6 +3161,28 @@
 
 
 
+MatcherObjCMethodDecl>isDefinition
+Matches if a declaration has a body attached.
+
+Example matches A, va, fa
+  class A {};
+  class B;  Doesn't match, as it has no body.
+  int va;
+  extern int vb;  Doesn't match, as it doesn't define the variable.
+  void fa() {}
+  void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
+
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched type is represented by the given string.
 
@@ -3433,8 +3462,15 @@
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: Matcher

r318152 - Make isDefinition matcher support ObjCMethodDecl

2017-11-14 Thread Dave Lee via cfe-commits
Author: kastiglione
Date: Tue Nov 14 06:17:26 2017
New Revision: 318152

URL: http://llvm.org/viewvc/llvm-project?rev=318152&view=rev
Log:
Make isDefinition matcher support ObjCMethodDecl

Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=318152&r1=318151&r2=318152&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Nov 14 06:17:26 2017
@@ -2746,8 +2746,8 @@ functionDecl(isDefaulted())
 
 
 
-MatcherFunctionDecl>isDefinition
-Matches if a 
declaration has a body attached.
+MatcherFunctionDecl>isDefinition
+Matches if a 
declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
@@ -2756,8 +2756,15 @@ Example matches A, va, fa
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 MatcherFunctionDecl>
+Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
 
 
 
@@ -3154,6 +3161,28 @@ a substring matched by the given RegExp.
 
 
 
+MatcherObjCMethodDecl>isDefinition
+Matches if a 
declaration has a body attached.
+
+Example matches A, va, fa
+  class A {};
+  class B;  Doesn't match, as it has no body.
+  int va;
+  extern int vb;  Doesn't match, as it doesn't define the variable.
+  void fa() {}
+  void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
+
+Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 
@@ -3433,8 +3462,15 @@ Example matches A, va, fa
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 MatcherFunctionDecl>
+Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
 
 
 
@@ -3696,8 +3732,15 @@ Example matches A, va, fa
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>,
 MatcherVarDecl>,
 Matche

[PATCH] D39948: Make isDefinition matcher support ObjCMethodDecl

2017-11-14 Thread Dave Lee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318152: Make isDefinition matcher support ObjCMethodDecl 
(authored by kastiglione).

Repository:
  rL LLVM

https://reviews.llvm.org/D39948

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1315,6 +1315,14 @@
 cxxMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
   EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
+
+  DeclarationMatcher DefinitionOfObjCMethodA =
+objcMethodDecl(hasName("a"), isDefinition());
+  EXPECT_TRUE(matchesObjC("@interface A @end "
+  "@implementation A; -(void)a {} @end",
+  DefinitionOfObjCMethodA));
+  EXPECT_TRUE(notMatchesObjC("@interface A; - (void)a; @end",
+ DefinitionOfObjCMethodA));
 }
 
 TEST(Matcher, HandlesNullQualTypes) {
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -2746,18 +2746,25 @@
 
 
 
-MatcherFunctionDecl>isDefinition
-Matches if a declaration has a body attached.
+MatcherFunctionDecl>isDefinition
+Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
   class B;  Doesn't match, as it has no body.
   int va;
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
 
 
 
@@ -3154,6 +3161,28 @@
 
 
 
+MatcherObjCMethodDecl>isDefinition
+Matches if a declaration has a body attached.
+
+Example matches A, va, fa
+  class A {};
+  class B;  Doesn't match, as it has no body.
+  int va;
+  extern int vb;  Doesn't match, as it doesn't define the variable.
+  void fa() {}
+  void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
+
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched type is represented by the given string.
 
@@ -3433,8 +3462,15 @@
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is declaration.
+  @end
+  @implementation X
+  - (void)ma {}
+  @end
 
-Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>
+Usable as: MatcherTagDecl>, MatcherVarDecl>, MatcherFunctionDecl>,
+  MatcherObjCMethodDecl>
 
 
 
@@ -3696,8 +3732,15 @@
   extern int vb;  Doesn't match, as it doesn't define the variable.
   void fa() {}
   void fb();  Doesn't match, as it has no body.
+  @interface X
+  - (void)ma; Doesn't match, interface is

[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

rjmccall wrote:
> Hahnfeld wrote:
> > rjmccall wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > Hahnfeld wrote:
> > > > > > rjmccall wrote:
> > > > > > > Hahnfeld wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > The way you've written this makes it sound like "does the 
> > > > > > > > > > > target support VLAs?", but the actual semantic checks 
> > > > > > > > > > > treat it as "do OpenMP devices on this target support 
> > > > > > > > > > > VLAs?"  Maybe there should be a more specific way to 
> > > > > > > > > > > query things about OpenMP devices instead of setting a 
> > > > > > > > > > > global flag for the target?
> > > > > > > > > > Actually, the NVPTX and SPIR targets never support VLAs. So 
> > > > > > > > > > I felt like it would be more correct to make this a global 
> > > > > > > > > > property of the target.
> > > > > > > > > > 
> > > > > > > > > > The difference is that the other programming models (OpenCL 
> > > > > > > > > > and CUDA) error out immediatelyand regardless of the target 
> > > > > > > > > > because this limitation is reflected in the standards that 
> > > > > > > > > > disallow VLAs (see SemaType.cpp). For OpenMP we might have 
> > > > > > > > > > target devices that support VLA so we shouldn't error out 
> > > > > > > > > > for those.
> > > > > > > > > If you want to make it a global property of the target, 
> > > > > > > > > that's fine, but then I don't understand why your diagnostic 
> > > > > > > > > only fires when (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > That is because of how OpenMP offloading works and how it is 
> > > > > > > > implemented in Clang. Consider the following snippet from the 
> > > > > > > > added test case:
> > > > > > > > ```lang=c
> > > > > > > > int vla[arg];
> > > > > > > > 
> > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > {
> > > > > > > >// more code here...
> > > > > > > > }
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > Clang will take the following steps to compile this into a 
> > > > > > > > working binary for a GPU:
> > > > > > > > 1. Parse and (semantically) analyze the code as-is for the host 
> > > > > > > > and produce LLVM Bitcode.
> > > > > > > > 2. Parse and analyze again the code as-is and generate code for 
> > > > > > > > the offloading target, the GPU in this case.
> > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary and embed 
> > > > > > > > target binary from 3.
> > > > > > > > 
> > > > > > > > `OpenMPIsDevice` will be true for 2., but the complete source 
> > > > > > > > code is analyzed. So to not throw errors for the host code, we 
> > > > > > > > have to make sure that we are actually generating code for the 
> > > > > > > > target device. This is either in a `target` directive or in a 
> > > > > > > > `declare target` region.
> > > > > > > > Note that this is quite similar to what CUDA does, only they 
> > > > > > > > have `CUDADiagIfDeviceCode` for this logic. If you want me to 
> > > > > > > > add something of that kind for OpenMP target devices, I'm fine 
> > > > > > > > with that. However for the given case, it's a bit different 
> > > > > > > > because this error should only be thrown for target devices 
> > > > > > > > that don't support VLAs...
> > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > re-Sema'ed from scratch for the target?  Which means you need to 
> > > > > > > avoid generating errors about things in the outer translation 
> > > > > > > unit that aren't part of the target directive that you actually 
> > > > > > > want to compile.  I would've expected there to be some existing 
> > > > > > > mechanism for that, to be honest, as opposed to explicitly trying 
> > > > > > > to suppress target-specific diagnostics one by one.
> > > > > > Yes, that is my understanding. For errors, we don't need to take 
> > > > > > anything special as the first `cc1` invocation will exit with a 
> > > > > > non-zero status so that the driver stops the compilation. For 
> > > > > > warnings, there seems to be no mechanism in place as I see them 
> > > > > > duplicated, even in code that is not generate for the target device 
> > > > > > (verified with an unused variable).
> > > > > > 
> > > > > > @ABataev @gtbercea Do I miss something here?
> > > > > I'm not aware of any.
> > > > John, target-specific checks require some special flags (like 
> > > > LangOpts.Cuda) that are not set when we re-compile the code for OpenMP 
> > > > devices. That's why errors are not emitted for the non-target code. But 
> > > > also because of that, we need some special Ope

[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 122838.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Fixed comments.
- Removed /*ref*/ annotations.
- Removed unused "Storage" variable.
- Extract a helper function that properly sets up VFS to access the PCHStorage.


https://reviews.llvm.org/D39842

Files:
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PrecompiledPreamble.cpp

Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,12 +28,41 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 
+#include 
+
 using namespace clang;
 
 namespace {
 
+StringRef getInMemoryPreamblePath() {
+  // Note that the lambda is called inline to initialize the variable.
+  static auto PreambleName = []() {
+SmallString<64> Path;
+llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/true, Path);
+llvm::sys::path::append(Path, "___clang_inmemory_preamble___");
+return Path;
+  }();
+  return PreambleName;
+}
+
+IntrusiveRefCntPtr
+createVFSOverlayForPreamblePCH(StringRef PCHFilename,
+   std::unique_ptr PCHBuffer,
+   IntrusiveRefCntPtr VFS) {
+  // We want only the PCH file from the real filesystem to be available,
+  // so we create an in-memory VFS with just that and overlay it on top.
+  IntrusiveRefCntPtr PCHFS(
+  new vfs::InMemoryFileSystem());
+  PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer));
+  IntrusiveRefCntPtr Overlay(
+  new vfs::OverlayFileSystem(VFS));
+  Overlay->pushOverlay(PCHFS);
+  return Overlay;
+}
+
 /// Keeps a track of files to be deleted in destructor.
 class TemporaryFiles {
 public:
@@ -101,8 +130,9 @@
 
 class PrecompilePreambleAction : public ASTFrontendAction {
 public:
-  PrecompilePreambleAction(PreambleCallbacks &Callbacks)
-  : Callbacks(Callbacks) {}
+  PrecompilePreambleAction(std::string *InMemStorage,
+   PreambleCallbacks &Callbacks)
+  : InMemStorage(InMemStorage), Callbacks(Callbacks) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;
@@ -123,6 +153,7 @@
   friend class PrecompilePreambleConsumer;
 
   bool HasEmittedPreamblePCH = false;
+  std::string *InMemStorage;
   PreambleCallbacks &Callbacks;
 };
 
@@ -164,13 +195,18 @@
 
 std::unique_ptr
 PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
-
 StringRef InFile) {
   std::string Sysroot;
-  std::string OutputFile;
-  std::unique_ptr OS =
-  GeneratePCHAction::ComputeASTConsumerArguments(CI, InFile, Sysroot,
- OutputFile);
+  if (!GeneratePCHAction::ComputeASTConsumerArguments(CI, Sysroot))
+return nullptr;
+
+  std::unique_ptr OS;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);
+  } else {
+std::string OutputFile;
+OS = GeneratePCHAction::CreateOutputFile(CI, InFile, OutputFile);
+  }
   if (!OS)
 return nullptr;
 
@@ -202,7 +238,7 @@
 const CompilerInvocation &Invocation,
 const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
 DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr VFS,
-std::shared_ptr PCHContainerOps,
+std::shared_ptr PCHContainerOps, bool StoreInMemory,
 PreambleCallbacks &Callbacks) {
   assert(VFS && "VFS is null");
 
@@ -214,12 +250,19 @@
   PreprocessorOptions &PreprocessorOpts =
   PreambleInvocation->getPreprocessorOpts();
 
-  // Create a temporary file for the precompiled preamble. In rare
-  // circumstances, this can fail.
-  llvm::ErrorOr PreamblePCHFile =
-  PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile();
-  if (!PreamblePCHFile)
-return BuildPreambleError::CouldntCreateTempFile;
+  llvm::Optional TempFile;
+  if (!StoreInMemory) {
+// Create a temporary file for the precompiled preamble. In rare
+// circumstances, this can fail.
+llvm::ErrorOr PreamblePCHFile =
+PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile();
+if (!PreamblePCHFile)
+  return BuildPreambleError::CouldntCreateTempFile;
+TempFile = std::move(*PreamblePCHFile);
+  }
+
+  PCHStorage Storage = StoreInMemory ? PCHStorage(InMemoryPreamble())
+ : PCHStorage(std::move(*TempFile));
 
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
@@ -230,8 +273,8 @@
 
   // Tell the compiler invocation to generate a temporary precompiled header.
   FrontendOpts.ProgramAction = frontend::G

[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Frontend/ASTUnit.cpp:1028
+IntrusiveRefCntPtr OldVFS = VFS;
+Preamble->AddImplicitPreamble(*CCInvocation, /*ref*/ VFS,
+  OverrideMainBuffer.get());

klimek wrote:
> Since when are we using the /*ref*/ annotation?
Oh, sorry, that's my thing. Slipped into this change.
Removed those.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:206
+  std::unique_ptr Storage;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);

klimek wrote:
> It looks like we should pass in the output stream, not the storage?
We're not actually using the `Storage` variable, it's a leftover from previous 
versions. Removed it.

Or did you mean that we should pass in the output stream directly to 
`PrecompilePreambleAction`'s constructor?



Comment at: lib/Frontend/PrecompiledPreamble.cpp:490
   PreprocessorOpts.DisablePCHValidation = true;
+  if (Storage.getKind() == PCHStorage::Kind::TempFile) {
+const TempPCHFile &PCHFile = Storage.asFile();

klimek wrote:
> This looks a bit like we should push it into the PCHStorage.
I've extracted a function here to make the code read simpler.
However, I placed it directly into the `PrecompiledPreamble` instead of 
`PCHStorage` to keep `PCHStorage` responsible for just one thing: managing the 
`variant`-like union.


https://reviews.llvm.org/D39842



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


[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true

2017-11-14 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM! But wait for @dcoughlin, @zaks.anna , or @NoQ  before commit.


https://reviews.llvm.org/D37187



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


r318154 - [tooling] Make compile_flags.txt negative test more hermetic

2017-11-14 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Nov 14 07:22:34 2017
New Revision: 318154

URL: http://llvm.org/viewvc/llvm-project?rev=318154&view=rev
Log:
[tooling] Make compile_flags.txt negative test more hermetic

Modified:
cfe/trunk/test/Tooling/fixed-database.cpp

Modified: cfe/trunk/test/Tooling/fixed-database.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/fixed-database.cpp?rev=318154&r1=318153&r2=318154&view=diff
==
--- cfe/trunk/test/Tooling/fixed-database.cpp (original)
+++ cfe/trunk/test/Tooling/fixed-database.cpp Tue Nov 14 07:22:34 2017
@@ -8,7 +8,8 @@
 // RUN: echo "-Dklazz=class" >> %t/compile_flags.txt
 // RUN: echo '-std=c++11' >> %t/compile_flags.txt
 // RUN: clang-check "%t/Src/test.cpp" 2>&1
-// RUN: not clang-check "%s" 2>&1 | FileCheck "%s" -check-prefix=NODB
+// RUN: echo > %t/compile_flags.txt
+// RUN: not clang-check "%t/Src/test.cpp" 2>&1 | FileCheck "%s" 
-check-prefix=NODB
 
 // NODB: unknown type name 'klazz'
 klazz F{};


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


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 122845.
ilya-biryukov added a comment.

Made in-memory preambles optional (on-disk by default).


https://reviews.llvm.org/D39843

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/tool/ClangdMain.cpp
  test/clangd/completion.test
  test/clangd/diagnostics-preamble.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -332,6 +332,7 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+/*StorePreamblesInMemory=*/true,
 clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
@@ -396,6 +397,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -442,6 +444,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -490,7 +493,9 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -524,7 +529,9 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -573,7 +580,9 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -642,6 +651,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -759,7 +769,8 @@
 
   auto TestWithOpts = [&](clangd::CodeCompleteOptions Opts) {
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-Opts, EmptyLogger::getInstance());
+/*StorePreamblesInMemory=*/true, Opts,
+EmptyLogger::getInstance());
 // No need to sync reparses here as there are no asserts on diagnostics (or
 // other async operations).
 Server.addDocument(FooCpp, GlobalCompletion.Text);
@@ -952,6 +963,7 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+/*StorePreamblesInMemory=*/true,
 clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 
@@ -1112,6 +1124,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -1238,7 +1251,8 @@
   std::move(StartSecondReparsePromise));
 
   MockCompilationDatabase CDB(/*AddFreesta

[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D39843#920568, @sammccall wrote:

> As a very first step, can we make this configurable but off-by-default? That 
> will address the pressing diskless-servers need.


I think on-disk by default makes sense now until we do the measurements and 
have a the data to prove the on-memory is really better.


https://reviews.llvm.org/D39843



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


[PATCH] D39852: [clangd] Support returning a limited number of completion results.

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D39852



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-11-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

One interesting trade-off I'm running into:
My gut feeling is that we really want to make local decisions about whether we 
want to break/reflow - this makes the code significantly simpler (IMO), and 
handles all tests in this patch correctly, but is fundamentally limiting the 
global optimizations we can do. Specifically, we would not correctly reflow 
this:

  //   |< limit
  // foo bar
  // baz
  // x

to

  // foo
  // bar
  // baz x

when the excess character limit is low.

That would be a point for global optimization, but I find it really hard to 
understand exactly why it's ok to do it. Won't we get things like this wrong:

  Limit: 13
  // foo  bar baz
  // bab  bob

as we'll not compress whitespace?


https://reviews.llvm.org/D33589



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


[PATCH] D38708: [AST] Flag the typo-corrected nodes for better tooling

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry, not familiar enough with the AST bits yet to LGTM this.

Looks good from a higher-level perspective, though.
It's a bit of a shame that's it is still super-easy to write code that does not 
account for typo-corrected nodes. A more explicit approach, similar to 
non-canonical and sugared `Type`s, would probably be nicer, but getting there 
seems to be hard and may not be worth the effort.


Repository:
  rL LLVM

https://reviews.llvm.org/D38708



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:153
+  if (ReplacementsOrError) {
+C.reply(json::ary{replacementsToEdits(Code, ReplacementsOrError.get())});
+  } else {

NIT: remove braces from single-statement branches



Comment at: clangd/ClangdLSPServer.cpp:165
+  if (ReplacementsOrError) {
+C.reply(json::ary{replacementsToEdits(Code, ReplacementsOrError.get())});
+  } else {

NIT: remove braces from single-statement branches



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected>
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

Why do we accept `Code` as a parameter here instead of getting it internally?

Maybe we should consider moving this method out of `ClangdServer`? Its 
signature looks pretty self-contained now.


https://reviews.llvm.org/D39430



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


[PATCH] D39129: [OpenCL] Fix generation of constant address space sampler in function scope

2017-11-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D39129#924425, @bader wrote:

> In https://reviews.llvm.org/D39129#923235, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D39129#902848, @bader wrote:
> >
> > > @Anastasia, during the discussion of similar fix 
> > > (https://reviews.llvm.org/D34342).
> > >
> > > I found another bug in the CodeGen library. Do you have time to fix it 
> > > too?
> > >  Here is the reproducer from the old review request:
> > >
> > >   int get_sampler_initializer(void);
> > >   kernel void foo() {
> > > const sampler_t const_smp_func_init = get_sampler_initializer();
> > >   }
> > >
> >
> >
> > I am getting an error currently: `error: internal error: could not emit 
> > constant value "abstractly"`. It seems very weird and also doesn't seem to 
> > be related to constant AS change.  I think this should be allowed to 
> > compile though? I can try to investigate but since I don't know the time 
> > frame yet and it doesn't seem to be related to constant AS I would prefer 
> > to do it as a separate change.
>
>
> I'm fine with fixing this test case later, but I assume that patch posted 
> https://reviews.llvm.org/D34342 covers more cases. Is this version able to 
> handle samples declared as `const sampler_t const_smp`?
>  Are you okay if I commit https://reviews.llvm.org/D34342 instead?


Sure. Sorry I overlooked it somehow.


https://reviews.llvm.org/D39129



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


[PATCH] D34342: [OpenCL] Fix code generation of function-scope constant samplers.

2017-11-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


https://reviews.llvm.org/D34342



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


[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans updated this revision to Diff 122878.
hans retitled this revision from "Add flags to control the 
-finstrument-functions instrumentation calls to __cyg_profile functions" to 
"Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter 
attributes".
hans edited the summary of this revision.
hans added a comment.

Minor updates to the diff, updating the description to match the new approach.

Please take a look.


https://reviews.llvm.org/D39331

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/instrument-functions.c
  test/CodeGen/mcount.c
  test/CodeGen/x86_64-instrument-functions.c
  test/CodeGenCXX/instrument-functions.cpp
  test/Frontend/gnu-mcount.c

Index: test/Frontend/gnu-mcount.c
===
--- test/Frontend/gnu-mcount.c
+++ test/Frontend/gnu-mcount.c
@@ -43,36 +43,36 @@
 
 // CHECK-LABEL: f
 // TODO: add profiling support for arm-baremetal
-// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01mcount"{{.*}} }
-// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-BAREMETAL-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-BAREMETAL-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
-// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01mcount"{{.*}} }
-// CHECK-ARM-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM64-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-LINUX: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"=".mcount"{{.*}} }
-// CHECK-ARM64-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-NETBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
-// CHECK-ARM-EABI-NETBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-RTEMS: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-RTEMS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-RTEMS: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-RTEMS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-CLOUDABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-CLOUDABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-CLOUDABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-CLOUDABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01mcount"{{.*}} }
+// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-BAREMETAL-EABI: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="mcount"{{.*}} }
+// CHECK-ARM64-BAREMETAL-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="

r318169 - [refactor][extract] avoid extracting expressions from types in functions

2017-11-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov 14 10:59:01 2017
New Revision: 318169

URL: http://llvm.org/viewvc/llvm-project?rev=318169&view=rev
Log:
[refactor][extract] avoid extracting expressions from types in functions

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=318169&r1=318168&r2=318169&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Tue Nov 14 10:59:01 2017
@@ -383,10 +383,12 @@ bool CodeRangeASTSelection::isInFunction
 if (const auto *D = Node.get()) {
   if (isFunctionLikeDeclaration(D))
 return IsPrevCompound;
-  // FIXME (Alex L): We should return false on top-level decls in functions
-  // e.g. we don't want to extract:
+  // Stop the search at any type declaration to avoid returning true for
+  // expressions in type declarations in functions, like:
   // function foo() { struct X {
   //   int m = /*selection:*/ 1 + 2 /*selection end*/; }; };
+  if (isa(D))
+return false;
 }
 IsPrevCompound = Node.get() != nullptr;
   }

Modified: cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp?rev=318169&r1=318168&r2=318169&view=diff
==
--- cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp (original)
+++ cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp Tue Nov 14 
10:59:01 2017
@@ -1,4 +1,4 @@
-// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 2>&1 | grep 
-v CHECK | FileCheck %s
+// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++14 2>&1 | grep 
-v CHECK | FileCheck %s
 
 
 void simpleExtractNoCaptures() {
@@ -42,7 +42,21 @@ struct OutOfBodyStuff {
   void foo(int x =/*range out_of_body_expr=->+0:58*/1 + 2);
 };
 
-// CHECK: 3 'out_of_body_expr' results:
+auto inFunctionOutOfBody() -> decltype(/*range out_of_body_expr=->+0:79*/1 + 
2) {
+  struct OutOfBodyStuff {
+int FieldInit = /*range out_of_body_expr=->+0:60*/1 + 2;
+
+void foo(int x =/*range out_of_body_expr=->+0:60*/1 + 2);
+  };
+  enum E {
+X = /*range out_of_body_expr=->+0:48*/1 + 2
+  };
+  int x = 0;
+  using T = decltype(/*range out_of_body_expr=->+0:61*/x + 3);
+  return x;
+}
+
+// CHECK: 8 'out_of_body_expr' results:
 // CHECK: the selected code is not a part of a function's / method's body
 
 void simpleExpressionNoExtraction() {


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


[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 122883.
erichkeane added a comment.

Fixed for bitfields.  Review by anyone greatly appreciated :)


https://reviews.llvm.org/D39347

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2166,151 +2166,6 @@
   return false;
 }
 
-bool QualType::unionHasUniqueObjectRepresentations(
-const ASTContext &Context) const {
-  assert((*this)->isUnionType() && "must be union type");
-  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
-  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
-
-  for (const auto *Field : Union->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-if (FieldSize != UnionSize)
-  return false;
-  }
-  return true;
-}
-
-static bool isStructEmpty(QualType Ty) {
-  assert(Ty.getTypePtr()->isStructureOrClassType() &&
- "Must be struct or class");
-  const RecordDecl *RD = Ty.getTypePtr()->getAs()->getDecl();
-
-  if (!RD->field_empty())
-return false;
-
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-return ClassDecl->isEmpty();
-  }
-
-  return true;
-}
-
-bool QualType::structHasUniqueObjectRepresentations(
-const ASTContext &Context) const {
-  assert((*this)->isStructureOrClassType() && "Must be struct or class");
-  const RecordDecl *RD = getTypePtr()->getAs()->getDecl();
-
-  if (isStructEmpty(*this))
-return false;
-
-  // Check base types.
-  CharUnits BaseSize{};
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-for (const auto Base : ClassDecl->bases()) {
-  if (Base.isVirtual())
-return false;
-
-  // Empty bases are permitted, otherwise ensure base has unique
-  // representation. Also, Empty Base Optimization means that an
-  // Empty base takes up 0 size.
-  if (!isStructEmpty(Base.getType())) {
-if (!Base.getType().structHasUniqueObjectRepresentations(Context))
-  return false;
-BaseSize += Context.getTypeSizeInChars(Base.getType());
-  }
-}
-  }
-
-  CharUnits StructSize = Context.getTypeSizeInChars(*this);
-
-  // This struct obviously has bases that keep it from being 'empty', so
-  // checking fields is no longer required.  Ensure that the struct size
-  // is the sum of the bases.
-  if (RD->field_empty())
-return StructSize == BaseSize;
-  ;
-
-  CharUnits CurOffset =
-  Context.toCharUnitsFromBits(Context.getFieldOffset(*RD->field_begin()));
-
-  // If the first field isn't at the sum of the size of the bases, there
-  // is padding somewhere.
-  if (BaseSize != CurOffset)
-return false;
-
-  for (const auto *Field : RD->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-CharUnits FieldOffset =
-Context.toCharUnitsFromBits(Context.getFieldOffset(Field));
-// Has padding between fields.
-if (FieldOffset != CurOffset)
-  return false;
-CurOffset += FieldSize;
-  }
-  // Check for tail padding.
-  return CurOffset == StructSize;
-}
-
-bool QualType::hasUniqueObjectRepresentations(const ASTContext &Context) const {
-  // C++17 [meta.unary.prop]:
-  //   The predicate condition for a template specialization
-  //   has_unique_object_representations shall be
-  //   satisfied if and only if:
-  // (9.1) - T is trivially copyable, and
-  // (9.2) - any two objects of type T with the same value have the same
-  // object representation, where two objects
-  //   of array or non-union class type are considered to have the same value
-  //   if their respective sequences of
-  //   direct subobjects have the same values, and two objects of union type
-  //   are considered to have the same
-  //   value if they have the same active member and the corresponding members
-  //   have the same value.
-  //   The set of scalar types for which this condition holds is
-  //   implementation-defined. [ Note: If a type has padding
-  //   bits, the condition does not hold; otherwise, the condition holds true
-  //   for unsigned integral types. -- end note ]
-  if (isNull())
-return false;
-
-  // Arrays are unique only if their element type is unique.
-  if ((*this)->isArrayType())
-return Context.getBaseElementType(*this).hasUniqueObjectRepresentations(
-Context);
-
-  // (9.1) - T is trivially copyable, and
-  if (!isTriviallyCopyableType(Context))
-return false;
-
-  // Functions are not unique.
-  if ((*this)->isFunctionType())
-return false;
-
-  // All integrals and enums are unique!
-  if ((*this)->isIntegralOrEnumerationType())
-return true

[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Driver/Options.td:1032
+def fno_instrument_functions_inline : Flag<["-"], 
"fno-instrument-functions-inline">, Group, Flags<[CC1Option]>,
+  HelpText<"When using -finstrument-functions, insert the calls after 
inlining">;
 

hans wrote:
> rnk wrote:
> > This actually describes GCC's behavior for `-finstrument-functions`. I 
> > suspect the current behavior is pretty useless for most people. I'd rather 
> > make the new behavior the default and add a flag to request the old 
> > behavior.
> At least with the GCC I tried, they do insert the calls before inlining, and 
> inline them:
> 
> ```
> $ echo 'static void f() {} void g() { f(); }' | gcc -x c -O3 
> -finstrument-functions -S -o - - | grep -A50 g:
> g:
> .LFB1:
> .cfi_startproc
> subq$8, %rsp
> .cfi_def_cfa_offset 16
> movl$g, %edi
> movq8(%rsp), %rsi
> call__cyg_profile_func_enter
> movq8(%rsp), %rsi
> movl$f, %edi
> call__cyg_profile_func_enter
> movq8(%rsp), %rsi
> movl$f, %edi
> call__cyg_profile_func_exit
> movq8(%rsp), %rsi
> movl$g, %edi
> addq$8, %rsp
> .cfi_def_cfa_offset 8
> jmp __cyg_profile_func_exit
> .cfi_endproc
> ```
You're right, I misread what I did locally.

I feel like there are too many negatives here, though. 
-finstrument-functions-after-inlining would probably be more readable, 
especially considering we don't have a finstrument-inline-functions. 
-finstrument-functions-after-inlining could imply -finstrument-functions, and 
users would have one less flag to set.


https://reviews.llvm.org/D39331



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


[PATCH] D33275: Keep into account if files were virtual.

2017-11-14 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D33275



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


[PATCH] D40044: [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

2017-11-14 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
Herald added a subscriber: mcrosier.

There are 20 LLVM math intrinsics that correspond to mathlib calls according to 
the LangRef:
http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics

We were only converting 3 mathlib calls (sqrt, fma, pow) and 12 builtin calls 
(ceil, copysign, fabs, floor, fma, fmax, fmin, nearbyint, pow, rint, round, 
trunc) to their intrinsic-equivalents.

This patch pulls the transforms together and handles all 20 cases. The switch 
is guarded by a check for const-ness to make sure we're not doing the transform 
if errno could possibly be set by the libcall or builtin.


https://reviews.llvm.org/D40044

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-sqrt.c
  test/CodeGen/builtins.c
  test/CodeGen/libcalls.c
  test/CodeGen/math-builtins.c
  test/CodeGen/math-libcalls.c

Index: test/CodeGen/math-libcalls.c
===
--- test/CodeGen/math-libcalls.c
+++ test/CodeGen/math-libcalls.c
@@ -17,21 +17,21 @@
 
   copysign(f,f); copysignf(f,f);copysignl(f,f);
 
-// NO__ERRNO: declare double @copysign(double, double) [[READNONE]]
-// NO__ERRNO: declare float @copysignf(float, float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @copysign(double, double) [[READNONE:#[0-9]+]]
-// HAS_ERRNO: declare float @copysignf(float, float) [[READNONE]]
-// HAS_ERRNO: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// NO__ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
   fabs(f);   fabsf(f);  fabsl(f);
 
-// NO__ERRNO: declare double @fabs(double) [[READNONE]]
-// NO__ERRNO: declare float @fabsf(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @fabsl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @fabs(double) [[READNONE]]
-// HAS_ERRNO: declare float @fabsf(float) [[READNONE]]
-// HAS_ERRNO: declare x86_fp80 @fabsl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
 
   fmod(f,f); fmodf(f,f);fmodl(f,f);
 
@@ -80,7 +80,7 @@
 
   pow(f,f);powf(f,f);   powl(f,f);
 
-// NO__ERRNO: declare double @llvm.pow.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// NO__ERRNO: declare double @llvm.pow.f64(double, double) [[READNONE_INTRINSIC]]
 // NO__ERRNO: declare float @llvm.pow.f32(float, float) [[READNONE_INTRINSIC]]
 // NO__ERRNO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare double @pow(double, double) [[NOT_READNONE]]
@@ -147,24 +147,24 @@
 // NO__ERRNO: declare double @cbrt(double) [[READNONE]]
 // NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @cbrt(double) [[READNONE]]
+// HAS_ERRNO: declare double @cbrt(double) [[READNONE:#[0-9]+]]
 // HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
 // HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
 
   ceil(f);   ceilf(f);  ceill(f);
 
-// NO__ERRNO: declare double @ceil(double) [[READNONE]]
-// NO__ERRNO: declare float @ceilf(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @ceill(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @ceil(double) [[READNONE]]
-// HAS_ERRNO: declare float @ceilf(float) [[READNONE]]
-// HAS_ERRNO: declare x86_fp80 @ceill(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]
 
   cos(f);cosf(f);   cosl(f); 
 
-// NO__ERRNO: declare double @cos(double) [[READNONE]]
-// NO__ERRNO: declare float @cosf(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @cosl(x86_fp80) [[READNONE]]
+// NO__ERRNO: dec

[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: include/clang/Driver/Options.td:1032
+def fno_instrument_functions_inline : Flag<["-"], 
"fno-instrument-functions-inline">, Group, Flags<[CC1Option]>,
+  HelpText<"When using -finstrument-functions, insert the calls after 
inlining">;
 

rnk wrote:
> hans wrote:
> > rnk wrote:
> > > This actually describes GCC's behavior for `-finstrument-functions`. I 
> > > suspect the current behavior is pretty useless for most people. I'd 
> > > rather make the new behavior the default and add a flag to request the 
> > > old behavior.
> > At least with the GCC I tried, they do insert the calls before inlining, 
> > and inline them:
> > 
> > ```
> > $ echo 'static void f() {} void g() { f(); }' | gcc -x c -O3 
> > -finstrument-functions -S -o - - | grep -A50 g:
> > g:
> > .LFB1:
> > .cfi_startproc
> > subq$8, %rsp
> > .cfi_def_cfa_offset 16
> > movl$g, %edi
> > movq8(%rsp), %rsi
> > call__cyg_profile_func_enter
> > movq8(%rsp), %rsi
> > movl$f, %edi
> > call__cyg_profile_func_enter
> > movq8(%rsp), %rsi
> > movl$f, %edi
> > call__cyg_profile_func_exit
> > movq8(%rsp), %rsi
> > movl$g, %edi
> > addq$8, %rsp
> > .cfi_def_cfa_offset 8
> > jmp __cyg_profile_func_exit
> > .cfi_endproc
> > ```
> You're right, I misread what I did locally.
> 
> I feel like there are too many negatives here, though. 
> -finstrument-functions-after-inlining would probably be more readable, 
> especially considering we don't have a finstrument-inline-functions. 
> -finstrument-functions-after-inlining could imply -finstrument-functions, and 
> users would have one less flag to set.
Thanks, that's a much better name.


https://reviews.llvm.org/D39331



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


[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans updated this revision to Diff 122889.
hans edited the summary of this revision.
hans added a comment.

Renaming the new flag and making it sufficient to turn on instrumentation by 
itself.


https://reviews.llvm.org/D39331

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/instrument-functions.c
  test/CodeGen/mcount.c
  test/CodeGen/x86_64-instrument-functions.c
  test/CodeGenCXX/instrument-functions.cpp
  test/Frontend/gnu-mcount.c

Index: test/Frontend/gnu-mcount.c
===
--- test/Frontend/gnu-mcount.c
+++ test/Frontend/gnu-mcount.c
@@ -43,36 +43,36 @@
 
 // CHECK-LABEL: f
 // TODO: add profiling support for arm-baremetal
-// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01mcount"{{.*}} }
-// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-BAREMETAL-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-BAREMETAL-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
-// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01mcount"{{.*}} }
-// CHECK-ARM-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM64-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-LINUX: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
-// CHECK-ARM-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"=".mcount"{{.*}} }
-// CHECK-ARM64-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-NETBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
-// CHECK-ARM-EABI-NETBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
-// CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-RTEMS: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-RTEMS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-RTEMS: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-RTEMS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM-EABI-CLOUDABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM-EABI-CLOUDABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
-// CHECK-ARM64-EABI-CLOUDABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
-// CHECK-ARM64-EABI-CLOUDABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01mcount"{{.*}} }
+// CHECK-ARM-BAREMETAL-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-BAREMETAL-EABI: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="mcount"{{.*}} }
+// CHECK-ARM64-BAREMETAL-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01_mcount"{{.*}} }
+// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="_mcount"{{.*}} }
+// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount

[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Thanks, looks good!


https://reviews.llvm.org/D39331



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


[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-14 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

It'd be good to have tests which have alignment directives on bitfields.


https://reviews.llvm.org/D39347



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


[PATCH] D40045: AMDGPU/GCN: Bring processors in sync with AMDGPUUsage

2017-11-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.

- Remove gfx804
- Remove gfx901
- Remove gfx903


https://reviews.llvm.org/D40045

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


Index: test/Driver/amdgpu-mcpu.cl
===
--- test/Driver/amdgpu-mcpu.cl
+++ test/Driver/amdgpu-mcpu.cl
@@ -69,13 +69,10 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=polaris10 %s -o - 
2>&1 | FileCheck --check-prefix=POLARIS10-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=polaris11 %s -o - 
2>&1 | FileCheck --check-prefix=POLARIS11-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx804 %s -o - 
2>&1 | FileCheck --check-prefix=GFX804-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx810 %s -o - 
2>&1 | FileCheck --check-prefix=GFX810-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 
2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 
2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx902 %s -o - 
2>&1 | FileCheck --check-prefix=GFX902-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx903 %s -o - 
2>&1 | FileCheck --check-prefix=GFX903-CHECK %s
 
 // GFX600-CHECK: "-target-cpu" "gfx600"
 // TAHITI-CHECK: "-target-cpu" "tahiti"
@@ -103,10 +100,7 @@
 // FIJI-CHECK: "-target-cpu" "fiji"
 // POLARIS10-CHECK: "-target-cpu" "polaris10"
 // POLARIS11-CHECK: "-target-cpu" "polaris11"
-// GFX804-CHECK: "-target-cpu" "gfx804"
 // GFX810-CHECK: "-target-cpu" "gfx810"
 // STONEY-CHECK: "-target-cpu" "stoney"
 // GFX900-CHECK: "-target-cpu" "gfx900"
-// GFX901-CHECK: "-target-cpu" "gfx901"
 // GFX902-CHECK: "-target-cpu" "gfx902"
-// GFX903-CHECK: "-target-cpu" "gfx903"
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -286,13 +286,10 @@
   .Case("fiji", GK_GFX8)
   .Case("polaris10", GK_GFX8)
   .Case("polaris11", GK_GFX8)
-  .Case("gfx804", GK_GFX8)
   .Case("gfx810", GK_GFX8)
   .Case("stoney", GK_GFX8)
   .Case("gfx900", GK_GFX9)
-  .Case("gfx901", GK_GFX9)
   .Case("gfx902", GK_GFX9)
-  .Case("gfx903", GK_GFX9)
   .Default(GK_NONE);
 }
 


Index: test/Driver/amdgpu-mcpu.cl
===
--- test/Driver/amdgpu-mcpu.cl
+++ test/Driver/amdgpu-mcpu.cl
@@ -69,13 +69,10 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=polaris10 %s -o - 2>&1 | FileCheck --check-prefix=POLARIS10-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=polaris11 %s -o - 2>&1 | FileCheck --check-prefix=POLARIS11-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx804 %s -o - 2>&1 | FileCheck --check-prefix=GFX804-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx810 %s -o - 2>&1 | FileCheck --check-prefix=GFX810-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx902 %s -o - 2>&1 | FileCheck --check-prefix=GFX902-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx903 %s -o - 2>&1 | FileCheck --check-prefix=GFX903-CHECK %s
 
 // GFX600-CHECK: "-target-cpu" "gfx600"
 // TAHITI-CHECK: "-target-cpu" "tahiti"
@@ -103,10 +100,7 @@
 // FIJI-CHECK: "-target-cpu" "fiji"
 // POLARIS10-CHECK: "-target-cpu" "polaris10"
 // POLARIS11-CHECK: "-target-cpu" "polaris11"
-// GFX804-CHECK: "-target-cpu" "gfx804"
 // GFX810-CHECK: "-target-cpu" "gfx810"
 // STONEY-CHECK: "-target-cpu" "stoney"
 // GFX900-CHECK: "-target-cpu" "gfx900"
-// GFX901-CHECK: "-target-cpu" "gfx901"
 // GFX902-CHECK: "-target-cpu" "gfx902"
-// GFX903-CHECK: "-target-cpu" "gfx903"
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -286,13 +286,10 @@
   .Case("fiji", GK_GFX8)
   .Case("polaris10", GK_GFX8)
  

[PATCH] D39879: AMDGPU: Remove -mamdgpu-debugger-abi option

2017-11-14 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Ping.


https://reviews.llvm.org/D39879



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

Hahnfeld wrote:
> rjmccall wrote:
> > Hahnfeld wrote:
> > > rjmccall wrote:
> > > > ABataev wrote:
> > > > > ABataev wrote:
> > > > > > Hahnfeld wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > Hahnfeld wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > The way you've written this makes it sound like "does 
> > > > > > > > > > > > the target support VLAs?", but the actual semantic 
> > > > > > > > > > > > checks treat it as "do OpenMP devices on this target 
> > > > > > > > > > > > support VLAs?"  Maybe there should be a more specific 
> > > > > > > > > > > > way to query things about OpenMP devices instead of 
> > > > > > > > > > > > setting a global flag for the target?
> > > > > > > > > > > Actually, the NVPTX and SPIR targets never support VLAs. 
> > > > > > > > > > > So I felt like it would be more correct to make this a 
> > > > > > > > > > > global property of the target.
> > > > > > > > > > > 
> > > > > > > > > > > The difference is that the other programming models 
> > > > > > > > > > > (OpenCL and CUDA) error out immediatelyand regardless of 
> > > > > > > > > > > the target because this limitation is reflected in the 
> > > > > > > > > > > standards that disallow VLAs (see SemaType.cpp). For 
> > > > > > > > > > > OpenMP we might have target devices that support VLA so 
> > > > > > > > > > > we shouldn't error out for those.
> > > > > > > > > > If you want to make it a global property of the target, 
> > > > > > > > > > that's fine, but then I don't understand why your 
> > > > > > > > > > diagnostic only fires when 
> > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > That is because of how OpenMP offloading works and how it is 
> > > > > > > > > implemented in Clang. Consider the following snippet from the 
> > > > > > > > > added test case:
> > > > > > > > > ```lang=c
> > > > > > > > > int vla[arg];
> > > > > > > > > 
> > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > {
> > > > > > > > >// more code here...
> > > > > > > > > }
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > Clang will take the following steps to compile this into a 
> > > > > > > > > working binary for a GPU:
> > > > > > > > > 1. Parse and (semantically) analyze the code as-is for the 
> > > > > > > > > host and produce LLVM Bitcode.
> > > > > > > > > 2. Parse and analyze again the code as-is and generate code 
> > > > > > > > > for the offloading target, the GPU in this case.
> > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary and embed 
> > > > > > > > > target binary from 3.
> > > > > > > > > 
> > > > > > > > > `OpenMPIsDevice` will be true for 2., but the complete source 
> > > > > > > > > code is analyzed. So to not throw errors for the host code, 
> > > > > > > > > we have to make sure that we are actually generating code for 
> > > > > > > > > the target device. This is either in a `target` directive or 
> > > > > > > > > in a `declare target` region.
> > > > > > > > > Note that this is quite similar to what CUDA does, only they 
> > > > > > > > > have `CUDADiagIfDeviceCode` for this logic. If you want me to 
> > > > > > > > > add something of that kind for OpenMP target devices, I'm 
> > > > > > > > > fine with that. However for the given case, it's a bit 
> > > > > > > > > different because this error should only be thrown for target 
> > > > > > > > > devices that don't support VLAs...
> > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > re-Sema'ed from scratch for the target?  Which means you need 
> > > > > > > > to avoid generating errors about things in the outer 
> > > > > > > > translation unit that aren't part of the target directive that 
> > > > > > > > you actually want to compile.  I would've expected there to be 
> > > > > > > > some existing mechanism for that, to be honest, as opposed to 
> > > > > > > > explicitly trying to suppress target-specific diagnostics one 
> > > > > > > > by one.
> > > > > > > Yes, that is my understanding. For errors, we don't need to take 
> > > > > > > anything special as the first `cc1` invocation will exit with a 
> > > > > > > non-zero status so that the driver stops the compilation. For 
> > > > > > > warnings, there seems to be no mechanism in place as I see them 
> > > > > > > duplicated, even in code that is not generate for the target 
> > > > > > > device (verified with an unused variable).
> > > > > > > 
> > > > > > > @ABataev @gtbercea Do I miss something here?
> > > > > > I'm not aware of any.
> > > > > John, target-specific checks require some special flags (like 
>

[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 122897.
erichkeane added a comment.

Added a test for aligned bitfield, as @majnemer requested.  Is this sufficient?


https://reviews.llvm.org/D39347

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2166,151 +2166,6 @@
   return false;
 }
 
-bool QualType::unionHasUniqueObjectRepresentations(
-const ASTContext &Context) const {
-  assert((*this)->isUnionType() && "must be union type");
-  CharUnits UnionSize = Context.getTypeSizeInChars(*this);
-  const RecordDecl *Union = getTypePtr()->getAs()->getDecl();
-
-  for (const auto *Field : Union->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-if (FieldSize != UnionSize)
-  return false;
-  }
-  return true;
-}
-
-static bool isStructEmpty(QualType Ty) {
-  assert(Ty.getTypePtr()->isStructureOrClassType() &&
- "Must be struct or class");
-  const RecordDecl *RD = Ty.getTypePtr()->getAs()->getDecl();
-
-  if (!RD->field_empty())
-return false;
-
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-return ClassDecl->isEmpty();
-  }
-
-  return true;
-}
-
-bool QualType::structHasUniqueObjectRepresentations(
-const ASTContext &Context) const {
-  assert((*this)->isStructureOrClassType() && "Must be struct or class");
-  const RecordDecl *RD = getTypePtr()->getAs()->getDecl();
-
-  if (isStructEmpty(*this))
-return false;
-
-  // Check base types.
-  CharUnits BaseSize{};
-  if (const CXXRecordDecl *ClassDecl = dyn_cast(RD)) {
-for (const auto Base : ClassDecl->bases()) {
-  if (Base.isVirtual())
-return false;
-
-  // Empty bases are permitted, otherwise ensure base has unique
-  // representation. Also, Empty Base Optimization means that an
-  // Empty base takes up 0 size.
-  if (!isStructEmpty(Base.getType())) {
-if (!Base.getType().structHasUniqueObjectRepresentations(Context))
-  return false;
-BaseSize += Context.getTypeSizeInChars(Base.getType());
-  }
-}
-  }
-
-  CharUnits StructSize = Context.getTypeSizeInChars(*this);
-
-  // This struct obviously has bases that keep it from being 'empty', so
-  // checking fields is no longer required.  Ensure that the struct size
-  // is the sum of the bases.
-  if (RD->field_empty())
-return StructSize == BaseSize;
-  ;
-
-  CharUnits CurOffset =
-  Context.toCharUnitsFromBits(Context.getFieldOffset(*RD->field_begin()));
-
-  // If the first field isn't at the sum of the size of the bases, there
-  // is padding somewhere.
-  if (BaseSize != CurOffset)
-return false;
-
-  for (const auto *Field : RD->fields()) {
-if (!Field->getType().hasUniqueObjectRepresentations(Context))
-  return false;
-CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
-CharUnits FieldOffset =
-Context.toCharUnitsFromBits(Context.getFieldOffset(Field));
-// Has padding between fields.
-if (FieldOffset != CurOffset)
-  return false;
-CurOffset += FieldSize;
-  }
-  // Check for tail padding.
-  return CurOffset == StructSize;
-}
-
-bool QualType::hasUniqueObjectRepresentations(const ASTContext &Context) const {
-  // C++17 [meta.unary.prop]:
-  //   The predicate condition for a template specialization
-  //   has_unique_object_representations shall be
-  //   satisfied if and only if:
-  // (9.1) - T is trivially copyable, and
-  // (9.2) - any two objects of type T with the same value have the same
-  // object representation, where two objects
-  //   of array or non-union class type are considered to have the same value
-  //   if their respective sequences of
-  //   direct subobjects have the same values, and two objects of union type
-  //   are considered to have the same
-  //   value if they have the same active member and the corresponding members
-  //   have the same value.
-  //   The set of scalar types for which this condition holds is
-  //   implementation-defined. [ Note: If a type has padding
-  //   bits, the condition does not hold; otherwise, the condition holds true
-  //   for unsigned integral types. -- end note ]
-  if (isNull())
-return false;
-
-  // Arrays are unique only if their element type is unique.
-  if ((*this)->isArrayType())
-return Context.getBaseElementType(*this).hasUniqueObjectRepresentations(
-Context);
-
-  // (9.1) - T is trivially copyable, and
-  if (!isTriviallyCopyableType(Context))
-return false;
-
-  // Functions are not unique.
-  if ((*this)->isFunctionType())
-return false;
-
-  // All integrals and enums are unique!
-  if ((*this)->isIntegralOrEnumerationType()

[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

rjmccall wrote:
> Hahnfeld wrote:
> > rjmccall wrote:
> > > Hahnfeld wrote:
> > > > rjmccall wrote:
> > > > > ABataev wrote:
> > > > > > ABataev wrote:
> > > > > > > Hahnfeld wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > The way you've written this makes it sound like "does 
> > > > > > > > > > > > > the target support VLAs?", but the actual semantic 
> > > > > > > > > > > > > checks treat it as "do OpenMP devices on this target 
> > > > > > > > > > > > > support VLAs?"  Maybe there should be a more specific 
> > > > > > > > > > > > > way to query things about OpenMP devices instead of 
> > > > > > > > > > > > > setting a global flag for the target?
> > > > > > > > > > > > Actually, the NVPTX and SPIR targets never support 
> > > > > > > > > > > > VLAs. So I felt like it would be more correct to make 
> > > > > > > > > > > > this a global property of the target.
> > > > > > > > > > > > 
> > > > > > > > > > > > The difference is that the other programming models 
> > > > > > > > > > > > (OpenCL and CUDA) error out immediatelyand regardless 
> > > > > > > > > > > > of the target because this limitation is reflected in 
> > > > > > > > > > > > the standards that disallow VLAs (see SemaType.cpp). 
> > > > > > > > > > > > For OpenMP we might have target devices that support 
> > > > > > > > > > > > VLA so we shouldn't error out for those.
> > > > > > > > > > > If you want to make it a global property of the target, 
> > > > > > > > > > > that's fine, but then I don't understand why your 
> > > > > > > > > > > diagnostic only fires when 
> > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > That is because of how OpenMP offloading works and how it 
> > > > > > > > > > is implemented in Clang. Consider the following snippet 
> > > > > > > > > > from the added test case:
> > > > > > > > > > ```lang=c
> > > > > > > > > > int vla[arg];
> > > > > > > > > > 
> > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > {
> > > > > > > > > >// more code here...
> > > > > > > > > > }
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > Clang will take the following steps to compile this into a 
> > > > > > > > > > working binary for a GPU:
> > > > > > > > > > 1. Parse and (semantically) analyze the code as-is for the 
> > > > > > > > > > host and produce LLVM Bitcode.
> > > > > > > > > > 2. Parse and analyze again the code as-is and generate code 
> > > > > > > > > > for the offloading target, the GPU in this case.
> > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary and 
> > > > > > > > > > embed target binary from 3.
> > > > > > > > > > 
> > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the complete 
> > > > > > > > > > source code is analyzed. So to not throw errors for the 
> > > > > > > > > > host code, we have to make sure that we are actually 
> > > > > > > > > > generating code for the target device. This is either in a 
> > > > > > > > > > `target` directive or in a `declare target` region.
> > > > > > > > > > Note that this is quite similar to what CUDA does, only 
> > > > > > > > > > they have `CUDADiagIfDeviceCode` for this logic. If you 
> > > > > > > > > > want me to add something of that kind for OpenMP target 
> > > > > > > > > > devices, I'm fine with that. However for the given case, 
> > > > > > > > > > it's a bit different because this error should only be 
> > > > > > > > > > thrown for target devices that don't support VLAs...
> > > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > > re-Sema'ed from scratch for the target?  Which means you need 
> > > > > > > > > to avoid generating errors about things in the outer 
> > > > > > > > > translation unit that aren't part of the target directive 
> > > > > > > > > that you actually want to compile.  I would've expected there 
> > > > > > > > > to be some existing mechanism for that, to be honest, as 
> > > > > > > > > opposed to explicitly trying to suppress target-specific 
> > > > > > > > > diagnostics one by one.
> > > > > > > > Yes, that is my understanding. For errors, we don't need to 
> > > > > > > > take anything special as the first `cc1` invocation will exit 
> > > > > > > > with a non-zero status so that the driver stops the 
> > > > > > > > compilation. For warnings, there seems to be no mechanism in 
> > > > > > > > place as I see them duplicated, even in code that is not 
> > > > > > > > generate for the target device (verified with an unused 
> > > > > > > > va

[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

Hahnfeld wrote:
> rjmccall wrote:
> > Hahnfeld wrote:
> > > rjmccall wrote:
> > > > Hahnfeld wrote:
> > > > > rjmccall wrote:
> > > > > > ABataev wrote:
> > > > > > > ABataev wrote:
> > > > > > > > Hahnfeld wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > The way you've written this makes it sound like 
> > > > > > > > > > > > > > "does the target support VLAs?", but the actual 
> > > > > > > > > > > > > > semantic checks treat it as "do OpenMP devices on 
> > > > > > > > > > > > > > this target support VLAs?"  Maybe there should be a 
> > > > > > > > > > > > > > more specific way to query things about OpenMP 
> > > > > > > > > > > > > > devices instead of setting a global flag for the 
> > > > > > > > > > > > > > target?
> > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never support 
> > > > > > > > > > > > > VLAs. So I felt like it would be more correct to make 
> > > > > > > > > > > > > this a global property of the target.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > The difference is that the other programming models 
> > > > > > > > > > > > > (OpenCL and CUDA) error out immediatelyand regardless 
> > > > > > > > > > > > > of the target because this limitation is reflected in 
> > > > > > > > > > > > > the standards that disallow VLAs (see SemaType.cpp). 
> > > > > > > > > > > > > For OpenMP we might have target devices that support 
> > > > > > > > > > > > > VLA so we shouldn't error out for those.
> > > > > > > > > > > > If you want to make it a global property of the target, 
> > > > > > > > > > > > that's fine, but then I don't understand why your 
> > > > > > > > > > > > diagnostic only fires when 
> > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > That is because of how OpenMP offloading works and how it 
> > > > > > > > > > > is implemented in Clang. Consider the following snippet 
> > > > > > > > > > > from the added test case:
> > > > > > > > > > > ```lang=c
> > > > > > > > > > > int vla[arg];
> > > > > > > > > > > 
> > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > {
> > > > > > > > > > >// more code here...
> > > > > > > > > > > }
> > > > > > > > > > > ```
> > > > > > > > > > > 
> > > > > > > > > > > Clang will take the following steps to compile this into 
> > > > > > > > > > > a working binary for a GPU:
> > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is for 
> > > > > > > > > > > the host and produce LLVM Bitcode.
> > > > > > > > > > > 2. Parse and analyze again the code as-is and generate 
> > > > > > > > > > > code for the offloading target, the GPU in this case.
> > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary and 
> > > > > > > > > > > embed target binary from 3.
> > > > > > > > > > > 
> > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the complete 
> > > > > > > > > > > source code is analyzed. So to not throw errors for the 
> > > > > > > > > > > host code, we have to make sure that we are actually 
> > > > > > > > > > > generating code for the target device. This is either in 
> > > > > > > > > > > a `target` directive or in a `declare target` region.
> > > > > > > > > > > Note that this is quite similar to what CUDA does, only 
> > > > > > > > > > > they have `CUDADiagIfDeviceCode` for this logic. If you 
> > > > > > > > > > > want me to add something of that kind for OpenMP target 
> > > > > > > > > > > devices, I'm fine with that. However for the given case, 
> > > > > > > > > > > it's a bit different because this error should only be 
> > > > > > > > > > > thrown for target devices that don't support VLAs...
> > > > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > > > re-Sema'ed from scratch for the target?  Which means you 
> > > > > > > > > > need to avoid generating errors about things in the outer 
> > > > > > > > > > translation unit that aren't part of the target directive 
> > > > > > > > > > that you actually want to compile.  I would've expected 
> > > > > > > > > > there to be some existing mechanism for that, to be honest, 
> > > > > > > > > > as opposed to explicitly trying to suppress target-specific 
> > > > > > > > > > diagnostics one by one.
> > > > > > > > > Yes, that is my understanding. For errors, we don't need to 
> > > > > > > > > take anything special as the first `cc1` invocation will exit 
> > > > > > > > > with a non-zero status so that the driver stops the 
> > > > > > > > > compilation. For warnings, 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good, sorry for the delay!




Comment at: include/clang/Basic/LangOptions.def:129
 LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
+LANGOPT(SEHExceptions , 1, 0, "structured exception handling")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")

"Structured exception handling" is very ambiguous. I would say something like 
"SEH .xdata exception handling" or something to clarify.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


r318194 - [OPENMP] Fix DSA analysis for threadprivates after deserialization.

2017-11-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Nov 14 13:01:01 2017
New Revision: 318194

URL: http://llvm.org/viewvc/llvm-project?rev=318194&view=rev
Log:
[OPENMP] Fix DSA analysis for threadprivates after deserialization.

If threadprivate vaible is deserialized, it is not marked as
threadprivate in DSAStack.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_ast_print.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=318194&r1=318193&r2=318194&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Nov 14 13:01:01 2017
@@ -966,6 +966,12 @@ DSAStackTy::DSAVarData DSAStackTy::getTo
 DVar.RefExpr = TI->getSecond().RefExpr.getPointer();
 DVar.CKind = OMPC_threadprivate;
 return DVar;
+  } else if (VD && VD->hasAttr()) {
+DVar.RefExpr = buildDeclRefExpr(
+SemaRef, VD, D->getType().getNonReferenceType(),
+VD->getAttr()->getLocation());
+DVar.CKind = OMPC_threadprivate;
+addDSA(D, DVar.RefExpr, OMPC_threadprivate);
   }
 
   if (isStackEmpty())

Modified: cfe/trunk/test/OpenMP/parallel_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_ast_print.cpp?rev=318194&r1=318193&r2=318194&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_ast_print.cpp Tue Nov 14 13:01:01 2017
@@ -135,6 +135,9 @@ struct S {
 // CHECK-NEXT:   #pragma omp threadprivate(S::TS)
 // CHECK-NEXT: }
 
+int thrp;
+#pragma omp threadprivate(thrp)
+
 template 
 T tmain(T argc, T *argv) {
   T b = argc, c, d, e, f, g;
@@ -143,7 +146,7 @@ T tmain(T argc, T *argv) {
   T arr[C][10], arr1[C];
 #pragma omp parallel
   a=2;
-#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(C) copyin(S::TS) proc_bind(master) 
reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
+#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared 
(d) if (parallel:argc > 0) num_threads(C) copyin(S::TS, thrp) 
proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
   foo();
 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, 
arr[0:C][:argc]) reduction(&& : g)
   foo();
@@ -157,7 +160,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: T arr[C][10], arr1[C];
 // CHECK-NEXT: #pragma omp parallel
 // CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: 
e,arr[:C][0:10])
+// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) 
copyin(S::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:C][0:10])
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) 
reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g)
 // CHECK-NEXT: foo()
@@ -168,7 +171,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: int arr[5][10], arr1[5];
 // CHECK-NEXT: #pragma omp parallel
 // CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) 
copyin(S::TS) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: 
e,arr[:5][0:10])
+// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) 
copyin(S::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:5][0:10])
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp parallel if(5) num_threads(s) proc_bind(close) 
reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g)
 // CHECK-NEXT: foo()
@@ -179,7 +182,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: long arr[1][10], arr1[1];
 // CHECK-NEXT: #pragma omp parallel
 // CHECK-NEXT: a = 2;
-// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) 
copyin(S::TS) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: 
e,arr[:1][0:10])
+// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) 
firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) 
copyin(S::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) 
reduction(max: e,arr[:1][0:10])
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp parallel if(1) num_threads(s) proc_bind(close) 
reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g)
 // CHECK-NEXT: foo()


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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added reviewers: efriedma, rjmccall.
efriedma added a comment.

You need more test coverage for the cases where arguments end up on the stack.  
And some test coverage for varargs calls.




Comment at: lib/CodeGen/TargetInfo.cpp:8858
+  else
+NeededArgGPRs = 1;
+

It looks like the ABI says there's a special rule for varargs here?



Comment at: lib/CodeGen/TargetInfo.cpp:8914
+Address RISCVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const {
+  CharUnits SlotSize = CharUnits::fromQuantity(XLen / 8);

The type of va_list and the behavior of va_arg should be documented in the ABI 
doc... but apparently it's missing at the moment?  (I mean, this is the obvious 
implementation from what is mentioned, but it would be nice to see something 
more explicit.)



Comment at: test/CodeGen/riscv32-abi.c:118
+// single 2*xlen-sized argument, to ensure that alignment can be maintained if
+// it spills to the stack
+

Please clarify this comment; the ABI doc doesn't say anything about aligning 
arguments whose alignment is 2✕XLEN, except in the case of varargs.


https://reviews.llvm.org/D40023



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


r318199 - Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Nov 14 13:13:27 2017
New Revision: 318199

URL: http://llvm.org/viewvc/llvm-project?rev=318199&view=rev
Log:
Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter 
attributes

This updates -mcount to use the new attribute names (LLVM r318195), and
switches over -finstrument-functions to also use these attributes rather
than inserting instrumentation in the frontend.

It also adds a new flag, -finstrument-functions-after-inlining, which
makes the cygprofile instrumentation get inserted after inlining rather
than before.

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

Added:
cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/instrument-functions.c
cfe/trunk/test/CodeGen/mcount.c
cfe/trunk/test/CodeGenCXX/instrument-functions.cpp
cfe/trunk/test/Frontend/gnu-mcount.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=318199&r1=318198&r2=318199&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Nov 14 13:13:27 2017
@@ -1028,6 +1028,8 @@ def finput_charset_EQ : Joined<["-"], "f
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, 
Group, Flags<[CC1Option]>,
   HelpText<"Generate calls to instrument function entry and exit">;
+def finstrument_functions_after_inlining : Flag<["-"], 
"finstrument-functions-after-inlining">, Group, Flags<[CC1Option]>,
+  HelpText<"Like -finstrument-functions, but insert the calls after inlining">;
 
 def fxray_instrument : Flag<["-"], "fxray-instrument">, Group,
   Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=318199&r1=318198&r2=318199&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Nov 14 13:13:27 2017
@@ -76,6 +76,8 @@ CODEGENOPT(ForbidGuardVariables , 1, 0)
 CODEGENOPT(FunctionSections  , 1, 0) ///< Set when -ffunction-sections is 
enabled.
 CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
///< enabled.
+CODEGENOPT(InstrumentFunctionsAfterInlining , 1, 0) ///< Set when
+  ///< -finstrument-functions-after-inlining is 
enabled.
 
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=318199&r1=318198&r2=318199&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Nov 14 13:13:27 2017
@@ -354,8 +354,12 @@ void CodeGenFunction::FinishFunction(Sou
   // Emit function epilog (to return).
   llvm::DebugLoc Loc = EmitReturnBlock();
 
-  if (ShouldInstrumentFunction())
-EmitFunctionInstrumentation("__cyg_profile_func_exit");
+  if (ShouldInstrumentFunction()) {
+CurFn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining
+ ? "instrument-function-exit"
+ : "instrument-function-exit-inlined",
+ "__cyg_profile_func_exit");
+  }
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
@@ -438,7 +442,8 @@ void CodeGenFunction::FinishFunction(Sou
 /// ShouldInstrumentFunction - Return true if the current function should be
 /// instrumented with __cyg_profile_func_* calls
 bool CodeGenFunction::ShouldInstrumentFunction() {
-  if (!CGM.getCodeGenOpts().InstrumentFunctions)
+  if (!CGM.getCodeGenOpts().InstrumentFunctions &&
+  !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
 return false;
   if (!CurFuncDecl || CurFuncDecl->hasAttr())
 return false;
@@ -488,31 +493,6 @@ CodeGenFunction::DecodeAddrUsedInPrologu
 "decoded_addr");
 }
 
-/// EmitFunctionInstrumentation - Emit LLVM code to call the specified
-/// instrumentation function with the current function and the call site, if
-/// function instrumentation is enabled.
-void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {

[PATCH] D39331: Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes

2017-11-14 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318199: Switch -mcount and -finstrument-functions to emit 
EnterExitInstrumenter… (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D39331?vs=122889&id=122901#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39331

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/instrument-functions.c
  cfe/trunk/test/CodeGen/mcount.c
  cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
  cfe/trunk/test/CodeGenCXX/instrument-functions.cpp
  cfe/trunk/test/Frontend/gnu-mcount.c

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -777,6 +777,8 @@
 
   Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.InstrumentFunctionsAfterInlining =
+  Args.hasArg(OPT_finstrument_functions_after_inlining);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -354,8 +354,12 @@
   // Emit function epilog (to return).
   llvm::DebugLoc Loc = EmitReturnBlock();
 
-  if (ShouldInstrumentFunction())
-EmitFunctionInstrumentation("__cyg_profile_func_exit");
+  if (ShouldInstrumentFunction()) {
+CurFn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining
+ ? "instrument-function-exit"
+ : "instrument-function-exit-inlined",
+ "__cyg_profile_func_exit");
+  }
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
@@ -438,7 +442,8 @@
 /// ShouldInstrumentFunction - Return true if the current function should be
 /// instrumented with __cyg_profile_func_* calls
 bool CodeGenFunction::ShouldInstrumentFunction() {
-  if (!CGM.getCodeGenOpts().InstrumentFunctions)
+  if (!CGM.getCodeGenOpts().InstrumentFunctions &&
+  !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
 return false;
   if (!CurFuncDecl || CurFuncDecl->hasAttr())
 return false;
@@ -488,31 +493,6 @@
 "decoded_addr");
 }
 
-/// EmitFunctionInstrumentation - Emit LLVM code to call the specified
-/// 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 };
-  llvm::FunctionType *FunctionTy =
-llvm::FunctionType::get(VoidTy, ProfileFuncArgs, false);
-
-  llvm::Constant *F = CGM.CreateRuntimeFunction(FunctionTy, Fn);
-  llvm::CallInst *CallSite = Builder.CreateCall(
-CGM.getIntrinsic(llvm::Intrinsic::returnaddress),
-llvm::ConstantInt::get(Int32Ty, 0),
-"callsite");
-
-  llvm::Value *args[] = {
-llvm::ConstantExpr::getBitCast(CurFn, PointerTy),
-CallSite
-  };
-
-  EmitNounwindRuntimeCall(F, args);
-}
-
 static void removeImageAccessQualifier(std::string& TyName) {
   std::string ReadOnlyQual("__read_only");
   std::string::size_type ReadOnlyPos = TyName.find(ReadOnlyQual);
@@ -1001,8 +981,12 @@
 DI->EmitFunctionStart(GD, Loc, StartLoc, FnType, CurFn, Builder);
   }
 
-  if (ShouldInstrumentFunction())
-EmitFunctionInstrumentation("__cyg_profile_func_enter");
+  if (ShouldInstrumentFunction()) {
+Fn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining
+  ? "instrument-function-entry"
+  : "instrument-function-entry-inlined",
+  "__cyg_profile_func_enter");
+  }
 
   // Since emitting the mcount call here impacts optimizations such as function
   // inlining, we just add an attribute to insert a mcount call in backend.
@@ -1012,8 +996,10 @@
 if (CGM.getCodeGenOpts().CallFEntry)
   Fn->addFnAttr("fentry-call", "true");
 else {
-  if (!CurFuncDecl || !CurFuncDecl->hasAttr())
-Fn->addFnAttr("counting-function", getTarget().getMCountName());
+  if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+Fn->addFnAttr("instrument-function-entry-inlined",
+

[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-14 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 122904.
rwols marked an inline comment as done.
rwols added a comment.

Removed braces around single statement if-else.


https://reviews.llvm.org/D39430

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h

Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
 #include 
@@ -58,11 +59,13 @@
   RequestContext(JSONOutput &Out, llvm::Optional ID)
   : Out(Out), ID(std::move(ID)) {}
 
-  /// Sends a successful reply.
+  /// Send a response to a request from the client.
   void reply(json::Expr &&Result);
-  /// Sends an error response to the client, and logs it.
+  /// Send an error response to the client, and logs it.
   void replyError(ErrorCode code, const llvm::StringRef &Message);
-  /// Sends a request to the client.
+  /// Send all error messages contained in Err to the client, and log them.
+  void replyError(llvm::Error Err);
+  /// Send a request to the client.
   void call(llvm::StringRef Method, json::Expr &&Params);
 
 private:
Index: clangd/JSONRPCDispatcher.cpp
===
--- clangd/JSONRPCDispatcher.cpp
+++ clangd/JSONRPCDispatcher.cpp
@@ -59,24 +59,28 @@
 Out.log("Attempted to reply to a notification!\n");
 return;
   }
-  Out.writeMessage(json::obj{
-  {"jsonrpc", "2.0"},
-  {"id", *ID},
-  {"result", std::move(Result)},
-  });
+  Out.writeMessage(
+  json::obj{{"jsonrpc", "2.0"}, {"id", *ID}, {"result", Result}});
 }
 
-void RequestContext::replyError(ErrorCode code, const llvm::StringRef &Message) {
+void RequestContext::replyError(ErrorCode code,
+const llvm::StringRef &Message) {
   Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", static_cast(code)}, {"message", Message}}},
+{"error",
+ json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }
 
+void RequestContext::replyError(llvm::Error Err) {
+  const auto Message = llvm::toString(std::move(Err));
+  replyError(ErrorCode::UnknownErrorCode, Message);
+}
+
 void RequestContext::call(StringRef Method, json::Expr &&Params) {
   // FIXME: Generate/Increment IDs for every request so that we can get proper
   // replies once we need to.
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -284,17 +284,23 @@
   /// given a header file and vice versa.
   llvm::Optional switchSourceHeader(PathRef Path);
 
-  /// Run formatting for \p Rng inside \p File.
-  std::vector formatRange(PathRef File, Range Rng);
-  /// Run formatting for the whole \p File.
-  std::vector formatFile(PathRef File);
-  /// Run formatting after a character was typed at \p Pos in \p File.
-  std::vector formatOnType(PathRef File, Position Pos);
+  /// Run formatting for \p Rng inside \p File with content \p Code.
+  llvm::Expected>
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
   Expected> rename(PathRef File, Position Pos,
  llvm::StringRef NewName);
 
+  /// Run formatting for the whole \p File with content \p Code.
+  llvm::Expected>
+  formatFile(llvm::StringRef Code, PathRef File);
+
+  /// Run formatting after a character was typed at \p Pos in \p File with
+  /// content \p Code.
+  llvm::Expected>
+  formatOnType(llvm::StringRef Code, PathRef File, Position Pos);
+
   /// Gets current document contents for \p File. \p File must point to a
   /// currently tracked file.
   /// FIXME(ibiryukov): This function is here to allow offset-to-Position
@@ -309,6 +315,12 @@
   void onFileEvent(const DidChangeWatchedFilesParams &Params);
 
 private:
+  /// FIXME: This stats several files to find a .clang-format file. I/O can be
+  /// slow. Think of a way to cache this.
+  llvm::Expected>
+  formatCode(llvm::StringRef Code, PathRef File,
+ ArrayRef Ranges);
+
   std::future
   scheduleReparseAndDiags(PathRef File, VersionedDraft Contents,
   std::shared_ptr Resources,
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -38,16 +38,6 @@
   std::promise &Promise;
 };
 
-std::vector formatCode(StringRef Code, StringRef Filename,
- 

[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-14 Thread Raoul Wols via Phabricator via cfe-commits
rwols marked 2 inline comments as done.
rwols added inline comments.



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected>
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

ilya-biryukov wrote:
> Why do we accept `Code` as a parameter here instead of getting it internally?
> 
> Maybe we should consider moving this method out of `ClangdServer`? Its 
> signature looks pretty self-contained now.
There are a couple intertwined problems:

1. replacementsToEdits wants llvm::StringRef Code
2. ClangdServer::formatCode wants llvm::StringRef Code
3. ClangdServer::getDocument returns an std::string

So yes, in principle you can call getDocument when you need it for 
replacementsToEdits, and you can let formatCode itself call getDocument for 
clang::format::getStyle. But then we create two copies of the document contents 
for one LSP request.

If getDocument returned an llvm::StringRef, I'd probably vote for removing the 
Code argument everywhere and call getDocument as needed.


https://reviews.llvm.org/D39430



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


[libclc] r318204 - native_powr: Switch implementation to native_exp2 and native_log2

2017-11-14 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Nov 14 13:55:41 2017
New Revision: 318204

URL: http://llvm.org/viewvc/llvm-project?rev=318204&view=rev
Log:
native_powr: Switch implementation to native_exp2 and native_log2

v2: don't use assume
check only for x<0, the other conditions are handled transparently
v3: don't check inputs at all, nan propagation works as expected

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/math/native_powr.cl
libclc/trunk/generic/lib/math/native_powr.inc
Modified:
libclc/trunk/generic/include/clc/math/native_powr.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/native_powr.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/native_powr.h?rev=318204&r1=318203&r2=318204&view=diff
==
--- libclc/trunk/generic/include/clc/math/native_powr.h (original)
+++ libclc/trunk/generic/include/clc/math/native_powr.h Tue Nov 14 13:55:41 2017
@@ -1 +1,7 @@
-#define native_powr pow
+#define __CLC_BODY 
+#define __CLC_FUNCTION native_powr
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=318204&r1=318203&r2=318204&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Tue Nov 14 13:55:41 2017
@@ -127,6 +127,7 @@ math/native_exp2.cl
 math/native_log.cl
 math/native_log10.cl
 math/native_log2.cl
+math/native_powr.cl
 math/native_recip.cl
 math/native_rsqrt.cl
 math/native_sin.cl

Added: libclc/trunk/generic/lib/math/native_powr.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/native_powr.cl?rev=318204&view=auto
==
--- libclc/trunk/generic/lib/math/native_powr.cl (added)
+++ libclc/trunk/generic/lib/math/native_powr.cl Tue Nov 14 13:55:41 2017
@@ -0,0 +1,5 @@
+#include 
+
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 

Added: libclc/trunk/generic/lib/math/native_powr.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/native_powr.inc?rev=318204&view=auto
==
--- libclc/trunk/generic/lib/math/native_powr.inc (added)
+++ libclc/trunk/generic/lib/math/native_powr.inc Tue Nov 14 13:55:41 2017
@@ -0,0 +1,5 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_powr(__CLC_GENTYPE x, 
__CLC_GENTYPE y) {
+  // x^y == 2^{log2 x^y} == 2^{y * log2 x}
+  // for x < 0 propagate nan created by log2
+  return native_exp2(y * native_log2(x));
+}


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


r318205 - [refactor][selection] canonicalize member expr callee to the full

2017-11-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov 14 14:06:55 2017
New Revision: 318205

URL: http://llvm.org/viewvc/llvm-project?rev=318205&view=rev
Log:
[refactor][selection] canonicalize member expr callee to the full
member call expression

We would like to extract the full call when just the callee is selected.

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=318205&r1=318204&r2=318205&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Tue Nov 14 14:06:55 2017
@@ -115,6 +115,11 @@ public:
   return true;
 if (auto *Opaque = dyn_cast(S))
   return TraverseOpaqueValueExpr(Opaque);
+// Avoid selecting implicit 'this' expressions.
+if (auto *TE = dyn_cast(S)) {
+  if (TE->isImplicit())
+return true;
+}
 // FIXME (Alex Lorenz): Improve handling for macro locations.
 SourceSelectionKind SelectionKind =
 selectionKindFor(CharSourceRange::getTokenRange(S->getSourceRange()));
@@ -268,9 +273,15 @@ void SelectedNodeWithParents::canonicali
   //  ~~ ~~~
   if (isa(S) && isa(Parent))
 Node = Parents.pop_back_val();
+  // The entire call should be selected when just the member expression
+  // that refers to the method is selected.
+  //f.call(args)  becomes  f.call(args)
+  //   
+  else if (isa(S) && isa(Parent) &&
+   cast(Parent)->getCallee() == S)
+Node = Parents.pop_back_val();
   // FIXME: Syntactic form -> Entire pseudo-object expr.
   // FIXME: Callee -> Call.
-  // FIXME: Callee member expr -> Call.
 }
 
 /// Finds the set of bottom-most selected AST nodes that are in the selection

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=318205&r1=318204&r2=318205&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Tue Nov 14 14:06:55 2017
@@ -1004,4 +1004,56 @@ void foo() {
   SelectionFinderVisitor::Lang_OBJC);
 }
 
+TEST(ASTSelectionFinder, CanonicalizeMemberCalleeToCall) {
+  StringRef Source = R"(
+class AClass { public:
+  void method();
+  int afield;
+  void selectWholeCallWhenJustMethodSelected(int &i) {
+method();
+  }
+};
+void selectWholeCallWhenJustMethodSelected() {
+  AClass a;
+  a.method();
+}
+void dontSelectArgument(AClass &a) {
+  a.selectWholeCallWhenJustMethodSelected(a.afield);
+}
+ )";
+  // Just 'method' with implicit 'this':
+  findSelectedASTNodesWithRange(
+  Source, {6, 5}, FileRange{{6, 5}, {6, 11}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 1u);
+EXPECT_TRUE(isa((*SelectedCode)[0]));
+  });
+  // Just 'method':
+  findSelectedASTNodesWithRange(
+  Source, {11, 5}, FileRange{{11, 5}, {11, 11}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 1u);
+EXPECT_TRUE(isa((*SelectedCode)[0]));
+  });
+  // Just 'afield', which should not select the call.
+  findSelectedASTNodesWithRange(
+  Source, {14, 5}, FileRange{{14, 45}, {14, 51}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 1u);
+EXPECT_FALSE(isa((*SelectedCode)[0]));
+  });
+}
+
 } // end anonymous namespace


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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-14 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked 18 inline comments as done.
Nebiroth added inline comments.



Comment at: clangd/Protocol.h:285
+
+  DidChangeConfigurationParams() {}
+

malaperle wrote:
> I don't think you need this constructor?
I do inside parse() for DidChangeConfigurationParams.


https://reviews.llvm.org/D39571



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


[libcxx] r318208 - Add two new macros: _LIBCPP_NODISCARD_AFTER_CXX17 and _LIBCPP_CONSTEXPR_AFTER_CXX17, along with a way to turn off the NODISCARD one: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17. No one is

2017-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Nov 14 14:26:50 2017
New Revision: 318208

URL: http://llvm.org/viewvc/llvm-project?rev=318208&view=rev
Log:
Add two new macros: _LIBCPP_NODISCARD_AFTER_CXX17 and 
_LIBCPP_CONSTEXPR_AFTER_CXX17, along with a way to turn off the NODISCARD one: 
_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17. No one is using these yet, but we will 
be ... soon

Added:
libcxx/trunk/test/libcxx/diagnostics/nodiscard.fail.cpp
libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp
Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=318208&r1=318207&r2=318208&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Nov 14 14:26:50 2017
@@ -121,6 +121,9 @@
 #ifndef __has_feature
 #define __has_feature(__x) 0
 #endif
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(__x) 0
+#endif
 // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
 // the compiler and '1' otherwise.
 #ifndef __is_identifier
@@ -951,6 +954,18 @@ template  struct __static_asse
 #define _LIBCPP_CONSTEXPR_AFTER_CXX14
 #endif
 
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX17
+#endif
+
+#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 && 
!defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17)
+#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+#else
+#define _LIBCPP_NODISCARD_AFTER_CXX17
+#endif
+
 // FIXME: Remove all usages of this macro once compilers catch up.
 #if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L)
 # define _LIBCPP_HAS_NO_INLINE_VARIABLES

Added: libcxx/trunk/test/libcxx/diagnostics/nodiscard.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/diagnostics/nodiscard.fail.cpp?rev=318208&view=auto
==
--- libcxx/trunk/test/libcxx/diagnostics/nodiscard.fail.cpp (added)
+++ libcxx/trunk/test/libcxx/diagnostics/nodiscard.fail.cpp Tue Nov 14 14:26:50 
2017
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
+// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+
+#include <__config>
+
+_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
+
+int main ()
+{
+   foo();  // expected-error {{ignoring return value of function declared 
with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp?rev=318208&view=auto
==
--- libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp Tue Nov 14 14:26:50 
2017
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
+// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#define _LIBCPP_DISABLE_AFTER_CXX17_NODISCARD
+#include <__config>
+
+_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
+
+int main ()
+{
+   foo();  // no error here!
+}


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


r318214 - Try to fix the instrument-functions tests

2017-11-14 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Nov 14 15:10:04 2017
New Revision: 318214

URL: http://llvm.org/viewvc/llvm-project?rev=318214&view=rev
Log:
Try to fix the instrument-functions tests

On e.g. PPC the return value and argument were marked 'signext'. This
makes the test expectations a bit more flexible.

Follow-up to r318199.

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

Modified: cfe/trunk/test/CodeGen/instrument-functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/instrument-functions.c?rev=318214&r1=318213&r2=318214&view=diff
==
--- cfe/trunk/test/CodeGen/instrument-functions.c (original)
+++ cfe/trunk/test/CodeGen/instrument-functions.c Tue Nov 14 15:10:04 2017
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s 
-finstrument-functions -disable-llvm-passes | FileCheck %s
 
 int test1(int x) {
-// CHECK: define i32 @test1(i32 %x) #[[ATTR1:[0-9]+]]
+// CHECK: @test1(i32 {{.*}}%x) #[[ATTR1:[0-9]+]]
 // CHECK: ret
   return x;
 }
 
 int test2(int) __attribute__((no_instrument_function));
 int test2(int x) {
-// CHECK: define i32 @test2(i32 %x) #[[ATTR2:[0-9]+]]
+// CHECK: @test2(i32 {{.*}}%x) #[[ATTR2:[0-9]+]]
 // CHECK: ret
   return x;
 }

Modified: cfe/trunk/test/CodeGenCXX/instrument-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/instrument-functions.cpp?rev=318214&r1=318213&r2=318214&view=diff
==
--- cfe/trunk/test/CodeGenCXX/instrument-functions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/instrument-functions.cpp Tue Nov 14 15:10:04 2017
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 -S -emit-llvm -triple %itanium_abi_triple -o - %s 
-finstrument-functions -disable-llvm-passes | FileCheck %s
 
 int test1(int x) {
-// CHECK: define i32 @_Z5test1i(i32 %x) #[[ATTR1:[0-9]+]]
+// CHECK: @_Z5test1i(i32 {{.*}}%x) #[[ATTR1:[0-9]+]]
 // CHECK: ret
   return x;
 }
 
 int test2(int) __attribute__((no_instrument_function));
 int test2(int x) {
-// CHECK: define i32 @_Z5test2i(i32 %x) #[[ATTR2:[0-9]+]]
+// CHECK: @_Z5test2i(i32 {{.*}}%x) #[[ATTR2:[0-9]+]]
 // CHECK: ret
   return x;
 }


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


r318215 - [refactor][selection] canonicalize decl ref callee to the call expr

2017-11-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov 14 15:10:50 2017
New Revision: 318215

URL: http://llvm.org/viewvc/llvm-project?rev=318215&view=rev
Log:
[refactor][selection] canonicalize decl ref callee to the call expr

We would like to extract the full call when just the callee function is
selected

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=318215&r1=318214&r2=318215&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Tue Nov 14 15:10:50 2017
@@ -259,29 +259,64 @@ struct SelectedNodeWithParents {
   /// when it makes sense to do so.
   void canonicalize();
 };
-} // end anonymous namespace
 
-void SelectedNodeWithParents::canonicalize() {
-  const Stmt *S = Node.get().Node.get();
-  assert(S && "non statement selection!");
-  const Stmt *Parent = Parents[Parents.size() - 1].get().Node.get();
-  if (!Parent)
-return;
+enum SelectionCanonicalizationAction { KeepSelection, SelectParent };
+
+/// Returns the canonicalization action which should be applied to the
+/// selected statement.
+SelectionCanonicalizationAction
+getSelectionCanonizalizationAction(const Stmt *S, const Stmt *Parent) {
   // Select the parent expression when:
   // - The string literal in ObjC string literal is selected, e.g.:
   // @"test"   becomes   @"test"
   //  ~~ ~~~
   if (isa(S) && isa(Parent))
-Node = Parents.pop_back_val();
+return SelectParent;
   // The entire call should be selected when just the member expression
-  // that refers to the method is selected.
+  // that refers to the method or the decl ref that refers to the function
+  // is selected.
   //f.call(args)  becomes  f.call(args)
   //   
-  else if (isa(S) && isa(Parent) &&
-   cast(Parent)->getCallee() == S)
-Node = Parents.pop_back_val();
+  //func(args)  becomes  func(args)
+  // ~~
+  else if (const auto *CE = dyn_cast(Parent)) {
+if ((isa(S) || isa(S)) &&
+CE->getCallee()->IgnoreImpCasts() == S)
+  return SelectParent;
+  }
   // FIXME: Syntactic form -> Entire pseudo-object expr.
-  // FIXME: Callee -> Call.
+  return KeepSelection;
+}
+
+} // end anonymous namespace
+
+void SelectedNodeWithParents::canonicalize() {
+  const Stmt *S = Node.get().Node.get();
+  assert(S && "non statement selection!");
+  const Stmt *Parent = Parents[Parents.size() - 1].get().Node.get();
+  if (!Parent)
+return;
+
+  // Look through the implicit casts in the parents.
+  unsigned ParentIndex = 1;
+  for (; (ParentIndex + 1) <= Parents.size() && isa(Parent);
+   ++ParentIndex) {
+const Stmt *NewParent =
+Parents[Parents.size() - ParentIndex - 1].get().Node.get();
+if (!NewParent)
+  break;
+Parent = NewParent;
+  }
+
+  switch (getSelectionCanonizalizationAction(S, Parent)) {
+  case SelectParent:
+Node = Parents[Parents.size() - ParentIndex];
+for (; ParentIndex != 0; --ParentIndex)
+  Parents.pop_back();
+break;
+  case KeepSelection:
+break;
+  }
 }
 
 /// Finds the set of bottom-most selected AST nodes that are in the selection

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=318215&r1=318214&r2=318215&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Tue Nov 14 15:10:50 2017
@@ -1056,4 +1056,30 @@ void dontSelectArgument(AClass &a) {
   });
 }
 
+TEST(ASTSelectionFinder, CanonicalizeFuncCalleeToCall) {
+  StringRef Source = R"(
+void function();
+
+void test() {
+  function();
+}
+ )";
+  // Just 'function':
+  findSelectedASTNodesWithRange(
+  Source, {5, 3}, FileRange{{5, 3}, {5, 11}},
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);
+Node->dump();
+Optional SelectedCode =
+CodeRangeASTSelection::create(SelectionRange, std::move(*Node));
+EXPECT_TRUE(SelectedCode);
+EXPECT_EQ(SelectedCode->size(), 1u);
+EXPECT_TRUE(isa((*SelectedCode)[0]));
+EXPECT_TRUE(isa(
+SelectedCode->getParents()[SelectedCode->getParents().size() - 1]
+.get()
+.Node.get()));
+  });
+}
+
 } // end anonymous namespace


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


[PATCH] D39446: [PGO] Detect more structural changes with the stable hash

2017-11-14 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for the review Alex. There hasn't been any more feedback so I'll commit 
this soon.


https://reviews.llvm.org/D39446



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


r318216 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-14 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Nov 14 15:13:32 2017
New Revision: 318216

URL: http://llvm.org/viewvc/llvm-project?rev=318216&view=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=318216&r1=318215&r2=318216&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Nov 14 15:13:32 2017
@@ -1,4 +1,4 @@
-//===-- DeclCXX.h - Classes for representing C++ declarations -*- C++ 
-*-=//
+//===- DeclCXX.h - Classes for representing C++ declarations --*- C++ 
-*-=//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -6,11 +6,11 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-///
+//
 /// \file
 /// \brief Defines the C++ Decl subclasses, other than those for templates
 /// (found in DeclTemplate.h) and friends (in DeclFriend.h).
-///
+//
 
//===--===//
 
 #ifndef LLVM_CLANG_AST_DECLCXX_H
@@ -20,29 +20,56 @@
 #include "clang/AST/ASTUnresolvedSet.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/LambdaCapture.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/Redeclarable.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Lambda.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/TrailingObjects.h"
+#include 
+#include 
+#include 
+#include 
+#include 
 
 namespace clang {
 
 class ClassTemplateDecl;
-class ClassTemplateSpecializationDecl;
 class ConstructorUsingShadowDecl;
 class CXXBasePath;
 class CXXBasePaths;
 class CXXConstructorDecl;
-class CXXConversionDecl;
 class CXXDestructorDecl;
-class CXXMethodDecl;
-class CXXRecordDecl;
-class CXXMemberLookupCriteria;
 class CXXFinalOverriderMap;
 class CXXIndirectPrimaryBaseSet;
+class CXXMethodDecl;
+class DiagnosticBuilder;
 class FriendDecl;
-class LambdaExpr;
+class FunctionTemplateDecl;
+class IdentifierInfo;
+class MemberSpecializationInfo;
+class TemplateDecl;
+class TemplateParameterList;
 class UsingDecl;
 
 /// \brief Represents any kind of function declaration, whether it is a
@@ -50,10 +77,10 @@ class UsingDecl;
 class AnyFunctionDecl {
   NamedDecl *Function;
 
-  AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
+  AnyFunctionDecl(NamedDecl *ND) : Function(ND) {}
 
 public:
-  AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
+  AnyFunctionDecl(FunctionDecl *FD) : Function(FD) {}
   AnyFunctionDecl(FunctionTemplateDecl *FTD);
 
   /// \brief Implicily converts any function or function template into a
@@ -68,16 +95,18 @@ public:
   }
 };
 
-} // end namespace clang
+} // namespace clang
 
 namespace llvm {
+
   // Provide PointerLikeTypeTraits for non-cvr pointers.
   template<>
   struct PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
-static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
+static void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
   return F.get();
 }
-static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
+
+static ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
   return ::clang::AnyFunctionDecl::getFromNamedDecl(
   static_cast< ::clang::NamedDecl*>(P));
 }
@@ -85,7 +114,7 @@ namespace llvm {
 enum { NumLowBitsAvailable = 2 };
   };
 
-} // end namespace llvm
+} // namespace llvm
 
 namespace clang {
 
@@ -100,7 +129,6 @@ namespace clang {
 /// Also note that this class has nothing to do with so-called
 /// "access declarations" (C++98 11.3 [class.access.dcl]).
 class AccessSpecDecl : public Decl {
-  virtual void anchor();
   /// \brief The location of the ':'.
   SourceLocation ColonLoc;
 
@@ -109,16 +137,21 @@ class AccessSpecDecl : public Decl {
 : Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) {
 setAccess(AS);
   }
-  AccessSpecDecl(EmptyShell Empty)
-: Decl(AccessSpec, Empty) { }
+
+  Access

[PATCH] D40045: AMDGPU/GCN: Bring processors in sync with AMDGPUUsage

2017-11-14 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM except for Bonaire.




Comment at: lib/Basic/Targets/AMDGPU.cpp:271
   .Case("gfx700", GK_GFX7)
   .Case("bonaire", GK_GFX7)
   .Case("kaveri", GK_GFX7)

D40051 proposes making Bonaire separate from Kaveri and named gfx704.


https://reviews.llvm.org/D40045



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


r318221 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-14 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Nov 14 15:35:42 2017
New Revision: 318221

URL: http://llvm.org/viewvc/llvm-project?rev=318221&view=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=318221&r1=318220&r2=318221&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Nov 14 15:35:42 2017
@@ -1,4 +1,4 @@
-//===--- Stmt.h - Classes for representing statements ---*- C++ 
-*-===//
+//===- Stmt.h - Classes for representing statements -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -22,34 +22,40 @@
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
+#include 
+#include 
 #include 
 
 namespace llvm {
-  class FoldingSetNodeID;
-}
+
+class FoldingSetNodeID;
+
+} // namespace llvm
 
 namespace clang {
-  class ASTContext;
-  class Attr;
-  class CapturedDecl;
-  class Decl;
-  class Expr;
-  class IdentifierInfo;
-  class LabelDecl;
-  class ODRHash;
-  class ParmVarDecl;
-  class PrinterHelper;
-  struct PrintingPolicy;
-  class QualType;
-  class RecordDecl;
-  class SourceManager;
-  class StringLiteral;
-  class SwitchStmt;
-  class Token;
-  class VarDecl;
+
+class ASTContext;
+class Attr;
+class CapturedDecl;
+class Decl;
+class Expr;
+class LabelDecl;
+class ODRHash;
+class PrinterHelper;
+struct PrintingPolicy;
+class RecordDecl;
+class SourceManager;
+class StringLiteral;
+class Token;
+class VarDecl;
 
 
//===--===//
 // AST classes for statements.
@@ -72,9 +78,13 @@ public:
 
   // Make vanilla 'new' and 'delete' illegal for Stmts.
 protected:
+  friend class ASTStmtReader;
+  friend class ASTStmtWriter;
+
   void *operator new(size_t bytes) noexcept {
 llvm_unreachable("Stmts cannot be allocated with regular 'new'.");
   }
+
   void operator delete(void *data) noexcept {
 llvm_unreachable("Stmts cannot be released with regular 'delete'.");
   }
@@ -89,6 +99,7 @@ protected:
 
   class CompoundStmtBitfields {
 friend class CompoundStmt;
+
 unsigned : NumStmtBits;
 
 unsigned NumStmts : 32 - NumStmtBits;
@@ -96,34 +107,36 @@ protected:
 
   class IfStmtBitfields {
 friend class IfStmt;
+
 unsigned : NumStmtBits;
 
 unsigned IsConstexpr : 1;
   };
 
   class ExprBitfields {
-friend class Expr;
-friend class DeclRefExpr; // computeDependence
-friend class InitListExpr; // ctor
-friend class DesignatedInitExpr; // ctor
-friend class BlockDeclRefExpr; // ctor
 friend class ASTStmtReader; // deserialization
+friend class AtomicExpr; // ctor
+friend class BlockDeclRefExpr; // ctor
+friend class CallExpr; // ctor
+friend class CXXConstructExpr; // ctor
+friend class CXXDependentScopeMemberExpr; // ctor
 friend class CXXNewExpr; // ctor
+friend class CXXUnresolvedConstructExpr; // ctor
+friend class DeclRefExpr; // computeDependence
 friend class DependentScopeDeclRefExpr; // ctor
-friend class CXXConstructExpr; // ctor
-friend class CallExpr; // ctor
-friend class OffsetOfExpr; // ctor
-friend class ObjCMessageExpr; // ctor
+friend class DesignatedInitExpr; // ctor
+friend class Expr;
+friend class InitListExpr; // ctor
 friend class ObjCArrayLiteral; // ctor
 friend class ObjCDictionaryLiteral; // ctor
-friend class ShuffleVectorExpr; // ctor
-friend class ParenListExpr; // ctor
-friend class CXXUnresolvedConstructExpr; // ctor
-friend class CXXDependentScopeMemberExpr; // ctor
+friend class ObjCMessageExpr; // ctor
+friend class OffsetOfExpr; // ctor
+friend class OpaqueValueExpr; // ctor
 friend class OverloadExpr; // ctor
+friend class ParenListExpr; // ctor
 friend class PseudoObjectExpr; // ctor
-friend class AtomicExpr; // ctor
-friend class OpaqueValueExpr; // ctor
+friend class ShuffleVectorExpr; // ctor
+
 unsigned : NumStmtBits;
 
 unsigned ValueKind : 2;
@@ -137,6 +150,7 @@ protected:
 
   class CharacterLiteralBitfields {
 friend class CharacterLiteral;
+
 unsigned : NumExprBits;
 
 unsigned Kind : 3;
@@ -153,6 +167,7 @@ protected:
 
   class FloatingLiteralBitfields {
 friend class FloatingLiteral;
+
 unsigned : NumExprBits;
 
 unsigned Semantics : 3; // Provides semantics for APFloat constructio

[PATCH] D40054: Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

LLVM exposes a file in the backend (X86TargetParser.def) that
contains information about the correct list of CpuIs values.

This patch removes 2 of the copied and pasted versions of this
list from clang and instead includes the data from the .def file.


https://reviews.llvm.org/D40054

Files:
  lib/Basic/Targets/X86.cpp
  lib/CodeGen/CGBuiltin.cpp

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -30,8 +30,9 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/TargetParser.h"
 #include 
 
 using namespace clang;
@@ -4626,8 +4627,8 @@
   case NEON::BI__builtin_neon_vsha1cq_u32:
   case NEON::BI__builtin_neon_vsha1pq_u32:
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:
 return false;
   }
   return true;
@@ -7497,78 +7498,6 @@
 
 Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
-  // This enum contains the vendor, type, and subtype enums from the
-  // runtime library concatenated together. The _START labels mark
-  // the start and are used to adjust the value into the correct
-  // encoding space.
-  enum X86CPUs {
-INTEL = 1,
-AMD,
-CPU_TYPE_START,
-INTEL_BONNELL,
-INTEL_CORE2,
-INTEL_COREI7,
-AMDFAM10H,
-AMDFAM15H,
-INTEL_SILVERMONT,
-INTEL_KNL,
-AMD_BTVER1,
-AMD_BTVER2,
-AMDFAM17H,
-CPU_SUBTYPE_START,
-INTEL_COREI7_NEHALEM,
-INTEL_COREI7_WESTMERE,
-INTEL_COREI7_SANDYBRIDGE,
-AMDFAM10H_BARCELONA,
-AMDFAM10H_SHANGHAI,
-AMDFAM10H_ISTANBUL,
-AMDFAM15H_BDVER1,
-AMDFAM15H_BDVER2,
-AMDFAM15H_BDVER3,
-AMDFAM15H_BDVER4,
-AMDFAM17H_ZNVER1,
-INTEL_COREI7_IVYBRIDGE,
-INTEL_COREI7_HASWELL,
-INTEL_COREI7_BROADWELL,
-INTEL_COREI7_SKYLAKE,
-INTEL_COREI7_SKYLAKE_AVX512,
-  };
-
-  X86CPUs CPU =
-StringSwitch(CPUStr)
-  .Case("amd", AMD)
-  .Case("amdfam10h", AMDFAM10H)
-  .Case("amdfam10", AMDFAM10H)
-  .Case("amdfam15h", AMDFAM15H)
-  .Case("amdfam15", AMDFAM15H)
-  .Case("amdfam17h", AMDFAM17H)
-  .Case("atom", INTEL_BONNELL)
-  .Case("barcelona", AMDFAM10H_BARCELONA)
-  .Case("bdver1", AMDFAM15H_BDVER1)
-  .Case("bdver2", AMDFAM15H_BDVER2)
-  .Case("bdver3", AMDFAM15H_BDVER3)
-  .Case("bdver4", AMDFAM15H_BDVER4)
-  .Case("bonnell", INTEL_BONNELL)
-  .Case("broadwell", INTEL_COREI7_BROADWELL)
-  .Case("btver1", AMD_BTVER1)
-  .Case("btver2", AMD_BTVER2)
-  .Case("core2", INTEL_CORE2)
-  .Case("corei7", INTEL_COREI7)
-  .Case("haswell", INTEL_COREI7_HASWELL)
-  .Case("intel", INTEL)
-  .Case("istanbul", AMDFAM10H_ISTANBUL)
-  .Case("ivybridge", INTEL_COREI7_IVYBRIDGE)
-  .Case("knl", INTEL_KNL)
-  .Case("nehalem", INTEL_COREI7_NEHALEM)
-  .Case("sandybridge", INTEL_COREI7_SANDYBRIDGE)
-  .Case("shanghai", AMDFAM10H_SHANGHAI)
-  .Case("silvermont", INTEL_SILVERMONT)
-  .Case("skylake", INTEL_COREI7_SKYLAKE)
-  .Case("skylake-avx512", INTEL_COREI7_SKYLAKE_AVX512)
-  .Case("slm", INTEL_SILVERMONT)
-  .Case("westmere", INTEL_COREI7_WESTMERE)
-  .Case("znver1", AMDFAM17H_ZNVER1);
-
   llvm::Type *Int32Ty = Builder.getInt32Ty();
 
   // Matching the struct layout from the compiler-rt/libgcc structure that is
@@ -7587,22 +7516,23 @@
   // range. Also adjust the expected value.
   unsigned Index;
   unsigned Value;
-  if (CPU > CPU_SUBTYPE_START) {
-Index = 2;
-Value = CPU - CPU_SUBTYPE_START;
-  } else if (CPU > CPU_TYPE_START) {
-Index = 1;
-Value = CPU - CPU_TYPE_START;
-  } else {
-Index = 0;
-Value = CPU;
-  }
+  std::tie(Index, Value) =
+  StringSwitch>(CPUStr)
+#define X86_VENDOR(ENUM, STRING)   \
+  .Case(STRING, {0u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \
+  .Cases(STR, ALIAS, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)   \
+  .Case(STR, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR)\
+  .Case(STR, {2u, static_cast(llvm::X86::ENUM)})
+#include "llvm/Support/X86TargetParser.def"
+  .Default({0,0});
+  assert(Value != 0 && "Invalid CPUStr passed to CpuIs");
 
   // Grab the appropriate field from __cpu_model.
-  llvm::Value *Idxs[] = {
-ConstantInt::get(Int32Ty, 0),
-ConstantInt::get(Int32Ty, Index)
-  };
+  llvm::Value *
+  Idxs[] = {ConstantInt::get(Int32Ty, 0), ConstantInt::get(Int32

[PATCH] D40054: Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:4630
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:

Note that these two are required, since there is an llvm::ARM and a clang::ARM, 
and the top of this does a 'using namespace clang' and a 'using namespace llvm'.


https://reviews.llvm.org/D40054



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


[PATCH] D39521: [x86 TargetInfo] Pull CPU handling for the x86 TargetInfo into a .def file.

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 122934.
erichkeane added a comment.

Re-ran clang-format, which now has more sane decisions in CGBuiltin.cpp


https://reviews.llvm.org/D39521

Files:
  lib/Basic/Targets/X86.cpp
  lib/CodeGen/CGBuiltin.cpp

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -30,8 +30,9 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/TargetParser.h"
 #include 
 
 using namespace clang;
@@ -4626,8 +4627,8 @@
   case NEON::BI__builtin_neon_vsha1cq_u32:
   case NEON::BI__builtin_neon_vsha1pq_u32:
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:
 return false;
   }
   return true;
@@ -7497,78 +7498,6 @@
 
 Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
-  // This enum contains the vendor, type, and subtype enums from the
-  // runtime library concatenated together. The _START labels mark
-  // the start and are used to adjust the value into the correct
-  // encoding space.
-  enum X86CPUs {
-INTEL = 1,
-AMD,
-CPU_TYPE_START,
-INTEL_BONNELL,
-INTEL_CORE2,
-INTEL_COREI7,
-AMDFAM10H,
-AMDFAM15H,
-INTEL_SILVERMONT,
-INTEL_KNL,
-AMD_BTVER1,
-AMD_BTVER2,
-AMDFAM17H,
-CPU_SUBTYPE_START,
-INTEL_COREI7_NEHALEM,
-INTEL_COREI7_WESTMERE,
-INTEL_COREI7_SANDYBRIDGE,
-AMDFAM10H_BARCELONA,
-AMDFAM10H_SHANGHAI,
-AMDFAM10H_ISTANBUL,
-AMDFAM15H_BDVER1,
-AMDFAM15H_BDVER2,
-AMDFAM15H_BDVER3,
-AMDFAM15H_BDVER4,
-AMDFAM17H_ZNVER1,
-INTEL_COREI7_IVYBRIDGE,
-INTEL_COREI7_HASWELL,
-INTEL_COREI7_BROADWELL,
-INTEL_COREI7_SKYLAKE,
-INTEL_COREI7_SKYLAKE_AVX512,
-  };
-
-  X86CPUs CPU =
-StringSwitch(CPUStr)
-  .Case("amd", AMD)
-  .Case("amdfam10h", AMDFAM10H)
-  .Case("amdfam10", AMDFAM10H)
-  .Case("amdfam15h", AMDFAM15H)
-  .Case("amdfam15", AMDFAM15H)
-  .Case("amdfam17h", AMDFAM17H)
-  .Case("atom", INTEL_BONNELL)
-  .Case("barcelona", AMDFAM10H_BARCELONA)
-  .Case("bdver1", AMDFAM15H_BDVER1)
-  .Case("bdver2", AMDFAM15H_BDVER2)
-  .Case("bdver3", AMDFAM15H_BDVER3)
-  .Case("bdver4", AMDFAM15H_BDVER4)
-  .Case("bonnell", INTEL_BONNELL)
-  .Case("broadwell", INTEL_COREI7_BROADWELL)
-  .Case("btver1", AMD_BTVER1)
-  .Case("btver2", AMD_BTVER2)
-  .Case("core2", INTEL_CORE2)
-  .Case("corei7", INTEL_COREI7)
-  .Case("haswell", INTEL_COREI7_HASWELL)
-  .Case("intel", INTEL)
-  .Case("istanbul", AMDFAM10H_ISTANBUL)
-  .Case("ivybridge", INTEL_COREI7_IVYBRIDGE)
-  .Case("knl", INTEL_KNL)
-  .Case("nehalem", INTEL_COREI7_NEHALEM)
-  .Case("sandybridge", INTEL_COREI7_SANDYBRIDGE)
-  .Case("shanghai", AMDFAM10H_SHANGHAI)
-  .Case("silvermont", INTEL_SILVERMONT)
-  .Case("skylake", INTEL_COREI7_SKYLAKE)
-  .Case("skylake-avx512", INTEL_COREI7_SKYLAKE_AVX512)
-  .Case("slm", INTEL_SILVERMONT)
-  .Case("westmere", INTEL_COREI7_WESTMERE)
-  .Case("znver1", AMDFAM17H_ZNVER1);
-
   llvm::Type *Int32Ty = Builder.getInt32Ty();
 
   // Matching the struct layout from the compiler-rt/libgcc structure that is
@@ -7587,22 +7516,22 @@
   // range. Also adjust the expected value.
   unsigned Index;
   unsigned Value;
-  if (CPU > CPU_SUBTYPE_START) {
-Index = 2;
-Value = CPU - CPU_SUBTYPE_START;
-  } else if (CPU > CPU_TYPE_START) {
-Index = 1;
-Value = CPU - CPU_TYPE_START;
-  } else {
-Index = 0;
-Value = CPU;
-  }
+  std::tie(Index, Value) = StringSwitch>(CPUStr)
+#define X86_VENDOR(ENUM, STRING)   \
+  .Case(STRING, {0u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \
+  .Cases(STR, ALIAS, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)   \
+  .Case(STR, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR)\
+  .Case(STR, {2u, static_cast(llvm::X86::ENUM)})
+#include "llvm/Support/X86TargetParser.def"
+   .Default({0, 0});
+  assert(Value != 0 && "Invalid CPUStr passed to CpuIs");
 
   // Grab the appropriate field from __cpu_model.
-  llvm::Value *Idxs[] = {
-ConstantInt::get(Int32Ty, 0),
-ConstantInt::get(Int32Ty, Index)
-  };
+  llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
+ ConstantInt::get(Int32Ty, Index)};
   llvm::Value *CpuValue = Builder.CreateGEP(STy, CpuModel, Idxs);
   CpuValue =

[PATCH] D39521: [x86 TargetInfo] Pull CPU handling for the x86 TargetInfo into a .def file.

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

First, updated this incorrectly.  Second, going to do this work over a few 
patches to take advantage of work that Craig did in the backend.


https://reviews.llvm.org/D39521



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


[PATCH] D40054: Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 122936.
erichkeane added a comment.

Re-ran format on a few lines to make them more sane.


https://reviews.llvm.org/D40054

Files:
  lib/Basic/Targets/X86.cpp
  lib/CodeGen/CGBuiltin.cpp

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -30,8 +30,9 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/TargetParser.h"
 #include 
 
 using namespace clang;
@@ -4626,8 +4627,8 @@
   case NEON::BI__builtin_neon_vsha1cq_u32:
   case NEON::BI__builtin_neon_vsha1pq_u32:
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:
 return false;
   }
   return true;
@@ -7497,78 +7498,6 @@
 
 Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
-  // This enum contains the vendor, type, and subtype enums from the
-  // runtime library concatenated together. The _START labels mark
-  // the start and are used to adjust the value into the correct
-  // encoding space.
-  enum X86CPUs {
-INTEL = 1,
-AMD,
-CPU_TYPE_START,
-INTEL_BONNELL,
-INTEL_CORE2,
-INTEL_COREI7,
-AMDFAM10H,
-AMDFAM15H,
-INTEL_SILVERMONT,
-INTEL_KNL,
-AMD_BTVER1,
-AMD_BTVER2,
-AMDFAM17H,
-CPU_SUBTYPE_START,
-INTEL_COREI7_NEHALEM,
-INTEL_COREI7_WESTMERE,
-INTEL_COREI7_SANDYBRIDGE,
-AMDFAM10H_BARCELONA,
-AMDFAM10H_SHANGHAI,
-AMDFAM10H_ISTANBUL,
-AMDFAM15H_BDVER1,
-AMDFAM15H_BDVER2,
-AMDFAM15H_BDVER3,
-AMDFAM15H_BDVER4,
-AMDFAM17H_ZNVER1,
-INTEL_COREI7_IVYBRIDGE,
-INTEL_COREI7_HASWELL,
-INTEL_COREI7_BROADWELL,
-INTEL_COREI7_SKYLAKE,
-INTEL_COREI7_SKYLAKE_AVX512,
-  };
-
-  X86CPUs CPU =
-StringSwitch(CPUStr)
-  .Case("amd", AMD)
-  .Case("amdfam10h", AMDFAM10H)
-  .Case("amdfam10", AMDFAM10H)
-  .Case("amdfam15h", AMDFAM15H)
-  .Case("amdfam15", AMDFAM15H)
-  .Case("amdfam17h", AMDFAM17H)
-  .Case("atom", INTEL_BONNELL)
-  .Case("barcelona", AMDFAM10H_BARCELONA)
-  .Case("bdver1", AMDFAM15H_BDVER1)
-  .Case("bdver2", AMDFAM15H_BDVER2)
-  .Case("bdver3", AMDFAM15H_BDVER3)
-  .Case("bdver4", AMDFAM15H_BDVER4)
-  .Case("bonnell", INTEL_BONNELL)
-  .Case("broadwell", INTEL_COREI7_BROADWELL)
-  .Case("btver1", AMD_BTVER1)
-  .Case("btver2", AMD_BTVER2)
-  .Case("core2", INTEL_CORE2)
-  .Case("corei7", INTEL_COREI7)
-  .Case("haswell", INTEL_COREI7_HASWELL)
-  .Case("intel", INTEL)
-  .Case("istanbul", AMDFAM10H_ISTANBUL)
-  .Case("ivybridge", INTEL_COREI7_IVYBRIDGE)
-  .Case("knl", INTEL_KNL)
-  .Case("nehalem", INTEL_COREI7_NEHALEM)
-  .Case("sandybridge", INTEL_COREI7_SANDYBRIDGE)
-  .Case("shanghai", AMDFAM10H_SHANGHAI)
-  .Case("silvermont", INTEL_SILVERMONT)
-  .Case("skylake", INTEL_COREI7_SKYLAKE)
-  .Case("skylake-avx512", INTEL_COREI7_SKYLAKE_AVX512)
-  .Case("slm", INTEL_SILVERMONT)
-  .Case("westmere", INTEL_COREI7_WESTMERE)
-  .Case("znver1", AMDFAM17H_ZNVER1);
-
   llvm::Type *Int32Ty = Builder.getInt32Ty();
 
   // Matching the struct layout from the compiler-rt/libgcc structure that is
@@ -7587,22 +7516,22 @@
   // range. Also adjust the expected value.
   unsigned Index;
   unsigned Value;
-  if (CPU > CPU_SUBTYPE_START) {
-Index = 2;
-Value = CPU - CPU_SUBTYPE_START;
-  } else if (CPU > CPU_TYPE_START) {
-Index = 1;
-Value = CPU - CPU_TYPE_START;
-  } else {
-Index = 0;
-Value = CPU;
-  }
+  std::tie(Index, Value) = StringSwitch>(CPUStr)
+#define X86_VENDOR(ENUM, STRING)   \
+  .Case(STRING, {0u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \
+  .Cases(STR, ALIAS, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)   \
+  .Case(STR, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR)\
+  .Case(STR, {2u, static_cast(llvm::X86::ENUM)})
+#include "llvm/Support/X86TargetParser.def"
+   .Default({0, 0});
+  assert(Value != 0 && "Invalid CPUStr passed to CpuIs");
 
   // Grab the appropriate field from __cpu_model.
-  llvm::Value *Idxs[] = {
-ConstantInt::get(Int32Ty, 0),
-ConstantInt::get(Int32Ty, Index)
-  };
+  llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
+ ConstantInt::get(Int32Ty, Index)};
   llvm::Value *CpuValue = Builder.CreateGEP(STy, CpuModel, Idxs);
   CpuValue = Builder.CreateAlig

r318229 - [PGO] Detect more structural changes with the stable hash

2017-11-14 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Nov 14 15:56:53 2017
New Revision: 318229

URL: http://llvm.org/viewvc/llvm-project?rev=318229&view=rev
Log:
[PGO] Detect more structural changes with the stable hash

Lifting from Bob Wilson's notes: The hash value that we compute and
store in PGO profile data to detect out-of-date profiles does not
include enough information. This means that many significant changes to
the source will not cause compiler warnings about the profile being out
of date, and worse, we may continue to use the outdated profile data to
make bad optimization decisions.  There is some tension here because
some source changes won't affect PGO and we don't want to invalidate the
profile unnecessarily.

This patch adds a new hashing scheme which is more sensitive to loop
nesting, conditions, and out-of-order control flow. Here are examples
which show snippets which get the same hash under the current scheme,
and different hashes under the new scheme:

Loop Nesting Example


  // Snippet 1
  while (foo()) {
while (bar()) {}
  }

  // Snippet 2
  while (foo()) {}
  while (bar()) {}

Condition Example
-

  // Snippet 1
  if (foo())
bar();
  baz();

  // Snippet 2
  if (foo())
bar();
  else
baz();

Out-of-order Control Flow Example
-

  // Snippet 1
  while (foo()) {
if (bar()) {}
baz();
  }

  // Snippet 2
  while (foo()) {
if (bar())
  continue;
baz();
  }

In each of these cases, it's useful to differentiate between the
snippets because swapping their profiles gives bad optimization hints.

The new hashing scheme considers some logical operators in an effort to
detect more changes in conditions. This isn't a perfect scheme. E.g, it
does not produce the same hash for these equivalent snippets:

  // Snippet 1
  bool c = !a || b;
  if (d && e) {}

  // Snippet 2
  bool f = d && e;
  bool c = !a || b;
  if (f) {}

This would require an expensive data flow analysis. Short of that, the
new hashing scheme looks reasonably complete, based on a scan over the
statements we place counters on.

Profiles which use the old version of the PGO hash remain valid and can
be used without issue (there are tests in tree which check this).

rdar://17068282

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

Added:
cfe/trunk/test/Profile/Inputs/cxx-hash-v2.profdata.v5
cfe/trunk/test/Profile/Inputs/cxx-hash-v2.proftext
cfe/trunk/test/Profile/cxx-hash-v2.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness.proftext
cfe/trunk/test/Profile/Inputs/c-captured.proftext
cfe/trunk/test/Profile/Inputs/c-counter-overflows.proftext
cfe/trunk/test/Profile/Inputs/c-general.proftext
cfe/trunk/test/Profile/Inputs/c-unprofiled-blocks.proftext
cfe/trunk/test/Profile/Inputs/cxx-class.proftext
cfe/trunk/test/Profile/Inputs/cxx-lambda.proftext
cfe/trunk/test/Profile/Inputs/cxx-rangefor.proftext
cfe/trunk/test/Profile/Inputs/cxx-templates.proftext
cfe/trunk/test/Profile/Inputs/cxx-throws.proftext
cfe/trunk/test/Profile/Inputs/func-entry.proftext
cfe/trunk/test/Profile/Inputs/gcc-flag-compatibility.proftext
cfe/trunk/test/Profile/Inputs/objc-general.proftext
cfe/trunk/test/Profile/c-outdated-data.c
cfe/trunk/test/Profile/objc-general.m

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=318229&r1=318228&r2=318229&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Nov 14 15:56:53 2017
@@ -47,6 +47,15 @@ void CodeGenPGO::setFuncName(llvm::Funct
   llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
+/// The version of the PGO hash algorithm.
+enum PGOHashVersion : unsigned {
+  PGO_HASH_V1,
+  PGO_HASH_V2,
+
+  // Keep this set to the latest hash version.
+  PGO_HASH_LATEST = PGO_HASH_V2
+};
+
 namespace {
 /// \brief Stable hasher for PGO region counters.
 ///
@@ -61,6 +70,7 @@ namespace {
 class PGOHash {
   uint64_t Working;
   unsigned Count;
+  PGOHashVersion HashVersion;
   llvm::MD5 MD5;
 
   static const int NumBitsPerType = 6;
@@ -93,24 +103,53 @@ public:
 BinaryOperatorLAnd,
 BinaryOperatorLOr,
 BinaryConditionalOperator,
+// The preceding values are available with PGO_HASH_V1.
+
+EndOfScope,
+IfThenBranch,
+IfElseBranch,
+GotoStmt,
+IndirectGotoStmt,
+BreakStmt,
+ContinueStmt,
+ReturnStmt,
+ThrowExpr,
+UnaryOperatorLNot,
+BinaryOperatorLT,
+BinaryOperatorGT,
+BinaryOperatorLE,
+BinaryOperatorGE,
+BinaryOperatorEQ,
+BinaryOperatorNE,
+// The preceding values are available with PGO_HASH_V2.
 
 // Keep this last.  It's for the static assert that follows.
 LastHashType
   };
   static_assert(LastHashType <

[PATCH] D39446: [PGO] Detect more structural changes with the stable hash

2017-11-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318229: [PGO] Detect more structural changes with the stable 
hash (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D39446?vs=122368&id=122939#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39446

Files:
  cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
  cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness.proftext
  cfe/trunk/test/Profile/Inputs/c-captured.proftext
  cfe/trunk/test/Profile/Inputs/c-counter-overflows.proftext
  cfe/trunk/test/Profile/Inputs/c-general.proftext
  cfe/trunk/test/Profile/Inputs/c-unprofiled-blocks.proftext
  cfe/trunk/test/Profile/Inputs/cxx-class.proftext
  cfe/trunk/test/Profile/Inputs/cxx-hash-v2.profdata.v5
  cfe/trunk/test/Profile/Inputs/cxx-hash-v2.proftext
  cfe/trunk/test/Profile/Inputs/cxx-lambda.proftext
  cfe/trunk/test/Profile/Inputs/cxx-rangefor.proftext
  cfe/trunk/test/Profile/Inputs/cxx-templates.proftext
  cfe/trunk/test/Profile/Inputs/cxx-throws.proftext
  cfe/trunk/test/Profile/Inputs/func-entry.proftext
  cfe/trunk/test/Profile/Inputs/gcc-flag-compatibility.proftext
  cfe/trunk/test/Profile/Inputs/objc-general.proftext
  cfe/trunk/test/Profile/c-outdated-data.c
  cfe/trunk/test/Profile/cxx-hash-v2.cpp
  cfe/trunk/test/Profile/objc-general.m

Index: cfe/trunk/test/Profile/c-outdated-data.c
===
--- cfe/trunk/test/Profile/c-outdated-data.c
+++ cfe/trunk/test/Profile/c-outdated-data.c
@@ -7,10 +7,10 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=NO_MISSING
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -Wprofile-instr-missing -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=WITH_MISSING
 
-// NO_MISSING: warning: profile data may be out of date: of 3 functions, 1 has mismatched data that will be ignored
+// NO_MISSING: warning: profile data may be out of date: of 3 functions, 2 have mismatched data that will be ignored
 // NO_MISSING-NOT: 1 has no data
 
-// WITH_MISSING: warning: profile data may be out of date: of 3 functions, 1 has mismatched data that will be ignored
+// WITH_MISSING: warning: profile data may be out of date: of 3 functions, 2 have mismatched data that will be ignored
 // WITH_MISSING: warning: profile data may be incomplete: of 3 functions, 1 has no data
 
 void no_usable_data() {
Index: cfe/trunk/test/Profile/cxx-hash-v2.cpp
===
--- cfe/trunk/test/Profile/cxx-hash-v2.cpp
+++ cfe/trunk/test/Profile/cxx-hash-v2.cpp
@@ -0,0 +1,177 @@
+// REQUIRES: shell
+
+// Check that all of the hashes in this file are unique (i.e, that none of the
+// profiles for these functions are mutually interchangeable).
+//
+// RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes
+// RUN: uniq %t.hashes > %t.hashes.unique
+// RUN: diff %t.hashes %t.hashes.unique
+
+// RUN: llvm-profdata merge %S/Inputs/cxx-hash-v2.proftext -o %t.profdata
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -allow-empty
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%S/Inputs/cxx-hash-v2.profdata.v5 2>&1 | FileCheck %s -allow-empty
+
+// CHECK-NOT: warning: profile data may be out of date
+
+int x;
+int arr[1] = {0};
+
+void loop_after_if_else() {
+  if (1)
+x = 1;
+  else
+x = 2;
+  while (0)
+++x;
+}
+
+void loop_in_then_block() {
+  if (1) {
+while (0)
+  ++x;
+  } else {
+x = 2;
+  }
+}
+
+void loop_in_else_block() {
+  if (1) {
+x = 1;
+  } else {
+while (0)
+  ++x;
+  }
+}
+
+void if_inside_of_for() {
+  for (x = 0; x < 0; ++x) {
+x = 1;
+if (1)
+  x = 2;
+  }
+}
+
+void if_outside_of_for() {
+  for (x = 0; x < 0; ++x)
+x = 1;
+  if (1)
+x = 2;
+}
+
+void if_inside_of_while() {
+  while (0) {
+x = 1;
+if (1)
+  x = 2;
+  }
+}
+
+void if_outside_of_while() {
+  while (0)
+x = 1;
+  if (1)
+x = 2;
+}
+
+void nested_dos() {
+  do {
+do {
+  ++x;
+} while (0);
+  } while (0);
+}
+
+void consecutive_dos() {
+  do {
+  } while (0);
+  do {
+++x;
+  } while (0);
+}
+
+void loop_empty() {
+  for (x = 0; x < 5; ++x) {}
+}
+
+void loop_return() {
+  for (x = 0; x < 5; ++x)
+return;
+}
+
+void loop_continue() {
+  for (x = 0; x < 5; ++x)
+continue;
+}
+
+void loop_break() {
+  for (x = 0; x < 5; ++x)
+break;
+}
+
+void no_gotos() {
+  static void *dispatch[

[PATCH] D40054: Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D40054



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


[PATCH] D40054: Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318234: Simplify CpuIs code to use include from LLVM 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D40054?vs=122936&id=122942#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40054

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -30,8 +30,9 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/TargetParser.h"
 #include 
 
 using namespace clang;
@@ -4626,8 +4627,8 @@
   case NEON::BI__builtin_neon_vsha1cq_u32:
   case NEON::BI__builtin_neon_vsha1pq_u32:
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:
 return false;
   }
   return true;
@@ -7497,78 +7498,6 @@
 
 Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
-  // This enum contains the vendor, type, and subtype enums from the
-  // runtime library concatenated together. The _START labels mark
-  // the start and are used to adjust the value into the correct
-  // encoding space.
-  enum X86CPUs {
-INTEL = 1,
-AMD,
-CPU_TYPE_START,
-INTEL_BONNELL,
-INTEL_CORE2,
-INTEL_COREI7,
-AMDFAM10H,
-AMDFAM15H,
-INTEL_SILVERMONT,
-INTEL_KNL,
-AMD_BTVER1,
-AMD_BTVER2,
-AMDFAM17H,
-CPU_SUBTYPE_START,
-INTEL_COREI7_NEHALEM,
-INTEL_COREI7_WESTMERE,
-INTEL_COREI7_SANDYBRIDGE,
-AMDFAM10H_BARCELONA,
-AMDFAM10H_SHANGHAI,
-AMDFAM10H_ISTANBUL,
-AMDFAM15H_BDVER1,
-AMDFAM15H_BDVER2,
-AMDFAM15H_BDVER3,
-AMDFAM15H_BDVER4,
-AMDFAM17H_ZNVER1,
-INTEL_COREI7_IVYBRIDGE,
-INTEL_COREI7_HASWELL,
-INTEL_COREI7_BROADWELL,
-INTEL_COREI7_SKYLAKE,
-INTEL_COREI7_SKYLAKE_AVX512,
-  };
-
-  X86CPUs CPU =
-StringSwitch(CPUStr)
-  .Case("amd", AMD)
-  .Case("amdfam10h", AMDFAM10H)
-  .Case("amdfam10", AMDFAM10H)
-  .Case("amdfam15h", AMDFAM15H)
-  .Case("amdfam15", AMDFAM15H)
-  .Case("amdfam17h", AMDFAM17H)
-  .Case("atom", INTEL_BONNELL)
-  .Case("barcelona", AMDFAM10H_BARCELONA)
-  .Case("bdver1", AMDFAM15H_BDVER1)
-  .Case("bdver2", AMDFAM15H_BDVER2)
-  .Case("bdver3", AMDFAM15H_BDVER3)
-  .Case("bdver4", AMDFAM15H_BDVER4)
-  .Case("bonnell", INTEL_BONNELL)
-  .Case("broadwell", INTEL_COREI7_BROADWELL)
-  .Case("btver1", AMD_BTVER1)
-  .Case("btver2", AMD_BTVER2)
-  .Case("core2", INTEL_CORE2)
-  .Case("corei7", INTEL_COREI7)
-  .Case("haswell", INTEL_COREI7_HASWELL)
-  .Case("intel", INTEL)
-  .Case("istanbul", AMDFAM10H_ISTANBUL)
-  .Case("ivybridge", INTEL_COREI7_IVYBRIDGE)
-  .Case("knl", INTEL_KNL)
-  .Case("nehalem", INTEL_COREI7_NEHALEM)
-  .Case("sandybridge", INTEL_COREI7_SANDYBRIDGE)
-  .Case("shanghai", AMDFAM10H_SHANGHAI)
-  .Case("silvermont", INTEL_SILVERMONT)
-  .Case("skylake", INTEL_COREI7_SKYLAKE)
-  .Case("skylake-avx512", INTEL_COREI7_SKYLAKE_AVX512)
-  .Case("slm", INTEL_SILVERMONT)
-  .Case("westmere", INTEL_COREI7_WESTMERE)
-  .Case("znver1", AMDFAM17H_ZNVER1);
-
   llvm::Type *Int32Ty = Builder.getInt32Ty();
 
   // Matching the struct layout from the compiler-rt/libgcc structure that is
@@ -7587,22 +7516,22 @@
   // range. Also adjust the expected value.
   unsigned Index;
   unsigned Value;
-  if (CPU > CPU_SUBTYPE_START) {
-Index = 2;
-Value = CPU - CPU_SUBTYPE_START;
-  } else if (CPU > CPU_TYPE_START) {
-Index = 1;
-Value = CPU - CPU_TYPE_START;
-  } else {
-Index = 0;
-Value = CPU;
-  }
+  std::tie(Index, Value) = StringSwitch>(CPUStr)
+#define X86_VENDOR(ENUM, STRING)   \
+  .Case(STRING, {0u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \
+  .Cases(STR, ALIAS, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR)   \
+  .Case(STR, {1u, static_cast(llvm::X86::ENUM)})
+#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR)\
+  .Case(STR, {2u, static_cast(llvm::X86::ENUM)})
+#include "llvm/Support/X86TargetParser.def"
+   .Default({0, 0});
+  assert(Value != 0 && "Invalid CPUStr passed to CpuIs");
 
   // Grab the appropriate field from __cpu_model.
-  llvm::Value *Idxs[] = {
-ConstantInt::get(Int32Ty, 0),
-ConstantInt::get(Int32Ty, Index)
-  };
+  llvm::Value *Id

r318234 - Simplify CpuIs code to use include from LLVM

2017-11-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Nov 14 16:11:24 2017
New Revision: 318234

URL: http://llvm.org/viewvc/llvm-project?rev=318234&view=rev
Log:
Simplify CpuIs code to use include from LLVM

LLVM exposes a file in the backend (X86TargetParser.def) that
contains information about the correct list of CpuIs values.

This patch removes 2 of the copied and pasted versions of this
list from clang and instead includes the data from the .def file.

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

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318234&r1=318233&r2=318234&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Nov 14 16:11:24 2017
@@ -1291,36 +1291,12 @@ bool X86TargetInfo::validateCpuSupports(
 // rather than the full range of cpus.
 bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const {
   return llvm::StringSwitch(FeatureStr)
-  .Case("amd", true)
-  .Case("amdfam10h", true)
-  .Case("amdfam15h", true)
-  .Case("amdfam17h", true)
-  .Case("atom", true)
-  .Case("barcelona", true)
-  .Case("bdver1", true)
-  .Case("bdver2", true)
-  .Case("bdver3", true)
-  .Case("bdver4", true)
-  .Case("bonnell", true)
-  .Case("broadwell", true)
-  .Case("btver1", true)
-  .Case("btver2", true)
-  .Case("core2", true)
-  .Case("corei7", true)
-  .Case("haswell", true)
-  .Case("intel", true)
-  .Case("istanbul", true)
-  .Case("ivybridge", true)
-  .Case("knl", true)
-  .Case("nehalem", true)
-  .Case("sandybridge", true)
-  .Case("shanghai", true)
-  .Case("silvermont", true)
-  .Case("skylake", true)
-  .Case("skylake-avx512", true)
-  .Case("slm", true)
-  .Case("westmere", true)
-  .Case("znver1", true)
+#define X86_VENDOR(ENUM, STRING) .Case(STRING, true)
+#define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) 
\
+  .Cases(STR, ALIAS, true)
+#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true)
+#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true)
+#include "llvm/Support/X86TargetParser.def"
   .Default(false);
 }
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=318234&r1=318233&r2=318234&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Nov 14 16:11:24 2017
@@ -30,8 +30,9 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/TargetParser.h"
 #include 
 
 using namespace clang;
@@ -4626,8 +4627,8 @@ static bool HasExtraNeonArgument(unsigne
   case NEON::BI__builtin_neon_vsha1cq_u32:
   case NEON::BI__builtin_neon_vsha1pq_u32:
   case NEON::BI__builtin_neon_vsha1mq_u32:
-  case ARM::BI_MoveToCoprocessor:
-  case ARM::BI_MoveToCoprocessor2:
+  case clang::ARM::BI_MoveToCoprocessor:
+  case clang::ARM::BI_MoveToCoprocessor2:
 return false;
   }
   return true;
@@ -7497,78 +7498,6 @@ Value *CodeGenFunction::EmitX86CpuIs(con
 
 Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
-  // This enum contains the vendor, type, and subtype enums from the
-  // runtime library concatenated together. The _START labels mark
-  // the start and are used to adjust the value into the correct
-  // encoding space.
-  enum X86CPUs {
-INTEL = 1,
-AMD,
-CPU_TYPE_START,
-INTEL_BONNELL,
-INTEL_CORE2,
-INTEL_COREI7,
-AMDFAM10H,
-AMDFAM15H,
-INTEL_SILVERMONT,
-INTEL_KNL,
-AMD_BTVER1,
-AMD_BTVER2,
-AMDFAM17H,
-CPU_SUBTYPE_START,
-INTEL_COREI7_NEHALEM,
-INTEL_COREI7_WESTMERE,
-INTEL_COREI7_SANDYBRIDGE,
-AMDFAM10H_BARCELONA,
-AMDFAM10H_SHANGHAI,
-AMDFAM10H_ISTANBUL,
-AMDFAM15H_BDVER1,
-AMDFAM15H_BDVER2,
-AMDFAM15H_BDVER3,
-AMDFAM15H_BDVER4,
-AMDFAM17H_ZNVER1,
-INTEL_COREI7_IVYBRIDGE,
-INTEL_COREI7_HASWELL,
-INTEL_COREI7_BROADWELL,
-INTEL_COREI7_SKYLAKE,
-INTEL_COREI7_SKYLAKE_AVX512,
-  };
-
-  X86CPUs CPU =
-StringSwitch(CPUStr)
-  .Case("amd", AMD)
-  .Case("amdfam10h", AMDFAM10H)
-  .Case("amdfam10", AMDFAM10H)
-  .Case("amdfam15h", AMDFAM15H)
-  .Case("amdfam15", AMDFAM15H)
-  .Case("amdfam17h", AMDFAM17H)
-  .Case("atom", INTEL_BONNELL)
-  .Case("barcelona", AMDFAM10H_BARCELONA)
-  .Case("bdver1", AMDFAM15H_BDVER1)
-  .Case("bdver2", AMDFAM15H_BDVER2)
-  .Case("bdver3", AMDFAM15H_BD

[libcxx] r318236 - Merging r313776:

2017-11-14 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Nov 14 16:21:20 2017
New Revision: 318236

URL: http://llvm.org/viewvc/llvm-project?rev=318236&view=rev
Log:
Merging r313776:


r313776 | marshall | 2017-09-20 10:34:11 -0700 (Wed, 20 Sep 2017) | 1 line

Fix a bit of UB in __independent_bits_engine. Fixes PR#34663


Modified:
libcxx/branches/release_50/include/algorithm

Modified: libcxx/branches/release_50/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/algorithm?rev=318236&r1=318235&r2=318236&view=diff
==
--- libcxx/branches/release_50/include/algorithm (original)
+++ libcxx/branches/release_50/include/algorithm Tue Nov 14 16:21:20 2017
@@ -3013,6 +3013,7 @@ template
 _UIntType
 __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
 {
+const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0_; ++__k)
 {
@@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y0_);
-if (__w0_ < _WDt)
+if (__w0_ < _WRt)
 _Sp <<= __w0_;
 else
 _Sp = 0;
@@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y1_);
-if (__w0_ < _WDt - 1)
+if (__w0_ < _WRt - 1)
 _Sp <<= __w0_ + 1;
 else
 _Sp = 0;


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


[PATCH] D39913: [ObjC] warn about availability attributes missing from a method's declaration when they're specified for a method's definition

2017-11-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D39913#924131, @ahatanak wrote:

> Is it not necessary to print a diagnostic when a non-member function 
> declaration is missing an availability attribute?
>
>   void foo1();
>  
>   __attribute__((availability(macos, introduced=10.1)))
>   void foo1() {
>   }
>


It's harder as we don't know the distinction between declaration/definition at 
merge time. Right now the C++ implementation of this warning actually checks 
the attributes too late, after they're merged. I'll take out the C++/C support 
completely and keep to ObjC in this patch for simplicity. The rest can be 
supported later.


Repository:
  rL LLVM

https://reviews.llvm.org/D39913



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


[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Let's keep the complete review thread together on 
https://reviews.llvm.org/D5767.


https://reviews.llvm.org/D38818



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


[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

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

LGTM


https://reviews.llvm.org/D5767



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


[PATCH] D39913: [ObjC] warn about availability attributes missing from a method's declaration when they're specified for a method's definition

2017-11-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 122949.
arphaman added a comment.

Remove C++ support for now (it will be in a followup patch along with 
non-member function support).


Repository:
  rL LLVM

https://reviews.llvm.org/D39913

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/method-attributes.m
  test/SemaObjC/unguarded-availability.m
  test/SemaObjC/warn-missing-method-decl-availability.m

Index: test/SemaObjC/warn-missing-method-decl-availability.m
===
--- /dev/null
+++ test/SemaObjC/warn-missing-method-decl-availability.m
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Warn about availability attribute when they're specified in the definition
+// of the method instead of the declaration.
+// rdar://15540962
+
+@interface MissingAvailabilityThingsInInterface
+
+- (void)missingIDO; // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+
+- (void)missingDO __attribute__((availability(macos, introduced=10.1))); // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+
+- (void)missingD __attribute__((availability(macos, introduced=10.1))); // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+
+- (void)missingIx2; // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+// expected-warning@-1 {{method declaration is missing an availability attribute for iOS that is specified in the definition}}
+
+- (void)missingIDOiOS __attribute__((availability(macos, introduced=10.1))); // expected-warning {{method declaration is missing an availability attribute for iOS that is specified in the definition}}
+
+- (void)differentIMissingD __attribute__((availability(macos, introduced=10.1))); // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+// expected-note@-1 {{previous attribute is here}}
+
+- (void)missingUnavailable; // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+
+- (void)same
+__attribute__((availability(macos, introduced=10.1)))
+__attribute__((availability(ios, unavailable)));
+
+- (void)missingDeprecatedAttr; // expected-warning {{method declaration is missing a deprecated attribute that is specified in the definition}}
+
+- (void)sameDeprecatedAttr __attribute__((deprecated("y")));
+
+@end
+
+@interface MissingAvailabilityThingsInInterface()
+
+- (void)missingInClassExtension; // expected-warning {{method declaration is missing an availability attribute for macOS that is specified in the definition}}
+
+@end
+
+@implementation MissingAvailabilityThingsInInterface
+
+- (void)missingIDO
+__attribute__((availability(macos, introduced=10.1, deprecated=10.2, obsoleted=10.3))) // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)missingDO
+__attribute__((availability(macos, introduced=10.1)))
+__attribute__((availability(macos, deprecated=10.2, obsoleted=10.3))) // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)missingD
+__attribute__((availability(macos, introduced=10.1, deprecated=10.2))) // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)missingIx2
+__attribute__((availability(ios, introduced=10))) // expected-note {{definition with iOS availability attribute is here}}
+__attribute__((availability(macos, introduced=10.1))) // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)missingIDOiOS
+__attribute__((availability(ios, introduced=10, deprecated=11, obsoleted=11.1))) // expected-note {{definition with iOS availability attribute is here}}
+__attribute__((availability(macOS, introduced=10.1)))
+{ }
+
+- (void)differentIMissingD __attribute__((availability(macos, introduced=10.2, deprecated=10.3))) // expected-note {{definition with macOS availability attribute is here}}
+{ } // expected-warning@-1{{availability does not match previous declaration}}
+
+- (void)missingInClassExtension
+__attribute__((availability(macos, introduced=10.1, deprecated=10.2))) // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)missingUnavailable
+__attribute__((availability(macos, unavailable))); // expected-note {{definition with macOS availability attribute is here}}
+{ }
+
+- (void)same
+__attribute__((availability(macos, introduced=10.1)))
+__attribute__((availability(ios, unavailable)))
+{ }
+
+- (void)missingDeprecatedAttr
+__attribute__((deprecated("x")))  // expected-n

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-14 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 122953.
Wizard added a comment.

new line


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using @throw to handle Objective-C exceptions [google-objc-avoid-throwing-exception]
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+===
+
+This check finds @throw usages in Objective-C files. According to Google's Objective-C
+Guide, we should not use @throw to handle exceptions.
+
+The corresponding style guide rule:
+http://go/objc-style#Avoid_Throwing_Exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect usage of @throw in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjcExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 CheckFactories.registerCheck(
 "google-objc-global-variable-declaration");
 CheckFactories.registerCheck(
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  AvoidThrowingObjcExceptionCheck.cpp
   DefaultArgumentsCheck.cpp
   ExplicitConstructorCheck.cpp
   ExplicitMakePairCheck.cpp
Index: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
===
--- /dev/null
+++ clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
@@ -0,0 +1,39 @@
+//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy--*- 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_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+/// The check is to find usage of @throw invocation in Objective-C code.
+/// We should avoid using @throw for Objective-C exceptions according to
+/// Goo

[libcxx] r318244 - Added tests for xxx.size() and xxx.empty() for all the sequence containers

2017-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Nov 14 17:33:33 2017
New Revision: 318244

URL: http://llvm.org/viewvc/llvm-project?rev=318244&view=rev
Log:
Added tests for xxx.size() and xxx.empty() for all the sequence containers

Added:

libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.capacity/size.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector.bool/empty.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp

Added: 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp?rev=318244&view=auto
==
--- 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.pass.cpp 
Tue Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class deque
+
+// bool empty() const noexcept;
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+{
+typedef std::deque C;
+C c;
+ASSERT_NOEXCEPT(c.empty());
+assert(c.empty());
+c.push_back(C::value_type(1));
+assert(!c.empty());
+c.clear();
+assert(c.empty());
+}
+#if TEST_STD_VER >= 11
+{
+typedef std::deque> C;
+C c;
+ASSERT_NOEXCEPT(c.empty());
+assert(c.empty());
+c.push_back(C::value_type(1));
+assert(!c.empty());
+c.clear();
+assert(c.empty());
+}
+#endif
+}

Added: 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp?rev=318244&view=auto
==
--- 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/size.pass.cpp 
Tue Nov 14 17:33:33 2017
@@ -0,0 +1,62 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class deque
+
+// size_type size() const noexcept;
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+{
+typedef std::deque C;
+C c;
+ASSERT_NOEXCEPT(c.size());
+assert(c.size() == 0);
+c.push_back(C::value_type(2));
+assert(c.size() == 1);
+c.push_back(C::value_type(1));
+assert(c.size() == 2);
+c.push_back(C::value_type(3));
+assert(c.size() == 3);
+c.erase(c.begin());
+assert(c.size() == 2);
+c.erase(c.begin());
+assert(c.size() == 1);
+c.erase(c.begin());
+assert(c.size() == 0);
+}
+#if TEST_STD_VER >= 11
+{
+typedef std::deque> C;
+C c;
+ASSERT_NOEXCEPT(c.size());
+assert(c.size() == 0);
+c.push_back(C::value_type(2));
+assert(c.size() == 1);
+c.push_back(C::value_type(1));
+assert(c.size() == 2);
+c.push_back(C::value_type(3));
+assert(c.size() == 3);
+c.erase(c.begin());
+assert(c.size() == 2);
+c.erase(c.begin());
+assert(c.size() == 1);
+c.erase(c.begin());
+assert(c.size() == 0);
+}
+#endif
+}

Added: libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp?rev=318244&view=auto
==
--- libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp 
(added)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/empty.pass.cpp Tue 
Nov 14 17:33:33 2017
@@ -0,0 +1,46 @@
+//===--

r318245 - [modules] Fix crash in complex class merging scenario.

2017-11-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 14 17:33:46 2017
New Revision: 318245

URL: http://llvm.org/viewvc/llvm-project?rev=318245&view=rev
Log:
[modules] Fix crash in complex class merging scenario.

When we merge together class definitions, we can end up with the canonical
declaration of a field not being the one that was lexically within the
canonical definition of the class. Additionally, when we merge class
definitions via update records (eg, for a template specialization whose
declaration is instantiated in one module and whose definition is instantiated
in multiple others), we can end up with the list of lexical contents for the
class not including a particular declaration of a field whose lexical parent is
that class definition. In the worst case, we have a field whose canonical
declaration's lexical parent has no fields, and in that case this attempt to
number the fields by walking the fields in the declaration of the class that
contained one of the canonical fields will fail.

Instead, when numbering fields in a class, do the obvious thing: walk the
fields in the definition.

I'm still trying to reduce a testcase; the setup that leads to the above
scenario seems to be quite fragile.

Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=318245&r1=318244&r2=318245&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Nov 14 17:33:46 2017
@@ -3630,7 +3630,8 @@ unsigned FieldDecl::getFieldIndex() cons
   if (CachedFieldIndex) return CachedFieldIndex - 1;
 
   unsigned Index = 0;
-  const RecordDecl *RD = getParent();
+  const RecordDecl *RD = getParent()->getDefinition();
+  assert(RD && "requested index for field of struct with no definition");
 
   for (auto *Field : RD->fields()) {
 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;


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


[libcxx] r318247 - Update Appveyor LLVM install link to be current and non-broken

2017-11-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Nov 14 17:37:11 2017
New Revision: 318247

URL: http://llvm.org/viewvc/llvm-project?rev=318247&view=rev
Log:
Update Appveyor LLVM install link to be current and non-broken

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

Modified: libcxx/trunk/appveyor-reqs-install.cmd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor-reqs-install.cmd?rev=318247&r1=318246&r2=318247&view=diff
==
--- libcxx/trunk/appveyor-reqs-install.cmd (original)
+++ libcxx/trunk/appveyor-reqs-install.cmd Tue Nov 14 17:37:11 2017
@@ -9,7 +9,7 @@ cd C:\projects\deps
 :: Setup Compiler
 ::###
 if NOT EXIST llvm-installer.exe (
-  appveyor DownloadFile 
http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r303050-win32.exe 
-FileName llvm-installer.exe
+  appveyor DownloadFile 
http://prereleases.llvm.org/win-snapshots/LLVM-6.0.0-r316086-win32.exe 
-FileName llvm-installer.exe
 )
 if "%CLANG_VERSION%"=="ToT" (
 START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"


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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added a subscriber: mgorny.

This will be used for rescoring code completion results based on partial
identifiers.
Short-term use:

- we want to limit the number of code completion results returned to improve 
performance of global completion. The scorer will be used to rerank the results 
to return when the user has applied a filter.

Long-term use case:

- ranking of completion results from in-memory index
- merging of completion results from multiple sources (merging usually works 
best when done at the component-score level, rescoring the fuzzy-match quality 
avoids different backends needing to have comparable scores)


https://reviews.llvm.org/D40060

Files:
  clangd/CMakeLists.txt
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- /dev/null
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -0,0 +1,122 @@
+//===-- FuzzyMatchTests.cpp - String fuzzy matcher tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using namespace llvm;
+using testing::Not;
+
+struct MatchesMatcher : public testing::MatcherInterface {
+  StringRef Candidate;
+  MatchesMatcher(StringRef Candidate) : Candidate(Candidate) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Matches '" << Candidate.str() << "'";
+  }
+
+  bool MatchAndExplain(StringRef Pattern, testing::MatchResultListener *L) const override{
+std::unique_ptr OS(L->stream() ? (raw_ostream*)(new raw_os_ostream(*L->stream())) : new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+auto Result = Matcher.match(Candidate);
+Matcher.dumpLast(*OS << "\n");
+return !!Result;
+  }
+};
+
+// Accepts patterns that match a given word.
+// Dumps the debug tables on match failure.
+testing::Matcher matches(StringRef Word) {
+return testing::MakeMatcher(new MatchesMatcher(Word));
+}
+
+TEST(FuzzyMatch, Matches) {
+  EXPECT_THAT("u_p", matches("unique_ptr"));
+  EXPECT_THAT("up", matches("unique_ptr"));
+  EXPECT_THAT("uq", matches("unique_ptr"));
+  EXPECT_THAT("qp", Not(matches("unique_ptr")));
+  EXPECT_THAT("log", Not(matches("SVGFEMorphologyElement")));
+}
+
+struct RankMatcher : public testing::MatcherInterface {
+  std::vector RankedStrings;
+  RankMatcher(std::initializer_list RankedStrings)
+  : RankedStrings(RankedStrings) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Ranks strings in order: ["
+<< join(RankedStrings.begin(), RankedStrings.end(), ", ") << "]";
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+StringRef LastString;
+Optional LastScore;
+bool Ok = true;
+for (StringRef Str : RankedStrings) {
+  auto Score = Matcher.match(Str);
+  if (!Score) {
+*OS << "\nDoesn't match '" << Str.str() << "'";
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  } else if (LastScore && *LastScore < *Score) {
+*OS << "\nRanks '" << Str.str() << "'=" << *Score << " above '"
+<< LastString.str() << "'=" << *LastScore;
+Matcher.dumpLast(*OS << "\n");
+Matcher.match(LastString);
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  }
+  LastString = Str;
+  LastScore = Score;
+}
+return Ok;
+  }
+};
+
+// Accepts patterns that match all the strings and rank them in the given order.
+// Dumps the debug tables on match failure.
+template 
+testing::Matcher ranks(T... RankedStrings) {
+  return testing::MakeMatcher(new RankMatcher{RankedStrings...});
+}
+
+TEST(FuzzyMatch, Ranking) {
+  EXPECT_THAT("eb", ranks("emplace_back", "embed"));
+  EXPECT_THAT("cons", ranks("console", "Console", "ArrayBufferConstructor"));
+  EXPECT_THAT("foo", ranks("foo", "Foo"));
+  EXPECT_THAT("onMess", ranks("onMessage", "onmessage", "onThisMegaEscapes"));
+  EXPECT_THAT("CC", ranks("CamelCase", "camelCase"));
+  EXPECT_THAT("cC", ranks("camelCase", "CamelCase"));
+  EXPECT_THAT("p", ranks("parse", "posix", "pafdsa", "path", "p"));
+  EXPECT_THAT("pa", ranks("parse", "path", "pafdsa"));
+  EXPECT_THAT("log", ranks("log", "ScrollLogicalPosition"));
+  EXPECT_THAT("e", ranks("else", "AbstractElement"));
+  EXPECT_THAT("workbench

[PATCH] D39579: BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaOverload.cpp:7618
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  SmallVector ArithmeticTypes;
+

Can we do better than a magic number here? I don't like that getting this wrong 
will lead to a silent performance change. (Can we at least assert `isSmall()` 
below or something?)


https://reviews.llvm.org/D39579



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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 122956.
sammccall added a comment.

clang-format


https://reviews.llvm.org/D40060

Files:
  clangd/CMakeLists.txt
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- /dev/null
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -0,0 +1,130 @@
+//===-- FuzzyMatchTests.cpp - String fuzzy matcher tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using namespace llvm;
+using testing::Not;
+
+struct MatchesMatcher : public testing::MatcherInterface {
+  StringRef Candidate;
+  MatchesMatcher(StringRef Candidate) : Candidate(Candidate) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Matches '" << Candidate.str() << "'";
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+auto Result = Matcher.match(Candidate);
+Matcher.dumpLast(*OS << "\n");
+return !!Result;
+  }
+};
+
+// Accepts patterns that match a given word.
+// Dumps the debug tables on match failure.
+testing::Matcher matches(StringRef Word) {
+  return testing::MakeMatcher(new MatchesMatcher(Word));
+}
+
+TEST(FuzzyMatch, Matches) {
+  EXPECT_THAT("u_p", matches("unique_ptr"));
+  EXPECT_THAT("up", matches("unique_ptr"));
+  EXPECT_THAT("uq", matches("unique_ptr"));
+  EXPECT_THAT("qp", Not(matches("unique_ptr")));
+  EXPECT_THAT("log", Not(matches("SVGFEMorphologyElement")));
+}
+
+struct RankMatcher : public testing::MatcherInterface {
+  std::vector RankedStrings;
+  RankMatcher(std::initializer_list RankedStrings)
+  : RankedStrings(RankedStrings) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+*OS << "Ranks strings in order: ["
+<< join(RankedStrings.begin(), RankedStrings.end(), ", ") << "]";
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+StringRef LastString;
+Optional LastScore;
+bool Ok = true;
+for (StringRef Str : RankedStrings) {
+  auto Score = Matcher.match(Str);
+  if (!Score) {
+*OS << "\nDoesn't match '" << Str.str() << "'";
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  } else if (LastScore && *LastScore < *Score) {
+*OS << "\nRanks '" << Str.str() << "'=" << *Score << " above '"
+<< LastString.str() << "'=" << *LastScore;
+Matcher.dumpLast(*OS << "\n");
+Matcher.match(LastString);
+Matcher.dumpLast(*OS << "\n");
+Ok = false;
+  }
+  LastString = Str;
+  LastScore = Score;
+}
+return Ok;
+  }
+};
+
+// Accepts patterns that match all the strings and rank them in the given order.
+// Dumps the debug tables on match failure.
+template  testing::Matcher ranks(T... RankedStrings) {
+  return testing::MakeMatcher(new RankMatcher{RankedStrings...});
+}
+
+TEST(FuzzyMatch, Ranking) {
+  EXPECT_THAT("eb", ranks("emplace_back", "embed"));
+  EXPECT_THAT("cons", ranks("console", "Console", "ArrayBufferConstructor"));
+  EXPECT_THAT("foo", ranks("foo", "Foo"));
+  EXPECT_THAT("onMess", ranks("onMessage", "onmessage", "onThisMegaEscapes"));
+  EXPECT_THAT("CC", ranks("CamelCase", "camelCase"));
+  EXPECT_THAT("cC", ranks("camelCase", "CamelCase"));
+  EXPECT_THAT("p", ranks("parse", "posix", "pafdsa", "path", "p"));
+  EXPECT_THAT("pa", ranks("parse", "path", "pafdsa"));
+  EXPECT_THAT("log", ranks("log", "ScrollLogicalPosition"));
+  EXPECT_THAT("e", ranks("else", "AbstractElement"));
+  EXPECT_THAT("workbench.sideb",
+  ranks("workbench.sideBar.location",
+"workbench.editor.defaultSideBySideLayout"));
+  EXPECT_THAT("editor.r", ranks("editor.renderControlCharacter",
+"editor.overviewRulerlanes",
+"diffEditor.renderSideBySide"));
+  EXPECT_THAT("-mo", ranks("-moz-columns", "-ms-ime-mode"));
+  EXPECT_THAT("convertModelPosition",
+  ranks("convertModelPositionToViewPosition",
+"convertViewToModelPositio

[PATCH] D40062: Update tests for llvm.invariant.group.barrier becoming mangled

2017-11-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added subscribers: Prazek, wdng.

https://reviews.llvm.org/D40062

Files:
  test/CodeGenCXX/invariant.group-for-vptrs.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -53,7 +53,7 @@
 };
 
 // CHECK-NEW-LABEL: define void @_Z12LocalObjectsv()
-// CHECK-NEW-NOT: @llvm.invariant.group.barrier(
+// CHECK-NEW-NOT: @llvm.invariant.group.barrier.p0i8(
 // CHECK-NEW-LABEL: {{^}}}
 void LocalObjects() {
   DynamicBase1 DB;
@@ -81,20 +81,20 @@
 
 struct DynamicFromVirtualStatic1;
 // CHECK-CTORS-LABEL: define linkonce_odr void @_ZN25DynamicFromVirtualStatic1C1Ev
-// CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
+// CHECK-CTORS-NOT: @llvm.invariant.group.barrier.p0i8(
 // CHECK-CTORS-LABEL: {{^}}}
 
 struct DynamicFrom2Virtuals;
 // CHECK-CTORS-LABEL: define linkonce_odr void @_ZN20DynamicFrom2VirtualsC1Ev
-// CHECK-CTORS: call i8* @llvm.invariant.group.barrier(
+// CHECK-CTORS: call i8* @llvm.invariant.group.barrier.p0i8(
 // CHECK-CTORS-LABEL: {{^}}}
 
 
 // CHECK-NEW-LABEL: define void @_Z9Pointers1v()
-// CHECK-NEW-NOT: @llvm.invariant.group.barrier(
+// CHECK-NEW-NOT: @llvm.invariant.group.barrier.p0i8(
 // CHECK-NEW-LABEL: call void @_ZN12DynamicBase1C1Ev(
 
-// CHECK-NEW: %[[THIS3:.*]] = call i8* @llvm.invariant.group.barrier(i8* %[[THIS2:.*]])
+// CHECK-NEW: %[[THIS3:.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* %[[THIS2:.*]])
 // CHECK-NEW: %[[THIS4:.*]] = bitcast i8* %[[THIS3]] to %[[DynamicDerived:.*]]*
 // CHECK-NEW: call void @_ZN14DynamicDerivedC1Ev(%[[DynamicDerived:.*]]* %[[THIS4]])
 // CHECK-NEW-LABEL: {{^}}}
@@ -109,9 +109,9 @@
 
 // CHECK-NEW-LABEL: define void @_Z14HackingObjectsv()
 // CHECK-NEW:  call void @_ZN12DynamicBase1C1Ev
-// CHECK-NEW:  call i8* @llvm.invariant.group.barrier(
+// CHECK-NEW:  call i8* @llvm.invariant.group.barrier.p0i8(
 // CHECK-NEW:  call void @_ZN14DynamicDerivedC1Ev(
-// CHECK-NEW:  call i8* @llvm.invariant.group.barrier(
+// CHECK-NEW:  call i8* @llvm.invariant.group.barrier.p0i8(
 // CHECK-NEW: call void @_ZN12DynamicBase1C1Ev(
 // CHECK-NEW-LABEL: {{^}}}
 void HackingObjects() {
@@ -131,16 +131,16 @@
 /*** Testing Constructors ***/
 struct DynamicBase1;
 // CHECK-CTORS-LABEL: define linkonce_odr void @_ZN12DynamicBase1C2Ev(
-// CHECK-CTORS-NOT: call i8* @llvm.invariant.group.barrier(
+// CHECK-CTORS-NOT: call i8* @llvm.invariant.group.barrier.p0i8(
 // CHECK-CTORS-LABEL: {{^}}}
 
 
 struct DynamicDerived;
 
 // CHECK-CTORS-LABEL: define linkonce_odr void @_ZN14DynamicDerivedC2Ev(
 // CHECK-CTORS: %[[THIS0:.*]] = load %[[DynamicDerived:.*]]*, %[[DynamicDerived]]** {{.*}}
 // CHECK-CTORS: %[[THIS1:.*]] = bitcast %[[DynamicDerived:.*]]* %[[THIS0]] to i8*
-// CHECK-CTORS: %[[THIS2:.*]] = call i8* @llvm.invariant.group.barrier(i8* %[[THIS1:.*]])
+// CHECK-CTORS: %[[THIS2:.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* %[[THIS1:.*]])
 // CHECK-CTORS: %[[THIS3:.*]] = bitcast i8* %[[THIS2]] to %[[DynamicDerived]]*
 // CHECK-CTORS: %[[THIS4:.*]] = bitcast %[[DynamicDerived]]* %[[THIS3]] to %[[DynamicBase:.*]]*
 // CHECK-CTORS: call void @_ZN12DynamicBase1C2Ev(%[[DynamicBase]]* %[[THIS4]])
@@ -154,15 +154,15 @@
 
 // CHECK-CTORS: %[[THIS0:.*]] = load %[[CLASS:.*]]*, %[[CLASS]]** {{.*}}
 // CHECK-CTORS: %[[THIS1:.*]] = bitcast %[[CLASS:.*]]* %[[THIS0]] to i8*
-// CHECK-CTORS: %[[THIS2:.*]] = call i8* @llvm.invariant.group.barrier(i8* %[[THIS1]])
+// CHECK-CTORS: %[[THIS2:.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* %[[THIS1]])
 // CHECK-CTORS: %[[THIS3:.*]] = bitcast i8* %[[THIS2]] to %[[CLASS]]*
 // CHECK-CTORS: %[[THIS4:.*]] = bitcast %[[CLASS]]* %[[THIS3]] to %[[BASE_CLASS:.*]]*
 // CHECK-CTORS: call void @_ZN12DynamicBase1C2Ev(%[[BASE_CLASS]]* %[[THIS4]])
 
-// CHECK-CTORS: call i8* @llvm.invariant.group.barrier(
+// CHECK-CTORS: call i8* @llvm.invariant.group.barrier.p0i8(
 
 // CHECK-CTORS: call void @_ZN12DynamicBase2C2Ev(
-// CHECK-CTORS-NOT: @llvm.invariant.group.barrier
+// CHECK-CTORS-NOT: @llvm.invariant.group.barrier.p0i8
 
 
 // CHECK-CTORS: %[[THIS10:.*]] = bitcast %struct.DynamicDerivedMultiple* %[[THIS0]] to i32 (...)***
@@ -177,7 +177,7 @@
 
 struct DynamicFromStatic;
 // CHECK-CTORS-LABEL: define linkonce_odr void @_ZN17DynamicFromStaticC2Ev(
-// CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
+// CHECK-CTORS-NOT: @llvm.invariant.group.barrier.p0i8(
 // CHECK-CTORS-LABEL: {{^}}}
 
 struct A {
@@ -206,15 +206,15 @@
 void UnionsBarriers(U *u) {
   // CHECK-NEW: call void @_Z9changeToBP1U(
   changeToB(u);
-  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier.p0i8(i8*
   // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
   g2(&u->b);
   // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* 
   changeToA(u);
-  // CHECK-NEW: call i8

[libcxx] r318256 - More missing tests - array<>::size() and array<>::max_size()

2017-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Nov 14 18:31:14 2017
New Revision: 318256

URL: http://llvm.org/viewvc/llvm-project?rev=318256&view=rev
Log:
More missing tests - array<>::size() and array<>::max_size()

Added:
libcxx/trunk/test/std/containers/sequences/array/empty.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/max_size.pass.cpp

Added: libcxx/trunk/test/std/containers/sequences/array/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/empty.pass.cpp?rev=318256&view=auto
==
--- libcxx/trunk/test/std/containers/sequences/array/empty.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/array/empty.pass.cpp Tue Nov 14 
18:31:14 2017
@@ -0,0 +1,36 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class array
+
+// bool empty() const noexcept;
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+{
+typedef std::array C;
+C c;
+ASSERT_NOEXCEPT(c.empty());
+assert(!c.empty());
+}
+{
+typedef std::array C;
+C c;
+ASSERT_NOEXCEPT(c.empty());
+assert( c.empty());
+}
+}

Added: libcxx/trunk/test/std/containers/sequences/array/max_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/max_size.pass.cpp?rev=318256&view=auto
==
--- libcxx/trunk/test/std/containers/sequences/array/max_size.pass.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/array/max_size.pass.cpp Tue Nov 
14 18:31:14 2017
@@ -0,0 +1,36 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// class array
+
+// bool max_size() const noexcept;
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main()
+{
+{
+typedef std::array C;
+C c;
+ASSERT_NOEXCEPT(c.max_size());
+assert(c.max_size() == 2);
+}
+{
+typedef std::array C;
+C c;
+ASSERT_NOEXCEPT(c.max_size());
+assert(c.max_size() == 0);
+}
+}


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


  1   2   >