[PATCH] D33314: clang-format: Add option to remove semicolon at end of namespace

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I stumbled on the issue when working on the CompactNamespaces 
 option, where the extra semicolon prevents 
merging the closing braces.
There was an easy fix, which guaranteed that the closing braces would be 
properly merged, so I went for it, just adding an option to keep things generic.

So there wasn't really a "long term" plan (though since I made the fix, I have 
though that it would be nice to remove other cases of extra semicolon, e.g. 
after function body).

I did not know of this 'Cleaner' class (I did not actually try to find it 
either, thruth be told), but it would seem more appropriate indeed. The only 
thing is I could not find where this is called, and esp. confirm if it happens 
before the NamespaceEndCommentsFixer.

Back to the point, I can see a few options here:

- Merge this patch into the CompactNamespaces patch, but remove the option and 
drop the semicolon only when CompactNamespaces mode is enabled
- Rework CompactNamespaces to merge namespace closing brace with extra 
semicolon (not a big fan, it would look very strange: `};}`)
- Implement this in a more generic fashion, in the Cleaner, with no style 
option (e.g. always on). Possibly the better option, but may be a more 
significant significant undertaking


https://reviews.llvm.org/D33314



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


[PATCH] D33314: clang-format: Add option to remove semicolon at end of namespace

2017-05-19 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I think we should just not do this for now. This addresses a very infrequent 
case that's easy enough to fix manually. As such, it's not worth the added 
complexity of clang-format and potential failures it might generate. Changing 
non-whitespace/non-comment code is always dangerous.

What's the current behavior of the compact namespaces in the presence of 
semicolons?


https://reviews.llvm.org/D33314



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


[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0

2017-05-19 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Is everyone ok with sending this patch?


https://reviews.llvm.org/D32401



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


[PATCH] D33053: [PowerPC] Implement vec_xxpermdi builtin.

2017-05-19 Thread Hiroshi Inoue via Phabricator via cfe-commits
inouehrs added inline comments.



Comment at: test/CodeGen/builtins-ppc-error.c:23
+void testXXPERMDI(void) {
+  int index = 5;
+  vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, 
expected at least 3, have 1}}

I am not sure we can assure that clang always do a constant propagation to 
resolve `index` as a compile time constant. But it seems that an existing test 
case above already assumes clang does it. 
IMO, `const unsigned index = 5;` is a little better.


https://reviews.llvm.org/D33053



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


[PATCH] D33350: [clangd] Switch to incomplete translation units

2017-05-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.

This speeds up code completion. All the cool kids (ycmd) are doing it.


https://reviews.llvm.org/D33350

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -45,7 +45,7 @@
   ArgP, ArgP + ArgStrs.size(), PCHs, Diags, ResourceDir,
   /*OnlyLocalDecls=*/false, /*CaptureDiagnostics=*/true, RemappedSource,
   /*RemappedFilesKeepOriginalName=*/true,
-  /*PrecompilePreambleAfterNParses=*/1, /*TUKind=*/TU_Complete,
+  /*PrecompilePreambleAfterNParses=*/1, /*TUKind=*/TU_Prefix,
   /*CacheCodeCompletionResults=*/true,
   /*IncludeBriefCommentsInCodeCompletion=*/true,
   /*AllowPCHWithCompilerErrors=*/true));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -45,7 +45,7 @@
   ArgP, ArgP + ArgStrs.size(), PCHs, Diags, ResourceDir,
   /*OnlyLocalDecls=*/false, /*CaptureDiagnostics=*/true, RemappedSource,
   /*RemappedFilesKeepOriginalName=*/true,
-  /*PrecompilePreambleAfterNParses=*/1, /*TUKind=*/TU_Complete,
+  /*PrecompilePreambleAfterNParses=*/1, /*TUKind=*/TU_Prefix,
   /*CacheCodeCompletionResults=*/true,
   /*IncludeBriefCommentsInCodeCompletion=*/true,
   /*AllowPCHWithCompilerErrors=*/true));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33350: [clangd] Switch to incomplete translation units

2017-05-19 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D33350



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


r303414 - CodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, possibly obsolete. [-Wdocumentation]

2017-05-19 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri May 19 05:19:59 2017
New Revision: 303414

URL: http://llvm.org/viewvc/llvm-project?rev=303414&view=rev
Log:
CodeGenFunction::EmitPointerWithAlignment(): Prune a \param in r303358, 
possibly obsolete. [-Wdocumentation]

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=303414&r1=303413&r2=303414&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri May 19 05:19:59 2017
@@ -3752,21 +3752,6 @@ public:
   ///
   /// Note that this function will conservatively fall back on the type
   /// when it doesn't 
-  ///
-  /// \param Source - If non-null, this will be initialized with
-  ///   information about the source of the alignment.  Note that this
-  ///   function will conservatively fall back on the type when it
-  ///   doesn't recognize the expression, which means that sometimes
-  ///   
-  ///   a worst-case One
-  ///   reasonable way to use this information is when there's a
-  ///   language guarantee that the pointer must be aligned to some
-  ///   stricter value, and we're simply trying to ensure that
-  ///   sufficiently obvious uses of under-aligned objects don't get
-  ///   miscompiled; for example, a placement new into the address of
-  ///   a local variable.  In such a case, it's quite reasonable to
-  ///   just ignore the returned alignment when it isn't from an
-  ///   explicit source.
   Address EmitPointerWithAlignment(const Expr *Addr,
LValueBaseInfo *BaseInfo = nullptr);
 


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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-19 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.



Comment at: cfe/trunk/lib/CodeGen/CodeGenFunction.h:3756
   ///
   /// \param Source - If non-null, this will be initialized with
   ///   information about the source of the alignment.  Note that this

Could you update this? See also r303414. [-Wdocumentation]


Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D33351: [clang-format] Handle trailing comment sections in import statement lines

2017-05-19 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

nice




Comment at: lib/Format/ContinuationIndenter.cpp:590
 1u, std::min(Current.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1));
+bool InPPDirective =
+State.Line->InPPDirective && State.Line->Type != LT_ImportStatement;

Call this "ContinuePPDirective".



Comment at: lib/Format/TokenAnnotator.cpp:713
 next();
-  }
+  } next();
 }

wat?


https://reviews.llvm.org/D33351



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


[PATCH] D33351: [clang-format] Handle trailing comment sections in import statement lines

2017-05-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 99538.
krasimir marked 2 inline comments as done.
krasimir added a comment.

- Address review comments


https://reviews.llvm.org/D33351

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -530,6 +530,14 @@
  20, 0));
 }
 
+TEST_F(FormatTestSelective, KeepsIndentAfterCommentSectionImport) {
+  std::string Code = "#include  // line 1\n" // 23 chars long
+ " // line 2\n" // 23 chars long
+ "\n"   // this newline is char 47
+ "int i;";  // this line is not indented
+  EXPECT_EQ(Code, format(Code, 47, 1));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -55,13 +55,18 @@
   std::vector &Stack;
 };
 
+static bool isLineComment(const FormatToken &FormatTok) {
+  return FormatTok.is(tok::comment) &&
+ FormatTok.TokenText.startswith("//");
+}
+
 class ScopedMacroState : public FormatTokenSource {
 public:
   ScopedMacroState(UnwrappedLine &Line, FormatTokenSource *&TokenSource,
FormatToken *&ResetToken)
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
-Token(nullptr) {
+Token(nullptr), PreviousToken(nullptr) {
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -78,6 +83,7 @@
 // The \c UnwrappedLineParser guards against this by never calling
 // \c getNextToken() after it has encountered the first eof token.
 assert(!eof());
+PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
   return getFakeEOF();
@@ -87,12 +93,17 @@
   unsigned getPosition() override { return PreviousTokenSource->getPosition(); }
 
   FormatToken *setPosition(unsigned Position) override {
+PreviousToken = nullptr;
 Token = PreviousTokenSource->setPosition(Position);
 return Token;
   }
 
 private:
-  bool eof() { return Token && Token->HasUnescapedNewline; }
+  bool eof() {
+return Token && Token->HasUnescapedNewline &&
+   !(PreviousToken && isLineComment(*PreviousToken) &&
+ isLineComment(*Token) && Token->NewlinesBefore == 1);
+  }
 
   FormatToken *getFakeEOF() {
 static bool EOFInitialized = false;
@@ -112,6 +123,7 @@
   FormatTokenSource *PreviousTokenSource;
 
   FormatToken *Token;
+  FormatToken *PreviousToken;
 };
 
 } // end anonymous namespace
@@ -2092,11 +2104,6 @@
  FormatTok.NewlinesBefore > 0;
 }
 
-static bool isLineComment(const FormatToken &FormatTok) {
-  return FormatTok.is(tok::comment) &&
- FormatTok.TokenText.startswith("//");
-}
-
 // Checks if \p FormatTok is a line comment that continues the line comment
 // section on \p Line.
 static bool continuesLineComment(const FormatToken &FormatTok,
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -703,9 +703,12 @@
 
   void parseIncludeDirective() {
 if (CurrentToken && CurrentToken->is(tok::less)) {
-  next();
-  while (CurrentToken) {
-if (CurrentToken->isNot(tok::comment) || CurrentToken->Next)
+ next();
+ while (CurrentToken) {
+// Mark tokens up to the trailing line comments as implicit string
+// literals.
+if (CurrentToken->isNot(tok::comment) &&
+!CurrentToken->TokenText.startswith("//"))
   CurrentToken->Type = TT_ImplicitStringLiteral;
 next();
   }
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -587,8 +587,10 @@
   if (!DryRun) {
 unsigned Newlines = std::max(
 1u, std::min(Current.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1));
+bool ContinuePPDirective =
+State.Line->InPPDirective && State.Line->Type != LT_ImportStatement;
 Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column,
-  State.Line->InPPDirective);
+  ContinuePPDirective);
   }
 
   if (!Current.isTrailingComment())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r303415 - [clang-format] Handle trailing comment sections in import statement lines

2017-05-19 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri May 19 05:34:57 2017
New Revision: 303415

URL: http://llvm.org/viewvc/llvm-project?rev=303415&view=rev
Log:
[clang-format] Handle trailing comment sections in import statement lines

Summary:
This patch updates the handling of multiline trailing comment sections in
import statement lines to make it more consistent with the case in general.
This includes updating the parsing logic to collect the trailing comment
sections and the formatting logic to not insert escaped newlines at the end of
comment lines in import statement lines.

Specifically, before this patch this code:
```
#include  // line 1
 // line 2
```
will be turned into two unwrapped lines, whereas this code:
```
int i; // line 1
   // line 2
```
is turned into a single unwrapped line, enabling reflowing across comments.

An example where the old behaviour is bad is when partially formatting the lines
3 to 4 of this code:
```
#include  // line 1
 // line 2

int i;
```
which gets turned into:
```
#include  // line 1
 // line 2

 int i;
```
because the two comment lines were independent and the indent was copied.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=303415&r1=303414&r2=303415&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri May 19 05:34:57 2017
@@ -587,8 +587,10 @@ unsigned ContinuationIndenter::addTokenO
   if (!DryRun) {
 unsigned Newlines = std::max(
 1u, std::min(Current.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1));
+bool ContinuePPDirective =
+State.Line->InPPDirective && State.Line->Type != LT_ImportStatement;
 Whitespaces.replaceWhitespace(Current, Newlines, State.Column, 
State.Column,
-  State.Line->InPPDirective);
+  ContinuePPDirective);
   }
 
   if (!Current.isTrailingComment())

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=303415&r1=303414&r2=303415&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri May 19 05:34:57 2017
@@ -703,9 +703,12 @@ private:
 
   void parseIncludeDirective() {
 if (CurrentToken && CurrentToken->is(tok::less)) {
-  next();
-  while (CurrentToken) {
-if (CurrentToken->isNot(tok::comment) || CurrentToken->Next)
+ next();
+ while (CurrentToken) {
+// Mark tokens up to the trailing line comments as implicit string
+// literals.
+if (CurrentToken->isNot(tok::comment) &&
+!CurrentToken->TokenText.startswith("//"))
   CurrentToken->Type = TT_ImplicitStringLiteral;
 next();
   }

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=303415&r1=303414&r2=303415&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri May 19 05:34:57 2017
@@ -55,13 +55,18 @@ private:
   std::vector &Stack;
 };
 
+static bool isLineComment(const FormatToken &FormatTok) {
+  return FormatTok.is(tok::comment) &&
+ FormatTok.TokenText.startswith("//");
+}
+
 class ScopedMacroState : public FormatTokenSource {
 public:
   ScopedMacroState(UnwrappedLine &Line, FormatTokenSource *&TokenSource,
FormatToken *&ResetToken)
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
-Token(nullptr) {
+Token(nullptr), PreviousToken(nullptr) {
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -78,6 +83,7 @@ public:
 // The \c UnwrappedLineParser guards against this by never calling
 // \c getNextToken() after it has encountered the first eof token.
 assert(!eof());
+PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
   return getFakeEOF();
@@ -87,12 +93,17 @@ public:
   unsigned getPosition() override { return PreviousTokenSource->getPosition(); 
}
 
   FormatToken *setPosition(unsigned Position) override {
+PreviousToken = 

[PATCH] D33351: [clang-format] Handle trailing comment sections in import statement lines

2017-05-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303415: [clang-format] Handle trailing comment sections in 
import statement lines (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D33351?vs=99538&id=99539#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33351

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp

Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -587,8 +587,10 @@
   if (!DryRun) {
 unsigned Newlines = std::max(
 1u, std::min(Current.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1));
+bool ContinuePPDirective =
+State.Line->InPPDirective && State.Line->Type != LT_ImportStatement;
 Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column,
-  State.Line->InPPDirective);
+  ContinuePPDirective);
   }
 
   if (!Current.isTrailingComment())
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -55,13 +55,18 @@
   std::vector &Stack;
 };
 
+static bool isLineComment(const FormatToken &FormatTok) {
+  return FormatTok.is(tok::comment) &&
+ FormatTok.TokenText.startswith("//");
+}
+
 class ScopedMacroState : public FormatTokenSource {
 public:
   ScopedMacroState(UnwrappedLine &Line, FormatTokenSource *&TokenSource,
FormatToken *&ResetToken)
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
-Token(nullptr) {
+Token(nullptr), PreviousToken(nullptr) {
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -78,6 +83,7 @@
 // The \c UnwrappedLineParser guards against this by never calling
 // \c getNextToken() after it has encountered the first eof token.
 assert(!eof());
+PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
   return getFakeEOF();
@@ -87,12 +93,17 @@
   unsigned getPosition() override { return PreviousTokenSource->getPosition(); }
 
   FormatToken *setPosition(unsigned Position) override {
+PreviousToken = nullptr;
 Token = PreviousTokenSource->setPosition(Position);
 return Token;
   }
 
 private:
-  bool eof() { return Token && Token->HasUnescapedNewline; }
+  bool eof() {
+return Token && Token->HasUnescapedNewline &&
+   !(PreviousToken && isLineComment(*PreviousToken) &&
+ isLineComment(*Token) && Token->NewlinesBefore == 1);
+  }
 
   FormatToken *getFakeEOF() {
 static bool EOFInitialized = false;
@@ -112,6 +123,7 @@
   FormatTokenSource *PreviousTokenSource;
 
   FormatToken *Token;
+  FormatToken *PreviousToken;
 };
 
 } // end anonymous namespace
@@ -2092,11 +2104,6 @@
  FormatTok.NewlinesBefore > 0;
 }
 
-static bool isLineComment(const FormatToken &FormatTok) {
-  return FormatTok.is(tok::comment) &&
- FormatTok.TokenText.startswith("//");
-}
-
 // Checks if \p FormatTok is a line comment that continues the line comment
 // section on \p Line.
 static bool continuesLineComment(const FormatToken &FormatTok,
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -703,9 +703,12 @@
 
   void parseIncludeDirective() {
 if (CurrentToken && CurrentToken->is(tok::less)) {
-  next();
-  while (CurrentToken) {
-if (CurrentToken->isNot(tok::comment) || CurrentToken->Next)
+ next();
+ while (CurrentToken) {
+// Mark tokens up to the trailing line comments as implicit string
+// literals.
+if (CurrentToken->isNot(tok::comment) &&
+!CurrentToken->TokenText.startswith("//"))
   CurrentToken->Type = TT_ImplicitStringLiteral;
 next();
   }
Index: cfe/trunk/unittests/Format/FormatTestSelective.cpp
===
--- cfe/trunk/unittests/Format/FormatTestSelective.cpp
+++ cfe/trunk/unittests/Format/FormatTestSelective.cpp
@@ -530,6 +530,14 @@
  20, 0));
 }
 
+TEST_F(FormatTestSelective, KeepsIndentAfterCommentSectionImport) {
+  std::string Code = "#include  // line 1\n" // 23 chars long
+ " // line 2\n" // 23 chars long
+ "\n"   // this newline is char 47
+ "int i;";  

[PATCH] D32178: Delete unstable integration tests

2017-05-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@jroelofs

I've managed to put together a solution that adds REQUIRES to the tests that 
ensure they only work with the latest SDK (10.12).

F3339761: macOSsdk.diff 

F3339760: sdkUtilLLVM.diff 

WDYT?


https://reviews.llvm.org/D32178



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


[PATCH] D32178: Delete unstable integration tests

2017-05-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

While I do agree that these tests would be better off in another place, we 
currently don't have the bandwidth to facilitate that move.


https://reviews.llvm.org/D32178



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


r303419 - Restore and update documentation comment for EmitPointerWithAlignment

2017-05-19 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri May 19 07:03:34 2017
New Revision: 303419

URL: http://llvm.org/viewvc/llvm-project?rev=303419&view=rev
Log:
Restore and update documentation comment for EmitPointerWithAlignment

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=303419&r1=303418&r2=303419&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri May 19 07:03:34 2017
@@ -3746,12 +3746,23 @@ public:
 unsigned ParamsToSkip = 0,
 EvaluationOrder Order = EvaluationOrder::Default);
 
-  /// EmitPointerWithAlignment - Given an expression with a pointer
-  /// type, emit the value and compute our best estimate of the
-  /// alignment of the pointee.
+  /// EmitPointerWithAlignment - Given an expression with a pointer type,
+  /// emit the value and compute our best estimate of the alignment of the
+  /// pointee.
   ///
-  /// Note that this function will conservatively fall back on the type
-  /// when it doesn't 
+  /// \param BaseInfo - If non-null, this will be initialized with
+  /// information about the source of the alignment and the may-alias
+  /// attribute.  Note that this function will conservatively fall back on
+  /// the type when it doesn't recognize the expression and may-alias will
+  /// be set to false.
+  ///
+  /// One reasonable way to use this information is when there's a language
+  /// guarantee that the pointer must be aligned to some stricter value, and
+  /// we're simply trying to ensure that sufficiently obvious uses of under-
+  /// aligned objects don't get miscompiled; for example, a placement new
+  /// into the address of a local variable.  In such a case, it's quite
+  /// reasonable to just ignore the returned alignment when it isn't from an
+  /// explicit source.
   Address EmitPointerWithAlignment(const Expr *Addr,
LValueBaseInfo *BaseInfo = nullptr);
 


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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-19 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz marked an inline comment as done.
kparzysz added inline comments.



Comment at: cfe/trunk/lib/CodeGen/CodeGenFunction.h:3756
   ///
   /// \param Source - If non-null, this will be initialized with
   ///   information about the source of the alignment.  Note that this

chapuni wrote:
> Could you update this? See also r303414. [-Wdocumentation]
Done in r303419.


Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-19 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D33353

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/arithmetic-conversions.cl
  test/SemaOpenCL/cond.cl

Index: test/SemaOpenCL/cond.cl
===
--- test/SemaOpenCL/cond.cl
+++ test/SemaOpenCL/cond.cl
@@ -89,7 +89,7 @@
 
 float2 ntest05(int2 C, int2 X, float Y)
 {
-  return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float')}}
+  return C ? X : Y; // expected-error {{scalar operand type has greater rank than the type of the vector element. ('int2' (vector of 2 'int' values) and 'float'}}
 }
 
 char2 ntest06(int2 C, char2 X, char2 Y)
Index: test/SemaOpenCL/arithmetic-conversions.cl
===
--- /dev/null
+++ test/SemaOpenCL/arithmetic-conversions.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef long long2 __attribute__((ext_vector_type(2)));
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+kernel void foo1(float2 in, global float2 *out) { *out = in + 0.5;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('float2' (vector of 2 'float' values) and 'double')}}
+
+kernel void foo2(float2 in, global float2 *out) { *out = 0.5 + in;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('double' and 'float2' (vector of 2 'float' values))}}
+
+kernel void foo3(float2 in, global float2 *out) { *out = 0.5f + in;}
+
+kernel void foo4(long2 in, global long2 *out) { *out = 5 + in;}
+
+kernel void foo5(float2 in, global float2 *out) {
+float* f;
+*out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('float *' and 'float2' (vector of 2 'float' values))}}
+}
+
+kernel void foo6(int2 in, global int2 *out) {
+int* f;
+*out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('int *' and 'int2' (vector of 2 'int' values))}}
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8064,28 +8064,38 @@
 /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except
 /// for float->int.
 ///
+/// OpenCL V2.0 6.2.6.p2:
+/// An error shall occur if any scalar operand type has greater rank
+/// than the type of the vector element.
+///
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
  QualType scalarTy,
  QualType vectorEltTy,
- QualType vectorTy) {
+ QualType vectorTy,
+ unsigned &DiagID) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_Invalid;
   
   if (vectorEltTy->isIntegralType(S.Context)) {
-if (!scalarTy->isIntegralType(S.Context))
+if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
+(scalarTy->isIntegerType() &&
+ S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
+  DiagID = diag::err_scalar_type_rank_greater_than_vector_type;
   return true;
-if (S.getLangOpts().OpenCL &&
-S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0)
+}
+if (!scalarTy->isIntegralType(S.Context))
   return true;
 scalarCast = CK_IntegralCast;
   } else if (vectorEltTy->isRealFloatingType()) {
 if (scalarTy->isRealFloatingType()) {
   if (S.getLangOpts().OpenCL &&
-  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0)
+  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) {
+DiagID = diag::err_scalar_type_rank_greater_than_vector_type;
 return true;
+  }
   scalarCast = CK_FloatingCast;
 }
 else if (scalarTy->isIntegralType(S.Context))
@@ -8331,10 +8341,12 @@
 
   // If there's a vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  unsigned DeclID = 0;
   if (!RHSVecType) {
 if (isa(LHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, &RHS, RHSType,
-LHSVecType->getElementType(), LHSType))
+LHSVecType->getElementType(), LHSType,
+DeclID))
 return LHSType;
 } else {
   if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS))
@@ -8345,15 +8357,22 @@
 if (isa(RHSVecType)) {
   if (!tryVec

[PATCH] D32479: [clang-format] Add BreakConstructorInitializersBeforeColon option

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 99553.
Typz added a comment.

Deprecate BreakConstructorInitializersBeforeComma and replace it with a more 
generic BreakConstructorInitializers option.


https://reviews.llvm.org/D32479

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -56,16 +56,17 @@
 return *Result;
   }
 
-  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
-FormatStyle Style = getLLVMStyle();
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
 Style.ColumnLimit = ColumnLimit;
 return Style;
   }
 
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }
+
   FormatStyle getGoogleStyleWithColumns(unsigned ColumnLimit) {
-FormatStyle Style = getGoogleStyle();
-Style.ColumnLimit = ColumnLimit;
-return Style;
+return getStyleWithColumns(getGoogleStyle(), ColumnLimit);
   }
 
   void verifyFormat(llvm::StringRef Code,
@@ -2699,6 +2700,128 @@
"() {}"));
 }
 
+TEST_F(FormatTest, BreakConstructorInitializersAfterColonAndComma) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColonAndComma;
+
+  verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}");
+  verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}",
+   getStyleWithColumns(Style, 45));
+  verifyFormat("Constructor() :\n"
+   "Inttializer(FitsOnTheLine) {}",
+   getStyleWithColumns(Style, 44));
+  verifyFormat("Constructor() :\n"
+   "Inttializer(FitsOnTheLine) {}",
+   getStyleWithColumns(Style, 43));
+
+  verifyFormat("template \n"
+   "Constructor() : Initializer(FitsOnTheLine) {}",
+   getStyleWithColumns(Style, 50));
+
+  verifyFormat(
+  "SomeClass::Constructor() :\n"
+  "a(aa), aaa() {}",
+	  Style);
+
+  verifyFormat(
+  "SomeClass::Constructor() :\n"
+  "a(aa), a(aa),\n"
+  "a(aa) {}",
+	  Style);
+  verifyFormat(
+  "SomeClass::Constructor() :\n"
+  "aa(aa),\n"
+  "aaa() {}",
+	  Style);
+  verifyFormat("Constructor(aa ,\n"
+   "aa ) :\n"
+   "aa(aa) {}",
+			   Style);
+
+  verifyFormat("Constructor() :\n"
+   "(aaa),\n"
+   "(aaa,\n"
+   " aaa),\n"
+   "aaa() {}",
+			   Style);
+
+  verifyFormat("Constructor() :\n"
+   "(\n"
+   "a) {}",
+			   Style);
+
+  verifyFormat("Constructor(int Parameter = 0) :\n"
+   "aa(a),\n"
+   "(a) {}",
+			   Style);
+  verifyFormat("Constructor() :\n"
+   "aa(a), (b) {\n"
+   "}",
+   getStyleWithColumns(Style, 60));
+  verifyFormat("Constructor() :\n"
+   "a(\n"
+   "a(, )) {}",
+			   Style);
+
+  // Here a line could be saved by splitting the second initializer onto two
+  // lines, but that is not desirable.
+  verifyFormat("Constructor() :\n"
+   "(),\n"
+   "aaa(aaa),\n"
+   "at() {}",
+			   Style);
+
+  FormatStyle OnePerLine = Style;
+  OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  OnePerLine.AllowAllParametersOfDeclarationOnNextLine = false;
+  verifyFormat("SomeClass::Constructor() :\n"
+   "a(aa),\n"
+   "a(aa),\n"
+   "a(aa) {}",
+   OnePerLine);
+  verifyFormat("SomeClass::Constructor() :\n"
+   "a(aa), // Some comment\n"
+   "a(aa),\n"
+   "aaa

[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D32478#758258, @djasper wrote:

> When you say "this doesn't happen in tests", do you mean this never happens 
> when there are parentheses around the expression?


By 'test' I meant 'conditional construct' : it happens when there are 
parentheses around the expression, but it does not happen when these 
parentheses are the parentheses from a `if (...)`


https://reviews.llvm.org/D32478



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


[PATCH] D33314: clang-format: Add option to remove semicolon at end of namespace

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz abandoned this revision.
Typz added a comment.

ATM, in the presence of semicolons, the closing braces will simply not be 
merged : i will check if I can handle this case easily (in the 
CompactNamespaces patch), and I'll abandon this one for now.


https://reviews.llvm.org/D33314



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


[PATCH] D33354: [clang-tidy] readability-braces-around-statements false positive with char literals

2017-05-19 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.
Herald added a subscriber: xazax.hun.

Single-line if statements cause a false positive when the last token in the 
conditional statement is a char constant:

  if (condition)
return 'a';

For some reason `findEndLocation` seems to skips too many (vertical) 
whitespaces in this case. The same problem already occured with string literals 
(https://reviews.llvm.org/D25558), and was fixed by adding a special check for 
this very case. I just extended the condition to also include char constants. 
No idea what really causes the issue though.


https://reviews.llvm.org/D33354

Files:
  clang-tidy/readability/BracesAroundStatementsCheck.cpp
  include/clang/Basic/TokenKinds.h
  test/clang-tidy/readability-braces-around-statements-single-line.cpp


Index: include/clang/Basic/TokenKinds.h
===
--- include/clang/Basic/TokenKinds.h
+++ include/clang/Basic/TokenKinds.h
@@ -82,12 +82,17 @@
  K == tok::utf32_string_literal;
 }
 
+/// \brief Return true if this is a char constant token
+inline bool isCharConstant(TokenKind K) {
+  return K == tok::char_constant || K == tok::wide_char_constant ||
+ K == tok::utf8_char_constant || K == tok::utf16_char_constant ||
+ K == tok::utf32_char_constant;
+}
+
 /// \brief Return true if this is a "literal" kind, like a numeric
 /// constant, string, etc.
 inline bool isLiteral(TokenKind K) {
-  return K == tok::numeric_constant || K == tok::char_constant ||
- K == tok::wide_char_constant || K == tok::utf8_char_constant ||
- K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
+  return K == tok::numeric_constant || isCharConstant(K) ||
  isStringLiteral(K) || K == tok::angle_string_literal;
 }
 
Index: test/clang-tidy/readability-braces-around-statements-single-line.cpp
===
--- test/clang-tidy/readability-braces-around-statements-single-line.cpp
+++ test/clang-tidy/readability-braces-around-statements-single-line.cpp
@@ -31,3 +31,21 @@
   // CHECK-FIXES: if (cond("if4") /*comment*/) {
   // CHECK-FIXES: }
 }
+
+const char *test2() {
+  if (cond("if1"))
+return "string";
+
+
+}
+
+char test3() {
+  if (cond("if1"))
+return 'a';
+
+
+  if (cond("if1"))
+return (char)L'a';
+
+
+}
Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -61,7 +61,8 @@
   bool SkipEndWhitespaceAndComments = true;
   tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
   if (TokKind == tok::NUM_TOKENS || TokKind == tok::semi ||
-  TokKind == tok::r_brace || isStringLiteral(TokKind)) {
+  TokKind == tok::r_brace || isCharConstant(TokKind) ||
+  isStringLiteral(TokKind)) {
 // If we are at ";" or "}", we found the last token. We could use as well
 // `if (isa(S))`, but it wouldn't work for nested statements.
 SkipEndWhitespaceAndComments = false;


Index: include/clang/Basic/TokenKinds.h
===
--- include/clang/Basic/TokenKinds.h
+++ include/clang/Basic/TokenKinds.h
@@ -82,12 +82,17 @@
  K == tok::utf32_string_literal;
 }
 
+/// \brief Return true if this is a char constant token
+inline bool isCharConstant(TokenKind K) {
+  return K == tok::char_constant || K == tok::wide_char_constant ||
+ K == tok::utf8_char_constant || K == tok::utf16_char_constant ||
+ K == tok::utf32_char_constant;
+}
+
 /// \brief Return true if this is a "literal" kind, like a numeric
 /// constant, string, etc.
 inline bool isLiteral(TokenKind K) {
-  return K == tok::numeric_constant || K == tok::char_constant ||
- K == tok::wide_char_constant || K == tok::utf8_char_constant ||
- K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
+  return K == tok::numeric_constant || isCharConstant(K) ||
  isStringLiteral(K) || K == tok::angle_string_literal;
 }
 
Index: test/clang-tidy/readability-braces-around-statements-single-line.cpp
===
--- test/clang-tidy/readability-braces-around-statements-single-line.cpp
+++ test/clang-tidy/readability-braces-around-statements-single-line.cpp
@@ -31,3 +31,21 @@
   // CHECK-FIXES: if (cond("if4") /*comment*/) {
   // CHECK-FIXES: }
 }
+
+const char *test2() {
+  if (cond("if1"))
+return "string";
+
+
+}
+
+char test3() {
+  if (cond("if1"))
+return 'a';
+
+
+  if (cond("if1"))
+return (char)L'a';
+
+
+}
Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -61,7 +6

[PATCH] D33042: [libclang] Allow to suspend a translation unit.

2017-05-19 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This makes sense to me.




Comment at: lib/Frontend/ASTUnit.cpp:2089
+void ASTUnit::ResetForParse()
+{
+  SavedMainFileBuffer.reset();

Put the `{` on the same line as the decl.


https://reviews.llvm.org/D33042



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim created this revision.

Hello,

This patch is part of our effort to implement Nios2 architecture support in 
LLVM and clang (our plans were announced in mailing list thread: "[llvm-dev] 
[RFC] Nios II backend" form April 12th).

This patch depends on changes introduced by patch D32669 
.

The patch contains following additions:

- Nios2 builtins;
- using -march or -mcpu options to specify Nios2 CPU type 
(https://reviews.llvm.org/diffusion/L/ or R2) ;
- TargetInfo class implementation for Nios2.

Please let me know what you think about proposed change set.

Kind regards,
Mateusz Belicki


https://reviews.llvm.org/D33356

Files:
  include/clang/Basic/BuiltinsNios2.def
  include/clang/Basic/TargetBuiltins.h
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains/CommonArgs.cpp

Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -215,6 +215,21 @@
   return "";
 }
 
+static std::string getNios2TargetCPU(const ArgList &Args) {
+  Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (A == nullptr)
+A = Args.getLastArg(options::OPT_march_EQ);
+
+  if (A) {
+const char *name = A->getValue();
+return llvm::StringSwitch(name)
+.Case("r1", "nios2r1")
+.Case("r2", "nios2r2")
+.Default(name);
+  }
+  return "";
+}
+
 static std::string getLanaiTargetCPU(const ArgList &Args) {
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 return A->getValue();
@@ -267,6 +282,10 @@
   return A->getValue();
 return "";
 
+  case llvm::Triple::nios2: {
+return getNios2TargetCPU(Args);
+  }
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7604,6 +7604,147 @@
   }
 };
 
+class Nios2TargetInfo : public TargetInfo {
+  void setDataLayout() {
+StringRef Layout = "p:32:32:32-i8:8:32-i16:16:32-n32";
+if (BigEndian) {
+  resetDataLayout(("E-" + Layout).str());
+} else {
+  resetDataLayout(("e-" + Layout).str());
+}
+  }
+
+  static const Builtin::Info BuiltinInfo[];
+  std::string CPU;
+  std::string ABI;
+
+public:
+  Nios2TargetInfo(const llvm::Triple &triple, const TargetOptions &opts)
+  : TargetInfo(triple), CPU(opts.CPU), ABI(opts.ABI) {
+SizeType = UnsignedInt;
+PtrDiffType = SignedInt;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+setDataLayout();
+  }
+
+  StringRef getABI() const override { return ABI; }
+  bool setABI(const std::string &Name) override {
+if ((Name == "o32") || (Name == "eabi")) {
+  ABI = Name;
+  return true;
+}
+return false;
+  }
+
+  bool setCPU(const std::string &Name) override {
+if ((Name == "nios2r1") || (Name == "nios2r2")) {
+  CPU = Name;
+  return true;
+}
+return false;
+  }
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+
+Builder.defineMacro("_NIOS2_ARCH", "\"" + CPU + "\"");
+Builder.defineMacro("_NIOS2_ARCH_" + StringRef(CPU).upper());
+  }
+
+  ArrayRef getTargetBuiltins() const override {
+return llvm::makeArrayRef(BuiltinInfo, clang::Nios2::LastTSBuiltin -
+   Builtin::FirstTSBuiltin);
+  }
+
+  bool isFeatureSupportedByCPU(StringRef Feature, StringRef CPU) const {
+const bool isR2 = CPU == "nios2r2";
+return llvm::StringSwitch(Feature)
+.Case("nios2r2mandatory", isR2)
+.Case("nios2r2bmx", isR2)
+.Case("nios2r2mpx", isR2)
+.Case("nios2r2cdx", isR2)
+.Default(false);
+  }
+
+  bool initFeatureMap(llvm::StringMap &Features,
+  DiagnosticsEngine &Diags, StringRef CPU,
+  const std::vector &FeatureVec) const override {
+static const char *allFeatures[] = {
+  "nios2r2mandatory", "nios2r2bmx", "nios2r2mpx", "nios2r2cdx"
+};
+for (const char *feature : allFeatures) {
+Features[feature] = isFeatureSupportedByCPU(feature, CPU);
+}
+return true;
+  }
+
+  bool hasFeature(StringRef Feature) const override {
+  return isFeatureSupportedByCPU(Feature, CPU);
+  }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::VoidPtrBuiltinVaList;
+  }
+
+  ArrayRef getGCCRegNames() const override {
+static const char *const GCCRegNames[] = {
+// CPU register names
+// Must match second column of GCCRegAliases
+"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+"r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20",
+"r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "

[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: lib/Basic/Targets.cpp:7614
+  resetDataLayout(("e-" + Layout).str());
+}
+  }

Can you just give the full string and avoid the runtime allocations?



Comment at: lib/Basic/Targets.cpp:7650
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+

DefineStd tends to give a lot of namespace pollution, is that intentional here?


https://reviews.llvm.org/D33356



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


[PATCH] D32146: PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+

2017-05-19 Thread Martin O'Riordan via Phabricator via cfe-commits
MartinO added a comment.

The introduction of the macros '__NEWLIB__' and '__NEWLIB_MINOR__' appear to 
have been first introduced in Newlib v2.3.0.20160226, but the new interface for 
'' was introduced in Newlib v2.4.0.20160923 - previous releases of 
v2.4.0 did not make these changes.

This is why the tests 'defined(__NEWLIB__)' and 'defined(__NEWLIB_MINOR__)' are 
also necessary.

Unfortunately, I don't know of anyway of telling if Newlib v2.4.0 is the 
20160923 version or an earlier version such as the original v2.4.0 release or 
the 20160527 version which was the last version of Newlib that used the old 
interface. There is no macro that provides this information and 
'__NEWLIB_PATCHLEVEL__' is always '0' for each is these intermediate versions 
(I don't know why they don't bump the patch number).

I've no comment about whether or not the '__POSIX_VISIBLE' test is required, it 
was already present and I simply supplemented it with the Newlib version checks.

  MartinO


https://reviews.llvm.org/D32146



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim added inline comments.



Comment at: lib/Basic/Targets.cpp:7614
+  resetDataLayout(("e-" + Layout).str());
+}
+  }

joerg wrote:
> Can you just give the full string and avoid the runtime allocations?
Yes, I will fix this.



Comment at: lib/Basic/Targets.cpp:7650
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+

joerg wrote:
> DefineStd tends to give a lot of namespace pollution, is that intentional 
> here?
Yes, the usage is intentional: definitions of all four: `__nios2`, `__nios2__`, 
`__NIOS2` and `__NIOS2__` are part of Nios2 ABI (page 23, 
https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/nios2/n2cpu_nii51016.pdf).


https://reviews.llvm.org/D33356



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim added a comment.

Additionally this information may be useful in context of this patch: here is 
specification of Nios2 builtins as implemented in GCC: 
https://gcc.gnu.org/onlinedocs/gcc/Altera-Nios-II-Built-in-Functions.html


https://reviews.llvm.org/D33356



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


[PATCH] D33045: [libclang] Avoid more stats than necessary for reparse.

2017-05-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry, didn't get a chance to look into it very thoroughly yet.

Are there any other callers to getMainBufferWithPrecompiledPreamble?
Maybe they cause LibclangReparseTest.ReparseWithModule to fail?




Comment at: lib/Frontend/ASTUnit.cpp:1395
+const FileEntry *fileEntry = FileMgr->getFile(R.second);
+if (!fileEntry) {
   // If we can't stat the file we're remapping to, assume that 
something

Are we relying on the caller to create new FileMgr before calling 
getMainBufferWithPrecompiledPreamble?
Otherwise we'll hit a cached entry and possibly miss an update to the file?

This deserves a comment if that's the case.



Comment at: lib/Frontend/ASTUnit.cpp:2074
   // Clear out the diagnostics state.
-  FileMgr.reset();
   getDiagnostics().Reset();

Parse method used to recreate FileMgr from CompilerInvocation, because it was 
reset() at this point.
Won't something break because we're reusing the FileMgr now?
Maybe the code creating FileMgr in Parse should be deleted?


https://reviews.llvm.org/D33045



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: lib/Basic/Targets.cpp:7650
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+

belickim wrote:
> joerg wrote:
> > DefineStd tends to give a lot of namespace pollution, is that intentional 
> > here?
> Yes, the usage is intentional: definitions of all four: `__nios2`, 
> `__nios2__`, `__NIOS2` and `__NIOS2__` are part of Nios2 ABI (page 23, 
> https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/nios2/n2cpu_nii51016.pdf).
The problem is that DefineStd will also define the no-underscore version in GNU 
mode.


https://reviews.llvm.org/D33356



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


[PATCH] D33357: Avoid calling report_fatal_error in the destructor of raw_fd_ostream when saving a module timestamp file

2017-05-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

We should clear the error on the output stream to prevent the call to 
`report_fatal_error` from `raw_fd_ostreams`'s destructor.

I couldn't think of a way to test this, do you think it's possible to have a 
test for this?


Repository:
  rL LLVM

https://reviews.llvm.org/D33357

Files:
  lib/Serialization/ASTReader.cpp


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3650,9 +3650,13 @@
   std::string TimestampFilename = MF.getTimestampFilename();
   std::error_code EC;
   llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
-  if (EC)
+  if (EC) {
+OS.clear_error(); // Avoid triggering a fatal error.
 return;
+  }
   OS << "Timestamp file\n";
+  OS.close();
+  OS.clear_error(); // Avoid triggering a fatal error.
 }
 
 /// \brief Given a cursor at the start of an AST file, scan ahead and drop the


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3650,9 +3650,13 @@
   std::string TimestampFilename = MF.getTimestampFilename();
   std::error_code EC;
   llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::F_Text);
-  if (EC)
+  if (EC) {
+OS.clear_error(); // Avoid triggering a fatal error.
 return;
+  }
   OS << "Timestamp file\n";
+  OS.close();
+  OS.clear_error(); // Avoid triggering a fatal error.
 }
 
 /// \brief Given a cursor at the start of an AST file, scan ahead and drop the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33358: [clang-tidy] readability-redundant-declaration false positive for defaulted function

2017-05-19 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.
Herald added a subscriber: xazax.hun.

  template 
  struct C {
C();
  };
  
  template 
  C::C() = default;

Causes a readability-redundant-declaration diagnostic. This is caused by 
`isDefinition` not matching defaulted functions.


https://reviews.llvm.org/D33358

Files:
  clang-tidy/readability/RedundantDeclarationCheck.cpp
  test/clang-tidy/readability-redundant-declaration.cpp


Index: test/clang-tidy/readability-redundant-declaration.cpp
===
--- test/clang-tidy/readability-redundant-declaration.cpp
+++ test/clang-tidy/readability-redundant-declaration.cpp
@@ -34,3 +34,11 @@
   static int I;
 };
 int C::I;
+
+template 
+struct C2 {
+  C2();
+};
+
+template 
+C2::C2() = default;
Index: clang-tidy/readability/RedundantDeclarationCheck.cpp
===
--- clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -19,11 +19,12 @@
 namespace readability {
 
 void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
-  auto UnlessDefinition = unless(isDefinition());
-  Finder->addMatcher(namedDecl(anyOf(varDecl(UnlessDefinition),
- functionDecl(UnlessDefinition)))
- .bind("Decl"),
- this);
+  Finder->addMatcher(
+  namedDecl(
+  anyOf(varDecl(unless(isDefinition())),
+functionDecl(unless(anyOf(isDefinition(), isDefaulted())
+  .bind("Decl"),
+  this);
 }
 
 void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) {


Index: test/clang-tidy/readability-redundant-declaration.cpp
===
--- test/clang-tidy/readability-redundant-declaration.cpp
+++ test/clang-tidy/readability-redundant-declaration.cpp
@@ -34,3 +34,11 @@
   static int I;
 };
 int C::I;
+
+template 
+struct C2 {
+  C2();
+};
+
+template 
+C2::C2() = default;
Index: clang-tidy/readability/RedundantDeclarationCheck.cpp
===
--- clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -19,11 +19,12 @@
 namespace readability {
 
 void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
-  auto UnlessDefinition = unless(isDefinition());
-  Finder->addMatcher(namedDecl(anyOf(varDecl(UnlessDefinition),
- functionDecl(UnlessDefinition)))
- .bind("Decl"),
- this);
+  Finder->addMatcher(
+  namedDecl(
+  anyOf(varDecl(unless(isDefinition())),
+functionDecl(unless(anyOf(isDefinition(), isDefaulted())
+  .bind("Decl"),
+  this);
 }
 
 void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33358: [clang-tidy] readability-redundant-declaration false positive for defaulted function

2017-05-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


https://reviews.llvm.org/D33358



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim added inline comments.



Comment at: lib/Basic/Targets.cpp:7650
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+

joerg wrote:
> belickim wrote:
> > joerg wrote:
> > > DefineStd tends to give a lot of namespace pollution, is that intentional 
> > > here?
> > Yes, the usage is intentional: definitions of all four: `__nios2`, 
> > `__nios2__`, `__NIOS2` and `__NIOS2__` are part of Nios2 ABI (page 23, 
> > https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/nios2/n2cpu_nii51016.pdf).
> The problem is that DefineStd will also define the no-underscore version in 
> GNU mode.
Oh, that definitely is not needed in our case. I will remove the usage of 
`DefineStd()`. Looking at implementations of other `TargetInfo`s, I assume that 
preferred solution would be to manually call `Builder.defineMacro()` for all 
four defintions.


https://reviews.llvm.org/D33356



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


[PATCH] D33354: [clang-tidy] readability-braces-around-statements false positive with char literals

2017-05-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I'll repeat my comment from https://reviews.llvm.org/D25558: "I'm thoroughly 
confused as to why the code in your test was not handled correctly and why this 
is the right fix. Can you explain?" The "For some reason ..." part doesn't 
really explain anything. I guess, we're papering over a more generic problem, 
and someone has to figure out what it is and how to fix it properly.


https://reviews.llvm.org/D33354



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


[PATCH] D32499: Further delay calling DeclMustBeEmitted until it's safe.

2017-05-19 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

This is mentioned as a fix for PR31863, which is a blocker for the 4.0.1 
release, is there any reason this hasn't been committed to trunk yet?


https://reviews.llvm.org/D32499



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


[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0

2017-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D32401#759223, @Prazek wrote:

> Is everyone ok with sending this patch?


As long as this continues to be an opt-in optimization, go ahead and do your 
research project, I suppose.


https://reviews.llvm.org/D32401



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


[PATCH] D33197: [libclang] [OpenCL] Expose more OpenCL CIndex types

2017-05-19 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 99574.
svenvh added a comment.

Adding comments.


https://reviews.llvm.org/D33197

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/opencl-types.cl
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -59,6 +59,13 @@
 BTCASE(ObjCId);
 BTCASE(ObjCClass);
 BTCASE(ObjCSel);
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) BTCASE(Id);
+#include "clang/Basic/OpenCLImageTypes.def"
+#undef IMAGE_TYPE
+BTCASE(OCLSampler);
+BTCASE(OCLEvent);
+BTCASE(OCLQueue);
+BTCASE(OCLReserveID);
   default:
 return CXType_Unexposed;
   }
@@ -94,6 +101,7 @@
 TKCASE(MemberPointer);
 TKCASE(Auto);
 TKCASE(Elaborated);
+TKCASE(Pipe);
 default:
   return CXType_Unexposed;
   }
@@ -535,6 +543,14 @@
 TKIND(MemberPointer);
 TKIND(Auto);
 TKIND(Elaborated);
+TKIND(Pipe);
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
+#include "clang/Basic/OpenCLImageTypes.def"
+#undef IMAGE_TYPE
+TKIND(OCLSampler);
+TKIND(OCLEvent);
+TKIND(OCLQueue);
+TKIND(OCLReserveID);
   }
 #undef TKIND
   return cxstring::createRef(s);
Index: test/Index/opencl-types.cl
===
--- test/Index/opencl-types.cl
+++ test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -22,3 +22,105 @@
 // CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] [typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
 // CHECK: VarDecl=scalarDouble:15:10 (Definition) [type=double] [typekind=Double] [isPOD=1]
 // CHECK: VarDecl=vectorDouble:16:11 (Definition) [type=double4] [typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+
+#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
+
+void kernel OCLImage1dROTest(read_only image1d_t scalarOCLImage1dRO);
+void kernel OCLImage1dArrayROTest(read_only image1d_array_t scalarOCLImage1dArrayRO);
+void kernel OCLImage1dBufferROTest(read_only image1d_buffer_t scalarOCLImage1dBufferRO);
+void kernel OCLImage2dROTest(read_only image2d_t scalarOCLImage2dRO);
+void kernel OCLImage2dArrayROTest(read_only image2d_array_t scalarOCLImage2dArrayRO);
+void kernel OCLImage2dDepthROTest(read_only image2d_depth_t scalarOCLImage2dDepthRO);
+void kernel OCLImage2dArrayDepthROTest(read_only image2d_array_depth_t scalarOCLImage2dArrayDepthRO);
+void kernel OCLImage2dMSAAROTest(read_only image2d_msaa_t scalarOCLImage2dMSAARO);
+void kernel OCLImage2dArrayMSAAROTest(read_only image2d_array_msaa_t scalarOCLImage2dArrayMSAARO);
+void kernel OCLImage2dMSAADepthROTest(read_only image2d_msaa_depth_t scalarOCLImage2dMSAADepthRO);
+void kernel OCLImage2dArrayMSAADepthROTest(read_only image2d_array_msaa_depth_t scalarOCLImage2dArrayMSAADepthRO);
+void kernel OCLImage3dROTest(read_only image3d_t scalarOCLImage3dRO);
+
+// CHECK: ParmDecl=scalarOCLImage1dRO:28:50 (Definition) [type=__read_only image1d_t] [typekind=OCLImage1dRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage1dArrayRO:29:61 (Definition) [type=__read_only image1d_array_t] [typekind=OCLImage1dArrayRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage1dBufferRO:30:63 (Definition) [type=__read_only image1d_buffer_t] [typekind=OCLImage1dBufferRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dRO:31:50 (Definition) [type=__read_only image2d_t] [typekind=OCLImage2dRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dArrayRO:32:61 (Definition) [type=__read_only image2d_array_t] [typekind=OCLImage2dArrayRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dDepthRO:33:61 (Definition) [type=__read_only image2d_depth_t] [typekind=OCLImage2dDepthRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dArrayDepthRO:34:72 (Definition) [type=__read_only image2d_array_depth_t] [typekind=OCLImage2dArrayDepthRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dMSAARO:35:59 (Definition) [type=__read_only image2d_msaa_t] [typekind=OCLImage2dMSAARO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dArrayMSAARO:36:70 (Definition) [type=__read_only image2d_array_msaa_t] [typekind=OCLImage2dArrayMSAARO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dMSAADepthRO:37:70 (Definition) [type=__read_only image2d_msaa_depth_t] [typekind=OCLImage2dMSAADepthRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage2dArrayMSAADepthRO:38:81 (Definition) [type=__read_only image2d_array_msaa_depth_t] [typekind=OCLImage2dArrayMSAADepthRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage3dRO:39:50 (Definition) [type=__read_only image3d_t] [typekind=OCLImage3dRO] 

[PATCH] D32499: Further delay calling DeclMustBeEmitted until it's safe.

2017-05-19 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

We were trying to come up with a test case. So far we are unsuccessful. I will 
check it in as is.


https://reviews.llvm.org/D32499



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


[PATCH] D33197: [libclang] [OpenCL] Expose more OpenCL CIndex types

2017-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D33197



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-19 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: lib/Basic/Targets.cpp:7650
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+

belickim wrote:
> joerg wrote:
> > belickim wrote:
> > > joerg wrote:
> > > > DefineStd tends to give a lot of namespace pollution, is that 
> > > > intentional here?
> > > Yes, the usage is intentional: definitions of all four: `__nios2`, 
> > > `__nios2__`, `__NIOS2` and `__NIOS2__` are part of Nios2 ABI (page 23, 
> > > https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/nios2/n2cpu_nii51016.pdf).
> > The problem is that DefineStd will also define the no-underscore version in 
> > GNU mode.
> Oh, that definitely is not needed in our case. I will remove the usage of 
> `DefineStd()`. Looking at implementations of other `TargetInfo`s, I assume 
> that preferred solution would be to manually call `Builder.defineMacro()` for 
> all four defintions.
Yes, that's fine/


https://reviews.llvm.org/D33356



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


[PATCH] D32480: clang-format: Add CompactNamespaces option

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 99575.
Typz marked 11 inline comments as done.
Typz edited the summary of this revision.
Typz added a comment.

update for review comments


https://reviews.llvm.org/D32480

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1308,6 +1308,140 @@
Style));
 }
 
+TEST_F(FormatTest, FormatsCompactNamespaces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.CompactNamespaces = true;
+
+  verifyFormat("namespace A { namespace B {\n"
+			   "}} // namespace A::B",
+			   Style);
+
+  EXPECT_EQ("namespace out { namespace in {\n"
+"}} // namespace out::in",
+format("namespace out {\n"
+   "namespace in {\n"
+   "} // namespace in\n"
+   "} // namespace out",
+   Style));
+
+  EXPECT_EQ("namespace out { namespace in1 {\n"
+"} // namespace in1\n"
+"namespace in2 {\n"
+"}} // namespace out::in2",
+format("namespace out {\n"
+   "namespace in1 {\n"
+   "} // namespace in1\n"
+   "namespace in2 {\n"
+   "} // namespace in2\n"
+   "} // namespace out",
+   Style));
+
+  EXPECT_EQ("namespace out {\n"
+"int i;\n"
+"namespace in {\n"
+"int j;\n"
+"} // namespace in\n"
+"int k;\n"
+"} // namespace out",
+format("namespace out { int i;\n"
+   "namespace in { int j; } // namespace in\n"
+   "int k; } // namespace out",
+   Style));
+
+  EXPECT_EQ("namespace A { namespace B { namespace C {\n"
+"}}} // namespace A::B::C\n",
+format("namespace A { namespace B {\n"
+   "namespace C {\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n",
+   Style));
+
+  EXPECT_EQ("namespace  {\n"
+			"namespace  {\n"
+"}} // namespace ::",
+format("namespace  {\n"
+   "namespace  {\n"
+   "} // namespace \n"
+   "} // namespace ",
+   Style));
+
+  EXPECT_EQ("namespace a { namespace b {\n"
+			"namespace c {\n"
+"}}} // namespace a::b::c",
+format("namespace a {\n"
+   "namespace b {\n"
+   "namespace c {\n"
+   "} // namespace c\n"
+   "} // namespace b\n"
+   "} // namespace a",
+   Style));
+
+  // Missing comments are added
+  EXPECT_EQ("namespace out { namespace in {\n"
+			"int i;\n"
+			"int j;\n"
+"}} // namespace out::in",
+format("namespace out {\n"
+   "namespace in {\n"
+   "int i;\n"
+   "int j;\n"
+   "}\n"
+   "}",
+   Style));
+
+  // Incorrect comments are fixed
+  EXPECT_EQ("namespace out { namespace in {\n"
+"}} // namespace out::in",
+format("namespace out { namespace in {\n"
+   "}} // namespace out",
+   Style));
+  EXPECT_EQ("namespace out { namespace in {\n"
+"}} // namespace out::in",
+format("namespace out { namespace in {\n"
+   "}} // namespace in",
+   Style));
+
+  // Extra semicolon after 'inner' closing brace prevents merging
+  EXPECT_EQ("namespace out { namespace in {\n"
+"}; } // namespace out::in",
+format("namespace out {\n"
+   "namespace in {\n"
+   "}; // namespace in\n"
+   "} // namespace out",
+   Style));
+
+  // Extra semicolon after 'outer' closing brace is conserved
+  EXPECT_EQ("namespace out { namespace in {\n"
+"}}; // namespace out::in",
+format("namespace out {\n"
+   "namespace in {\n"
+   "} // namespace in\n"
+   "}; // namespace out",
+   Style));
+
+  Style.NamespaceIndentation = FormatStyle::NI_All;
+  EXPECT_EQ("namespace out { namespace in {\n"
+"int i;\n"
+  

[PATCH] D32480: clang-format: Add CompactNamespaces option

2017-05-19 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: include/clang/Format/Format.h:358
+  /// \endcode
+  bool BinPackNamespaces;
+

djasper wrote:
> Typz wrote:
> > djasper wrote:
> > > This is not bin packing at all. Maybe CompactNamespaces? Or 
> > > SingleLineNamespaces?
> > > 
> > > Also, could you clarify what happens if the namespaces don't fit within 
> > > the column limit (both in the comment describing the flag and by adding 
> > > tests for it)?
> > This is not binpacking, but has a similar effect and made the option name 
> > somewhat consistent with the other binpack options :-)
> > I'll change to CompactNamespaces then.
> How does this option interact with NamespaceIndentation. Do all the values 
> you can set there make sense and work as expected?
> 
> I am wondering whether we should generally rename this to NamespaceStyle and 
> make it an enum. That way, we can start to also support C++17 namespace, but 
> people that don't want to use C++17 yet, can still use this style of compact 
> namespace.
> How does this option interact with NamespaceIndentation. Do all the values 
> you can set there make sense and work as expected?

NamespaceIndentation is not affected, indent is done as before (e.g. just 
"counting" the imbricated namespaces).

In 'NI_All' we may want to reduce the indent when multiple namespaces are 
declared in the same line, but this would become inconsistent if the beginning 
and end of all namespaces do not match:

  namepace A { namespace B {
  int i;
  } // namespace B
int i;
  } // namespace A

So I think reducing indent in that case should be (if ever needed) another 
value in NamespaceIndentation...

> I am wondering whether we should generally rename this to NamespaceStyle and 
> make it an enum. That way, we can start to also support C++17 namespace, but 
> people that don't want to use C++17 yet, can still use this style of compact 
> namespace.

As for C++17, I am not sure we need another option: just having 
CompactNamespaces=true and Standard=C++17 would use the "real" C++17 mode. That 
said converting to C++17 namespace blocks is slightly more restrictive, as it 
will require that both the beginning and end of the inner & outer blocks to 
match...

I will keep the boolean flag for now, just let me know if you prefer to have 
the enum in case other modes are needed and I will update the patch.



Comment at: lib/Format/UnwrappedLineFormatter.cpp:139
+
+bool isEndOfNamespace(const AnnotatedLine *line,
+  const SmallVectorImpl &AnnotatedLines) {

djasper wrote:
> s/line/Line/
these methods (isEndOfNamespace, ...) are somewhat duplicated in 
UnwrapperLinesFormatter and NamespaceEndComments (not really, but very similar) 
: should I factorize these into helper methods of FormatToken?


https://reviews.llvm.org/D32480



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


[PATCH] D33354: [clang-tidy] readability-braces-around-statements false positive with char literals

2017-05-19 Thread Florian Gross via Phabricator via cfe-commits
fgross updated this revision to Diff 99576.
fgross added a comment.

After some digging into it, here is my uneducated guess:

The comment in `findEndLocation` states that //"Loc points to the beginning of 
the last token before ';'"//. But `checkStmt` calls it with

`FileRange.getEnd().getLocWithOffset(-1)`

so in fact it points to the last char of the last token. For a string literal 
this would be '"' or ''', not enough for `Lexer::getLocForEndOfToken` to query 
the correct token type. It ends up moving behind the following ';' and skipping 
all whitespaces to next token.

I've updated the diff, this seems to resolve the issue. But I'm sure there is a 
way to pass the correct location in the first place.


https://reviews.llvm.org/D33354

Files:
  clang-tidy/readability/BracesAroundStatementsCheck.cpp


Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -54,14 +54,15 @@
 SourceLocation findEndLocation(SourceLocation LastTokenLoc,
const SourceManager &SM,
const ASTContext *Context) {
-  SourceLocation Loc = LastTokenLoc;
+  SourceLocation Loc =
+  Lexer::GetBeginningOfToken(LastTokenLoc, SM, Context->getLangOpts());
   // Loc points to the beginning of the last (non-comment non-ws) token
   // before end or ';'.
   assert(Loc.isValid());
   bool SkipEndWhitespaceAndComments = true;
   tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
   if (TokKind == tok::NUM_TOKENS || TokKind == tok::semi ||
-  TokKind == tok::r_brace || isStringLiteral(TokKind)) {
+  TokKind == tok::r_brace) {
 // If we are at ";" or "}", we found the last token. We could use as well
 // `if (isa(S))`, but it wouldn't work for nested statements.
 SkipEndWhitespaceAndComments = false;


Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -54,14 +54,15 @@
 SourceLocation findEndLocation(SourceLocation LastTokenLoc,
const SourceManager &SM,
const ASTContext *Context) {
-  SourceLocation Loc = LastTokenLoc;
+  SourceLocation Loc =
+  Lexer::GetBeginningOfToken(LastTokenLoc, SM, Context->getLangOpts());
   // Loc points to the beginning of the last (non-comment non-ws) token
   // before end or ';'.
   assert(Loc.isValid());
   bool SkipEndWhitespaceAndComments = true;
   tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
   if (TokKind == tok::NUM_TOKENS || TokKind == tok::semi ||
-  TokKind == tok::r_brace || isStringLiteral(TokKind)) {
+  TokKind == tok::r_brace) {
 // If we are at ";" or "}", we found the last token. We could use as well
 // `if (isa(S))`, but it wouldn't work for nested statements.
 SkipEndWhitespaceAndComments = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-05-19 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked 3 inline comments as done.
bruno added a comment.

> I think the problem is that we don't take module visibility into account when 
> doing redefinition checking for enumerators. Instead of passing through this 
> flag, we should probably just ignore hidden declarations when checking for a 
> redefinition of an enumerator.

Right, now that the patch changed to only merge the definition after the 
structural check it does makes sense to do that.


https://reviews.llvm.org/D31778



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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-05-19 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 99585.
bruno added a comment.

Update the patch to address @rsmith comments and rebase


https://reviews.llvm.org/D31778

Files:
  include/clang/AST/ASTStructuralEquivalence.h
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTStructuralEquivalence.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/Modules/Inputs/F.framework/Headers/F.h
  test/Modules/Inputs/F.framework/Modules/module.modulemap
  test/Modules/Inputs/F.framework/Modules/module.private.modulemap
  test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
  test/Modules/elaborated-type-specifier-from-hidden-module.m
  test/Modules/redefinition-c-tagtypes.m
  test/Modules/redefinition-same-header.m

Index: test/Modules/redefinition-same-header.m
===
--- test/Modules/redefinition-same-header.m
+++ test/Modules/redefinition-same-header.m
@@ -6,15 +6,7 @@
 // expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
 // expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
 // expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
+// expected-warning@Inputs/SameHeader/C.h:9 {{typedef requires a name}}
 
-// expected-error@Inputs/SameHeader/C.h:5 {{redefinition of 'aaa'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
-
-// expected-error@Inputs/SameHeader/C.h:9 {{redefinition of 'fd_set'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
 #include "A.h" // maps to a modular
 #include "C.h" // textual include
Index: test/Modules/redefinition-c-tagtypes.m
===
--- /dev/null
+++ test/Modules/redefinition-c-tagtypes.m
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN:   -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
+#include "F/F.h"
+
+#ifndef CHANGE_TAGS
+// expected-no-diagnostics
+#endif
+
+struct NS {
+  int a;
+#ifndef CHANGE_TAGS
+  int b;
+#else
+  int c; // expected-note {{field has name 'c' here}}
+  // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
+#endif
+};
+
+enum NSE {
+  FST = 22,
+#ifndef CHANGE_TAGS
+  SND = 43,
+#else
+  SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
+  // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
+#endif
+  TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+  enum _name : _type _name;   \
+  enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+  MinX = 11,
+#ifndef CHANGE_TAGS
+  MinXOther = MinX,
+#else
+  MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
+  // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
+  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}}
+#endif
+};
Index: test/Modules/elaborated-type-specifier-from-hidden-module.m
===
--- test/Modules/elaborated-type-specifier-from-hidden-module.m
+++ test/Modules/elaborated-type-specifier-from-hidden-module.m
@@ -4,12 +4,11 @@
 @import ElaboratedTypeStructs.Empty; // The structs are now hidden.
 struct S1 *x;
 struct S2 *y;
-// FIXME: compatible definition should not be an error.
-struct S2 { int x; }; // expected-error {{redefinition}}
+struct S2 { int x; };
 struct S3 *z;
 // Incompatible definition.
-struct S3 { float y; }; // expected-error {{redefinition}}
-// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
+struct S3 { float y; }; // expected-error {{has incompatible definitions}} // expected-note {{field has name}}
+// expected-note@Inputs/elaborated-type-structs.h:3 {{field has nam

r303432 - [modules] Further delay calling DeclMustBeEmitted until it's safe.

2017-05-19 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri May 19 11:46:06 2017
New Revision: 303432

URL: http://llvm.org/viewvc/llvm-project?rev=303432&view=rev
Log:
[modules] Further delay calling DeclMustBeEmitted until it's safe.

As discussed in D30793, we have some unsafe calls to isConsumerInterestedIn().
This patch implements Richard's suggestion (from the inline comment) that we
should track if we just deserialized an declaration. If we just deserialized,
we can skip the unsafe call because we know it's interesting. If we didn't just
deserialize the declaration, calling isConsumerInterestedIn() should be safe.

We tried to create a test case for this but we were not successful.

Patch by Raphael Isemann (D32499)!

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri May 19 11:46:06 2017
@@ -478,10 +478,18 @@ private:
   /// in the chain.
   DeclUpdateOffsetsMap DeclUpdateOffsets;
 
+  struct PendingUpdateRecord {
+Decl *D;
+serialization::GlobalDeclID ID;
+// Whether the declaration was just deserialized.
+bool JustLoaded;
+PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
+bool JustLoaded)
+: D(D), ID(ID), JustLoaded(JustLoaded) {}
+  };
   /// \brief Declaration updates for already-loaded declarations that we need
   /// to apply once we finish processing an import.
-  llvm::SmallVector, 16>
-  PendingUpdateRecords;
+  llvm::SmallVector PendingUpdateRecords;
 
   enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
 
@@ -1279,7 +1287,7 @@ private:
 
   RecordLocation DeclCursorForID(serialization::DeclID ID,
  SourceLocation &Location);
-  void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
+  void loadDeclUpdateRecords(PendingUpdateRecord &Record);
   void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
   void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
   unsigned PreviousGeneration = 0);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri May 19 11:46:06 2017
@@ -2756,7 +2756,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
   // If we've already loaded the decl, perform the updates when we finish
   // loading this block.
   if (Decl *D = GetExistingDecl(ID))
-PendingUpdateRecords.push_back(std::make_pair(ID, D));
+PendingUpdateRecords.push_back(
+PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
   break;
 }
 
@@ -3086,7 +3087,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
 // If we've already loaded the decl, perform the updates when we finish
 // loading this block.
 if (Decl *D = GetExistingDecl(ID))
-  PendingUpdateRecords.push_back(std::make_pair(ID, D));
+  PendingUpdateRecords.push_back(
+  PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
   }
   break;
 }
@@ -8956,7 +8958,7 @@ void ASTReader::finishPendingActions() {
 while (!PendingUpdateRecords.empty()) {
   auto Update = PendingUpdateRecords.pop_back_val();
   ReadingKindTracker ReadingKind(Read_Decl, *this);
-  loadDeclUpdateRecords(Update.first, Update.second);
+  loadDeclUpdateRecords(Update);
 }
   }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri May 19 11:46:06 2017
@@ -3612,7 +3612,8 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
   assert(Record.getIdx() == Record.size());
 
   // Load any relevant update records.
-  PendingUpdateRecords.push_back(std::make_pair(ID, D));
+  PendingUpdateRecords.push_back(
+  PendingUpdateRecord(ID, D, /*JustLoaded=*/true));
 
   // Load the categories after recursive loading is finished.
   if (ObjCInterfaceDecl *Class = dyn_cast(D))
@@ -3657,20 +3658,24 @@ void ASTReader::PassInterestingDeclsToCo
   }
 }
 
-void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *

[PATCH] D32499: Further delay calling DeclMustBeEmitted until it's safe.

2017-05-19 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r303432.


https://reviews.llvm.org/D32499



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


[PATCH] D33363: [mips] Support `micromips` attribute

2017-05-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
Herald added subscribers: arichardson, javed.absar.

This patch adds support for the `micromips` and `nomicromips` attributes for 
MIPS targets.


Repository:
  rL LLVM

https://reviews.llvm.org/D33363

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/micromips-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-micromips.c
  test/Sema/mips-interrupt-attr.c

Index: test/Sema/mips-interrupt-attr.c
===
--- test/Sema/mips-interrupt-attr.c
+++ test/Sema/mips-interrupt-attr.c
@@ -27,3 +27,8 @@
 // expected-note {{conflicting attribute is here}}
 __attribute__((mips16)) __attribute ((interrupt)) void foo11() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
   // expected-note {{conflicting attribute is here}}
+
+__attribute__((interrupt,micromips)) void foo12() {}  // expected-error {{'interrupt' and 'micromips' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
+__attribute__((micromips,interrupt)) void foo13() {}  // expected-error {{'micromips' and 'interrupt' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/Sema/attr-micromips.c
===
--- /dev/null
+++ test/Sema/attr-micromips.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((nomicromips(0))) void foo1();  // expected-error {{'nomicromips' attribute takes no arguments}}
+__attribute__((micromips(1))) void foo2();// expected-error {{'micromips' attribute takes no arguments}}
+
+__attribute((nomicromips)) int a; // expected-error {{attribute only applies to functions}}
+__attribute((micromips)) int b;   // expected-error {{attribute only applies to functions}}
+
+__attribute__((micromips,mips16)) void foo5();  // expected-error {{'micromips' and 'mips16' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}
+__attribute__((mips16,micromips)) void foo6();  // expected-error {{'mips16' and 'micromips' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}
+
+__attribute((micromips)) void foo7();
+__attribute((nomicromips)) void foo8();
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 60 attributes:
+// CHECK: #pragma clang attribute supports 62 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -30,8 +30,10 @@
 // CHECK-NEXT: IFunc (SubjectMatchRule_function)
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
+// CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
+// CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
Index: test/CodeGen/micromips-attr.c
===
--- /dev/null
+++ test/CodeGen/micromips-attr.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((micromips)) foo (void) {}
+
+// CHECK: define void @foo() [[MICROMIPS:#[0-9]+]]
+
+void __attribute__((nomicromips)) nofoo (void) {}
+
+// CHECK: define void @nofoo() [[NOMICROMIPS:#[0-9]+]]
+
+// CHECK: attributes [[MICROMIPS]] = { noinline nounwind {{.*}} "micromips" {{.*}} }
+// CHECK: attributes [[NOMICROMIPS]]  = { noinline nounwind {{.*}} "nomicromips" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/Sema

[PATCH] D33364: [mips] Support micromips attribute passed by front-end

2017-05-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
Herald added a subscriber: arichardson.

This patch adds handling of the `micromips` and `nomicromips` attributes passed 
by front-end. The patch depends on https://reviews.llvm.org/D33363.


Repository:
  rL LLVM

https://reviews.llvm.org/D33364

Files:
  lib/Target/Mips/MipsTargetMachine.cpp


Index: lib/Target/Mips/MipsTargetMachine.cpp
===
--- lib/Target/Mips/MipsTargetMachine.cpp
+++ lib/Target/Mips/MipsTargetMachine.cpp
@@ -154,6 +154,11 @@
   bool hasNoMips16Attr =
   !F.getFnAttribute("nomips16").hasAttribute(Attribute::None);
 
+  bool HasMicroMipsAttr =
+  !F.getFnAttribute("micromips").hasAttribute(Attribute::None);
+  bool HasNoMicroMipsAttr =
+  !F.getFnAttribute("nomicromips").hasAttribute(Attribute::None);
+
   // FIXME: This is related to the code below to reset the target options,
   // we need to know whether or not the soft float flag is set on the
   // function, so we can enable it as a subtarget feature.
@@ -165,6 +170,10 @@
 FS += FS.empty() ? "+mips16" : ",+mips16";
   else if (hasNoMips16Attr)
 FS += FS.empty() ? "-mips16" : ",-mips16";
+  if (HasMicroMipsAttr)
+FS += FS.empty() ? "+micromips" : ",+micromips";
+  else if (HasNoMicroMipsAttr)
+FS += FS.empty() ? "-micromips" : ",-micromips";
   if (softFloat)
 FS += FS.empty() ? "+soft-float" : ",+soft-float";
 


Index: lib/Target/Mips/MipsTargetMachine.cpp
===
--- lib/Target/Mips/MipsTargetMachine.cpp
+++ lib/Target/Mips/MipsTargetMachine.cpp
@@ -154,6 +154,11 @@
   bool hasNoMips16Attr =
   !F.getFnAttribute("nomips16").hasAttribute(Attribute::None);
 
+  bool HasMicroMipsAttr =
+  !F.getFnAttribute("micromips").hasAttribute(Attribute::None);
+  bool HasNoMicroMipsAttr =
+  !F.getFnAttribute("nomicromips").hasAttribute(Attribute::None);
+
   // FIXME: This is related to the code below to reset the target options,
   // we need to know whether or not the soft float flag is set on the
   // function, so we can enable it as a subtarget feature.
@@ -165,6 +170,10 @@
 FS += FS.empty() ? "+mips16" : ",+mips16";
   else if (hasNoMips16Attr)
 FS += FS.empty() ? "-mips16" : ",-mips16";
+  if (HasMicroMipsAttr)
+FS += FS.empty() ? "+micromips" : ",+micromips";
+  else if (HasNoMicroMipsAttr)
+FS += FS.empty() ? "-micromips" : ",-micromips";
   if (softFloat)
 FS += FS.empty() ? "+soft-float" : ",+soft-float";
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0

2017-05-19 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D32401



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


[PATCH] D32178: Delete unstable integration tests

2017-05-19 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

@arphaman Those patches seem reasonable.


https://reviews.llvm.org/D32178



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


[PATCH] D33272: Method loadFromCommandLine should be able to report errors

2017-05-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In https://reviews.llvm.org/D33272#758616, @joerg wrote:

> Can this use ErrorOr?


It makes sense if constructing methods of `CompilationDatabase` were also 
changed to return `ErrorOr`, as there is no need to have different interfaces 
for the similar functionality. On the other hand, such change would not present 
a gain over existing implementation IMHO.


https://reviews.llvm.org/D33272



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


[PATCH] D33272: Method loadFromCommandLine should be able to report errors

2017-05-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 99600.
sepavloff added a comment.

Change loadFromCommandLine so that it returns std::unique_ptr as methods of 
CompilationDatabase does


https://reviews.llvm.org/D33272

Files:
  include/clang/Tooling/CompilationDatabase.h
  lib/Frontend/CreateInvocationFromCommandLine.cpp
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/Tooling.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -504,29 +504,35 @@
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) {
   int Argc = 0;
-  std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr));
+  std::string ErrorMsg;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr, ErrorMsg);
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: no arguments specified\n");
   EXPECT_EQ(0, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullWithoutDoubleDash) {
   int Argc = 2;
   const char *Argv[] = { "1", "2" };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: double dash not found\n");
   EXPECT_EQ(2, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsArgumentsAfterDoubleDash) {
   int Argc = 5;
   const char *Argv[] = {
 "1", "2", "--\0no-constant-folding", "-DDEF3", "-DDEF4"
   };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -543,9 +549,11 @@
 TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) {
   int Argc = 3;
   const char *Argv[] = { "1", "2", "--\0no-constant-folding" };
-  std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  std::string ErrorMsg;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg);
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -560,9 +568,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) {
   const char *Argv[] = {"1", "2", "--", "-c", "somefile.cpp", "-DDEF3"};
   int Argc = sizeof(Argv) / sizeof(char*);
-  std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  std::string ErrorMsg;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg);
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -579,9 +589,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);
-  std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  std::string ErrorMsg;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg);
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -260,6 +260,8 @@
   Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
+  if (!Compilation)
+return false;
   const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
   &Diagnostics, Compilation.get());
   if (!CC1Args) {
Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 using namespace clang;
@@ -150,23 +151,21 @@
 // options.
 class UnusedInputDiagConsumer : public DiagnosticConsumer {
 public:
-  UnusedInputDiagConsumer() : Other(nullptr) {}
-
-  // Useful for debugging, chain diagnostics to another consumer after
-  // recording for our own pu

[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-05-19 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Parse/Parser.h:1956-1957
   AccessSpecifier AS, DeclSpecContext DSC);
-  void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
+  void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
+ bool IgnorePrevDef = false);
   void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType,

Please remove this (now unused) parameter.



Comment at: lib/Parse/ParseDecl.cpp:4391
 if (TryConsumeToken(tok::equal, EqualLoc)) {
-  AssignedVal = ParseConstantExpression();
+  AssignedVal = ParseConstantExpression(NotTypeCast /*isTypeCast*/);
   if (AssignedVal.isInvalid())

Please revert this no-op change (left over from when you were passing in 
IgnorePrevDef).



Comment at: lib/Sema/SemaDecl.cpp:15423
+ isa(PrevDecl) &&
+ PrevDecl->isFromASTFile() && !isVisible(PrevDecl);
 // When in C++, we may get a TagDecl with the same name; in this case the

The `isFromASTFile` check here is not correct: whether a declaration is from an 
AST file is independent of whether it might be not visible due to being in a 
module (local submodule visibility rules allow a local declaration to not be 
visible). The `Modules` check is also not correct: we do visibility checking 
for local `#include`s of module headers under 
`-fmodules-local-submodule-visibility -fno-modules`.

We also shouldn't diagnose ambiguity if we find two different hidden previous 
declarations, but we will do so (within `LookupSingleName`) with this approach.

Digging into this a bit more, I think the root of the problem is that the 
`ND->isExternallyVisible()` call in `LookupResult::isHiddenDeclarationVisible` 
is wrong. Redeclaration lookup should never find hidden enumerators in C, 
because they do not have linkage (C11 6.2.2/6). (The same is true in C++, but I 
don't know whether we can apply the same thing there too, due to the different 
merging rules.) A function `foo` in some source file should not conflict with 
an enumerator `foo` in a non-imported module, for instance.


https://reviews.llvm.org/D31778



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


[PATCH] D33339: Fix valid-for-expr ellipses eaten as invalid decl

2017-05-19 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D9#759146, @hubert.reinterpretcast wrote:

> The `check-all` target passes even if the ellipsis-after-declarator-id 
> disambiguation as a declarator is removed entirely.


[...]

> So, on the whole, the stray ellipsis treatment is both too complicated and 
> not complicated enough.

I think if we want to keep it, the way to do that would be to carry on through 
the disambiguation process and treat it as a tiebreaker (that's what we do, for 
instance, if we see an undeclared identifier in a position where we're looking 
for a type). I'm not convinced that's worthwhile, especially since our existing 
testcases do not need this disambiguation rule, but perhaps we could remove the 
stray ellipsis treatment entirely for now and reconsider adding it back if we 
find poor diagnostics result from it later?


https://reviews.llvm.org/D9



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


[PATCH] D33250: [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location

2017-05-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 99605.
erik.pilkington added a comment.

> Can we ignore the TypeLocs with invalid location and instead look at 
> ObjCPropertyRefExprs with a class receiver?

Sure, good idea. This new patch does exactly that.

Thanks,
Erik


https://reviews.llvm.org/D33250

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability.m


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -135,6 +135,26 @@
 func_10_12();
 };
 
+AVAILABLE_10_12
+__attribute__((objc_root_class))
+@interface InterWithProp // expected-note 2 {{marked partial here}}
+@property(class) int x;
++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial 
here}}
+@end
+void test_property(void) {
+  int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only 
available on macOS 10.12 or newer}} expected-note{{@available}}
+  InterWithProp.x = y; // expected-warning{{'InterWithProp' is only available 
on macOS 10.12 or newer}} expected-note{{@available}} expected-warning{{'setX:' 
is only available on macOS 10.12 or newer}} expected-note{{@available}}
+}
+
+__attribute__((objc_root_class))
+@interface Subscriptable
+- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // 
expected-note{{marked partial here}}
+@end
+
+void test_at(Subscriptable *x) {
+  id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only 
available on macOS 10.12 or newer}} expected-note{{@available}}
+}
+
 #ifdef OBJCPP
 
 int f(char) AVAILABLE_10_12;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7252,6 +7252,12 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
+if (ObjCInterfaceDecl *ID = PRE->getClassReceiver())
+  DiagnoseDeclAvailability(ID, PRE->getReceiverLocation());
+return true;
+  }
+
   bool VisitObjCMessageExpr(ObjCMessageExpr *Msg) {
 if (ObjCMethodDecl *D = Msg->getMethodDecl())
   DiagnoseDeclAvailability(
@@ -7381,6 +7387,9 @@
   const Type *TyPtr = Ty.getTypePtr();
   SourceRange Range{Ty.getBeginLoc(), Ty.getEndLoc()};
 
+  if (Range.isInvalid())
+return true;
+
   if (const TagType *TT = dyn_cast(TyPtr)) {
 TagDecl *TD = TT->getDecl();
 DiagnoseDeclAvailability(TD, Range);


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -135,6 +135,26 @@
 func_10_12();
 };
 
+AVAILABLE_10_12
+__attribute__((objc_root_class))
+@interface InterWithProp // expected-note 2 {{marked partial here}}
+@property(class) int x;
++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial here}}
+@end
+void test_property(void) {
+  int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
+  InterWithProp.x = y; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}} expected-warning{{'setX:' is only available on macOS 10.12 or newer}} expected-note{{@available}}
+}
+
+__attribute__((objc_root_class))
+@interface Subscriptable
+- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{marked partial here}}
+@end
+
+void test_at(Subscriptable *x) {
+  id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only available on macOS 10.12 or newer}} expected-note{{@available}}
+}
+
 #ifdef OBJCPP
 
 int f(char) AVAILABLE_10_12;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7252,6 +7252,12 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
+if (ObjCInterfaceDecl *ID = PRE->getClassReceiver())
+  DiagnoseDeclAvailability(ID, PRE->getReceiverLocation());
+return true;
+  }
+
   bool VisitObjCMessageExpr(ObjCMessageExpr *Msg) {
 if (ObjCMethodDecl *D = Msg->getMethodDecl())
   DiagnoseDeclAvailability(
@@ -7381,6 +7387,9 @@
   const Type *TyPtr = Ty.getTypePtr();
   SourceRange Range{Ty.getBeginLoc(), Ty.getEndLoc()};
 
+  if (Range.isInvalid())
+return true;
+
   if (const TagType *TT = dyn_cast(TyPtr)) {
 TagDecl *TD = TT->getDecl();
 DiagnoseDeclAvailability(TD, Range);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r303450 - [ODRHash] Support TemplateName and TemplateArgument

2017-05-19 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri May 19 15:05:16 2017
New Revision: 303450

URL: http://llvm.org/viewvc/llvm-project?rev=303450&view=rev
Log:
[ODRHash] Support TemplateName and TemplateArgument

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=303450&r1=303449&r2=303450&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri May 19 15:05:16 2017
@@ -110,8 +110,88 @@ void ODRHash::AddNestedNameSpecifier(con
   }
 }
 
-void ODRHash::AddTemplateName(TemplateName Name) {}
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
+void ODRHash::AddTemplateName(TemplateName Name) {
+  const auto Kind = Name.getKind();
+  ID.AddInteger(Kind);
+  AddBoolean(Name.isDependent());
+  AddBoolean(Name.isInstantiationDependent());
+  switch (Kind) {
+  case TemplateName::Template:
+AddDecl(Name.getAsTemplateDecl());
+break;
+  case TemplateName::OverloadedTemplate: {
+const auto *Storage = Name.getAsOverloadedTemplate();
+ID.AddInteger(Storage->size());
+for (const auto *ND : *Storage) {
+  AddDecl(ND);
+}
+break;
+  }
+  case TemplateName::QualifiedTemplate: {
+const auto *QTN = Name.getAsQualifiedTemplateName();
+AddNestedNameSpecifier(QTN->getQualifier());
+AddBoolean(QTN->hasTemplateKeyword());
+AddDecl(QTN->getDecl());
+break;
+  }
+  case TemplateName::DependentTemplate: {
+const auto *DTN = Name.getAsDependentTemplateName();
+AddBoolean(DTN->isIdentifier());
+if (DTN->isIdentifier()) {
+  AddIdentifierInfo(DTN->getIdentifier());
+} else {
+  ID.AddInteger(DTN->getOperator());
+}
+break;
+  }
+  case TemplateName::SubstTemplateTemplateParm: {
+const auto *Storage = Name.getAsSubstTemplateTemplateParm();
+AddDecl(Storage->getParameter());
+AddTemplateName(Storage->getReplacement());
+break;
+  }
+  case TemplateName::SubstTemplateTemplateParmPack: {
+const auto *Storage = Name.getAsSubstTemplateTemplateParmPack();
+AddDecl(Storage->getParameterPack());
+AddTemplateArgument(Storage->getArgumentPack());
+break;
+  }
+  }
+}
+
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  const auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+  switch (Kind) {
+  case TemplateArgument::Null:
+llvm_unreachable("Require valid TemplateArgument");
+  case TemplateArgument::Type:
+AddQualType(TA.getAsType());
+break;
+  case TemplateArgument::Declaration:
+AddDecl(TA.getAsDecl());
+break;
+  case TemplateArgument::NullPtr:
+AddQualType(TA.getNullPtrType());
+break;
+  case TemplateArgument::Integral:
+TA.getAsIntegral().Profile(ID);
+AddQualType(TA.getIntegralType());
+break;
+  case TemplateArgument::Template:
+  case TemplateArgument::TemplateExpansion:
+AddTemplateName(TA.getAsTemplateOrTemplatePattern());
+break;
+  case TemplateArgument::Expression:
+AddStmt(TA.getAsExpr());
+break;
+  case TemplateArgument::Pack:
+ID.AddInteger(TA.pack_size());
+for (auto SubTA : TA.pack_elements())
+  AddTemplateArgument(SubTA);
+break;
+  }
+}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {
@@ -492,6 +572,14 @@ public:
 AddQualType(T->getNamedType());
 VisitTypeWithKeyword(T);
   }
+
+  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
+ID.AddInteger(T->getNumArgs());
+for (const auto &TA : T->template_arguments()) {
+  Hash.AddTemplateArgument(TA);
+}
+Hash.AddTemplateName(T->getTemplateName());
+  }
 };
 
 void ODRHash::AddType(const Type *T) {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=303450&r1=303449&r2=303450&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri May 19 15:05:16 2017
@@ -866,6 +866,108 @@ S9 s9;
 #endif
 }
 
+namespace TemplateArgument {
+#if defined(FIRST)
+template  struct A1 {};
+struct S1 {
+  A1 x;
+};
+#elif defined(SECOND)
+template  struct A1 {};
+struct S1 {
+  A1 x;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'TemplateArgument::S1::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+template  struct A2 {};
+struct S2 {
+  A2 x;
+};
+#elif defined(SECOND)
+template  struct A2 {};
+struct S2 {
+  A2 x;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{'TemplateArgument::S2::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S2' in module 
'SecondModul

[PATCH] D33339: Fix valid-for-expr ellipses eaten as invalid decl

2017-05-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In https://reviews.llvm.org/D9#759797, @rsmith wrote:

> In https://reviews.llvm.org/D9#759146, @hubert.reinterpretcast wrote:
>
> > The `check-all` target passes even if the ellipsis-after-declarator-id 
> > disambiguation as a declarator is removed entirely.
>
>
> [...]
>
> > So, on the whole, the stray ellipsis treatment is both too complicated and 
> > not complicated enough.
>
> I think if we want to keep it, the way to do that would be to carry on 
> through the disambiguation process and treat it as a tiebreaker (that's what 
> we do, for instance, if we see an undeclared identifier in a position where 
> we're looking for a type). I'm not convinced that's worthwhile, especially 
> since our existing testcases do not need this disambiguation rule, but 
> perhaps we could remove the stray ellipsis treatment entirely for now and 
> reconsider adding it back if we find poor diagnostics result from it later?


Okay. I'll update the patch to remove the stray ellipsis treatment entirely.


https://reviews.llvm.org/D9



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


Re: [libcxx] r302723 - XFAIL is_trivially_copyable test for compilers that don't implement Core 2094

2017-05-19 Thread Evgenii Stepanov via cfe-commits
Hi,

this test is failing for me with ToT clang (clang -cc1 version 5.0.0
based upon LLVM 5.0.0svn). All the failing static_assert's mention
volatile one way or the other.



On Wed, May 10, 2017 at 1:19 PM, Eric Fiselier via cfe-commits
 wrote:
> Author: ericwf
> Date: Wed May 10 15:19:35 2017
> New Revision: 302723
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302723&view=rev
> Log:
> XFAIL is_trivially_copyable test for compilers that don't implement Core 2094
>
> Modified:
> 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>
> Modified: 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp?rev=302723&r1=302722&r2=302723&view=diff
> ==
> --- 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>  Wed May 10 15:19:35 2017
> @@ -11,7 +11,9 @@
>
>  // is_trivially_copyable
>
> -// XFAIL: gcc-4.9
> +// These compilers have not implemented Core 2094 which makes volatile
> +// qualified types trivially copyable.
> +// XFAIL: clang-3, clang-4, apple-clang, gcc
>
>  #include 
>  #include 
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r302723 - XFAIL is_trivially_copyable test for compilers that don't implement Core 2094

2017-05-19 Thread Evgenii Stepanov via cfe-commits
No, sorry, this is not ToT. This is r298531, which already self
identifies as clang-5.0, but, apparently, does not implement Core
2094. I'll just upgrade.


On Fri, May 19, 2017 at 1:27 PM, Evgenii Stepanov
 wrote:
> Hi,
>
> this test is failing for me with ToT clang (clang -cc1 version 5.0.0
> based upon LLVM 5.0.0svn). All the failing static_assert's mention
> volatile one way or the other.
>
>
>
> On Wed, May 10, 2017 at 1:19 PM, Eric Fiselier via cfe-commits
>  wrote:
>> Author: ericwf
>> Date: Wed May 10 15:19:35 2017
>> New Revision: 302723
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=302723&view=rev
>> Log:
>> XFAIL is_trivially_copyable test for compilers that don't implement Core 2094
>>
>> Modified:
>> 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>>
>> Modified: 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp?rev=302723&r1=302722&r2=302723&view=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
>>  Wed May 10 15:19:35 2017
>> @@ -11,7 +11,9 @@
>>
>>  // is_trivially_copyable
>>
>> -// XFAIL: gcc-4.9
>> +// These compilers have not implemented Core 2094 which makes volatile
>> +// qualified types trivially copyable.
>> +// XFAIL: clang-3, clang-4, apple-clang, gcc
>>
>>  #include 
>>  #include 
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r303451 - Do not issue -Wnullability-completeness for dependent types that are not written as pointer types.

2017-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 19 15:20:13 2017
New Revision: 303451

URL: http://llvm.org/viewvc/llvm-project?rev=303451&view=rev
Log:
Do not issue -Wnullability-completeness for dependent types that are not 
written as pointer types.

Added:
cfe/trunk/test/SemaCXX/Inputs/nullability-completeness.h
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/nullability.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=303451&r1=303450&r2=303451&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri May 19 15:20:13 2017
@@ -2011,10 +2011,11 @@ public:
   Optional getNullability(const ASTContext &context) const;
 
   /// Determine whether the given type can have a nullability
-  /// specifier applied to it, i.e., if it is any kind of pointer type
-  /// or a dependent type that could instantiate to any kind of
-  /// pointer type.
-  bool canHaveNullability() const;
+  /// specifier applied to it, i.e., if it is any kind of pointer type.
+  ///
+  /// \param ResultIfUnknown The value to return if we don't yet know whether
+  ///this type can have nullability because it is dependent.
+  bool canHaveNullability(bool ResultIfUnknown = true) const;
 
   /// Retrieve the set of substitutions required when accessing a member
   /// of the Objective-C receiver type that is declared in the given context.

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=303451&r1=303450&r2=303451&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri May 19 15:20:13 2017
@@ -3531,7 +3531,7 @@ Optional Type::getNulla
   } while (true);
 }
 
-bool Type::canHaveNullability() const {
+bool Type::canHaveNullability(bool ResultIfUnknown) const {
   QualType type = getCanonicalTypeInternal();
   
   switch (type->getTypeClass()) {
@@ -3559,7 +3559,8 @@ bool Type::canHaveNullability() const {
   case Type::SubstTemplateTypeParmPack:
   case Type::DependentName:
   case Type::DependentTemplateSpecialization:
-return true;
+  case Type::Auto:
+return ResultIfUnknown;
 
   // Dependent template specializations can instantiate to pointer
   // types unless they're known to be specializations of a class
@@ -3571,12 +3572,7 @@ bool Type::canHaveNullability() const {
   if (isa(templateDecl))
 return false;
 }
-return true;
-
-  // auto is considered dependent when it isn't deduced.
-  case Type::Auto:
-  case Type::DeducedTemplateSpecialization:
-return !cast(type.getTypePtr())->isDeduced();
+return ResultIfUnknown;
 
   case Type::Builtin:
 switch (cast(type.getTypePtr())->getKind()) {
@@ -3595,7 +3591,7 @@ bool Type::canHaveNullability() const {
 case BuiltinType::PseudoObject:
 case BuiltinType::UnknownAny:
 case BuiltinType::ARCUnbridgedCast:
-  return true;
+  return ResultIfUnknown;
 
 case BuiltinType::Void:
 case BuiltinType::ObjCId:
@@ -3614,6 +3610,7 @@ bool Type::canHaveNullability() const {
 case BuiltinType::OMPArraySection:
   return false;
 }
+llvm_unreachable("unknown builtin type");
 
   // Non-pointer types.
   case Type::Complex:
@@ -3629,6 +3626,7 @@ bool Type::canHaveNullability() const {
   case Type::FunctionProto:
   case Type::FunctionNoProto:
   case Type::Record:
+  case Type::DeducedTemplateSpecialization:
   case Type::Enum:
   case Type::InjectedClassName:
   case Type::PackExpansion:

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=303451&r1=303450&r2=303451&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 19 15:20:13 2017
@@ -3735,16 +3735,8 @@ static TypeSourceInfo *GetFullTypeForDec
 // inner pointers.
 complainAboutMissingNullability = CAMN_InnerPointers;
 
-auto isDependentNonPointerType = [](QualType T) -> bool {
-  // Note: This is intended to be the same check as 
Type::canHaveNullability
-  // except with all of the ambiguous cases being treated as 'false' rather
-  // than 'true'.
-  return T->isDependentType() && !T->isAnyPointerType() &&
-!T->isBlockPointerType() && !T->isMemberPointerType();
-};
-
-if (T->canHaveNullability() && !T->getNullability(S.Context) &&
-!isDependentNonPointerType(T)) {
+if (T->canHaveNullability(/*ResultIfUnknown*/false) &&
+!T->getNullability(S.Context)) {
   // Note that we allow but don't require nullability on dependent types.
   ++NumPointersRemaining;
   

[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

2017-05-19 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.

In the current local-submodule-visibility mode, as soon as we discover a 
virtual destructor, we declare on demand a global delete operator. However, 
this causes that this delete operator is owned by the submodule which contains 
said virtual destructor. This means that other modules no longer can see the 
global delete operator which is hidden inside another submodule and fail to 
compile.

As an example, see the test case which contains just two classes with virtual 
destructors. The header a.h has a virtual destructor which declares the delete 
operator in module `a`. Module `b` now fails to compile because it can't 
redeclare the delete operator (due to the shared `Sema` instance) but also 
can't see the hidden delete contained in the unimported module `a`.

This patch declares the delete/new operators before we go into the submoules, 
which prevents that a single submodule can own them.


https://reviews.llvm.org/D33366

Files:
  lib/Sema/Sema.cpp
  test/Modules/Inputs/local-submodule-globaldelete/a.h
  test/Modules/Inputs/local-submodule-globaldelete/b.h
  test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
  test/Modules/local-submodule-globaldelete.cpp


Index: test/Modules/local-submodule-globaldelete.cpp
===
--- /dev/null
+++ test/Modules/local-submodule-globaldelete.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -r %S/Inputs/local-submodule-globaldelete 
%t/local-submodule-globaldelete
+// RUN: cd %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -verify 
-fmodules-cache-path=%t  -fimplicit-module-maps -I local-submodule-globaldelete 
%s -H
+
+// expected-no-diagnostics
+
+// This tests that the global delete operator is not by accident assigned
+// to a submodule in local-submodule-visibility mode. This could happen
+// when the operator is created on demand when we discover a virtual destructor
+// inside a module.
+
+#include "a.h"
Index: test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
@@ -0,0 +1,4 @@
+module M {
+  module a { header "a.h" export * }
+  module b { header "b.h" export * }
+}
Index: test/Modules/Inputs/local-submodule-globaldelete/b.h
===
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/b.h
@@ -0,0 +1,6 @@
+#ifndef B_H
+#define B_H
+class B {
+  virtual ~B() {};
+};
+#endif
Index: test/Modules/Inputs/local-submodule-globaldelete/a.h
===
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/a.h
@@ -0,0 +1,6 @@
+#ifndef A_H
+#define A_H
+class A {
+  virtual ~A() {};
+};
+#endif
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -122,6 +122,12 @@
 
   // Initilization of data sharing attributes stack for OpenMP
   InitDataSharingAttributesStack();
+
+  // If we're now in a module, we declare the global new/delete
+  // functions to make sure they don't end up being owned by a certain
+  // submodule (and are therefore always visible to all submodules).
+  if (getLangOpts().ModulesLocalVisibility && 
!getLangOpts().CurrentModule.empty())
+DeclareGlobalNewDelete();
 }
 
 void Sema::addImplicitTypedef(StringRef Name, QualType T) {


Index: test/Modules/local-submodule-globaldelete.cpp
===
--- /dev/null
+++ test/Modules/local-submodule-globaldelete.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -r %S/Inputs/local-submodule-globaldelete %t/local-submodule-globaldelete
+// RUN: cd %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -verify -fmodules-cache-path=%t  -fimplicit-module-maps -I local-submodule-globaldelete %s -H
+
+// expected-no-diagnostics
+
+// This tests that the global delete operator is not by accident assigned
+// to a submodule in local-submodule-visibility mode. This could happen
+// when the operator is created on demand when we discover a virtual destructor
+// inside a module.
+
+#include "a.h"
Index: test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/module.modulemap
@@ -0,0 +1,4 @@
+module M {
+  module a { header "a.h" export * }
+  module b { header "b.h" export * }
+}
Index: test/Modules/Inputs/local-submodule-globaldelete/b.h
===
--- /dev/null
+++ test/Modules/Inputs/local-submodule-globaldelete/b.h
@@ -0,0 +1,6 @@
+#ifndef B_H
+#define B_H
+class B {
+  virtual ~B() {};
+};
+

[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

2017-05-19 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I'm not 100% sure if that's the right fix, but I didn't see a obvious way to 
declare the new/delete outside the current submodule. Maybe Richard knows a 
better way :)


https://reviews.llvm.org/D33366



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


[PATCH] D33368: [libcxxabi][demangler] Fix a crash in the demangler

2017-05-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
Herald added a reviewer: EricWF.

This patch fixes a bug in the demangler where a pack expansion template 
parameter substitution with more than one element in a lambda's parameter list 
resulted in either a misdemangle or a crash. I'll commit this change to 
ItaniumDemangle.cpp as well, as it has the same problem.

rdar://32098667

Thanks for taking a look,
Erik


https://reviews.llvm.org/D33368

Files:
  src/cxa_demangle.cpp
  test/test_demangle.pass.cpp


Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29604,6 +29604,7 @@
 {"PFvRmOE", "void (*)(unsigned long&) &&"},
 {"_ZTW1x", "thread-local wrapper routine for x"},
 {"_ZTHN3fooE", "thread-local initialization routine for foo"},
+{"_Z4algoIJiiiEEvZ1gEUlT_E_", "void algo(g::'lambda'(int, 
int, int))"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -3015,6 +3015,7 @@
 break;
 case 'l':
   {
+size_t lambda_pos = db.names.size();
 db.names.push_back(typename C::String("'lambda'("));
 const char* t0 = first+2;
 if (first[2] == 'v')
@@ -3024,36 +3025,42 @@
 }
 else
 {
-const char* t1 = parse_type(t0, last, db);
-if (t1 == t0)
-{
-if(!db.names.empty())
-db.names.pop_back();
-return first;
-}
-if (db.names.size() < 2)
-return first;
-auto tmp = db.names.back().move_full();
-db.names.pop_back();
-db.names.back().first.append(tmp);
-t0 = t1;
+bool is_first_it = true;
 while (true)
 {
-t1 = parse_type(t0, last, db);
+size_t k0 = db.names.size();
+const char* t1 = parse_type(t0, last, db);
+size_t k1 = db.names.size();
 if (t1 == t0)
 break;
-if (db.names.size() < 2)
+if (k1 <= k0)
 return first;
-tmp = db.names.back().move_full();
-db.names.pop_back();
-if (!tmp.empty())
-{
-db.names.back().first.append(", ");
-db.names.back().first.append(tmp);
+// If the call to parse_type above found a pack expansion
+// substitution, then multiple names could have been
+// inserted into the name table. Walk through the names,
+// appending each onto the lambda's parameter list.
+for (size_t k = k0; k < k1; ++k) {
+auto tmp = db.names[k].move_full();
+if (!tmp.empty())
+{
+if (!is_first_it)
+db.names[lambda_pos].first.append(", ");
+is_first_it = false;
+db.names[lambda_pos].first.append(tmp);
+}
 }
+db.names.erase(db.names.begin() +
+   static_cast(lambda_pos) + 1,
+   db.names.end());
 t0 = t1;
 }
-if(db.names.empty())
+if (is_first_it)
+{
+if (!db.names.empty())
+db.names.pop_back();
+return first;
+}
+if (db.names.empty() || db.names.size() - 1 != lambda_pos)
   return first;
 db.names.back().first.append(")");
 }


Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29604,6 +29604,7 @@
 {"PFvRmOE", "void (*)(unsigned long&) &&"},
 {"_ZTW1x", "thread-local wrapper routine for x"},
 {"_ZTHN3fooE", "thread-local initialization routine for foo"},
+{"_Z4algoIJiiiEEvZ1gEUlT_E_", "void algo(g::'lambda'(int, int, int))"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -3015,6 +3015,7 @@
 break;
 case 'l':
   {
+size_t lambda_pos = db.names.size();
 db.names.push_back(typename C::Str

LLVM buildmaster will be updated and restarted tonight

2017-05-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 99628.
erik.pilkington added a comment.

In this new patch:

- Add support for toggling -fobjc-arc, this is done by using file extensions, 
ie: `foo.arc.pass.mm` instead of `foo.pass.mm`. (Thanks @dexonsmith for the 
suggestion!)
- Clean up/simplify things a bit

Thanks,
Erik


https://reviews.llvm.org/D33049

Files:
  test/libcxx/selftest/test.arc.fail.mm
  test/libcxx/selftest/test.arc.pass.mm
  test/libcxx/selftest/test.fail.mm
  test/libcxx/selftest/test.pass.mm
  utils/libcxx/compiler.py
  utils/libcxx/test/config.py
  utils/libcxx/test/format.py

Index: utils/libcxx/test/format.py
===
--- utils/libcxx/test/format.py
+++ utils/libcxx/test/format.py
@@ -87,14 +87,22 @@
 name_root, name_ext = os.path.splitext(name)
 is_libcxx_test = test.path_in_suite[0] == 'libcxx'
 is_sh_test = name_root.endswith('.sh')
-is_pass_test = name.endswith('.pass.cpp')
-is_fail_test = name.endswith('.fail.cpp')
-assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test'
+is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
+is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
+is_objcxx_test = name.endswith('.mm')
+is_objcxx_arc_test = name.endswith('.arc.pass.mm') or \
+ name.endswith('.arc.fail.mm')
+assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
+'non-cpp file must be sh test'
 
 if test.config.unsupported:
 return (lit.Test.UNSUPPORTED,
 "A lit.local.cfg marked this unsupported")
 
+if is_objcxx_test and not \
+   'objective-c++' in test.config.available_features:
+return (lit.Test.UNSUPPORTED, "Objective-C++ is not supported")
+
 parsers = self._make_custom_parsers()
 script = lit.TestRunner.parseIntegratedTestScript(
 test, additional_parsers=parsers, require_script=is_sh_test)
@@ -133,6 +141,14 @@
 if '#define _LIBCPP_ASSERT' in contents:
 test_cxx.useModules(False)
 
+if is_objcxx_test:
+test_cxx.source_lang = 'objective-c++'
+if is_objcxx_arc_test:
+test_cxx.compile_flags += ['-fobjc-arc']
+else:
+test_cxx.compile_flags += ['-fno-objc-arc']
+test_cxx.link_flags += ['-framework', 'Foundation']
+
 # Dispatch the test based on its suffix.
 if is_sh_test:
 if not isinstance(self.executor, LocalExecutor):
Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -466,6 +466,12 @@
 self.config.available_features.add('glibc-%s' % maj_v)
 self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
 
+# Support Objective-C++ only on MacOS and if the compiler supports it.
+if self.target_info.platform() == "darwin" and \
+   self.target_info.is_host_macosx() and \
+   self.cxx.hasCompileFlag(["-x", "objective-c++", "-fobjc-arc"]):
+self.config.available_features.add("objective-c++")
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:
Index: utils/libcxx/compiler.py
===
--- utils/libcxx/compiler.py
+++ utils/libcxx/compiler.py
@@ -24,6 +24,7 @@
  modules_flags=None, use_modules=False,
  use_ccache=False, use_warnings=False, compile_env=None,
  cxx_type=None, cxx_version=None):
+self.source_lang = 'c++'
 self.path = path
 self.flags = list(flags or [])
 self.compile_flags = list(compile_flags or [])
@@ -108,7 +109,7 @@
 if out is not None:
 cmd += ['-o', out]
 if input_is_cxx:
-cmd += ['-x', 'c++']
+cmd += ['-x', self.source_lang]
 if isinstance(source_files, list):
 cmd += source_files
 elif isinstance(source_files, str):
Index: test/libcxx/selftest/test.pass.mm
===
--- test/libcxx/selftest/test.pass.mm
+++ test/libcxx/selftest/test.pass.mm
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===--===//
+
+int main()
+{
+}
Index: test/libcxx/selftest/test.fail.mm
===

[PATCH] D33339: Fix valid-for-expr ellipses eaten as invalid decl

2017-05-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast updated this revision to Diff 99632.
hubert.reinterpretcast added a comment.

Remove stray ellipsis treatment entirely


https://reviews.llvm.org/D9

Files:
  lib/Parse/ParseTentative.cpp
  test/Parser/cxx0x-ambig.cpp

Index: test/Parser/cxx0x-ambig.cpp
===
--- test/Parser/cxx0x-ambig.cpp
+++ test/Parser/cxx0x-ambig.cpp
@@ -132,6 +132,32 @@
 void l(int(*...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}}
 void l(int(S::*...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}}
   };
+
+  struct CtorSink {
+template  constexpr CtorSink(T &&...t) { }
+constexpr operator int() const { return 42; }
+  };
+
+  template  struct UnsignedTmplArgSink;
+
+  template 
+  void foo(int x, T ...t) {
+// Have a variety of cases where the syntax is technically unambiguous, but hinges on careful treatment of ellipses.
+CtorSink(t ...), x; // ok, expression; expected-warning 2{{expression result unused}}
+
+int x0(CtorSink(t ...)); // ok, declares object x0
+int *p0 = &x0;
+(void)p0;
+
+CtorSink x1(int(t) ..., int(x)); // ok, declares object x1
+CtorSink *p1 = &x1;
+(void)p1;
+
+UnsignedTmplArgSink *t0; // ok
+UnsignedTmplArgSink<((T *)0, 42u) ...> **t0p = &t0;
+  }
+
+  template void foo(int, int, int); // expected-note {{in instantiation of function template specialization 'ellipsis::foo' requested here}}
 }
 
 namespace braced_init_list {
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -481,10 +481,10 @@
   /// the corresponding ')'. If the context is
   /// TypeIdAsTemplateArgument, we've already parsed the '<' or ','
   /// before this template argument, and will cease lookahead when we
-  /// hit a '>', '>>' (in C++0x), or ','. Returns true for a type-id
-  /// and false for an expression.  If during the disambiguation
-  /// process a parsing error is encountered, the function returns
-  /// true to let the declaration parsing code handle it.
+  /// hit a '>', '>>' (in C++0x), or ','; or, in C++0x, an ellipsis immediately
+  /// preceding such. Returns true for a type-id and false for an expression.
+  /// If during the disambiguation process a parsing error is encountered,
+  /// the function returns true to let the declaration parsing code handle it.
   ///
   /// type-id:
   ///   type-specifier-seq abstract-declarator[opt]
@@ -533,10 +533,15 @@
 
 // We are supposed to be inside a template argument, so if after
 // the abstract declarator we encounter a '>', '>>' (in C++0x), or
-// ',', this is a type-id. Otherwise, it's an expression.
+// ','; or, in C++0x, an ellipsis immediately preceding such, this
+// is a type-id. Otherwise, it's an expression.
 } else if (Context == TypeIdAsTemplateArgument &&
(Tok.isOneOf(tok::greater, tok::comma) ||
-(getLangOpts().CPlusPlus11 && Tok.is(tok::greatergreater {
+(getLangOpts().CPlusPlus11 &&
+ (Tok.is(tok::greatergreater) ||
+  (Tok.is(tok::ellipsis) &&
+   NextToken().isOneOf(tok::greater, tok::greatergreater,
+   tok::comma)) {
   TPR = TPResult::True;
   isAmbiguous = true;
 
@@ -829,14 +834,14 @@
 /// abstract-declarator:
 ///   ptr-operator abstract-declarator[opt]
 ///   direct-abstract-declarator
-///   ...
 ///
 /// direct-abstract-declarator:
 ///   direct-abstract-declarator[opt]
-///   '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
+/// '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
 /// exception-specification[opt]
 ///   direct-abstract-declarator[opt] '[' constant-expression[opt] ']'
 ///   '(' abstract-declarator ')'
+/// [C++0x]   ...
 ///
 /// ptr-operator:
 ///   '*' cv-qualifier-seq[opt]
@@ -928,10 +933,6 @@
   while (1) {
 TPResult TPR(TPResult::Ambiguous);
 
-// abstract-declarator: ...
-if (Tok.is(tok::ellipsis))
-  ConsumeToken();
-
 if (Tok.is(tok::l_paren)) {
   // Check whether we have a function declarator or a possible ctor-style
   // initializer that follows the declarator. Note that ctor-style
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-19 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Would be good to test for the presence/absence of the flag, too:




Comment at: test/libcxx/selftest/test.arc.pass.mm:10
+//===--===//
+
+int main()

```
#if __has_feature(objc_arc) != 1
#error "arc should be enabled"
#endif
```



Comment at: test/libcxx/selftest/test.pass.mm:10
+//===--===//
+
+int main()

```
#if __has_feature(objc_arc) == 1
#error "arc should *not* be enabled"
#endif
```


https://reviews.llvm.org/D33049



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


[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 99633.
erik.pilkington marked an inline comment as done.
erik.pilkington added a comment.

This new patch checks to make sure ARC is enabled in the tests, thanks for the 
suggestion!


https://reviews.llvm.org/D33049

Files:
  test/libcxx/selftest/test.arc.fail.mm
  test/libcxx/selftest/test.arc.pass.mm
  test/libcxx/selftest/test.fail.mm
  test/libcxx/selftest/test.pass.mm
  utils/libcxx/compiler.py
  utils/libcxx/test/config.py
  utils/libcxx/test/format.py

Index: utils/libcxx/test/format.py
===
--- utils/libcxx/test/format.py
+++ utils/libcxx/test/format.py
@@ -87,14 +87,22 @@
 name_root, name_ext = os.path.splitext(name)
 is_libcxx_test = test.path_in_suite[0] == 'libcxx'
 is_sh_test = name_root.endswith('.sh')
-is_pass_test = name.endswith('.pass.cpp')
-is_fail_test = name.endswith('.fail.cpp')
-assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test'
+is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
+is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
+is_objcxx_test = name.endswith('.mm')
+is_objcxx_arc_test = name.endswith('.arc.pass.mm') or \
+ name.endswith('.arc.fail.mm')
+assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
+'non-cpp file must be sh test'
 
 if test.config.unsupported:
 return (lit.Test.UNSUPPORTED,
 "A lit.local.cfg marked this unsupported")
 
+if is_objcxx_test and not \
+   'objective-c++' in test.config.available_features:
+return (lit.Test.UNSUPPORTED, "Objective-C++ is not supported")
+
 parsers = self._make_custom_parsers()
 script = lit.TestRunner.parseIntegratedTestScript(
 test, additional_parsers=parsers, require_script=is_sh_test)
@@ -133,6 +141,14 @@
 if '#define _LIBCPP_ASSERT' in contents:
 test_cxx.useModules(False)
 
+if is_objcxx_test:
+test_cxx.source_lang = 'objective-c++'
+if is_objcxx_arc_test:
+test_cxx.compile_flags += ['-fobjc-arc']
+else:
+test_cxx.compile_flags += ['-fno-objc-arc']
+test_cxx.link_flags += ['-framework', 'Foundation']
+
 # Dispatch the test based on its suffix.
 if is_sh_test:
 if not isinstance(self.executor, LocalExecutor):
Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -466,6 +466,12 @@
 self.config.available_features.add('glibc-%s' % maj_v)
 self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
 
+# Support Objective-C++ only on MacOS and if the compiler supports it.
+if self.target_info.platform() == "darwin" and \
+   self.target_info.is_host_macosx() and \
+   self.cxx.hasCompileFlag(["-x", "objective-c++", "-fobjc-arc"]):
+self.config.available_features.add("objective-c++")
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:
Index: utils/libcxx/compiler.py
===
--- utils/libcxx/compiler.py
+++ utils/libcxx/compiler.py
@@ -24,6 +24,7 @@
  modules_flags=None, use_modules=False,
  use_ccache=False, use_warnings=False, compile_env=None,
  cxx_type=None, cxx_version=None):
+self.source_lang = 'c++'
 self.path = path
 self.flags = list(flags or [])
 self.compile_flags = list(compile_flags or [])
@@ -108,7 +109,7 @@
 if out is not None:
 cmd += ['-o', out]
 if input_is_cxx:
-cmd += ['-x', 'c++']
+cmd += ['-x', self.source_lang]
 if isinstance(source_files, list):
 cmd += source_files
 elif isinstance(source_files, str):
Index: test/libcxx/selftest/test.pass.mm
===
--- test/libcxx/selftest/test.pass.mm
+++ test/libcxx/selftest/test.pass.mm
@@ -0,0 +1,17 @@
+// -*- 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.
+//
+//===--===//
+
+#if __has_feature(objc_arc)
+#error "arc should *not* be enabled"
+#endif
+
+int main()
+{
+}
Index: test/libcxx/selftest/test.fail.mm

[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-19 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D33049



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


[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

2017-05-19 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

This is supposed to be handled by `Sema::DeclareGlobalAllocationFunction`:

  DeclContext::lookup_result R = GlobalCtx->lookup(Name);
  for (DeclContext::lookup_iterator Alloc = R.begin(), AllocEnd = R.end();
   Alloc != AllocEnd; ++Alloc) {
// Only look at non-template functions, as it is the predefined,
// non-templated allocation function we are trying to declare here.
if (FunctionDecl *Func = dyn_cast(*Alloc)) {
  if (Func->getNumParams() == Params.size()) {
llvm::SmallVector FuncParams;
for (auto *P : Func->parameters())
  FuncParams.push_back(
  Context.getCanonicalType(P->getType().getUnqualifiedType()));
if (llvm::makeArrayRef(FuncParams) == Params) {
  // Make the function visible to name lookup, even if we found it in
  // an unimported module. It either is an implicitly-declared global
  // allocation function, or is suppressing that function.
  Func->setHidden(false);
  return;

... but it looks like we only get there once per compilation, which means that 
we won't unset the 'hidden' flag if we create the functions in one submodule 
and then need them from a second one, as in your testcase.

A better approach would be to call `Alloc->setHidden(false)` (and maybe also 
`Alloc->setLocalOwningModule(nullptr)`) after we create the implicit 
declaration in the `CreateAllocationFunctionDecl` lambda, rather than waiting 
until the second time we want it.


https://reviews.llvm.org/D33366



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


r303459 - [ODRHash] Revert r303450 to fix buildbot

2017-05-19 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri May 19 17:35:41 2017
New Revision: 303459

URL: http://llvm.org/viewvc/llvm-project?rev=303459&view=rev
Log:
[ODRHash] Revert r303450 to fix buildbot

r303450
[ODRHash] Support TemplateName and TemplateArgument


Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=303459&r1=303458&r2=303459&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri May 19 17:35:41 2017
@@ -110,88 +110,8 @@ void ODRHash::AddNestedNameSpecifier(con
   }
 }
 
-void ODRHash::AddTemplateName(TemplateName Name) {
-  const auto Kind = Name.getKind();
-  ID.AddInteger(Kind);
-  AddBoolean(Name.isDependent());
-  AddBoolean(Name.isInstantiationDependent());
-  switch (Kind) {
-  case TemplateName::Template:
-AddDecl(Name.getAsTemplateDecl());
-break;
-  case TemplateName::OverloadedTemplate: {
-const auto *Storage = Name.getAsOverloadedTemplate();
-ID.AddInteger(Storage->size());
-for (const auto *ND : *Storage) {
-  AddDecl(ND);
-}
-break;
-  }
-  case TemplateName::QualifiedTemplate: {
-const auto *QTN = Name.getAsQualifiedTemplateName();
-AddNestedNameSpecifier(QTN->getQualifier());
-AddBoolean(QTN->hasTemplateKeyword());
-AddDecl(QTN->getDecl());
-break;
-  }
-  case TemplateName::DependentTemplate: {
-const auto *DTN = Name.getAsDependentTemplateName();
-AddBoolean(DTN->isIdentifier());
-if (DTN->isIdentifier()) {
-  AddIdentifierInfo(DTN->getIdentifier());
-} else {
-  ID.AddInteger(DTN->getOperator());
-}
-break;
-  }
-  case TemplateName::SubstTemplateTemplateParm: {
-const auto *Storage = Name.getAsSubstTemplateTemplateParm();
-AddDecl(Storage->getParameter());
-AddTemplateName(Storage->getReplacement());
-break;
-  }
-  case TemplateName::SubstTemplateTemplateParmPack: {
-const auto *Storage = Name.getAsSubstTemplateTemplateParmPack();
-AddDecl(Storage->getParameterPack());
-AddTemplateArgument(Storage->getArgumentPack());
-break;
-  }
-  }
-}
-
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {
-  const auto Kind = TA.getKind();
-  ID.AddInteger(Kind);
-  switch (Kind) {
-  case TemplateArgument::Null:
-llvm_unreachable("Require valid TemplateArgument");
-  case TemplateArgument::Type:
-AddQualType(TA.getAsType());
-break;
-  case TemplateArgument::Declaration:
-AddDecl(TA.getAsDecl());
-break;
-  case TemplateArgument::NullPtr:
-AddQualType(TA.getNullPtrType());
-break;
-  case TemplateArgument::Integral:
-TA.getAsIntegral().Profile(ID);
-AddQualType(TA.getIntegralType());
-break;
-  case TemplateArgument::Template:
-  case TemplateArgument::TemplateExpansion:
-AddTemplateName(TA.getAsTemplateOrTemplatePattern());
-break;
-  case TemplateArgument::Expression:
-AddStmt(TA.getAsExpr());
-break;
-  case TemplateArgument::Pack:
-ID.AddInteger(TA.pack_size());
-for (auto SubTA : TA.pack_elements())
-  AddTemplateArgument(SubTA);
-break;
-  }
-}
+void ODRHash::AddTemplateName(TemplateName Name) {}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {
@@ -572,14 +492,6 @@ public:
 AddQualType(T->getNamedType());
 VisitTypeWithKeyword(T);
   }
-
-  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
-ID.AddInteger(T->getNumArgs());
-for (const auto &TA : T->template_arguments()) {
-  Hash.AddTemplateArgument(TA);
-}
-Hash.AddTemplateName(T->getTemplateName());
-  }
 };
 
 void ODRHash::AddType(const Type *T) {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=303459&r1=303458&r2=303459&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri May 19 17:35:41 2017
@@ -866,108 +866,6 @@ S9 s9;
 #endif
 }
 
-namespace TemplateArgument {
-#if defined(FIRST)
-template  struct A1 {};
-struct S1 {
-  A1 x;
-};
-#elif defined(SECOND)
-template  struct A1 {};
-struct S1 {
-  A1 x;
-};
-#else
-S1 s1;
-// expected-error@first.h:* {{'TemplateArgument::S1::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'x' does not match}}
-#endif
-
-#if defined(FIRST)
-template  struct A2 {};
-struct S2 {
-  A2 x;
-};
-#elif defined(SECOND)
-template  struct A2 {};
-struct S2 {
-  A2 x;
-};
-#else
-S2 s2;
-// expected-error@first.h:* {{'TemplateArgument::S2::x' from module 
'FirstModule' is not present in definitio

r303463 - CodeGenModule: Always output wchar_size, check LLVM assumptions.

2017-05-19 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri May 19 17:37:15 2017
New Revision: 303463

URL: http://llvm.org/viewvc/llvm-project?rev=303463&view=rev
Log:
CodeGenModule: Always output wchar_size, check LLVM assumptions.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

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

Added:
cfe/trunk/test/CodeGen/wchar-size.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=303463&r1=303462&r2=303463&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 19 17:37:15 2017
@@ -45,6 +45,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/DataLayout.h"
@@ -465,18 +466,24 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
 
+  // Width of wchar_t in bytes
+  uint64_t WCharWidth =
+  Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
+  assert(LangOpts.ShortWChar ||
+ llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) ==
+ Target.getWCharWidth() / 8 &&
+ "LLVM wchar_t size out of sync");
+
   // We need to record the widths of enums and wchar_t, so that we can generate
-  // the correct build attributes in the ARM backend.
+  // the correct build attributes in the ARM backend. wchar_size is also used 
by
+  // TargetLibraryInfo.
+  getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
+
   llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
   if (   Arch == llvm::Triple::arm
   || Arch == llvm::Triple::armeb
   || Arch == llvm::Triple::thumb
   || Arch == llvm::Triple::thumbeb) {
-// Width of wchar_t in bytes
-uint64_t WCharWidth =
-Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
-
 // The minimum width of an enum in bytes
 uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);

Added: cfe/trunk/test/CodeGen/wchar-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wchar-size.c?rev=303463&view=auto
==
--- cfe/trunk/test/CodeGen/wchar-size.c (added)
+++ cfe/trunk/test/CodeGen/wchar-size.c Fri May 19 17:37:15 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fshort-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// Note: -fno-short-wchar implies the target default is used; so there is no
+// need to test this separately here.
+
+// LONG-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 4}
+// SHORT-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 2}


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


[libcxx] r303466 - [test] Add support for Objective-C++ tests

2017-05-19 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri May 19 18:02:49 2017
New Revision: 303466

URL: http://llvm.org/viewvc/llvm-project?rev=303466&view=rev
Log:
[test] Add support for Objective-C++ tests

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

Added:
libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm
libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm
libcxx/trunk/test/libcxx/selftest/test.fail.mm
libcxx/trunk/test/libcxx/selftest/test.pass.mm
Modified:
libcxx/trunk/utils/libcxx/compiler.py
libcxx/trunk/utils/libcxx/test/config.py
libcxx/trunk/utils/libcxx/test/format.py

Added: libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm?rev=303466&view=auto
==
--- libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm (added)
+++ libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm Fri May 19 18:02:49 2017
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===--===//
+
+#if __has_feature(objc_arc)
+#error This test should not compile.
+#endif

Added: libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm?rev=303466&view=auto
==
--- libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm (added)
+++ libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm Fri May 19 18:02:49 2017
@@ -0,0 +1,17 @@
+// -*- 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.
+//
+//===--===//
+
+#if __has_feature(objc_arc) == 0
+#error "arc should be enabled"
+#endif
+
+int main()
+{
+}

Added: libcxx/trunk/test/libcxx/selftest/test.fail.mm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/selftest/test.fail.mm?rev=303466&view=auto
==
--- libcxx/trunk/test/libcxx/selftest/test.fail.mm (added)
+++ libcxx/trunk/test/libcxx/selftest/test.fail.mm Fri May 19 18:02:49 2017
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===--===//
+
+#if __has_feature(objc_arc) == 0
+#error This test should not compile.
+#endif

Added: libcxx/trunk/test/libcxx/selftest/test.pass.mm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/selftest/test.pass.mm?rev=303466&view=auto
==
--- libcxx/trunk/test/libcxx/selftest/test.pass.mm (added)
+++ libcxx/trunk/test/libcxx/selftest/test.pass.mm Fri May 19 18:02:49 2017
@@ -0,0 +1,17 @@
+// -*- 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.
+//
+//===--===//
+
+#if __has_feature(objc_arc)
+#error "arc should *not* be enabled"
+#endif
+
+int main()
+{
+}

Modified: libcxx/trunk/utils/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/compiler.py?rev=303466&r1=303465&r2=303466&view=diff
==
--- libcxx/trunk/utils/libcxx/compiler.py (original)
+++ libcxx/trunk/utils/libcxx/compiler.py Fri May 19 18:02:49 2017
@@ -24,6 +24,7 @@ class CXXCompiler(object):
  modules_flags=None, use_modules=False,
  use_ccache=False, use_warnings=False, compile_env=None,
  cxx_type=None, cxx_version=None):
+self.source_lang = 'c++'
 self.path = path
 self.flags = list(flags or [])
 self.compile_flags = list(compile_flags or [])
@@ -108,7 +109,7 @@ class CXXCompiler(object):
 if out is not None:
 cmd += ['-o', out]
 if input_is_cxx:
-cmd += ['-x', 'c+

[PATCH] D33049: [libcxx] Support for Objective-C++ tests

2017-05-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303466: [test] Add support for Objective-C++ tests (authored 
by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D33049?vs=99633&id=99643#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33049

Files:
  libcxx/trunk/test/libcxx/selftest/test.arc.fail.mm
  libcxx/trunk/test/libcxx/selftest/test.arc.pass.mm
  libcxx/trunk/test/libcxx/selftest/test.fail.mm
  libcxx/trunk/test/libcxx/selftest/test.pass.mm
  libcxx/trunk/utils/libcxx/compiler.py
  libcxx/trunk/utils/libcxx/test/config.py
  libcxx/trunk/utils/libcxx/test/format.py

Index: libcxx/trunk/utils/libcxx/compiler.py
===
--- libcxx/trunk/utils/libcxx/compiler.py
+++ libcxx/trunk/utils/libcxx/compiler.py
@@ -24,6 +24,7 @@
  modules_flags=None, use_modules=False,
  use_ccache=False, use_warnings=False, compile_env=None,
  cxx_type=None, cxx_version=None):
+self.source_lang = 'c++'
 self.path = path
 self.flags = list(flags or [])
 self.compile_flags = list(compile_flags or [])
@@ -108,7 +109,7 @@
 if out is not None:
 cmd += ['-o', out]
 if input_is_cxx:
-cmd += ['-x', 'c++']
+cmd += ['-x', self.source_lang]
 if isinstance(source_files, list):
 cmd += source_files
 elif isinstance(source_files, str):
Index: libcxx/trunk/utils/libcxx/test/format.py
===
--- libcxx/trunk/utils/libcxx/test/format.py
+++ libcxx/trunk/utils/libcxx/test/format.py
@@ -87,14 +87,22 @@
 name_root, name_ext = os.path.splitext(name)
 is_libcxx_test = test.path_in_suite[0] == 'libcxx'
 is_sh_test = name_root.endswith('.sh')
-is_pass_test = name.endswith('.pass.cpp')
-is_fail_test = name.endswith('.fail.cpp')
-assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test'
+is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
+is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
+is_objcxx_test = name.endswith('.mm')
+is_objcxx_arc_test = name.endswith('.arc.pass.mm') or \
+ name.endswith('.arc.fail.mm')
+assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
+'non-cpp file must be sh test'
 
 if test.config.unsupported:
 return (lit.Test.UNSUPPORTED,
 "A lit.local.cfg marked this unsupported")
 
+if is_objcxx_test and not \
+   'objective-c++' in test.config.available_features:
+return (lit.Test.UNSUPPORTED, "Objective-C++ is not supported")
+
 parsers = self._make_custom_parsers()
 script = lit.TestRunner.parseIntegratedTestScript(
 test, additional_parsers=parsers, require_script=is_sh_test)
@@ -133,6 +141,14 @@
 if '#define _LIBCPP_ASSERT' in contents:
 test_cxx.useModules(False)
 
+if is_objcxx_test:
+test_cxx.source_lang = 'objective-c++'
+if is_objcxx_arc_test:
+test_cxx.compile_flags += ['-fobjc-arc']
+else:
+test_cxx.compile_flags += ['-fno-objc-arc']
+test_cxx.link_flags += ['-framework', 'Foundation']
+
 # Dispatch the test based on its suffix.
 if is_sh_test:
 if not isinstance(self.executor, LocalExecutor):
Index: libcxx/trunk/utils/libcxx/test/config.py
===
--- libcxx/trunk/utils/libcxx/test/config.py
+++ libcxx/trunk/utils/libcxx/test/config.py
@@ -466,6 +466,12 @@
 self.config.available_features.add('glibc-%s' % maj_v)
 self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
 
+# Support Objective-C++ only on MacOS and if the compiler supports it.
+if self.target_info.platform() == "darwin" and \
+   self.target_info.is_host_macosx() and \
+   self.cxx.hasCompileFlag(["-x", "objective-c++", "-fobjc-arc"]):
+self.config.available_features.add("objective-c++")
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:
Index: libcxx/trunk/test/libcxx/selftest/test.pass.mm
===
--- libcxx/trunk/test/libcxx/selftest/test.pass.mm
+++ libcxx/trunk/test/libcxx/selftest/test.pass.mm
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT f

r303468 - [modules] Simplify module macro handling in non-local-submodule-visibility mode.

2017-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 19 18:32:38 2017
New Revision: 303468

URL: http://llvm.org/viewvc/llvm-project?rev=303468&view=rev
Log:
[modules] Simplify module macro handling in non-local-submodule-visibility mode.

When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)


This reinstates r302932, reverted in r302947, with a fix for a bug that
resulted in us sometimes losing macro definitions due to failing to clear out
the overridden module macro list when promoting a directive to a module macro.

Added:
cfe/trunk/test/Modules/macro-redefinition.cpp
Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=303468&r1=303467&r2=303468&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 19 18:32:38 2017
@@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
   Module *LeavingMod = Info.M;
   SourceLocation ImportLoc = Info.ImportLoc;
 
-  if (!needModuleMacros() || 
+  if (!needModuleMacros() ||
   (!getLangOpts().ModulesLocalVisibility &&
LeavingMod->getTopLevelModuleName() != getLangOpts().CurrentModule)) {
 // If we don't need module macros, or this is not a module for which we
@@ -777,17 +777,6 @@ Module *Preprocessor::LeaveSubmodule(boo
 for (auto *MD = Macro.getLatest(); MD != OldMD; MD = MD->getPrevious()) {
   assert(MD && "broken macro directive chain");
 
-  // Stop on macros defined in other submodules of this module that we
-  // #included along the way. There's no point doing this if we're
-  // tracking local submodule visibility, since there can be no such
-  // directives in our list.
-  if (!getLangOpts().ModulesLocalVisibility) {
-Module *Mod = getModuleContainingLocation(MD->getLocation());
-if (Mod != LeavingMod &&
-Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
-  break;
-  }
-
   if (auto *VisMD = dyn_cast(MD)) {
 // The latest visibility directive for a name in a submodule affects
 // all the directives that come before it.
@@ -809,6 +798,13 @@ Module *Preprocessor::LeaveSubmodule(boo
 if (Def || !Macro.getOverriddenMacros().empty())
   addModuleMacro(LeavingMod, II, Def,
  Macro.getOverriddenMacros(), IsNew);
+
+if (!getLangOpts().ModulesLocalVisibility) {
+  // This macro is exposed to the rest of this compilation as a
+  // ModuleMacro; we don't need to track its MacroDirective any more.
+  Macro.setLatest(nullptr);
+  Macro.setOverriddenMacros(*this, {});
+}
 break;
   }
 }

Added: cfe/trunk/test/Modules/macro-redefinition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macro-redefinition.cpp?rev=303468&view=auto
==
--- cfe/trunk/test/Modules/macro-redefinition.cpp (added)
+++ cfe/trunk/test/Modules/macro-redefinition.cpp Fri May 19 18:32:38 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fmodules -x c++-module-map %s -fmodule-name=__usr_include 
-verify
+// RUN: %clang_cc1 -fmodules -x c++-module-map %s -fmodule-name=__usr_include 
-verify -DIMPORT
+
+module __usr_include {
+  module stddef {}
+  module stdlib {}
+}
+
+#pragma clang module contents
+
+// expected-no-diagnostics
+
+#pragma clang module begin __usr_include.stddef
+  #define NULL 0
+#pragma clang module end
+
+#pragma clang module begin __usr_include.stdlib
+  #ifdef IMPORT
+#pragma clang module import __usr_include.stddef
+  #else
+#pragma clang module begin __usr_include.stddef
+  #define NU

[PATCH] D33339: Fix valid-for-expr ellipses eaten as invalid decl

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

LGTM, thanks!


https://reviews.llvm.org/D9



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


r303469 - Remove last (unnecessary) use of mapping from SourceLocation to Module and

2017-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 19 18:49:00 2017
New Revision: 303469

URL: http://llvm.org/viewvc/llvm-project?rev=303469&view=rev
Log:
Remove last (unnecessary) use of mapping from SourceLocation to Module and
remove the mechanism for doing so.

This mechanism was incorrect in the presence of preprocessed modules (and
#pragma clang module begin/end).

Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=303469&r1=303468&r2=303469&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri May 19 18:49:00 2017
@@ -507,16 +507,6 @@ public:
   /// false otherwise.
   bool resolveConflicts(Module *Mod, bool Complain);
 
-  /// \brief Infers the (sub)module based on the given source location and
-  /// source manager.
-  ///
-  /// \param Loc The location within the source that we are querying, along
-  /// with its source manager.
-  ///
-  /// \returns The module that owns this source location, or null if no
-  /// module owns this source location.
-  Module *inferModuleFromLocation(FullSourceLoc Loc);
-  
   /// \brief Sets the umbrella header of the given module to the given
   /// header.
   void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader,

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=303469&r1=303468&r2=303469&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri May 19 18:49:00 2017
@@ -1917,14 +1917,11 @@ public:
   /// into a module, or is outside any module, returns nullptr.
   Module *getModuleForLocation(SourceLocation Loc);
 
-  /// \brief Find the module that contains the specified location, either
-  /// directly or indirectly.
-  Module *getModuleContainingLocation(SourceLocation Loc);
-
   /// \brief We want to produce a diagnostic at location IncLoc concerning a
   /// missing module import.
   ///
   /// \param IncLoc The location at which the missing import was detected.
+  /// \param M The desired module.
   /// \param MLoc A location within the desired module at which some desired
   ///effect occurred (eg, where a desired entity was declared).
   ///
@@ -1932,6 +1929,7 @@ public:
   /// Null if no such file could be determined or if a #include is not
   /// appropriate.
   const FileEntry *getModuleHeaderToIncludeForDiagnostics(SourceLocation 
IncLoc,
+  Module *M,
   SourceLocation MLoc);
 
 private:

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=303469&r1=303468&r2=303469&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri May 19 18:49:00 2017
@@ -950,39 +950,6 @@ bool ModuleMap::resolveConflicts(Module
   return !Mod->UnresolvedConflicts.empty();
 }
 
-Module *ModuleMap::inferModuleFromLocation(FullSourceLoc Loc) {
-  if (Loc.isInvalid())
-return nullptr;
-
-  if (UmbrellaDirs.empty() && Headers.empty())
-return nullptr;
-
-  // Use the expansion location to determine which module we're in.
-  FullSourceLoc ExpansionLoc = Loc.getExpansionLoc();
-  if (!ExpansionLoc.isFileID())
-return nullptr;
-
-  const SourceManager &SrcMgr = Loc.getManager();
-  FileID ExpansionFileID = ExpansionLoc.getFileID();
-  
-  while (const FileEntry *ExpansionFile
-   = SrcMgr.getFileEntryForID(ExpansionFileID)) {
-// Find the module that owns this header (if any).
-if (Module *Mod = findModuleForHeader(ExpansionFile).getModule())
-  return Mod;
-
-// No module owns this header, so look up the inclusion chain to see if
-// any included header has an associated module.
-SourceLocation IncludeLoc = SrcMgr.getIncludeLoc(ExpansionFileID);
-if (IncludeLoc.isInvalid())
-  return nullptr;
-
-ExpansionFileID = SrcMgr.getFileID(IncludeLoc);
-  }
-
-  return nullptr;
-}
-
 
////
 // Module map file parser
 
////

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=303469&r1=303468&r2=303469&view=diff

Buildbot numbers for the week of 05/07/2017 - 05/13/2017

2017-05-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 05/07/2017 -
05/13/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-x86-windows-msvc2015 | 92:22:56
 clang-x64-ninja-win7   | 75:31:27
 clang-ppc64be-linux-multistage | 60:46:12
 clang-ppc64be-linux-lnt| 60:18:00
 clang-ppc64be-linux| 58:35:55
 sanitizer-x86_64-linux | 33:16:50
 clang-x86_64-linux-abi-test| 32:52:04
 sanitizer-ppc64be-linux| 31:35:20
 clang-ppc64le-linux-multistage | 30:26:04
 clang-ppc64le-linux| 28:38:02
 sanitizer-ppc64le-linux| 28:23:33
 clang-cuda-build   | 25:23:15
 sanitizer-x86_64-linux-bootstrap   | 24:17:40
 clang-cmake-aarch64-39vma  | 20:31:49
 clang-cmake-aarch64-42vma  | 20:10:59
 sanitizer-x86_64-linux-fast| 19:07:17
 sanitizer-x86_64-linux-autoconf| 18:41:42
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 18:13:58
 libcxx-libcxxabi-libunwind-arm-linux   | 18:04:54
 sanitizer-windows  | 18:03:27
 clang-bpf-build| 17:57:19
 sanitizer-x86_64-linux-fuzzer  | 17:10:34
 lldb-x86_64-darwin-13.4| 15:08:46
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 15:07:05
 perf-x86_64-penryn-O3  | 13:04:57
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 11:23:49
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14 | 10:57:23
 perf-x86_64-penryn-O3-polly| 10:44:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11 | 10:30:43
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 10:09:00
 polly-amd64-linux  | 09:49:59
 polly-arm-linux| 09:30:53
 clang-tools-sphinx-docs| 09:29:52
 libcxx-libcxxabi-libunwind-aarch64-linux   | 09:01:33
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-cxx1z | 08:47:16
 clang-hexagon-elf  | 08:22:42
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 08:19:42
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions  | 08:14:08
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions  | 08:13:24
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 07:56:42
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 07:39:36
 perf-x86_64-penryn-O3-polly-fast   | 07:35:42
 clang-cmake-armv7-a15-full | 07:29:36
 clang-cmake-armv7-a15-selfhost | 07:28:51
 clang-cmake-aarch64-lld| 07:19:15
 clang-with-lto-ubuntu  | 07:12:30
 clang-cmake-thumbv7-a15-full-sh| 06:56:50
 clang-cmake-armv7-a15  | 06:55:54
 clang-cmake-thumbv7-a15| 06:50:31
 perf-x86_64-penryn-O3-polly-parallel-fast  | 06:46:32
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 06:17:24
 clang-lld-x86_64-2stage| 05:57:13
 perf-x86_64-penryn-O3-polly-unprofitable   | 05:47:12
 clang-cmake-armv7-a15-selfhost-neon| 05:28:37
 clang-with-thin-lto-ubuntu | 05:28:04
 clang-cmake-aarch64-full   | 04:46:07
 clang-s390x-linux  | 04:30:33
 clang-x86_64-linux-selfhost-modules| 03:44:26
 llvm-clang-x86_64-expensive-checks-win | 03:38:38
 llvm-hexagon-elf

Buildbot numbers for the week of 04/30/2017 - 05/06/2017

2017-05-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 04/30/2017 - 05/06/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 sanitizer-x86_64-linux-fast| 38:52:51
 sanitizer-x86_64-linux-bootstrap   | 38:49:41
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 32:10:27
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 32:05:29
 clang-ppc64be-linux-lnt| 21:39:00
 clang-ppc64le-linux| 20:49:44
 clang-ppc64le-linux-multistage | 20:39:25
 clang-ppc64be-linux| 20:13:44
 clang-ppc64be-linux-multistage | 19:55:41
 sanitizer-ppc64be-linux| 19:34:10
 sanitizer-ppc64le-linux| 19:19:32
 clang-cmake-armv7-a15-selfhost | 17:53:59
 clang-cmake-armv7-a15-selfhost-neon| 15:00:41
 sanitizer-windows  | 14:53:51
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 14:21:27
 clang-cmake-thumbv7-a15-full-sh| 13:26:48
 lldb-windows7-android  | 10:47:15
 polly-amd64-linux  | 09:43:55
 polly-arm-linux| 08:59:31
 clang-x86-windows-msvc2015 | 08:22:05
 llvm-clang-x86_64-expensive-checks-win | 06:52:39
 clang-lld-x86_64-2stage| 05:35:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 04:56:09
 clang-cmake-aarch64-full   | 04:24:35
 clang-with-thin-lto-ubuntu | 04:05:06
 clang-bpf-build| 03:51:45
 clang-with-lto-ubuntu  | 03:31:15
 sanitizer-x86_64-linux | 03:11:14
 lld-sphinx-docs| 02:57:07
 clang-sphinx-docs  | 02:56:38
 clang-tools-sphinx-docs| 02:56:28
 lld-x86_64-darwin13| 02:43:21
 clang-cmake-aarch64-lld| 02:38:26
 clang-s390x-linux  | 02:09:45
 clang-cuda-build   | 02:02:40
 perf-x86_64-penryn-O3  | 02:02:12
 sanitizer-x86_64-linux-fuzzer  | 01:52:53
 clang-x86_64-linux-selfhost-modules| 01:45:44
 clang-x86_64-linux-selfhost-modules-2  | 01:26:51
 sanitizer-x86_64-linux-autoconf| 01:23:32
 clang-x64-ninja-win7   | 01:22:15
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 01:18:55
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:15:35
 clang-cmake-aarch64-42vma  | 01:08:25
 lld-x86_64-freebsd | 01:08:17
 clang-hexagon-elf  | 01:07:56
 lldb-x86_64-darwin-13.4| 01:05:38
 clang-x86_64-linux-abi-test| 01:04:30
 clang-cmake-armv7-a15-full | 01:00:54
 clang-x86_64-debian-fast   | 00:56:39
 lldb-amd64-ninja-netbsd8   | 00:56:28
 clang-cmake-thumbv7-a15| 00:56:07
 clang-cmake-armv7-a15  | 00:55:46
 lldb-x86-windows-msvc2015  | 00:53:38
 perf-x86_64-penryn-O3-polly-parallel-fast  | 00:50:44
 lldb-x86_64-ubuntu-14.04-android   | 00:47:48
 clang-native-arm-lnt   | 00:45:04
 llvm-hexagon-elf   | 00:42:39
 lld-x86_64-win7| 00:40:37
 clang-cmake-aarch64-quick

r303472 - Fix valid-for-expr ellipses eaten as invalid decl

2017-05-19 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Fri May 19 19:21:55 2017
New Revision: 303472

URL: http://llvm.org/viewvc/llvm-project?rev=303472&view=rev
Log:
Fix valid-for-expr ellipses eaten as invalid decl

Summary:
The trial parse for declarative syntax accepts an invalid pack
declaration syntax, which is ambiguous with valid pack expansions of
expressions. This commit removes the invalid pack declaration syntax to
avoid mistaking valid pack expansions as invalid declarator components.

Additionally, the trial parse of a //template-argument-list// then needs
to handle the optional ellipsis that is part of that grammar, as opposed
to relying on the trial parse for declarators accepting stray ellipses.

Reviewers: rsmith, rcraik, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/test/Parser/cxx0x-ambig.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=303472&r1=303471&r2=303472&view=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Fri May 19 19:21:55 2017
@@ -481,10 +481,10 @@ Parser::isCXXConditionDeclarationOrInitS
   /// the corresponding ')'. If the context is
   /// TypeIdAsTemplateArgument, we've already parsed the '<' or ','
   /// before this template argument, and will cease lookahead when we
-  /// hit a '>', '>>' (in C++0x), or ','. Returns true for a type-id
-  /// and false for an expression.  If during the disambiguation
-  /// process a parsing error is encountered, the function returns
-  /// true to let the declaration parsing code handle it.
+  /// hit a '>', '>>' (in C++0x), or ','; or, in C++0x, an ellipsis immediately
+  /// preceding such. Returns true for a type-id and false for an expression.
+  /// If during the disambiguation process a parsing error is encountered,
+  /// the function returns true to let the declaration parsing code handle it.
   ///
   /// type-id:
   ///   type-specifier-seq abstract-declarator[opt]
@@ -533,10 +533,15 @@ bool Parser::isCXXTypeId(TentativeCXXTyp
 
 // We are supposed to be inside a template argument, so if after
 // the abstract declarator we encounter a '>', '>>' (in C++0x), or
-// ',', this is a type-id. Otherwise, it's an expression.
+// ','; or, in C++0x, an ellipsis immediately preceding such, this
+// is a type-id. Otherwise, it's an expression.
 } else if (Context == TypeIdAsTemplateArgument &&
(Tok.isOneOf(tok::greater, tok::comma) ||
-(getLangOpts().CPlusPlus11 && Tok.is(tok::greatergreater {
+(getLangOpts().CPlusPlus11 &&
+ (Tok.is(tok::greatergreater) ||
+  (Tok.is(tok::ellipsis) &&
+   NextToken().isOneOf(tok::greater, tok::greatergreater,
+   tok::comma)) {
   TPR = TPResult::True;
   isAmbiguous = true;
 
@@ -829,14 +834,14 @@ Parser::TPResult Parser::TryParseOperato
 /// abstract-declarator:
 ///   ptr-operator abstract-declarator[opt]
 ///   direct-abstract-declarator
-///   ...
 ///
 /// direct-abstract-declarator:
 ///   direct-abstract-declarator[opt]
-///   '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
+/// '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
 /// exception-specification[opt]
 ///   direct-abstract-declarator[opt] '[' constant-expression[opt] ']'
 ///   '(' abstract-declarator ')'
+/// [C++0x]   ...
 ///
 /// ptr-operator:
 ///   '*' cv-qualifier-seq[opt]
@@ -928,10 +933,6 @@ Parser::TPResult Parser::TryParseDeclara
   while (1) {
 TPResult TPR(TPResult::Ambiguous);
 
-// abstract-declarator: ...
-if (Tok.is(tok::ellipsis))
-  ConsumeToken();
-
 if (Tok.is(tok::l_paren)) {
   // Check whether we have a function declarator or a possible ctor-style
   // initializer that follows the declarator. Note that ctor-style

Modified: cfe/trunk/test/Parser/cxx0x-ambig.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-ambig.cpp?rev=303472&r1=303471&r2=303472&view=diff
==
--- cfe/trunk/test/Parser/cxx0x-ambig.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-ambig.cpp Fri May 19 19:21:55 2017
@@ -132,6 +132,32 @@ namespace ellipsis {
 void l(int(*...)(T)); // expected-warning {{ISO C++11 requires a 
parenthesized pack declaration to have a name}}
 void l(int(S::*...)(T)); // expected-warning {{ISO C++11 requires a 
parenthesized pack declaration to have a name}}
   };
+
+  struct CtorSink {
+template  constexpr CtorSink(T &&...t) { }
+co

r303474 - Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."

2017-05-19 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri May 19 19:38:27 2017
New Revision: 303474

URL: http://llvm.org/viewvc/llvm-project?rev=303474&view=rev
Log:
Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."

Let's revert this for now (and with it the assert()) to get the bots
back to green until I have LLVM synced up properly.

This reverts commit r303463.

Removed:
cfe/trunk/test/CodeGen/wchar-size.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=303474&r1=303473&r2=303474&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 19 19:38:27 2017
@@ -45,7 +45,6 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/DataLayout.h"
@@ -466,24 +465,18 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
 
-  // Width of wchar_t in bytes
-  uint64_t WCharWidth =
-  Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert(LangOpts.ShortWChar ||
- llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) ==
- Target.getWCharWidth() / 8 &&
- "LLVM wchar_t size out of sync");
-
   // We need to record the widths of enums and wchar_t, so that we can generate
-  // the correct build attributes in the ARM backend. wchar_size is also used 
by
-  // TargetLibraryInfo.
-  getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
-
+  // the correct build attributes in the ARM backend.
   llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
   if (   Arch == llvm::Triple::arm
   || Arch == llvm::Triple::armeb
   || Arch == llvm::Triple::thumb
   || Arch == llvm::Triple::thumbeb) {
+// Width of wchar_t in bytes
+uint64_t WCharWidth =
+Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
+getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
+
 // The minimum width of an enum in bytes
 uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);

Removed: cfe/trunk/test/CodeGen/wchar-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wchar-size.c?rev=303473&view=auto
==
--- cfe/trunk/test/CodeGen/wchar-size.c (original)
+++ cfe/trunk/test/CodeGen/wchar-size.c (removed)
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
-// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fshort-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
-// Note: -fno-short-wchar implies the target default is used; so there is no
-// need to test this separately here.
-
-// LONG-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 4}
-// SHORT-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 2}


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


r303478 - CodeGenModule: Always output wchar_size, check LLVM assumptions.

2017-05-19 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri May 19 20:29:55 2017
New Revision: 303478

URL: http://llvm.org/viewvc/llvm-project?rev=303478&view=rev
Log:
CodeGenModule: Always output wchar_size, check LLVM assumptions.

Re-commit r303463 now that LLVM is fixed and adjust some lit tests.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

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

Added:
cfe/trunk/test/CodeGen/wchar-size.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCUDA/flush-denormals.cu
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=303478&r1=303477&r2=303478&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 19 20:29:55 2017
@@ -45,6 +45,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/DataLayout.h"
@@ -465,18 +466,24 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
 
+  // Width of wchar_t in bytes
+  uint64_t WCharWidth =
+  Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
+  assert(LangOpts.ShortWChar ||
+ llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) ==
+ Target.getWCharWidth() / 8 &&
+ "LLVM wchar_t size out of sync");
+
   // We need to record the widths of enums and wchar_t, so that we can generate
-  // the correct build attributes in the ARM backend.
+  // the correct build attributes in the ARM backend. wchar_size is also used 
by
+  // TargetLibraryInfo.
+  getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
+
   llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
   if (   Arch == llvm::Triple::arm
   || Arch == llvm::Triple::armeb
   || Arch == llvm::Triple::thumb
   || Arch == llvm::Triple::thumbeb) {
-// Width of wchar_t in bytes
-uint64_t WCharWidth =
-Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
-
 // The minimum width of an enum in bytes
 uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);

Added: cfe/trunk/test/CodeGen/wchar-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wchar-size.c?rev=303478&view=auto
==
--- cfe/trunk/test/CodeGen/wchar-size.c (added)
+++ cfe/trunk/test/CodeGen/wchar-size.c Fri May 19 20:29:55 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fshort-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// Note: -fno-short-wchar implies the target default is used; so there is no
+// need to test this separately here.
+
+// LONG-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 4}
+// SHORT-WCHAR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"wchar_size", i32 2}

Modified: cfe/trunk/test/CodeGenCUDA/flush-denormals.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/flush-denormals.cu?rev=303478&r1=303477&r2=303478&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/flush-denormals.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/flush-denormals.cu Fri May 19 20:29:55 2017
@@ -18,8 +18,8 @@ extern "C" __device__ void foo() {}
 // FTZ: attributes #0 = {{.*}} "nvptx-f32ftz"="true"
 // NOFTZ-NOT: attributes #0 = {{.*}} "nvptx-f32ftz"
 
-// FTZ:!llvm.module.flags = !{[[MODFLAG:![0-9]+]]}
+// FTZ:!llvm.module.flags = !{{{.*}}[[MODFLAG:![0-9]+]]}
 // FTZ:[[MODFLAG]] = !{i32 4, !"nvvm-reflect-ftz", i32 1}
 
-// NOFTZ:!llvm.module.flags = !{[[MODFLAG:![0-9]+]]}
+// NOFTZ:!llvm.module.flags = !{{{.*}}[[MODFLAG:![0-9]+]]}
 // NOFTZ:[[MODFLAG]] = !{i32 4, !"nvvm-reflect-ftz", i32 0}

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/t

r303479 - Rename RAII objects for performing eager instantiation to have names that

2017-05-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 19 20:36:41 2017
New Revision: 303479

URL: http://llvm.org/viewvc/llvm-project?rev=303479&view=rev
Log:
Rename RAII objects for performing eager instantiation to have names that
describe what they're for, not how they do it, and factor out a bit more
common code into them.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303479&r1=303478&r2=303479&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 19 20:36:41 2017
@@ -7383,9 +7383,9 @@ public:
   /// but have not yet been performed.
   std::deque PendingInstantiations;
 
-  class SavePendingInstantiationsAndVTableUsesRAII {
+  class GlobalEagerInstantiationScope {
   public:
-SavePendingInstantiationsAndVTableUsesRAII(Sema &S, bool Enabled)
+GlobalEagerInstantiationScope(Sema &S, bool Enabled)
 : S(S), Enabled(Enabled) {
   if (!Enabled) return;
 
@@ -7393,7 +7393,14 @@ public:
   SavedVTableUses.swap(S.VTableUses);
 }
 
-~SavePendingInstantiationsAndVTableUsesRAII() {
+void perform() {
+  if (Enabled) {
+S.DefineUsedVTables();
+S.PerformPendingInstantiations();
+  }
+}
+
+~GlobalEagerInstantiationScope() {
   if (!Enabled) return;
 
   // Restore the set of pending vtables.
@@ -7423,14 +7430,16 @@ public:
   /// types, static variables, enumerators, etc.
   std::deque PendingLocalImplicitInstantiations;
 
-  class SavePendingLocalImplicitInstantiationsRAII {
+  class LocalEagerInstantiationScope {
   public:
-SavePendingLocalImplicitInstantiationsRAII(Sema &S): S(S) {
+LocalEagerInstantiationScope(Sema &S) : S(S) {
   SavedPendingLocalImplicitInstantiations.swap(
   S.PendingLocalImplicitInstantiations);
 }
 
-~SavePendingLocalImplicitInstantiationsRAII() {
+void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
+
+~LocalEagerInstantiationScope() {
   assert(S.PendingLocalImplicitInstantiations.empty() &&
  "there shouldn't be any pending local implicit instantiations");
   SavedPendingLocalImplicitInstantiations.swap(
@@ -7440,7 +7449,7 @@ public:
   private:
 Sema &S;
 std::deque
-SavedPendingLocalImplicitInstantiations;
+SavedPendingLocalImplicitInstantiations;
   };
 
   /// A helper class for building up ExtParameterInfos.

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=303479&r1=303478&r2=303479&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri May 19 20:36:41 2017
@@ -1540,8 +1540,7 @@ Decl *TemplateDeclInstantiator::VisitCXX
   // DR1484 clarifies that the members of a local class are instantiated as 
part
   // of the instantiation of their enclosing entity.
   if (D->isCompleteDefinition() && D->isLocalClass()) {
-Sema::SavePendingLocalImplicitInstantiationsRAII
-SavedPendingLocalImplicitInstantiations(SemaRef);
+Sema::LocalEagerInstantiationScope LocalInstantiations(SemaRef);
 
 SemaRef.InstantiateClass(D->getLocation(), Record, D, TemplateArgs,
  TSK_ImplicitInstantiation,
@@ -1555,7 +1554,7 @@ Decl *TemplateDeclInstantiator::VisitCXX
 
 // This class may have local implicit instantiations that need to be
 // performed within this scope.
-SemaRef.PerformPendingInstantiations(/*LocalOnly=*/true);
+LocalInstantiations.perform();
   }
 
   SemaRef.DiagnoseUnusedNestedTypedefs(Record);
@@ -3812,10 +3811,9 @@ void Sema::InstantiateFunctionDefinition
   // while we're still within our own instantiation context.
   // This has to happen before LateTemplateParser below is called, so that
   // it marks vtables used in late parsed templates as used.
-  SavePendingLocalImplicitInstantiationsRAII
-  SavedPendingLocalImplicitInstantiations(*this);
-  SavePendingInstantiationsAndVTableUsesRAII
-  SavePendingInstantiationsAndVTableUses(*this, /*Enabled=*/Recursive);
+  GlobalEagerInstantiationScope GlobalInstantiations(*this,
+ /*Enabled=*/Recursive);
+  LocalEagerInstantiationScope LocalInstantiations(*this);
 
   // Call the LateTemplateParser callback if there is a need to late parse
   // a templated function definition.
@@ -3942,20 +3940,9 @@ void Sema::InstantiateFunctionDefinition
 
   // This class may have local implicit instantiations that need to be
   // instantiation within this scope.
-  PerformPendingInstantiations(/*LocalOnly=*/true);
+  L

r303484 - [index] Fix forward declarations interfering with USR generation of external source symbols

2017-05-19 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri May 19 23:11:33 2017
New Revision: 303484

URL: http://llvm.org/viewvc/llvm-project?rev=303484&view=rev
Log:
[index] Fix forward declarations interfering with USR generation of external 
source symbols

Patch by Nathan Hawes.
https://reviews.llvm.org/D33346

Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/external-source-symbol-attr.m
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303484&r1=303483&r2=303484&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri May 19 23:11:33 2017
@@ -34,6 +34,7 @@ class DeclarationName;
 class DependentDiagnostic;
 class EnumDecl;
 class ExportDecl;
+class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 enum Linkage : unsigned char;
@@ -562,6 +563,10 @@ public:
 NextInContextAndBits.setInt(Bits);
   }
 
+  /// \brief Looks on this and related declarations for an applicable
+  /// external source symbol attribute.
+  ExternalSourceSymbolAttr *getExternalSourceSymbolAttr() const;
+
   /// \brief Whether this declaration was marked as being private to the
   /// module in which it was defined.
   bool isModulePrivate() const {

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=303484&r1=303483&r2=303484&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 19 23:11:33 2017
@@ -407,6 +407,27 @@ bool Decl::isExported() const {
   return false;
 }
 
+ExternalSourceSymbolAttr *Decl::getExternalSourceSymbolAttr() const {
+  const Decl *Definition = nullptr;
+  if (auto ID = dyn_cast(this)) {
+Definition = ID->getDefinition();
+  } else if (auto PD = dyn_cast(this)) {
+Definition = PD->getDefinition();
+  } else if (auto TD = dyn_cast(this)) {
+Definition = TD->getDefinition();
+  }
+  if (!Definition)
+Definition = this;
+
+  if (auto *attr = Definition->getAttr())
+return attr;
+  if (auto *dcd = dyn_cast(getDeclContext())) {
+return dcd->getAttr();
+  }
+
+  return nullptr;
+}
+
 bool Decl::hasDefiningAttr() const {
   return hasAttr() || hasAttr();
 }

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=303484&r1=303483&r2=303484&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri May 19 23:11:33 2017
@@ -318,16 +318,7 @@ SymbolInfo index::getSymbolInfo(const De
   if (Info.Properties & (unsigned)SymbolProperty::Generic)
 Info.Lang = SymbolLanguage::CXX;
 
-  auto getExternalSymAttr = [](const Decl *D) -> ExternalSourceSymbolAttr* {
-if (auto *attr = D->getAttr())
-  return attr;
-if (auto *dcd = dyn_cast(D->getDeclContext())) {
-  if (auto *attr = dcd->getAttr())
-return attr;
-}
-return nullptr;
-  };
-  if (auto *attr = getExternalSymAttr(D)) {
+  if (auto *attr = D->getExternalSourceSymbolAttr()) {
 if (attr->getLanguage() == "Swift")
   Info.Lang = SymbolLanguage::Swift;
   }

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=303484&r1=303483&r2=303484&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri May 19 23:11:33 2017
@@ -49,7 +49,7 @@ static bool printLoc(llvm::raw_ostream &
 static StringRef GetExternalSourceContainer(const NamedDecl *D) {
   if (!D)
 return StringRef();
-  if (auto *attr = D->getAttr()) {
+  if (auto *attr = D->getExternalSourceSymbolAttr()) {
 return attr->getDefinedIn();
   }
   return StringRef();

Modified: cfe/trunk/test/Index/Core/external-source-symbol-attr.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/external-source-symbol-attr.m?rev=303484&r1=303483&r2=303484&view=diff
==
--- cfe/trunk/test/Index/Core/external-source-symbol-attr.m (original)
+++ cfe/trunk/test/Index/Core/external-source-symbol-attr.m Fri May 19 23:11:33 
2017
@@ -4,6 +4,10 @@
 #define GEN_DECL(mod_name) 
__attribute__((external_source_symbol(language="Swift", defined_in=mod_name, 
generated_declaration)))
 #define PUSH_GEN_DECL(mod_name) push(GEN_DECL(mod_name), apply_to=any(enum, 
objc_interface, objc_category, objc_protocol))