[PATCH] Add clang-format option for ensuring newlines after @(interface|implementation|protocol) and before @end

2014-04-14 Thread Allen Ding
Hi all,

Made the following patch for use internally for our iOS projects. Wondering
if it would be useful to other clang-format users.

Before:
@interface Foo : NSObject NSSomeDelegate
- (id)init;
@property(nonatomic) NSInteger whizzy;
@end

After:
@interface Foo : NSObject NSSomeDelegate

- (id)init;
@property (nonatomic) NSInteger whizzy;

@end

Regards,

--
Allen Ding
Lentor Solutions


objcnewlinesbetweendeclarations.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add clang-format option for ensuring newlines after @(interface|implementation|protocol) and before @end

2014-04-14 Thread Daniel Jasper
Hi,

thanks for working on this.

+**ObjCNewlinesBetweenDeclarations** (``bool``)
+  Add a line break before and after Objective-C declarations.
+

Just generate this with cfe/docs/tools/dump_format_style.py.


Also, please at tests for the different cases where you'd want to insert a
newline or not (similar to the RemovesEmptyLines test).

Cheers,
Daniel


On Mon, Apr 14, 2014 at 9:22 AM, Allen Ding ald...@gmail.com wrote:

 Hi all,

 Made the following patch for use internally for our iOS projects.
 Wondering if it would be useful to other clang-format users.

 Before:
 @interface Foo : NSObject NSSomeDelegate
 - (id)init;
 @property(nonatomic) NSInteger whizzy;
 @end

 After:
 @interface Foo : NSObject NSSomeDelegate

 - (id)init;
 @property (nonatomic) NSInteger whizzy;

 @end

 Regards,

 --
 Allen Ding
 Lentor Solutions


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] PR19095 Undefined reference to friend template function defined inside template class

2014-04-14 Thread suyog sarda
Hi Richard,

Thanks for the review. I Agree to your explaination. Following are the
points what i understood :

1. setInstantiatedFromMemberTemplate call should not be skipped since it
causes mix up of  template parameter list numbering and wrong
substitutions,
which is clearly visible in the test case as well.
2. When C is instantiated twice, it should throw re-definition error of
function f, which is not done (with or without my patch).
3. In the same function call 'TemplateDeclInstantiator::VisitFunctionDecl',
there is a check 'if (isFriend)'.
There is a standard described '[temp.friend] p4 (DR329)' inside that
check, which checks if the *FunctionDecl D *is Declared as well as Defined
(isThisDeclarationADefintion).
In my opinion, at this point the function defintion is not being set
for friend function defined inside the class template.
4. While debugging, it is seen that, the *FunctionDecl D *is *defined *holds
true but '*Function-isDefined(Definition)*' evaluates to false (I did not
get why it evaluates to false), because of which
re-defintion error is not emitted.

There is a similar bug for operator overloading - Bug 14785. There also
same case is happening - not able to identify if friend function (in 14785
its operator overloading function) is defined inside class template.

Can you please help me out if my above analysis is correct as well as
indicate where/how to set the definition of the declared function? Your
help is highly appreciated.



On Sat, Apr 12, 2014 at 1:57 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Hi!

 I'm afraid this patch is incorrect; it even does the wrong thing in your
 test case. Skipping the setInstantiatedFromMemberTemplate call causes us to
 mix up the template parameter list numbering -- we substitute the argument
 given for T as the value U, and we don't substitute anything for T. For
 instance, in the definition of f instantiated for the f(3.0) call, we
 should have T=double, U=int, but we actually have T=no value, U=double,
 as can be seen in the AST dump.

 This also does the wrong thing if C is instantiated twice -- such a case
 should be an error, because f would have multiple definitions.


 On Mon, Mar 24, 2014 at 5:29 AM, suyog sarda sardas...@gmail.com wrote:

 Gentle Ping!!


 On Thu, Mar 20, 2014 at 9:46 AM, suyog sarda sardas...@gmail.com wrote:

 Gentle Ping!!


 On Fri, Mar 14, 2014 at 10:29 PM, suyog sarda sardas...@gmail.comwrote:

 Hi,

 Attaching patch for bug 19095. Please help in reviewing the same.

 Also, I haven't attached a test case yet in the patch as i am not sure
 how it should be and in which file it should be.

 In my opinion, the test case would go into 
 *tools/clang/test/SemaCXX/friend.cpp
 *would be something like below (similar to that mentioned in the bug)




























 * template class Tvoid f(T);template class Uclass C{  template
 class T  friend void f(T)  { CU c; c.i = 3;  }  public :
 void g()  {   f(3.0); // OK }int i;};void h (){  f(7); //
 OK  Cdouble c;  c.g();}*


 Please help in reviewing the patch as well as the test case.
 --
 With regards,
 Suyog Sarda




 --
 With regards,
 Suyog Sarda




 --
 With regards,
 Suyog Sarda

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





-- 
With regards,
Suyog Sarda
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206155 - clang-format: Improve formatting of annotated variables.

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 03:15:20 2014
New Revision: 206155

URL: http://llvm.org/viewvc/llvm-project?rev=206155view=rev
Log:
clang-format: Improve formatting of annotated variables.

Before:
  bool aa GUARDED_BY(
  ) = ::aaa;

After:
  bool aa GUARDED_BY() =
  ::aaa;

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=206155r1=206154r2=206155view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 14 03:15:20 2014
@@ -799,6 +799,7 @@ private:
 PreviousNoComment-isOneOf(tok::comma, tok::l_brace))
   Current.Type = TT_DesignatedInitializerPeriod;
   } else if (Current.isOneOf(tok::identifier, tok::kw_const) 
+ Current.Previous  Current.Previous-isNot(tok::equal) 
  Line.MightBeFunctionDecl  Contexts.size() == 1) {
 // Line.MightBeFunctionDecl can only be true after the parentheses of a
 // function declaration have been found.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=206155r1=206154r2=206155view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 14 03:15:20 2014
@@ -3304,14 +3304,15 @@ TEST_F(FormatTest, BreaksFunctionDeclara
  a)););
   verifyFormat(bool aaa\n
__attribute__((unused)););
-  verifyFormat(
+  verifyGoogleFormat(
   bool 
a\n
-  GUARDED_BY();,
-  getGoogleStyle());
-  verifyFormat(
+  GUARDED_BY(););
+  verifyGoogleFormat(
   bool a\n
-  GUARDED_BY();,
-  getGoogleStyle());
+  GUARDED_BY(););
+  verifyGoogleFormat(
+  bool aa GUARDED_BY() =\n
+  ::aaa;);
 }
 
 TEST_F(FormatTest, BreaksDesireably) {


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Format code around VCS conflict markers.

2014-04-14 Thread Daniel Jasper

  Still looks good.



Comment at: lib/Format/UnwrappedLineParser.h:111-114
@@ +110,6 @@
+
+  // Marks a conditional compilation edge (for example, an '#if', '#ifdef',
+  // '#else' or merge conflict marker). If 'Unreachable' is true, assumes
+  // this branch either cannot be taken (for example '#if false'), or should
+  // not be taken in this round.
+  void conditionalCompilationCondition(bool Unreachable);

According to this comment, 'unreachable' does not seem like quite the right 
word. May Active or ProcessBranch?


http://reviews.llvm.org/D3355

BRANCH
  implement-conflict-markers

ARCANIST PROJECT
  clang



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Format code around VCS conflict markers.

2014-04-14 Thread Manuel Klimek

  (sending comments I had forgotten to send earlier...)



Comment at: lib/Format/Format.cpp:1268
@@ +1267,3 @@
+FileID ID;
+unsigned offset;
+std::tie(ID, offset) = SourceMgr.getDecomposedLoc(

Daniel Jasper wrote:
 s/offset/Offset/
 
 Also, offset of what? Consider adding a comment or using a more specific name.
Done.


Comment at: lib/Format/Format.cpp:1272
@@ +1271,3 @@
+StringRef Buffer = SourceMgr.getBuffer(ID)-getBuffer();
+auto LineOffset = Buffer.rfind('\n', offset);
+if (LineOffset == StringRef::npos) {

Daniel Jasper wrote:
 LineOffset carries very little meaning, or at least I can't understand what 
 it means without carefully looking at the code. Maybe add a comment.
Done.


Comment at: lib/Format/Format.cpp:1285
@@ +1284,3 @@
+// we expect a space.
+bool GitMarkerSize = Line.size() = 7 || Line[7] == ' ' || Line[7] == '\n';
+// Perforce markers are 4 characters long.

Daniel Jasper wrote:
 ..Size is not a good name for a bool. Here and below. Just remove Size?
Changed to parse out the start of the line until the first whitespace and use 
that.


Comment at: lib/Format/Format.cpp:1307-1309
@@ +1306,5 @@
+  Tokens.resize(FirstInLineIndex + 1);
+  // We do not need to build a complete token here, as we will skip it
+  // during parsing anyway (as we must not touch whitespace around conflict
+  // markers).
+  Tokens.back()-Type = Type;

Daniel Jasper wrote:
 I think a comment here would help what an expected conflict line together 
 with the generated tokens would look like. Possibly here or at the start of 
 the function.
Done, hopefully...


Comment at: lib/Format/Format.cpp:1392
@@ -1391,3 +1454,2 @@
   }
-
   FormatToken *FormatTok;

Daniel Jasper wrote:
 I liked this empty line.
Done.


Comment at: lib/Format/Format.cpp:1467
@@ -1404,1 +1466,3 @@
+  // Index of the last token that starts a new line in 'Tokens'.
+  unsigned FirstInLineIndex;
   SmallVectorFormatToken *, 16 Tokens;

Daniel Jasper wrote:
 Just to make this even clearer:
 
   // Index (in 'Tokens') of the last token that starts a new line.
Done.


Comment at: lib/Format/FormatToken.h:67
@@ -66,1 +66,3 @@
   TT_UnaryOperator,
+  TT_ConflictStart,
+  TT_ConflictAlternative,

Daniel Jasper wrote:
 While this order makes sense, I think we should keep this alphabetical.
Done.


Comment at: unittests/Format/FormatTest.cpp:15
@@ -14,2 +14,3 @@
 #include llvm/Support/Debug.h
+#include llvm/ADT/Twine.h
 #include gtest/gtest.h

Daniel Jasper wrote:
 Remove?
Done.


Comment at: lib/Format/UnwrappedLineParser.cpp:468
@@ -467,10 +467,3 @@
 
-void UnwrappedLineParser::pushPPConditional() {
-  if (!PPStack.empty()  PPStack.back() == PP_Unreachable)
-PPStack.push_back(PP_Unreachable);
-  else
-PPStack.push_back(PP_Conditional);
-}
-
-void UnwrappedLineParser::parsePPIf(bool IfDef) {
+void UnwrappedLineParser::conditionalCompilationStart(bool Unreachable) {
   ++PPBranchLevel;

Daniel Jasper wrote:
 I think Unreachable needs some explanation...
I think that generally the names are bad. I should rename them, but not in this 
CL. Added a comment that hopefully helps a bit.


Comment at: lib/Format/UnwrappedLineParser.cpp:1418-1431
@@ +1417,16 @@
+   FormatTok-Type == TT_ConflictAlternative) {
+  switch (FormatTok-Type) {
+  case TT_ConflictStart:
+conditionalCompilationStart(/*Unreachable=*/false);
+break;
+  case TT_ConflictAlternative:
+conditionalCompilationAlternative();
+break;
+  case TT_ConflictEnd:
+conditionalCompilationEnd();
+break;
+  default:
+llvm_unreachable(Unexpected token type.);
+break;
+  }
+  FormatTok = Tokens-getNextToken();

Daniel Jasper wrote:
 This would be just 6 lines with if () ..
Done.


http://reviews.llvm.org/D3355

BRANCH
  implement-conflict-markers

ARCANIST PROJECT
  clang



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Format code around VCS conflict markers.

2014-04-14 Thread Manuel Klimek



Comment at: lib/Format/UnwrappedLineParser.h:111-114
@@ +110,6 @@
+
+  // Marks a conditional compilation edge (for example, an '#if', '#ifdef',
+  // '#else' or merge conflict marker). If 'Unreachable' is true, assumes
+  // this branch either cannot be taken (for example '#if false'), or should
+  // not be taken in this round.
+  void conditionalCompilationCondition(bool Unreachable);

Daniel Jasper wrote:
 According to this comment, 'unreachable' does not seem like quite the right 
 word. May Active or ProcessBranch?
Fully agreed - in a follow-up CL.


http://reviews.llvm.org/D3355

BRANCH
  implement-conflict-markers

ARCANIST PROJECT
  clang



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206157 - Format code around VCS conflict markers.

2014-04-14 Thread Manuel Klimek
Author: klimek
Date: Mon Apr 14 04:14:11 2014
New Revision: 206157

URL: http://llvm.org/viewvc/llvm-project?rev=206157view=rev
Log:
Format code around VCS conflict markers.

Now correctly formats:
  {
int a;
void f() {
  callme(some(parameter1,
   text by the vcs
  parameter2),
  ||| text by the vcs
  parameter2),
 parameter3,
  === text by the vcs
  parameter2, parameter3),
   text by the vcs
 otherparameter);
}
  }

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=206157r1=206156r2=206157view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Apr 14 04:14:11 2014
@@ -1157,7 +1157,8 @@ public:
encoding::Encoding Encoding)
   : FormatTok(NULL), IsFirstToken(true), GreaterStashed(false), Column(0),
 TrailingWhitespace(0), Lex(Lex), SourceMgr(SourceMgr), Style(Style),
-IdentTable(getFormattingLangOpts()), Encoding(Encoding) {
+IdentTable(getFormattingLangOpts()), Encoding(Encoding),
+FirstInLineIndex(0) {
 Lex.SetKeepWhitespaceMode(true);
 
 for (const std::string ForEachMacro : Style.ForEachMacros)
@@ -1167,9 +1168,12 @@ public:
 
   ArrayRefFormatToken * lex() {
 assert(Tokens.empty());
+assert(FirstInLineIndex == 0);
 do {
   Tokens.push_back(getNextToken());
   tryMergePreviousTokens();
+  if (Tokens.back()-NewlinesBefore  0)
+FirstInLineIndex = Tokens.size() - 1;
 } while (Tokens.back()-Tok.isNot(tok::eof));
 return Tokens;
   }
@@ -1180,6 +1184,8 @@ private:
   void tryMergePreviousTokens() {
 if (tryMerge_TMacro())
   return;
+if (tryMergeConflictMarkers())
+  return;
 
 if (Style.Language == FormatStyle::LK_JavaScript) {
   static tok::TokenKind JSIdentity[] = { tok::equalequal, tok::equal };
@@ -1254,6 +1260,68 @@ private:
 return true;
   }
 
+  bool tryMergeConflictMarkers() {
+if (Tokens.back()-NewlinesBefore == 0  Tokens.back()-isNot(tok::eof))
+  return false;
+
+// Conflict lines look like:
+// marker text from the vcs
+// For example:
+//  /file/in/file/system at revision 1234
+//
+// We merge all tokens in a line that starts with a conflict marker
+// into a single token with a special token type that the unwrapped line
+// parser will use to correctly rebuild the underlying code.
+
+FileID ID;
+// Get the position of the first token in the line.
+unsigned FirstInLineOffset;
+std::tie(ID, FirstInLineOffset) = SourceMgr.getDecomposedLoc(
+Tokens[FirstInLineIndex]-getStartOfNonWhitespace());
+StringRef Buffer = SourceMgr.getBuffer(ID)-getBuffer();
+// Calculate the offset of the start of the current line.
+auto LineOffset = Buffer.rfind('\n', FirstInLineOffset);
+if (LineOffset == StringRef::npos) {
+  LineOffset = 0;
+} else {
+  ++LineOffset;
+}
+
+auto FirstSpace = Buffer.find_first_of( \n, LineOffset);
+StringRef LineStart;
+if (FirstSpace == StringRef::npos) {
+  LineStart = Buffer.substr(LineOffset);
+} else {
+  LineStart = Buffer.substr(LineOffset, FirstSpace - LineOffset);
+}
+
+TokenType Type = TT_Unknown;
+if (LineStart ==  || LineStart == ) {
+  Type = TT_ConflictStart;
+} else if (LineStart == ||| || LineStart == === ||
+   LineStart == ) {
+  Type = TT_ConflictAlternative;
+} else if (LineStart ==  || LineStart == ) {
+  Type = TT_ConflictEnd;
+}
+
+if (Type != TT_Unknown) {
+  FormatToken *Next = Tokens.back();
+
+  Tokens.resize(FirstInLineIndex + 1);
+  // We do not need to build a complete token here, as we will skip it
+  // during parsing anyway (as we must not touch whitespace around conflict
+  // markers).
+  Tokens.back()-Type = Type;
+  Tokens.back()-Tok.setKind(tok::kw___unknown_anytype);
+
+  Tokens.push_back(Next);
+  return true;
+}
+
+return false;
+  }
+
   FormatToken *getNextToken() {
 if (GreaterStashed) {
   // Create a synthesized second '' token.
@@ -1401,6 +1469,8 @@ private:
   IdentifierTable IdentTable;
   encoding::Encoding Encoding;
   llvm::SpecificBumpPtrAllocatorFormatToken Allocator;
+  // Index (in 'Tokens') of the last token that starts a new line.
+  unsigned FirstInLineIndex;
   SmallVectorFormatToken *, 16 Tokens;
   SmallVectorIdentifierInfo*, 8 ForEachMacros;
 

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 

[PATCH] Partial revert of 183015

2014-04-14 Thread Evgeniy Stepanov
Hi rsmith,

Re-enable several builtins in non-gnu modes.
Fixes PR16138.

http://reviews.llvm.org/D3369

Files:
  test/CodeGen/function-attributes.c
  test/Sema/builtins-gnu-mode.c
  include/clang/Basic/Builtins.def

Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -std=c99 -o - 
%s | FileCheck %s
 // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]]
 // CHECK: define zeroext i8 @f1(i32 %x) [[NUW]]
 // CHECK: define void @f2(i8 signext %x) [[NUW]]
@@ -117,6 +118,16 @@
   setjmp(0);
 }
 
+// CHECK-LABEL: define void @f20()
+// CHECK: {
+// CHECK: call i32 @_setjmp(i32* null)
+// CHECK: [[RT_CALL]]
+// CHECK: ret void
+int _setjmp(jmp_buf);
+void f20(void) {
+  _setjmp(0);
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[ALIGN]] = { nounwind optsize readnone 
alignstack=16{{.*}} }
Index: test/Sema/builtins-gnu-mode.c
===
--- test/Sema/builtins-gnu-mode.c
+++ test/Sema/builtins-gnu-mode.c
@@ -12,16 +12,5 @@
 int bzero;
 int strcasecmp;
 int strncasecmp;
-int _exit;
-int vfork;
-int _setjmp;
-int __sigsetjmp;
-int sigsetjmp;
-int setjmp_syscall;
-int savectx;
-int qsetjmp;
-int getcontext;
-int _longjmp;
-int siglongjmp;
 int strlcpy;
 int strlcat;
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -755,22 +755,22 @@
 LIBBUILTIN(strcasecmp, icC*cC*, f, strings.h, ALL_GNU_LANGUAGES)
 LIBBUILTIN(strncasecmp, icC*cC*z, f,   strings.h, ALL_GNU_LANGUAGES)
 // POSIX unistd.h
-LIBBUILTIN(_exit, vi,   fr,unistd.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(vfork, p,fj,unistd.h, ALL_GNU_LANGUAGES)
+LIBBUILTIN(_exit, vi,   fr,unistd.h, ALL_LANGUAGES)
+LIBBUILTIN(vfork, p,fj,unistd.h, ALL_LANGUAGES)
 // POSIX setjmp.h
 
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.
-LIBBUILTIN(_setjmp, iJ, fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(__sigsetjmp, iSJi,   fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(sigsetjmp, iSJi, fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(setjmp_syscall, iJ,  fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(savectx, iJ, fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(qsetjmp, iJ, fj,   setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(getcontext, iK*, fj,   setjmp.h, ALL_GNU_LANGUAGES)
+LIBBUILTIN(_setjmp, iJ, fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(__sigsetjmp, iSJi,   fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(sigsetjmp, iSJi, fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(setjmp_syscall, iJ,  fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(savectx, iJ, fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(qsetjmp, iJ, fj,   setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(getcontext, iK*, fj,   setjmp.h, ALL_LANGUAGES)
 
-LIBBUILTIN(_longjmp, vJi,   fr,setjmp.h, ALL_GNU_LANGUAGES)
-LIBBUILTIN(siglongjmp, vSJi,fr,setjmp.h, ALL_GNU_LANGUAGES)
+LIBBUILTIN(_longjmp, vJi,   fr,setjmp.h, ALL_LANGUAGES)
+LIBBUILTIN(siglongjmp, vSJi,fr,setjmp.h, ALL_LANGUAGES)
 // non-standard but very common
 LIBBUILTIN(strlcpy, zc*cC*z,f, string.h, ALL_GNU_LANGUAGES)
 LIBBUILTIN(strlcat, zc*cC*z,f, string.h, ALL_GNU_LANGUAGES)
Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -std=c99 -o - %s | FileCheck %s
 // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]]
 // CHECK: define zeroext i8 @f1(i32 %x) [[NUW]]
 // CHECK: define void @f2(i8 signext %x) [[NUW]]
@@ -117,6 +118,16 @@
   setjmp(0);
 }
 
+// CHECK-LABEL: define void @f20()
+// CHECK: {
+// CHECK: call i32 @_setjmp(i32* null)
+// CHECK: [[RT_CALL]]
+// CHECK: ret void
+int _setjmp(jmp_buf);
+void f20(void) {
+  _setjmp(0);
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[ALIGN]] = { nounwind optsize readnone alignstack=16{{.*}} }
Index: test/Sema/builtins-gnu-mode.c
===
--- test/Sema/builtins-gnu-mode.c
+++ test/Sema/builtins-gnu-mode.c

__is_constructible return true for abstract types PR19178

2014-04-14 Thread Nikola Smiljanic
Please review.
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 8b9c0e2..2ff501f 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -3656,6 +3656,12 @@ static bool evaluateTypeTrait(Sema S, TypeTrait Kind, SourceLocation KWLoc,
 if (Args[0]-getType()-isIncompleteType())
   return false;
 
+// Make sure the first argument is not an abstract type.
+
+CXXRecordDecl *RD = Args[0]-getType()-getAsCXXRecordDecl();
+if (RD  RD-isAbstract())
+  return false;
+
 SmallVectorOpaqueValueExpr, 2 OpaqueArgExprs;
 SmallVectorExpr *, 2 ArgExprs;
 ArgExprs.reserve(Args.size() - 1);
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 28fb8dc..b8557c4 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -1964,6 +1964,8 @@ void constructible_checks() {
 
   { int arr[T(__is_constructible(NonPOD, int))]; }
   { int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
+
+  { int arr[F(__is_constructible(Abstract))]; } // PR19178
 }
 
 // Instantiation of __is_trivially_constructible
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206159 - clang-format: Don't allow hanging indentation for operators on new lines

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 06:08:45 2014
New Revision: 206159

URL: http://llvm.org/viewvc/llvm-project?rev=206159view=rev
Log:
clang-format: Don't allow hanging indentation for operators on new lines

Before:
  if (  bbb // need to wrap
  == cc) ...

After:
  if (
   bbb // need to wrap
 == cc) ...

The same rule has already be implemented for BreakBeforeBinaryOperators
set to false in r205527.

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=206159r1=206158r2=206159view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Apr 14 06:08:45 2014
@@ -173,8 +173,7 @@ bool ContinuationIndenter::mustBreak(con
 if (Previous.Type == TT_BinaryOperator 
 (!IsComparison || LHSIsBinaryExpr) 
 Current.Type != TT_BinaryOperator  // For .
-!Current.isTrailingComment() 
-!Previous.isOneOf(tok::lessless, tok::question) 
+!Current.isTrailingComment()  !Previous.is(tok::lessless) 
 Previous.getPrecedence() != prec::Assignment 
 State.Stack.back().BreakBeforeParameter)
   return true;
@@ -485,7 +484,8 @@ unsigned ContinuationIndenter::getNewLin
 }
   }
   if (State.Stack.back().QuestionColumn != 0 
-  (NextNonComment-Type == TT_ConditionalExpr ||
+  ((NextNonComment-is(tok::colon) 
+NextNonComment-Type == TT_ConditionalExpr) ||
Previous.Type == TT_ConditionalExpr))
 return State.Stack.back().QuestionColumn;
   if (Previous.is(tok::comma)  State.Stack.back().VariablePos != 0)
@@ -547,9 +547,15 @@ unsigned ContinuationIndenter::moveState
 
   if (Current.Type == TT_InheritanceColon)
 State.Stack.back().AvoidBinPacking = true;
-  if (Current.is(tok::lessless)  Current.Type != TT_OverloadedOperator 
-  State.Stack.back().FirstLessLess == 0)
-State.Stack.back().FirstLessLess = State.Column;
+  if (Current.is(tok::lessless)  Current.Type != TT_OverloadedOperator) {
+if (State.Stack.back().FirstLessLess == 0)
+  State.Stack.back().FirstLessLess = State.Column;
+else
+  State.Stack.back().LastOperatorWrapped = Newline;
+  }
+  if ((Current.Type == TT_BinaryOperator  Current.isNot(tok::lessless)) ||
+  Current.Type == TT_ConditionalExpr)
+State.Stack.back().LastOperatorWrapped = Newline;
   if (Current.Type == TT_ArraySubscriptLSquare 
   State.Stack.back().StartOfArraySubscripts == 0)
 State.Stack.back().StartOfArraySubscripts = State.Column;
@@ -615,13 +621,19 @@ unsigned ContinuationIndenter::moveState
 // there is a line-break right after the operator.
 // Exclude relational operators, as there, it is always more desirable to
 // have the LHS 'left' of the RHS.
-// FIXME: Implement this for '' and BreakBeforeBinaryOperators.
-if (!Newline  Previous  Previous-Type == TT_BinaryOperator 
-!Previous-isOneOf(tok::lessless, tok::question, tok::colon) 
-Previous-getPrecedence()  prec::Assignment 
-Previous-getPrecedence() != prec::Relational 
-!Style.BreakBeforeBinaryOperators)
-  NewParenState.NoLineBreak = true;
+if (Previous  Previous-getPrecedence()  prec::Assignment 
+(Previous-Type == TT_BinaryOperator ||
+ Previous-Type == TT_ConditionalExpr) 
+Previous-getPrecedence() != prec::Relational) {
+  bool BreakBeforeOperator = Previous-is(tok::lessless) ||
+ (Previous-Type == TT_BinaryOperator 
+  Style.BreakBeforeBinaryOperators) ||
+ (Previous-Type == TT_ConditionalExpr 
+  Style.BreakBeforeTernaryOperators);
+  if ((!Newline  !BreakBeforeOperator) ||
+  (!State.Stack.back().LastOperatorWrapped  BreakBeforeOperator))
+NewParenState.NoLineBreak = true;
+}
 
 // Do not indent relative to the fake parentheses inserted for . or -.
 // This is a special case to make the following to statements consistent:

Modified: cfe/trunk/lib/Format/ContinuationIndenter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.h?rev=206159r1=206158r2=206159view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.h (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.h Mon Apr 14 06:08:45 2014
@@ -135,11 +135,11 @@ struct ParenState {
   : Indent(Indent), IndentLevel(IndentLevel), LastSpace(LastSpace),
 

r206161 - clang-format: With ColumnLimit=0, keep short array literals on a line.

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 07:05:05 2014
New Revision: 206161

URL: http://llvm.org/viewvc/llvm-project?rev=206161view=rev
Log:
clang-format: With ColumnLimit=0, keep short array literals on a line.

Before:
NSArray* a = [[NSArray alloc] initWithArray:@[
   @a
]
  copyItems:YES];

After:
NSArray* a = [[NSArray alloc] initWithArray:@[ @a ]
  copyItems:YES];

This fixed llvm.org/PR19080.

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=206161r1=206160r2=206161view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Apr 14 07:05:05 2014
@@ -142,6 +142,7 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if (((Previous.Type == TT_DictLiteral  Previous.is(tok::l_brace)) ||
Previous.Type == TT_ArrayInitializerLSquare) 
+  (Style.ColumnLimit  0 || Previous.ParameterCount  1) 
   getLengthToMatchingParen(Previous) + State.Column  
getColumnLimit(State))
 return true;
   if (Current.Type == TT_CtorInitializerColon 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=206161r1=206160r2=206161view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 14 07:05:05 2014
@@ -8148,6 +8148,20 @@ TEST_F(FormatTest, FormatsWithWebKitStyl
 format(#define aNumber \\\n
 10,
Style));
+
+  // Keep empty and one-element array literals on a single line.
+  verifyFormat(NSArray* a = [[NSArray alloc] initWithArray:@[]\n
+ copyItems:YES];,
+   Style);
+  verifyFormat(NSArray* a = [[NSArray alloc] initWithArray:@[ @\a\ ]\n
+ copyItems:YES];,
+   Style);
+  verifyFormat(NSArray* a = [[NSArray alloc] initWithArray:@[\n
+  @\a\,\n
+  @\a\\n
+   ]\n
+ copyItems:YES];,
+   Style);
 }
 
 TEST_F(FormatTest, FormatsLambdas) {


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206162 - clang-format: Improve array literal formatting fix in r206161.

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 07:11:07 2014
New Revision: 206162

URL: http://llvm.org/viewvc/llvm-project?rev=206162view=rev
Log:
clang-format: Improve array literal formatting fix in r206161.

Instead of choosing based on the number of elements, simply respect the
user's choice of where to wrap array literals.

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=206162r1=206161r2=206162view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Apr 14 07:11:07 2014
@@ -142,7 +142,7 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if (((Previous.Type == TT_DictLiteral  Previous.is(tok::l_brace)) ||
Previous.Type == TT_ArrayInitializerLSquare) 
-  (Style.ColumnLimit  0 || Previous.ParameterCount  1) 
+  Style.ColumnLimit  0 
   getLengthToMatchingParen(Previous) + State.Column  
getColumnLimit(State))
 return true;
   if (Current.Type == TT_CtorInitializerColon 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=206162r1=206161r2=206162view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 14 07:11:07 2014
@@ -8156,12 +8156,21 @@ TEST_F(FormatTest, FormatsWithWebKitStyl
   verifyFormat(NSArray* a = [[NSArray alloc] initWithArray:@[ @\a\ ]\n
  copyItems:YES];,
Style);
-  verifyFormat(NSArray* a = [[NSArray alloc] initWithArray:@[\n
-  @\a\,\n
-  @\a\\n
-   ]\n
- copyItems:YES];,
-   Style);
+  EXPECT_EQ(NSArray* a = [[NSArray alloc] initWithArray:@[\n
+   @\a\,\n
+   @\a\\n
+]\n
+  copyItems:YES];,
+format(NSArray* a = [[NSArray alloc] initWithArray:@[\n
+@\a\,\n
+@\a\\n
+]\n
+  copyItems:YES];,
+   Style));
+  verifyFormat(
+  NSArray* a = [[NSArray alloc] initWithArray:@[ @\a\, @\a\ ]\n
+copyItems:YES];,
+  Style);
 }
 
 TEST_F(FormatTest, FormatsLambdas) {


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206165 - clang-format: Fix incorrect -detection in macros.

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 07:50:02 2014
New Revision: 206165

URL: http://llvm.org/viewvc/llvm-project?rev=206165view=rev
Log:
clang-format: Fix incorrect -detection in macros.

Before:
  #define A(a, b) (a b)

After:
  #define A(a, b) (a  b)

This fixes llvm.org/PR19343.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=206165r1=206164r2=206165view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 14 07:50:02 2014
@@ -110,6 +110,9 @@ private:
  Left-Previous-Type == TT_BinaryOperator)) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
+} else if (Line.InPPDirective 
+   (!Left-Previous || Left-Previous-isNot(tok::identifier))) {
+  Contexts.back().IsExpression = true;
 } else if (Left-Previous  Left-Previous-is(tok::r_square) 
Left-Previous-MatchingParen 
Left-Previous-MatchingParen-Type == TT_LambdaLSquare) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=206165r1=206164r2=206165view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 14 07:50:02 2014
@@ -4647,6 +4647,7 @@ TEST_F(FormatTest, UnderstandsRvalueRefe
};);
   verifyGoogleFormat(#define IF(a, b, c) if (a  (b == c)));
   verifyGoogleFormat(#define WHILE(a, b, c) while (a  (b == c)));
+  verifyFormat(#define A(a, b) (a  b));
 }
 
 TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) {


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206173 - clang-format: Fix regression caused by r206165.

2014-04-14 Thread Daniel Jasper
Author: djasper
Date: Mon Apr 14 08:15:29 2014
New Revision: 206173

URL: http://llvm.org/viewvc/llvm-project?rev=206173view=rev
Log:
clang-format: Fix regression caused by r206165.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=206173r1=206172r2=206173view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 14 08:15:29 2014
@@ -111,7 +111,9 @@ private:
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
 } else if (Line.InPPDirective 
-   (!Left-Previous || Left-Previous-isNot(tok::identifier))) {
+   (!Left-Previous ||
+(Left-Previous-isNot(tok::identifier) 
+ Left-Previous-Type != TT_OverloadedOperator))) {
   Contexts.back().IsExpression = true;
 } else if (Left-Previous  Left-Previous-is(tok::r_square) 
Left-Previous-MatchingParen 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=206173r1=206172r2=206173view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 14 08:15:29 2014
@@ -4584,6 +4584,16 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   // FIXME: Is there a way to make this work?
   // verifyIndependentOfContext(MACRO(A *a););
 
+  EXPECT_EQ(#define OP(x)\\\n
+  ostream operator(ostream s, const A a) {  \\\n
+return s  a.DebugString(); \\\n
+  },
+format(#define OP(x) \\\n
+ ostream operator(ostream s, const A a) { \\\n
+   return s  a.DebugString(); \\\n
+ },
+   getLLVMStyleWithColumns(50)));
+
   // FIXME: We cannot handle this case yet; we might be able to figure out that
   // foox d  v; doesn't make sense.
   verifyFormat(fooa  b  c d  v;);


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206176 - Add support for named values in the parser.

2014-04-14 Thread Samuel Benzaquen
Author: sbenza
Date: Mon Apr 14 08:51:21 2014
New Revision: 206176

URL: http://llvm.org/viewvc/llvm-project?rev=206176view=rev
Log:
Add support for named values in the parser.

Summary: Add support for named values in the parser.

Reviewers: pcc

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3276

Modified:
cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h?rev=206176r1=206175r2=206176view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h Mon Apr 14 
08:51:21 2014
@@ -60,11 +60,12 @@ public:
   enum ErrorType {
 ET_None = 0,
 
-ET_RegistryNotFound = 1,
+ET_RegistryMatcherNotFound = 1,
 ET_RegistryWrongArgCount = 2,
 ET_RegistryWrongArgType = 3,
 ET_RegistryNotBindable = 4,
 ET_RegistryAmbiguousOverload = 5,
+ET_RegistryValueNotFound = 6,
 
 ET_ParserStringError = 100,
 ET_ParserNoOpenParen = 101,

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=206176r1=206175r2=206176view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Mon Apr 14 08:51:21 
2014
@@ -18,13 +18,14 @@
 ///
 /// \code
 /// Grammar for the expressions supported:
-/// Expression:= Literal | MatcherExpression
+/// Expression:= Literal | NamedValue | MatcherExpression
 /// Literal   := StringLiteral | Unsigned
 /// StringLiteral := quoted string
 /// Unsigned  := [0-9]+
-/// MatcherExpression := MatcherName(ArgumentList) |
-///MatcherName(ArgumentList).bind(StringLiteral)
-/// MatcherName   := [a-zA-Z]+
+/// NamedValue:= Identifier
+/// MatcherExpression := Identifier(ArgumentList) |
+///Identifier(ArgumentList).bind(StringLiteral)
+/// Identifier:= [a-zA-Z]+
 /// ArgumentList  := Expression | Expression,ArgumentList
 /// \endcode
 ///
@@ -62,6 +63,17 @@ public:
   public:
 virtual ~Sema();
 
+/// \brief Lookup a value by name.
+///
+/// This can be used in the Sema layer to declare known constants or to
+/// allow to split an expression in pieces.
+///
+/// \param Name The name of the value to lookup.
+///
+/// \return The named value. It could be any type that VariantValue
+///   supports. An empty value means that the name is not recognized.
+virtual VariantValue getNamedValue(StringRef Name);
+
 /// \brief Process a matcher expression.
 ///
 /// All the arguments passed here have already been processed.
@@ -89,15 +101,26 @@ public:
 ///
 /// \param MatcherName The matcher name found by the parser.
 ///
-/// \param NameRange The location of the name in the matcher source.
-///   Useful for error reporting.
-///
-/// \return The matcher constructor, or OptionalMatcherCtor() if an error
-///   occurred. In that case, \c Error will contain a description of the
-///   error.
+/// \return The matcher constructor, or OptionalMatcherCtor() if not
+/// found.
 virtual llvm::OptionalMatcherCtor
-lookupMatcherCtor(StringRef MatcherName, const SourceRange NameRange,
-  Diagnostics *Error) = 0;
+lookupMatcherCtor(StringRef MatcherName) = 0;
+  };
+
+  /// \brief Sema implementation that uses the matcher registry to process the
+  ///   tokens.
+  class RegistrySema : public Parser::Sema {
+   public:
+virtual ~RegistrySema();
+
+llvm::OptionalMatcherCtor
+lookupMatcherCtor(StringRef MatcherName) override;
+
+VariantMatcher actOnMatcherExpression(MatcherCtor Ctor,
+  const SourceRange NameRange,
+  StringRef BindID,
+  ArrayRefParserValue Args,
+  Diagnostics *Error) override;
   };
 
   /// \brief Parse a matcher expression, creating matchers from the 

RE: r206124 - MS ABI: #pragma vtordisp(0) only disables new vtordisps

2014-04-14 Thread Keith Walker
David,

The changes in the test ms_x86-vtordisp.cpp

 +#pragma vtordisp(pop, 2)
 +#pragma vtordisp(pop, 0)

are causing this test to fail on our build system because clang is
generating the following warnings which the cause the FileCheck to fail as
this is not expected output.

 llvm/tools/clang/test/Layout/ms-x86-vtordisp.cpp:389:9: warning: missing
')' after '#pragma vtordisp' - ignoring
 #pragma vtordisp(pop, 2)
 ^
 llvm/tools/clang/test/Layout/ms-x86-vtordisp.cpp:392:9: warning: missing
')' after '#pragma vtordisp' - ignoring
 #pragma vtordisp(pop, 0)
 ^
 2 warnings generated.

I assume that removing the 2nd parameter is the correct fix.

Keith

 -Original Message-
 From: cfe-commits-boun...@cs.uiuc.edu [mailto:cfe-commits-
 boun...@cs.uiuc.edu] On Behalf Of David Majnemer
 Sent: 13 April 2014 03:28
 To: cfe-commits@cs.uiuc.edu
 Subject: r206124 - MS ABI: #pragma vtordisp(0) only disables new
 vtordisps
 
 Author: majnemer
 Date: Sat Apr 12 21:27:32 2014
 New Revision: 206124
 
 URL: http://llvm.org/viewvc/llvm-project?rev=206124view=rev
 Log:
 MS ABI: #pragma vtordisp(0) only disables new vtordisps
 
 Previously, it was believed that #pragma vtordisp(0) would prohibit the
 generation of any and all vtordisps.
 
 In actuality, it only disables the generation of additional vtordisps.
 
 This fixes PR19413.
 
 Modified:
 cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
 cfe/trunk/test/Layout/ms-x86-vtordisp.cpp
 
 Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
 URL: http://llvm.org/viewvc/llvm-
 project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206124r1=206123
 r2=206124view=diff
 ===
 ===
 --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
 +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sat Apr 12 21:27:32 2014
 @@ -2674,10 +2674,6 @@ llvm::SmallPtrSetconst CXXRecordDecl *,
  MicrosoftRecordLayoutBuilder::computeVtorDispSet(const CXXRecordDecl
 *RD) {
llvm::SmallPtrSetconst CXXRecordDecl *, 2 HasVtordispSet;
 
 -  // /vd0 or #pragma vtordisp(0): Never use vtordisps when used as a
 vbase.
 -  if (RD-getMSVtorDispMode() == MSVtorDispAttr::Never)
 -return HasVtordispSet;
 -
// /vd2 or #pragma vtordisp(2): Always use vtordisps for virtual
 bases with
// vftables.
if (RD-getMSVtorDispMode() == MSVtorDispAttr::ForVFTable) {
 @@ -2690,11 +2686,6 @@ MicrosoftRecordLayoutBuilder::computeVto
  return HasVtordispSet;
}
 
 -  // /vd1 or #pragma vtordisp(1): Try to guess based on whether we
 think it's
 -  // possible for a partially constructed object with virtual base
 overrides to
 -  // escape a non-trivial constructor.
 -  assert(RD-getMSVtorDispMode() == MSVtorDispAttr::ForVBaseOverride);
 -
// If any of our bases need a vtordisp for this type, so do we.
 Check our
// direct bases for vtordisp requirements.
for (const auto I : RD-bases()) {
 @@ -2704,10 +2695,16 @@ MicrosoftRecordLayoutBuilder::computeVto
if (bi.second.hasVtorDisp())
  HasVtordispSet.insert(bi.first);
}
 -  // If we do not have a user declared constructor or destructor then
 we don't
 -  // introduce any additional vtordisps.
 -  if (!RD-hasUserDeclaredConstructor()  !RD-
 hasUserDeclaredDestructor())
 +  // We don't introduce any additional vtordisps if either:
 +  // * A user declared constructor or destructor aren't declared.
 +  // * #pragma vtordisp(0) or the /vd0 flag are in use.
 +  if ((!RD-hasUserDeclaredConstructor()  !RD-
 hasUserDeclaredDestructor()) ||
 +  RD-getMSVtorDispMode() == MSVtorDispAttr::Never)
  return HasVtordispSet;
 +  // /vd1 or #pragma vtordisp(1): Try to guess based on whether we
 think it's
 +  // possible for a partially constructed object with virtual base
 overrides to
 +  // escape a non-trivial constructor.
 +  assert(RD-getMSVtorDispMode() == MSVtorDispAttr::ForVBaseOverride);
// Compute a set of base classes which define methods we override.
 A virtual
// base in this set will require a vtordisp.  A virtual base that
 transitively
// contains one of these bases as a non-virtual base will also
 require a
 
 Modified: cfe/trunk/test/Layout/ms-x86-vtordisp.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-
 vtordisp.cpp?rev=206124r1=206123r2=206124view=diff
 ===
 ===
 --- cfe/trunk/test/Layout/ms-x86-vtordisp.cpp (original)
 +++ cfe/trunk/test/Layout/ms-x86-vtordisp.cpp Sat Apr 12 21:27:32 2014
 @@ -381,6 +381,41 @@ struct GD: public virtual GC, public vir
  // CHECK-X64-NEXT:  | [sizeof=40, align=8
  // CHECK-X64-NEXT:  |  nvsize=8, nvalign=8]
 
 +struct HA {
 +  virtual void fun() {}
 +};
 +#pragma vtordisp(push, 2)
 +struct HB : virtual HA {};
 +#pragma vtordisp(pop, 2)
 +#pragma vtordisp(push, 0)
 +struct HC : virtual HB {};
 +#pragma vtordisp(pop, 0)
 +
 +// CHECK: *** Dumping AST Record Layout
 +// CHECK: *** 

Re: r204261 - Add a new spelling for module map files 'module.modulemap'

2014-04-14 Thread Nico Weber
Should tools/clang/lib/Headers/module.map be renamed to the new name?


On Thu, Mar 20, 2014 at 7:47 AM, Ben Langmuir blangm...@apple.com wrote:

 Thanks for letting me know.  Looks like Aaron Ballman already fixed this
 in r204345.

 Be

 On Mar 20, 2014, at 6:11 AM, Timur Iskhodzhanov timur...@google.com
 wrote:


 2014-03-20 0:23 GMT+04:00 Ben Langmuir blangm...@apple.com:

  bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool
 IsSystem) {
 +  switch (loadModuleMapFileImpl(File, IsSystem)) {
 +  case LMM_AlreadyLoaded:
 +  case LMM_NewlyLoaded:
 +return false;
 +  case LMM_NoDirectory:
 +  case LMM_InvalidModuleMap:
 +return true;
 +  }
 +}


 FYI
 gcc-4.8.2 doesn't like it:
 ../tools/clang/lib/Lex/HeaderSearch.cpp: In member function ‘bool
 clang::HeaderSearch::loadModuleMapFile(const clang::FileEntry*, bool)’:
 ../tools/clang/lib/Lex/HeaderSearch.cpp:1159:1: warning: control reaches
 end of non-void function [-Wreturn-type]
  }
  ^



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [Patch] Missed evaluation in type parameter of va_arg

2014-04-14 Thread Rahul Jain
Hi Richard,

Thanks for your valuable input.
Updated the patch accordingly.

Please if you could commit the same for me.

Thanks,
Rahul


On Mon, Apr 14, 2014 at 5:08 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Please add a triple to your test (right now, it'd fail on targets where
 'int' isn't i32). Otherwise, LGTM.


 On Mon, Apr 7, 2014 at 11:26 AM, Rahul Jain 1989.rahulj...@gmail.comwrote:


 Hi Dmitri,

 Thanks for replying.

 Updated patch with test case.
 Please help review the same.

 Thanks,
 Rahul


 On Fri, Apr 4, 2014 at 8:46 PM, Dmitri Gribenko griboz...@gmail.comwrote:

 On Wed, Apr 2, 2014 at 6:55 AM, Rahul Jain 1989.rahulj...@gmail.com
 wrote:
  Gentle ping!
 
  Please if someone could help review this small patch!

 Hello Rahul,

 This patch needs a testcase.

 Dmitri

 --
 main(i,j){for(i=2;;i++){for(j=2;ji;j++){if(!(i%j)){j=0;break;}}if
 (j){printf(%d\n,i);}}} /*Dmitri Gribenko griboz...@gmail.com*/






vla_3.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add support for optimization reports.

2014-04-14 Thread Diego Novillo



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:119-121
@@ -117,1 +118,5 @@
+  %0 in '%1';
+def warn_drv_optimization_remark_missing_loc : Warningoptimization remarks 
+  will not show source location information (use -gline-tables-only 
+  -gcolumn-info to enable it), InGroupBackendOptimizationRemark;
 

Richard Smith wrote:
 I think this would make more sense as a note on the diagnostic we produce, if 
 we ever actually produce one.
Oh, yeah, much better. Done. One question, however, this will cause the note to 
be emitted on every remark we print. Should I try to reduce the noise by making 
sure it's only emitted once?


Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:35-42
@@ -34,1 +34,10 @@
 
+def err_fe_backend_optimization_remark: Remark%0, CatBackend,
+InGroupBackendOptimizationRemark;
+def warn_fe_backend_optimization_remark: Remark%0, CatBackend,
+InGroupBackendOptimizationRemark;
+def remark_fe_backend_optimization_remark: Remark%0, CatBackend,
+InGroupBackendOptimizationRemark, DefaultRemark;
+def note_fe_backend_optimization_remark: Remark%0, CatBackend,
+InGroupBackendOptimizationRemark;
+

Richard Smith wrote:
 I assume that these shouldn't all be `Remark`s?
 
 `Note`s should not have an `InGroup`.
 
 Please put a space to the left of the `:` (this file is inconsistent on this, 
 but spaces on both sides is the established convention elsewhere).
 
 Are you actually using any of these except for the `remark_...` form?
I fixed them to be the right type. They are not really used, except by the 
boilerplate macro ComputeDiagRemarkID() in lib/CodeGen/CodeGenAction.cpp. I 
replicated the behaviour of all the other handlers. I am not really sure what 
they are supposed to do.


Comment at: include/clang/Driver/Options.td:259
@@ -257,1 +258,3 @@
+  HelpTextReport transformations performed by optimization passes whose 
+   name matches the given POSIX regular expression.;
 def S : Flag[-], S, Flags[DriverOption,CC1Option], GroupAction_Group,

Richard Smith wrote:
 No full stop here, please. (I think we're inconsistent on this too.)
Done.


Comment at: lib/Frontend/CompilerInvocation.cpp:526
@@ +525,3 @@
+std::string RegexError;
+Opts.OptimizationRemarkPattern = new llvm::Regex(Val);
+if (!Opts.OptimizationRemarkPattern-isValid(RegexError)) {

Richard Smith wrote:
 It looks like this is leaked. Maybe use an `llvm::Optionalllvm::Regex` 
 instead?
I tried but llvm::Regex has an explicitly deleted constructor. I'm not sure how 
to deal with that, so I ended up using regular pointer semantics.


http://reviews.llvm.org/D3226



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add support for optimization reports.

2014-04-14 Thread Diego Novillo
  Address review feedback.

Hi qcolombet, rsmith,

http://reviews.llvm.org/D3226

CHANGE SINCE LAST DIFF
  http://reviews.llvm.org/D3226?vs=8491id=8509#toc

Files:
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticFrontendKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/Basic/DiagnosticIDs.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/TextDiagnosticPrinter.cpp
  test/Frontend/optimization-remark.c
Index: include/clang/Basic/Diagnostic.td
===
--- include/clang/Basic/Diagnostic.td
+++ include/clang/Basic/Diagnostic.td
@@ -102,6 +102,7 @@
 class DefaultWarnShowInSystemHeader {
   bit WarningShowInSystemHeader = 1;
 }
+class DefaultRemark { DiagMapping DefaultMapping = MAP_REMARK; }
 
 // Definitions for Diagnostics.
 include DiagnosticASTKinds.td
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -114,6 +114,8 @@
   unknown or ill-formed Objective-C runtime '%0';
 def err_drv_emit_llvm_link : Error
-emit-llvm cannot be used when linking;
+def err_drv_optimization_remark_pattern : Error
+  %0 in '%1';
 
 def warn_O4_is_O3 : Warning-O4 is equivalent to -O3, InGroupDeprecated;
 def warn_drv_optimization_value : Warningoptimization level '%0' is unsupported; using '%1%2' instead,
Index: include/clang/Basic/DiagnosticFrontendKinds.td
===
--- include/clang/Basic/DiagnosticFrontendKinds.td
+++ include/clang/Basic/DiagnosticFrontendKinds.td
@@ -32,6 +32,15 @@
 def remark_fe_backend_plugin: Remark%0, CatBackend, InGroupRemarkBackendPlugin;
 def note_fe_backend_plugin: Note%0, CatBackend;
 
+def err_fe_backend_optimization_remark : Error%0, CatBackend;
+def warn_fe_backend_optimization_remark : Warning%0, CatBackend;
+def remark_fe_backend_optimization_remark : Remark%0, CatBackend,
+InGroupBackendOptimizationRemark, DefaultRemark;
+def note_fe_backend_optimization_remark : Note%0, CatBackend;
+def note_fe_backend_optimization_remark_missing_loc : Noteoptimization 
+  remarks cannot show source location information (use -gline-tables-only 
+  -gcolumn-info to enable it);
+
 def err_fe_invalid_code_complete_file : Error
 cannot locate code-completion file %0, DefaultFatal;
 def err_fe_stdout_binary : Errorunable to change standard output to binary,
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -665,3 +665,4 @@
 def BackendFrameLargerThan : DiagGroupframe-larger-than;
 def BackendPlugin : DiagGroupbackend-plugin;
 def RemarkBackendPlugin : DiagGroupremark-backend-plugin;
+def BackendOptimizationRemark : DiagGrouppass;
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -154,6 +154,9 @@
   /// default.
   static bool isDefaultMappingAsError(unsigned DiagID);
 
+  /// \brief Return true if the specified diagnostic is a Remark.
+  static bool isRemark(unsigned DiagID);
+
   /// \brief Determine whether the given built-in diagnostic ID is a Note.
   static bool isBuiltinNote(unsigned DiagID);
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -60,6 +60,7 @@
 def M_Group   : OptionGroupM group, GroupCompileOnly_Group;
 def T_Group   : OptionGroupT group;
 def O_Group   : OptionGroupO group, GroupCompileOnly_Group;
+def R_Group   : OptionGroupR group, GroupCompileOnly_Group;
 def W_Group   : OptionGroupW group, GroupCompileOnly_Group;
 def d_Group   : OptionGroupd group;
 def f_Group   : OptionGroupf group, GroupCompileOnly_Group;
@@ -253,7 +254,9 @@
 def Qunused_arguments : Flag[-], Qunused-arguments, Flags[DriverOption, CoreOption],
   HelpTextDon't emit warning for unused driver arguments;
 def Q : Flag[-], Q;
-def R : Flag[-], R;
+def Rpass_EQ : Joined[-], Rpass=, GroupR_Group, Flags[CC1Option],
+  HelpTextReport transformations performed by optimization passes whose 
+   name matches the given POSIX regular expression;
 def S : Flag[-], S, Flags[DriverOption,CC1Option], GroupAction_Group,
   HelpTextOnly run preprocess and compilation steps;
 def Tbss : JoinedOrSeparate[-], Tbss, GroupT_Group;
Index: include/clang/Frontend/CodeGenOptions.h

Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Ben Langmuir

On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:

   IntrusiveRefCntPtrLangOptions LangOpts;
   IntrusiveRefCntPtrDiagnosticsEngine   Diagnostics;
 +  IntrusiveRefCntPtrvfs::FileSystem VFS;
   IntrusiveRefCntPtrFileManager FileMgr;
   IntrusiveRefCntPtrSourceManager   SourceMgr;
 
 …
 
 DiagnosticsEngine Diag, LangOptions LangOpts,
 SourceManager SourceMgr, FileManager FileMgr,
 +vfs::FileSystem VFS,
 
 Why do we need to keep the VFS separately, isn’t it owned by the FileManager ?
 
 
No, it is conceptually owned by the CompilerInstance.  The FileManager is a 
user (albeit the only user right now). I say conceptually owned, because it is 
a ref-counted object that doesn’t really have a single owner.

 
 Would it be better if a
   IntrusiveRefCntPtrvfs::FileSystem FS;
 is part of FileSystemOptions ? And created at the time with get the 
 FileSystemOptions for the compiler invocation ?
 
 It seems it would simplify a bunch of code.

This would confuse the division of responsibilities between the compiler 
invocation (which owns the FileSystemOptions) and the compiler instance. I 
don’t think that the constructed VFS belongs in the compiler invocation.  I’m 
also not sure we should be reading and parsing VFS files during command-line 
argument parsing.

Ben

 
 On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:
 
 Hi Dmitri and Argyrios,
 
 Could one (or both) of you take a look at my changes to the ASTUnit to 
 support the VFS? The VFS needs to be created for most/all of the 
 FileManagers that get created, and I’m a bit worried by the sheer number of 
 FileManager and SourceManager creations that I needed to plug up.
 
 Ben
 
 astunit.patch
 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH][cxxabi] ARM EHABI zero-cost exception handling for libc++abi

2014-04-14 Thread Jonathan Roelofs

Logan,

On 4/13/14, 9:37 AM, Logan Chien wrote:

Hi Jonathan,

Thanks for your reply.

   *  One thing that immediately jumps out at me as missing from this
  implementation are the __aeabi_unwind_pr{0,1,2} functions, which
  are necessary to unwind more kinds of frames that the backend spits out.

Yes.  I have only implemented the personality function in this patch.  Thus, we
still have to link with libgcc at the moment.


Is it going to work having half of the unwinder come from libgcc and the other 
half come from libcxxabi+libcxx? I was under the impression that support had to 
be all or nothing...


 AFAICT, following important functions are missing:


- __aeabi_unwind_pr{0,1,2}()
- _Unwind_RaiseException(), _Unwind_GetLanguageSpecificData(),
_Unwind_GetRegionStart()
- _Unwind_VRS_{Get,Set}()
- __gnu_unwind_frame()
If these two implementations can be merged, then we'll get all but the last one 
for 'free'. I believe the last one is an implementation detail of libgcc, and is 
not part of the unwinder's public api, so I don't think it needs implementing.


To reduce my own merge anxiety, I'd like to get Nico's patches upstreamed too. 
I'll focus more on that in the next couple of days.


   *  Also, I believe there might be a catch clause indexing bug as fixed in 
[2]
  (though maybe that change should be under #if LIBCXXABI_ARM_EHABI ?).

It seems that I am using different way to handle the filter type index, thus it
won't be a problem.

   *  A bunch of the _Unwind_* functions are done up as static inline... would 
be
  nicer to use the unwind cursor abstraction to help keep down #ifdef
  proliferation.

I don't quite understand what do you mean by unwind cursor abstraction.  May
you give further explanation?
I'm referring to the AbstractUnwindCursor class in UnwindCursor.hpp. This makes 
a nice platform agnostic interface for these kinds of operations. Also see 
UnwindLevel1.c.


I wrote those static inline function simply because I wish to reuse the code
with _Unwind_GetGR()/_Unwind_SetGR().  It seems that the header from clang did
the same thing.

Oh... never mind, I see what you did now.


  I'm being pedantic here: you say they compile  run, but what's the pass 
rate?

I have tried every test cases in libcxxabi/test, and all of them are passing
except one case in test_demangle.cpp.  That case assumes that long double has
80-bit, which is not true for ARM.  Thus, I have changed it in the patch.
Ok, excellent. That one was failing for me with [1], and I hadn't looked into it 
yet.


I haven't tried the test case from libc++ yet, though I am planning to do so.

Cheers,
Logan


--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[libcxx] r206184 - Define a new macro in libc++ named '_LIBCPP_HAS_NO_ASAN'. When this is defined,

2014-04-14 Thread Marshall Clow
Author: marshall
Date: Mon Apr 14 10:44:57 2014
New Revision: 206184

URL: http://llvm.org/viewvc/llvm-project?rev=206184view=rev
Log:
Define a new macro in libc++ named '_LIBCPP_HAS_NO_ASAN'. When this is defined,
libc++ will not call address_sanitizer to detect addressing errors in the
standard library containers. This is a negative macro to enable users to
disable the libc++ checks even if they are compiling with address sanitizer
enabled by defining this macro.

At the present time, there is no code in libc++ that looks at this macro.
That will come soon. This is just infrastructure.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=206184r1=206183r2=206184view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Apr 14 10:44:57 2014
@@ -352,6 +352,10 @@ namespace std {
   }
 }
 
+#if !defined(_LIBCPP_HAS_NO_ASAN)  !__has_feature(address_sanitizer)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
 #elif defined(__GNUC__)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -426,6 +430,10 @@ namespace _LIBCPP_NAMESPACE {
 using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
 }
 
+#if !defined(_LIBCPP_HAS_NO_ASAN)  !defined(__SANITIZE_ADDRESS__)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
 #elif defined(_LIBCPP_MSVC)
 
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
@@ -451,6 +459,8 @@ using namespace _LIBCPP_NAMESPACE __attr
 namespace std {
 }
 
+#define _LIBCPP_HAS_NO_ASAN
+
 #elif defined(__IBMCPP__)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -483,6 +493,8 @@ namespace std {
   }
 }
 
+#define _LIBCPP_HAS_NO_ASAN
+
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206186 - Properly diagnose standard C++ attributes which have optional argument lists when the arguments are elided. eg)

2014-04-14 Thread Aaron Ballman
Author: aaronballman
Date: Mon Apr 14 11:03:22 2014
New Revision: 206186

URL: http://llvm.org/viewvc/llvm-project?rev=206186view=rev
Log:
Properly diagnose standard C++ attributes which have optional argument lists 
when the arguments are elided. eg)

[[deprecated()]] // error
[[deprecated]] // OK
[[deprecated()]] // OK
[[gnu::deprecated()]] // OK

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/attributes.c
cfe/trunk/test/Parser/cxx0x-attributes.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=206186r1=206185r2=206186view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 14 11:03:22 
2014
@@ -526,7 +526,9 @@ def warn_cxx98_compat_attribute : Warnin
   C++11 attribute syntax is incompatible with C++98,
   InGroupCXX98Compat, DefaultIgnore;
 def err_cxx11_attribute_forbids_arguments : Error
-  attribute '%0' cannot have an argument list;
+  attribute %0 cannot have an argument list;
+def err_attribute_requires_arguements : Error
+  attribute %0 requires a nonempty argument list;
 def err_cxx11_attribute_forbids_ellipsis : Error
   attribute '%0' cannot be used as an attribute pack;
 def err_cxx11_attribute_repeated : Error

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=206186r1=206185r2=206186view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Apr 14 11:03:22 2014
@@ -2012,13 +2012,13 @@ private:
 
   /// \brief Parses syntax-generic attribute arguments for attributes which are
   /// known to the implementation, and adds them to the given ParsedAttributes
-  /// list with the given attribute syntax.
-  void ParseAttributeArgsCommon(IdentifierInfo *AttrName,
-SourceLocation AttrNameLoc,
-ParsedAttributes Attrs, SourceLocation 
*EndLoc,
-IdentifierInfo *ScopeName,
-SourceLocation ScopeLoc,
-AttributeList::Syntax Syntax);
+  /// list with the given attribute syntax. Returns the number of arguments
+  /// parsed for the attribute.
+  unsigned
+  ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation 
AttrNameLoc,
+   ParsedAttributes Attrs, SourceLocation *EndLoc,
+   IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
+   AttributeList::Syntax Syntax);
 
   void MaybeParseGNUAttributes(Declarator D,
LateParsedAttrList *LateAttrs = 0) {

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206186r1=206185r2=206186view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 11:03:22 2014
@@ -261,7 +261,7 @@ void Parser::ParseAttributeWithTypeArg(I
  0, AttrNameLoc, 0, 0, AttributeList::AS_GNU);
 }
 
-void Parser::ParseAttributeArgsCommon(
+unsigned Parser::ParseAttributeArgsCommon(
 IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
 ParsedAttributes Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName,
 SourceLocation ScopeLoc, AttributeList::Syntax Syntax) {
@@ -302,7 +302,7 @@ void Parser::ParseAttributeArgsCommon(
   ExprResult ArgExpr(ParseAssignmentExpression());
   if (ArgExpr.isInvalid()) {
 SkipUntil(tok::r_paren, StopAtSemi);
-return;
+return 0;
   }
   ArgExprs.push_back(ArgExpr.release());
   // Eat the comma, move to the next argument
@@ -318,6 +318,8 @@ void Parser::ParseAttributeArgsCommon(
 
   if (EndLoc)
 *EndLoc = RParen;
+
+  return static_castunsigned(ArgExprs.size());
 }
 
 /// Parse the arguments to a parameterized GNU attribute or

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=206186r1=206185r2=206186view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Apr 14 11:03:22 2014
@@ -3194,6 +3194,7 @@ static bool IsBuiltInOrStandardCXX11Attr
   switch (AttributeList::getKind(AttrName, ScopeName,
  AttributeList::AS_CXX11)) {
   

Re: r204261 - Add a new spelling for module map files 'module.modulemap'

2014-04-14 Thread Ben Langmuir
Yes, although there is no immediate need to do so.

On Apr 14, 2014, at 7:24 AM, Nico Weber tha...@chromium.org wrote:

 Should tools/clang/lib/Headers/module.map be renamed to the new name?
 
 
 On Thu, Mar 20, 2014 at 7:47 AM, Ben Langmuir blangm...@apple.com wrote:
 Thanks for letting me know.  Looks like Aaron Ballman already fixed this in 
 r204345.
 
 Be
 
 On Mar 20, 2014, at 6:11 AM, Timur Iskhodzhanov timur...@google.com wrote:
 
 
 2014-03-20 0:23 GMT+04:00 Ben Langmuir blangm...@apple.com:
  bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem) {
 +  switch (loadModuleMapFileImpl(File, IsSystem)) {
 +  case LMM_AlreadyLoaded:
 +  case LMM_NewlyLoaded:
 +return false;
 +  case LMM_NoDirectory:
 +  case LMM_InvalidModuleMap:
 +return true;
 +  }
 +}
 
 FYI
 gcc-4.8.2 doesn't like it:
 ../tools/clang/lib/Lex/HeaderSearch.cpp: In member function ‘bool 
 clang::HeaderSearch::loadModuleMapFile(const clang::FileEntry*, bool)’:
 ../tools/clang/lib/Lex/HeaderSearch.cpp:1159:1: warning: control reaches end 
 of non-void function [-Wreturn-type]
  }
  ^
 
 
 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 
 

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Argyrios Kyrtzidis

On Apr 14, 2014, at 8:45 AM, Ben Langmuir blangm...@apple.com wrote:

 
 On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
  IntrusiveRefCntPtrLangOptions LangOpts;
  IntrusiveRefCntPtrDiagnosticsEngine   Diagnostics;
 +  IntrusiveRefCntPtrvfs::FileSystem VFS;
  IntrusiveRefCntPtrFileManager FileMgr;
  IntrusiveRefCntPtrSourceManager   SourceMgr;
 
 …
 
DiagnosticsEngine Diag, LangOptions LangOpts,
SourceManager SourceMgr, FileManager FileMgr,
 +vfs::FileSystem VFS,
 
 Why do we need to keep the VFS separately, isn’t it owned by the FileManager 
 ?
 
 
 No, it is conceptually owned by the CompilerInstance.  The FileManager is a 
 user (albeit the only user right now). I say conceptually owned, because it 
 is a ref-counted object that doesn’t really have a single owner.

So taking into account that it is a ref-counted object with no single owner, 
and FileManager already has reference to it (I think considering the 
FileManager as one of its owners makes sense IMO), why do we need it as a field 
in ASTUnit class and passing around as parameter when a FileManager parameter 
is already there ?

 
 
 Would it be better if a
  IntrusiveRefCntPtrvfs::FileSystem FS;
 is part of FileSystemOptions ? And created at the time with get the 
 FileSystemOptions for the compiler invocation ?
 
 It seems it would simplify a bunch of code.
 
 This would confuse the division of responsibilities between the compiler 
 invocation (which owns the FileSystemOptions) and the compiler instance. I 
 don’t think that the constructed VFS belongs in the compiler invocation.  I’m 
 also not sure we should be reading and parsing VFS files during command-line 
 argument parsing.

Fair enough, but on a related note, doesn’t the “VFSOverlayFiles” belong to the 
FileSystemOptions and not the HeaderSearchOptions ?

 
 Ben
 
 
 On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:
 
 Hi Dmitri and Argyrios,
 
 Could one (or both) of you take a look at my changes to the ASTUnit to 
 support the VFS? The VFS needs to be created for most/all of the 
 FileManagers that get created, and I’m a bit worried by the sheer number of 
 FileManager and SourceManager creations that I needed to plug up.
 
 Ben
 
 astunit.patch
 
 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Support for CUDA __launch_bounds__ attribute

2014-04-14 Thread keve...@gmail.com
Ping. Attaching the patch.

On Wed Apr 09 2014 at 2:02:10 PM, keve...@gmail.com keve...@gmail.com
wrote:

 http://reviews.llvm.org/D3318

diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 1f98920..5d58471 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -4762,7 +4762,10 @@ public:
   void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule M) const override;
 private:
-  static void addKernelMetadata(llvm::Function *F);
+  // Adds a NamedMDNode with F, Name, and Operand as operands, and adds the
+  // resulting MDNode to the nvvm.annotations MDNode.
+  static void addNVVMMetadata(llvm::Function *F, StringRef Name,
+  const int Operand);
 };
 
 ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType RetTy) const {
@@ -4821,7 +4824,8 @@ SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
 // By default, all functions are device functions
 if (FD-hasAttrOpenCLKernelAttr()) {
   // OpenCL __kernel functions get kernel metadata
-  addKernelMetadata(F);
+  // Create !{func-ref, metadata !kernel, i32 1} node
+  addNVVMMetadata(F, kernel, 1);
   // And kernel functions are not subject to inlining
   F-addFnAttr(llvm::Attribute::NoInline);
 }
@@ -4832,28 +4836,43 @@ SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
 // CUDA __global__ functions get a kernel metadata entry.  Since
 // __global__ functions cannot be called from the device, we do not
 // need to set the noinline attribute.
-if (FD-hasAttrCUDAGlobalAttr())
-  addKernelMetadata(F);
+if (FD-hasAttrCUDAGlobalAttr()) {
+  // Create !{func-ref, metadata !kernel, i32 1} node
+  addNVVMMetadata(F, kernel, 1);
+}
+if (FD-hasAttrCUDALaunchBoundsAttr()) {
+  // Create !{func-ref, metadata !maxntidx, i32 val} node
+  addNVVMMetadata(F, maxntidx,
+   FD-getAttrCUDALaunchBoundsAttr()-getMaxThreads());
+  // min blocks is a default argument for CUDALaunchBoundsAttr, so getting a
+  // zero value from getMinBlocks either means it was not specified in
+  // __launch_bounds__ or the user specified a 0 value. In both cases, we
+  // don't have to add a PTX directive.
+  int minctasm = FD-getAttrCUDALaunchBoundsAttr()-getMinBlocks();
+  if (minctasm  0) {
+// Create !{func-ref, metadata !minctasm, i32 val} node
+addNVVMMetadata(F, minctasm, minctasm);
+  }
+}
   }
 }
 
-void NVPTXTargetCodeGenInfo::addKernelMetadata(llvm::Function *F) {
+void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::Function *F, StringRef Name,
+ const int Operand) {
   llvm::Module *M = F-getParent();
   llvm::LLVMContext Ctx = M-getContext();
 
   // Get nvvm.annotations metadata node
   llvm::NamedMDNode *MD = M-getOrInsertNamedMetadata(nvvm.annotations);
 
-  // Create !{func-ref, metadata !kernel, i32 1} node
   llvm::SmallVectorllvm::Value *, 3 MDVals;
   MDVals.push_back(F);
-  MDVals.push_back(llvm::MDString::get(Ctx, kernel));
-  MDVals.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), 1));
-
+  MDVals.push_back(llvm::MDString::get(Ctx, Name));
+  MDVals.push_back(
+  llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), Operand));
   // Append metadata to nvvm.annotations
   MD-addOperand(llvm::MDNode::get(Ctx, MDVals));
 }
-
 }
 
 //===--===//
diff --git a/test/CodeGenCUDA/launch-bounds.cu b/test/CodeGenCUDA/launch-bounds.cu
new file mode 100644
index 000..3f88aeb
--- /dev/null
+++ b/test/CodeGenCUDA/launch-bounds.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
+
+#include ../SemaCUDA/cuda.h
+
+#define MAX_THREADS_PER_BLOCK 256
+#define MIN_BLOCKS_PER_MP 2
+
+// Test both max threads per block and Min cta per sm.
+extern C {
+__global__ void
+__launch_bounds__( MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
+Kernel1()
+{
+}
+}
+
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel1, metadata !maxntidx, i32 256}
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel1, metadata !minctasm, i32 2}
+
+// Test only max threads per block. Min cta per sm defaults to 0, and
+// CodeGen doesn't output a zero value for minctasm.
+extern C {
+__global__ void
+__launch_bounds__( MAX_THREADS_PER_BLOCK )
+Kernel2()
+{
+}
+}
+
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel2, metadata !maxntidx, i32 256}
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r205226 - Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lis

2014-04-14 Thread Aaron Ballman
On Fri, Apr 11, 2014 at 5:40 PM, Aaron Ballman aa...@aaronballman.com wrote:
 On Fri, Apr 11, 2014 at 5:38 PM, Richard Smith rich...@metafoo.co.uk wrote:
 Thanks for doing this!

 Looks like this won't reject the ill-formed construct [[deprecated()]].
 (Both [[gnu::deprecated()]] and __attribute__((deprecated())) are OK, IIRC.)

 Good point! I'll add that on my TODO list. :-)

Fixed in r206186, but I have a question -- I think
IsBuiltInOrStandardCXX11Attribute should actually be implemented more
in terms of the scope name. If there's no scope name, it must be a
standard C++ attribute. If the scope name is clang, then it is one of
our built-in attributes and we can reason about it. But anything else
doesn't qualify. Would you agree with the attached patch?

~Aaron


ParseDeclCXX.cpp.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a new flag -fmodules-require-modular-includes

2014-04-14 Thread Ben Langmuir
The primary reason I didn’t go that route is that this flag should show up in 
the module hash so that we don’t load modules that depend on non-modular 
content simply because they are already built.

Ben

On Apr 13, 2014, at 6:15 PM, Richard Smith rich...@metafoo.co.uk wrote:

 Have you considered making this be a normal warning flag, instead of a 
 language options and an error?
 
 
 On Thu, Apr 10, 2014 at 6:43 AM, Ben Langmuir blangm...@apple.com wrote:
 As suggested off-list, this updated patch only affects frameworks for now, 
 although the intent is to include all modules in the future.  It also has 
 small fix for submodules including non-modular content and files that are 
 nested inside umbrella directories.
 
 Ben
 
 
 
 
 On Apr 8, 2014, at 5:09 PM, Ben Langmuir blangm...@apple.com wrote:
 
  When set, the new flag enforces that all of the files included by a module 
  are themselves part of a module, or are explicitly excluded by some module. 
  This will not affect headers that are part of the module being built, nor 
  files included outside of the module build (e.g. in an implementation file 
  with -fmodule-name set).
 
  Ben
 
  non-modular-includes.patch___
  cfe-commits mailing list
  cfe-commits@cs.uiuc.edu
  http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 
 
 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 
 

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206189 - OnDiskHashTable: Make the iterable version separate.

2014-04-14 Thread Justin Bogner
Author: bogner
Date: Mon Apr 14 11:34:29 2014
New Revision: 206189

URL: http://llvm.org/viewvc/llvm-project?rev=206189view=rev
Log:
OnDiskHashTable: Make the iterable version separate.

Currently the on disk hash table's key_iterator and data_iterator make
the assumption that the table data starts exactly four bytes after the
base of the table. This happens to be true for all of the tables we
currently iterate over, but not for all of the OnDiskHashTables we
currently use. For example, key_ and data_iterator would iterate over
meaningless data if they were used on the hash tables in PTHLexer.

We make the API safer by breaking this into two types. One doesn't
have the iterators, and the other must be told where the payload
starts.

Modified:
cfe/trunk/include/clang/Basic/OnDiskHashTable.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderInternals.h
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/include/clang/Basic/OnDiskHashTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OnDiskHashTable.h?rev=206189r1=206188r2=206189view=diff
==
--- cfe/trunk/include/clang/Basic/OnDiskHashTable.h (original)
+++ cfe/trunk/include/clang/Basic/OnDiskHashTable.h Mon Apr 14 11:34:29 2014
@@ -266,6 +266,41 @@ public:
 
   iterator end() const { return iterator(); }
 
+  Info getInfoObj() { return InfoObj; }
+
+  static OnDiskChainedHashTable* Create(const unsigned char* Buckets,
+const unsigned char* const Base,
+const Info InfoObj = Info()) {
+using namespace llvm::support;
+assert(Buckets  Base);
+assert((reinterpret_castuintptr_t(Buckets)  0x3) == 0 
+   buckets should be 4-byte aligned.);
+
+unsigned NumBuckets = endian::readNextuint32_t, little, aligned(Buckets);
+unsigned NumEntries = endian::readNextuint32_t, little, aligned(Buckets);
+return new OnDiskChainedHashTableInfo(NumBuckets, NumEntries, Buckets,
+Base, InfoObj);
+  }
+};
+
+templatetypename Info
+class OnDiskIterableChainedHashTable : public OnDiskChainedHashTableInfo {
+  const unsigned char *Payload;
+
+public:
+  typedef OnDiskChainedHashTableInfo  base_type;
+  typedef typename base_type::internal_key_type internal_key_type;
+  typedef typename base_type::external_key_type external_key_type;
+  typedef typename base_type::data_type data_type;
+
+  OnDiskIterableChainedHashTable(unsigned NumBuckets, unsigned NumEntries,
+ const unsigned char *Buckets,
+ const unsigned char *Payload,
+ const unsigned char *Base,
+ const Info InfoObj = Info())
+  : base_type(NumBuckets, NumEntries, Buckets, Base, InfoObj),
+Payload(Payload) {}
+
   /// \brief Iterates over all of the keys in the table.
   class key_iterator {
 const unsigned char *Ptr;
@@ -329,7 +364,7 @@ public:
   };
 
   key_iterator key_begin() {
-return key_iterator(Base + 4, getNumEntries(), InfoObj);
+return key_iterator(Payload, this-getNumEntries(), this-getInfoObj());
   }
   key_iterator key_end() { return key_iterator(); }
 
@@ -396,15 +431,13 @@ public:
   };
 
   data_iterator data_begin() {
-return data_iterator(Base + 4, getNumEntries(), InfoObj);
+return data_iterator(Payload, this-getNumEntries(), this-getInfoObj());
   }
   data_iterator data_end() { return data_iterator(); }
 
-  Info getInfoObj() { return InfoObj; }
-
-  static OnDiskChainedHashTable *Create(const unsigned char *Buckets,
-const unsigned char *const Base,
-const Info InfoObj = Info()) {
+  static OnDiskIterableChainedHashTable *
+  Create(const unsigned char *Buckets, const unsigned char *const Payload,
+ const unsigned char *const Base, const Info InfoObj = Info()) {
 using namespace llvm::support;
 assert(Buckets  Base);
 assert((reinterpret_castuintptr_t(Buckets)  0x3) == 0 
@@ -412,8 +445,8 @@ public:
 
 unsigned NumBuckets = endian::readNextuint32_t, little, aligned(Buckets);
 unsigned NumEntries = endian::readNextuint32_t, little, aligned(Buckets);
-return new OnDiskChainedHashTableInfo(NumBuckets, NumEntries, Buckets,
-Base, InfoObj);
+return new OnDiskIterableChainedHashTableInfo(
+NumBuckets, NumEntries, Buckets, Payload, Base, InfoObj);
   }
 };
 

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=206189r1=206188r2=206189view=diff

r206188 - OnDiskHashTable: clang-format and consistent naming

2014-04-14 Thread Justin Bogner
Author: bogner
Date: Mon Apr 14 11:34:19 2014
New Revision: 206188

URL: http://llvm.org/viewvc/llvm-project?rev=206188view=rev
Log:
OnDiskHashTable: clang-format and consistent naming

No functional change. Style cleanups in OnDiskChainedHashTable in
preparation for some other changes here.

Modified:
cfe/trunk/include/clang/Basic/OnDiskHashTable.h

Modified: cfe/trunk/include/clang/Basic/OnDiskHashTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OnDiskHashTable.h?rev=206188r1=206187r2=206188view=diff
==
--- cfe/trunk/include/clang/Basic/OnDiskHashTable.h (original)
+++ cfe/trunk/include/clang/Basic/OnDiskHashTable.h Mon Apr 14 11:34:19 2014
@@ -166,12 +166,11 @@ public:
   }
 };
 
-templatetypename Info
-class OnDiskChainedHashTable {
+template typename Info class OnDiskChainedHashTable {
   const unsigned NumBuckets;
   const unsigned NumEntries;
-  const unsigned char* const Buckets;
-  const unsigned char* const Base;
+  const unsigned char *const Buckets;
+  const unsigned char *const Base;
   Info InfoObj;
 
 public:
@@ -179,80 +178,82 @@ public:
   typedef typename Info::external_key_type external_key_type;
   typedef typename Info::data_type data_type;
 
-  OnDiskChainedHashTable(unsigned numBuckets, unsigned numEntries,
- const unsigned char* buckets,
- const unsigned char* base,
+  OnDiskChainedHashTable(unsigned NumBuckets, unsigned NumEntries,
+ const unsigned char *Buckets,
+ const unsigned char *Base,
  const Info InfoObj = Info())
-: NumBuckets(numBuckets), NumEntries(numEntries),
-  Buckets(buckets), Base(base), InfoObj(InfoObj) {
-assert((reinterpret_castuintptr_t(buckets)  0x3) == 0 
-   'buckets' must have a 4-byte alignment);
-  }
+  : NumBuckets(NumBuckets), NumEntries(NumEntries), Buckets(Buckets),
+Base(Base), InfoObj(InfoObj) {
+assert((reinterpret_castuintptr_t(Buckets)  0x3) == 0 
+   'buckets' must have a 4-byte alignment);
+  }
 
   unsigned getNumBuckets() const { return NumBuckets; }
   unsigned getNumEntries() const { return NumEntries; }
-  const unsigned char* getBase() const { return Base; }
-  const unsigned char* getBuckets() const { return Buckets; }
+  const unsigned char *getBase() const { return Base; }
+  const unsigned char *getBuckets() const { return Buckets; }
 
   bool isEmpty() const { return NumEntries == 0; }
 
   class iterator {
-internal_key_type key;
-const unsigned char* const data;
-const unsigned len;
+internal_key_type Key;
+const unsigned char *const Data;
+const unsigned Len;
 Info *InfoObj;
+
   public:
-iterator() : data(0), len(0) {}
-iterator(const internal_key_type k, const unsigned char* d, unsigned l,
+iterator() : Data(0), Len(0) {}
+iterator(const internal_key_type K, const unsigned char *D, unsigned L,
  Info *InfoObj)
-  : key(k), data(d), len(l), InfoObj(InfoObj) {}
+: Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
 
-data_type operator*() const { return InfoObj-ReadData(key, data, len); }
-bool operator==(const iterator X) const { return X.data == data; }
-bool operator!=(const iterator X) const { return X.data != data; }
+data_type operator*() const { return InfoObj-ReadData(Key, Data, Len); }
+bool operator==(const iterator X) const { return X.Data == Data; }
+bool operator!=(const iterator X) const { return X.Data != Data; }
   };
 
-  iterator find(const external_key_type eKey, Info *InfoPtr = 0) {
+  iterator find(const external_key_type EKey, Info *InfoPtr = 0) {
 if (!InfoPtr)
   InfoPtr = InfoObj;
 
 using namespace llvm::support;
-const internal_key_type iKey = InfoObj.GetInternalKey(eKey);
-unsigned key_hash = InfoObj.ComputeHash(iKey);
+const internal_key_type IKey = InfoObj.GetInternalKey(EKey);
+unsigned KeyHash = InfoObj.ComputeHash(IKey);
 
 // Each bucket is just a 32-bit offset into the hash table file.
-unsigned idx = key_hash  (NumBuckets - 1);
-const unsigned char* Bucket = Buckets + sizeof(uint32_t)*idx;
+unsigned Idx = KeyHash  (NumBuckets - 1);
+const unsigned char *Bucket = Buckets + sizeof(uint32_t) * Idx;
 
-unsigned offset = endian::readNextuint32_t, little, aligned(Bucket);
-if (offset == 0) return iterator(); // Empty bucket.
-const unsigned char* Items = Base + offset;
+unsigned Offset = endian::readNextuint32_t, little, aligned(Bucket);
+if (Offset == 0)
+  return iterator(); // Empty bucket.
+const unsigned char *Items = Base + Offset;
 
 // 'Items' starts with a 16-bit unsigned integer representing the
 // number of items in this bucket.
-unsigned len = endian::readNextuint16_t, little, unaligned(Items);
+unsigned Len = 

Re: [PATCH] OnDiskHashTable: Make the iterable version separate

2014-04-14 Thread Justin Bogner
I've clang-formatted and fixed up naming for the whole class in r206188,
and then applied this as r206189. Thanks!

Richard Smith rich...@metafoo.co.uk writes:
 Please fix some pre-existing style issues in code you moved around /
 refactored: * on the right, variables start with a uppercase letter, functions
 start with a lowercase letter. Otherwise, LGTM.

 On Tue, Apr 8, 2014 at 1:15 PM, Justin Bogner m...@justinbogner.com wrote:

 Currently the on disk hash table's key_iterator and data_iterator make
 the assumption that the table data starts exactly four bytes after the
 base of the table. This happens to be true for all of the tables we
 currently iterate over, but not for all of the OnDiskHashTables we
 currently use. For example, key_ and data_iterator would iterate over
 meaningless data if they were used on the hash tables in PTHLexer.

 We can make the API safer by breaking this into two types. One doesn't
 have the iterators, and the other must be told where the payload starts.

 The name I've chosen, OnDiskIterableHashTable, is a bit wordy, but I
 couldn't think of anything better.

 Does this look okay to commit?

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206191 - Properly diagnose Microsoft __declspec attributes which have optional argument lists when the arguments are elided. eg)

2014-04-14 Thread Aaron Ballman
Author: aaronballman
Date: Mon Apr 14 11:44:26 2014
New Revision: 206191

URL: http://llvm.org/viewvc/llvm-project?rev=206191view=rev
Log:
Properly diagnose Microsoft __declspec attributes which have optional argument 
lists when the arguments are elided. eg)

__declspec(deprecated()) // error
__declspec(deprecated) // OK
__declspec(deprecated()) // OK

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.c

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206191r1=206190r2=206191view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 11:44:26 2014
@@ -394,6 +394,8 @@ bool Parser::ParseMicrosoftDeclSpecArgs(
 return false;
   }
 
+  SourceLocation OpenParenLoc = Tok.getLocation();
+
   if (AttrName-getName() == property) {
 // The property declspec is more complex in that it can take one or two
 // assignment expressions as a parameter, but the lhs of the assignment
@@ -507,8 +509,17 @@ bool Parser::ParseMicrosoftDeclSpecArgs(
 return !HasInvalidAccessor;
   }
 
-  ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, nullptr, nullptr,
-   SourceLocation(), AttributeList::AS_Declspec);
+  unsigned NumArgs =
+  ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, nullptr, nullptr,
+   SourceLocation(), AttributeList::AS_Declspec);
+
+  // If this attribute's args were parsed, and it was expected to have
+  // arguments but none were provided, emit a diagnostic.
+  const AttributeList *Attr = Attrs.getList();
+  if (Attr  Attr-getMaxArgs()  !NumArgs) {
+Diag(OpenParenLoc, diag::err_attribute_requires_arguements)  AttrName;
+return false;
+  }
   return true;
 }
 

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=206191r1=206190r2=206191view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Mon Apr 14 11:44:26 2014
@@ -102,6 +102,12 @@ struct __declspec(frobble) S1 {};  /* exp
 struct __declspec(12) S2 {};   /* expected-error {{__declspec attributes must 
be an identifier or string literal}} */
 struct __declspec(testing) S3 {}; /* expected-warning {{__declspec attribute 
'testing' is not supported}} */
 
+/* declspecs with arguments cannot have an empty argument list, even if the
+   arguments are optional. */
+__declspec(deprecated()) void dep_func_test(void); /* expected-error 
{{attribute 'deprecated' requires a nonempty argument list}} */
+__declspec(deprecated) void dep_func_test2(void);
+__declspec(deprecated()) void dep_func_test3(void);
+
 /* Ensure multiple declspec attributes are supported */
 struct __declspec(align(8) deprecated) S4 {};
 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: __is_constructible return true for abstract types PR19178

2014-04-14 Thread Alp Toker


On 14/04/2014 11:59, Nikola Smiljanic wrote:

Please review.

pr19178.patch


diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 8b9c0e2..2ff501f 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -3656,6 +3656,12 @@ static bool evaluateTypeTrait(Sema S, TypeTrait Kind, 
SourceLocation KWLoc,
  if (Args[0]-getType()-isIncompleteType())
return false;
  
+// Make sure the first argument is not an abstract type.

+
+CXXRecordDecl *RD = Args[0]-getType()-getAsCXXRecordDecl();
+if (RD  RD-isAbstract())
+  return false;
+


The fix is correct. Perhaps you could use RequireNonAbstractType() 
instead of checking for CXXRecordDecl directly, something like this 
taken from the counterpart in BTT_IsConvertible:



-// Make sure the first argument is a complete type.
-if (Args[0]-getType()-isIncompleteType())
+// Make sure the first argument is a complete non-abstract type.
+if (S.RequireCompleteType(KWLoc, Args[0]-getType(), 0) ||
+S.RequireNonAbstractType(KWLoc, Args[0]-getType(), 0))
   return false;

Either way looks good to me, thanks!

Alp.



  SmallVectorOpaqueValueExpr, 2 OpaqueArgExprs;
  SmallVectorExpr *, 2 ArgExprs;
  ArgExprs.reserve(Args.size() - 1);
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 28fb8dc..b8557c4 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -1964,6 +1964,8 @@ void constructible_checks() {
  
{ int arr[T(__is_constructible(NonPOD, int))]; }

{ int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
+
+  { int arr[F(__is_constructible(Abstract))]; } // PR19178
  }
  
  // Instantiation of __is_trivially_constructible



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


--
http://www.nuanti.com
the browser experts

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Ben Langmuir
On Apr 14, 2014, at 9:16 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:On Apr 14, 2014, at 8:45 AM, Ben Langmuir blangm...@apple.com wrote:On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:IntrusiveRefCntPtrLangOptions LangOpts;IntrusiveRefCntPtrDiagnosticsEngine Diagnostics;+ IntrusiveRefCntPtrvfs::FileSystem VFS;IntrusiveRefCntPtrFileManager FileMgr;IntrusiveRefCntPtrSourceManager SourceMgr;…DiagnosticsEngine Diag, LangOptions LangOpts,SourceManager SourceMgr, FileManager FileMgr,+ vfs::FileSystem VFS,Why do we need to keep the VFS separately, isn’t it owned by the FileManager ?No, it is conceptually owned by the CompilerInstance. The FileManager is a user (albeit the only user right now). I say conceptually owned, because it is a ref-counted object that doesn’t really have a single owner.So taking into account that it is a ref-counted object with no single owner, and FileManager already has reference to it (I think considering the FileManager as one of its owners makes sense IMO), why do we need it as a field in ASTUnit class and passing around as parameter when a FileManager parameter is already there ?Sure, I can drop the field. I will change ASTUnit, but keep CompilerInstance the way it is for now, since you can reuse a VFS without reusing the FileManager, so it makes sense to have a separate field in that case. Updated patch attached.

astunit.patch
Description: Binary data
Would it be better if a	IntrusiveRefCntPtrvfs::FileSystem FS;is part of FileSystemOptions ? And created at the time with get the FileSystemOptions for the compiler invocation ?It seems it would simplify a bunch of code.This would confuse the division of responsibilities between the compiler invocation (which owns the FileSystemOptions) and the compiler instance. I don’t think that the constructed VFS belongs in the compiler invocation. I’m also not sure we should be reading and parsing VFS files during command-line argument parsing.Fair enough, but on a related note, doesn’t the “VFSOverlayFiles” belong to the FileSystemOptions and not the HeaderSearchOptions ?Yeah that makes sense. I will move them in a separate patch, since it is not directly relevant to this change.BenBenOn Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:Hi Dmitri and Argyrios,Could one (or both) of you take a look at my changes to the ASTUnit to support the VFS? The VFS needs to be created for most/all of the FileManagers that get created, and I’m a bit worried by the sheer number of FileManager and SourceManager creations that I needed to plug up.Benastunit.patch___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Allow multiple modules with the same name to coexist in the module cache

2014-04-14 Thread Ben Langmuir
Thanks, I figured you were still traveling.  Committed as r206201.


On Apr 13, 2014, at 5:10 PM, Richard Smith rich...@metafoo.co.uk wrote:

 On Tue, Apr 8, 2014 at 4:38 PM, Ben Langmuir blangm...@apple.com wrote:
 Gentle ping. Richard, did you want to continue to review this patch in 
 detail, or can I commit now that the high-level issues are resolved (at least 
 for this patch)? I’m happy to evolve this patch post-commit or here in this 
 review thread.
 
 Really sorry for the delay (EuroLLVM + catching up afterwards), LGTM.
 
 I'm rather surprised we don't already store the MODULE_NAME information into 
 the .pcm file...
 
 Ben
 
 On Apr 4, 2014, at 4:13 PM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 4, 2014, at 2:35 PM, Richard Smith rich...@metafoo.co.uk wrote:
 
 On Fri, Apr 4, 2014 at 10:44 AM, Ben Langmuir blangm...@apple.com wrote:
 
 On Apr 4, 2014, at 10:35 AM, Richard Smith rich...@metafoo.co.uk wrote:
 
 
 On 4 Apr 2014 09:09, Ben Langmuir blangm...@apple.com wrote:
 
 
  On Apr 3, 2014, at 7:49 PM, Richard Smith rich...@metafoo.co.uk wrote:
 
  On Thu, Apr 3, 2014 at 3:40 PM, Ben Langmuir blangm...@apple.com 
  wrote:
 
 
  On Mar 28, 2014, at 2:45 PM, Richard Smith rich...@metafoo.co.uk 
  wrote:
 
  On Fri, Mar 28, 2014 at 1:12 PM, Ben Langmuir blangm...@apple.com 
  wrote:
 
  This patch allows multiple modules that have the same name to 
  coexist in the module cache.  To differentiate between two modules 
  with the same name, we will consider the path the module map file 
  that they are defined by* part of the ‘key’ for looking up the 
  precompiled module (pcm file).  Specifically, this patch renames the 
  precompiled module (pcm) files from
 
  cache-path/module hash/Foo.pcm
 
  to
 
  cache-path/module hash/Foo-hash of module map path.pcm
 
 
  From a high level, I don't really see why we need a second hash here. 
  Shouldn't the -I options be included in the module hash? If I build 
  the same module with different -I flags, that should resolve to 
  different .pcm files, regardless of whether it makes the module name 
  resolve to a different module.map file.
 
  Are you trying to cope with the case where the -I path finds multiple 
  module.map files defining the same module (where it's basically 
  chance which one will get built and used)? I don't really feel like 
  this is the right solution to that problem either -- we should remove 
  the 'luck' aspect and use some sane mechanism to determine which 
  module.map files are loaded, and in what order.
 
  Is this addressing some other case?
 
   
 
  In addition, I’ve taught the ASTReader to re-resolve the names of 
  imported modules during module loading so that if the header search 
  context changes between when a module was originally built and when 
  it is loaded we can rebuild it if necessary.  For example, if module 
  A imports module B
 
  first time:
  clang -I /path/to/A -I /path/to/B …
 
  second time:
  clang -I /path/to/A -I /different/path/to/B …
 
  will now rebuild A as expected.
 
 
  * in the case of inferred modules, we use the module map file that 
  *allowed* the inference, not the __inferred_module.map file, since 
  the inferred file path is the same for every inferred module.
 
 
 
  Review comments on the patch itself:
 
   +  /// the inferrence (e.g. contained 'module *') rather than the 
  virtual
 
  Typo 'inference', 'Module *'.
 
  +  /// For an explanaition of \p ModuleMap, see Module::ModuleMap.
 
  Typo 'explanation'.
 
  +  // safe becuase the FileManager is shared between the compiler 
  instances.
 
  Typo 'because'
 
  +  // the inferred module. If this-ModuleMap is nullptr, then we are 
  using
  +  // -emit-module directly, and we cannot have an inferred module.
 
  I don't understand what this comment is trying to say. If we're using 
  -emit-module, then we were given a module map on the command-line; 
  should that not be referred to by this-ModuleMap? (Also, why 
  'this-'?) How can a top-level module be inferred? Is that a 
  framework-specific thing?
 
  +StringRef ModuleMap = this-ModuleMap ? 
  this-ModuleMap-getName() : InFile;
 
  Please pick a different variable name rather than shadowing a member 
  of '*this' here.
 
  +// Construct the name ModuleName-hash of ModuleMapPath.pcm 
  which should
  +// be globally unique to this particular module.
  +llvm::APInt Code(64, llvm::hash_value(ModuleMapPath));
  +SmallString128 HashStr;
  +Code.toStringUnsigned(HashStr);
 
  Use base 36, like the module hash.
 
 
  I’ve attached an updated patch.  Changes since the previous one:
  1. Fixed the typos and other issues Richard pointed out
  2. I’ve added code to canonicalize the module map path (using 
  realpath); I was getting spurious failures on case-intensitive 
  filesystems.
 
 
  This part is probably not OK, because it'll do the wrong thing on some 
  build farms (where the canonical path is not predictable, but the path 
  that 

Re: r204261 - Add a new spelling for module map files 'module.modulemap'

2014-04-14 Thread Nico Weber
http://clang.llvm.org/docs/Modules.html currently contains both ...Clang
will also search for a file named module.map. This behavior is deprecated
and we plan to eventually remove it. and Where To Learn More About
Modules...clang/lib/Headers/module.map which I found a bit weird :-)


On Mon, Apr 14, 2014 at 9:14 AM, Ben Langmuir blangm...@apple.com wrote:

 Yes, although there is no immediate need to do so.

 On Apr 14, 2014, at 7:24 AM, Nico Weber tha...@chromium.org wrote:

 Should tools/clang/lib/Headers/module.map be renamed to the new name?


 On Thu, Mar 20, 2014 at 7:47 AM, Ben Langmuir blangm...@apple.com wrote:

 Thanks for letting me know.  Looks like Aaron Ballman already fixed this
 in r204345.

 Be

 On Mar 20, 2014, at 6:11 AM, Timur Iskhodzhanov timur...@google.com
 wrote:


 2014-03-20 0:23 GMT+04:00 Ben Langmuir blangm...@apple.com:

  bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool
 IsSystem) {
 +  switch (loadModuleMapFileImpl(File, IsSystem)) {
 +  case LMM_AlreadyLoaded:
 +  case LMM_NewlyLoaded:
 +return false;
 +  case LMM_NoDirectory:
 +  case LMM_InvalidModuleMap:
 +return true;
 +  }
 +}


 FYI
 gcc-4.8.2 doesn't like it:
 ../tools/clang/lib/Lex/HeaderSearch.cpp: In member function ‘bool
 clang::HeaderSearch::loadModuleMapFile(const clang::FileEntry*, bool)’:
 ../tools/clang/lib/Lex/HeaderSearch.cpp:1159:1: warning: control reaches
 end of non-void function [-Wreturn-type]
  }
  ^



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a new flag -fmodules-require-modular-includes

2014-04-14 Thread Richard Smith
I don't see why this is a special case. We have that same issue with *all*
warning flags.

On Mon, Apr 14, 2014 at 9:22 AM, Ben Langmuir blangm...@apple.com wrote:

 The primary reason I didn’t go that route is that this flag should show up
 in the module hash so that we don’t load modules that depend on non-modular
 content simply because they are already built.

 Ben

 On Apr 13, 2014, at 6:15 PM, Richard Smith rich...@metafoo.co.uk wrote:

 Have you considered making this be a normal warning flag, instead of a
 language options and an error?


 On Thu, Apr 10, 2014 at 6:43 AM, Ben Langmuir blangm...@apple.com wrote:

 As suggested off-list, this updated patch only affects frameworks for
 now, although the intent is to include all modules in the future.  It also
 has small fix for submodules including non-modular content and files that
 are nested inside umbrella directories.

 Ben




 On Apr 8, 2014, at 5:09 PM, Ben Langmuir blangm...@apple.com wrote:

  When set, the new flag enforces that all of the files included by a
 module are themselves part of a module, or are explicitly excluded by some
 module. This will not affect headers that are part of the module being
 built, nor files included outside of the module build (e.g. in an
 implementation file with -fmodule-name set).
 
  Ben
 
 
 non-modular-includes.patch___
  cfe-commits mailing list
  cfe-commits@cs.uiuc.edu
  http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206202 - Add clang:: qualifier back to Module

2014-04-14 Thread Ben Langmuir
Author: benlangmuir
Date: Mon Apr 14 13:21:04 2014
New Revision: 206202

URL: http://llvm.org/viewvc/llvm-project?rev=206202view=rev
Log:
Add clang:: qualifier back to Module

Apparently this was required by some compilers.

Modified:
cfe/trunk/include/clang/Frontend/FrontendActions.h

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206202r1=206201r2=206202view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Apr 14 13:21:04 2014
@@ -93,7 +93,7 @@ public:
 };
 
 class GenerateModuleAction : public ASTFrontendAction {
-  Module *Module;
+  clang::Module *Module;
   const FileEntry *ModuleMapForUniquing;
   bool IsSystem;
   


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Argyrios Kyrtzidis

On Apr 14, 2014, at 10:27 AM, Ben Langmuir blangm...@apple.com wrote:

 
 On Apr 14, 2014, at 9:16 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
 
 On Apr 14, 2014, at 8:45 AM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
 IntrusiveRefCntPtrLangOptions LangOpts;
 IntrusiveRefCntPtrDiagnosticsEngine   Diagnostics;
 +  IntrusiveRefCntPtrvfs::FileSystem VFS;
 IntrusiveRefCntPtrFileManager FileMgr;
 IntrusiveRefCntPtrSourceManager   SourceMgr;
 
 …
 
   DiagnosticsEngine Diag, LangOptions LangOpts,
   SourceManager SourceMgr, FileManager FileMgr,
 +vfs::FileSystem VFS,
 
 Why do we need to keep the VFS separately, isn’t it owned by the 
 FileManager ?
 
 
 No, it is conceptually owned by the CompilerInstance.  The FileManager is a 
 user (albeit the only user right now). I say conceptually owned, because it 
 is a ref-counted object that doesn’t really have a single owner.
 
 So taking into account that it is a ref-counted object with no single owner, 
 and FileManager already has reference to it (I think considering the 
 FileManager as one of its owners makes sense IMO), why do we need it as a 
 field in ASTUnit class and passing around as parameter when a FileManager 
 parameter is already there ?
 
 Sure, I can drop the field.  I will change ASTUnit, but keep CompilerInstance 
 the way it is for now, since you can reuse a VFS without reusing the 
 FileManager, so it makes sense to have a separate field in that case.  
 Updated patch attached.
 
 astunit.patch
 
 
 
 
 Would it be better if a
IntrusiveRefCntPtrvfs::FileSystem FS;
 is part of FileSystemOptions ? And created at the time with get the 
 FileSystemOptions for the compiler invocation ?
 
 It seems it would simplify a bunch of code.
 
 This would confuse the division of responsibilities between the compiler 
 invocation (which owns the FileSystemOptions) and the compiler instance. I 
 don’t think that the constructed VFS belongs in the compiler invocation.  
 I’m also not sure we should be reading and parsing VFS files during 
 command-line argument parsing.
 
 Fair enough, but on a related note, doesn’t the “VFSOverlayFiles” belong to 
 the FileSystemOptions and not the HeaderSearchOptions ?
 
 Yeah that makes sense.  I will move them in a separate patch, since it is not 
 directly relevant to this change.

After you make this change how about changing:

-  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts);
+  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts,
+ vfs::FileSystem VFS);

And have it accept only ‘FileSystemOptions’ which will then use it to create a 
VFS object out of it ?

Also nitpicking, isn’t better to pass the VFS here by ref-pointer so that the 
API is clear that it is accepts and retains a reference to it ? Otherwise it’s 
unclear if the AllocatedCXCodeCompleteResults will outlive the FileSystem you 
pass to it or not.

Otherwise LGTM!

 
 Ben
 
 
 
 Ben
 
 
 On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:
 
 Hi Dmitri and Argyrios,
 
 Could one (or both) of you take a look at my changes to the ASTUnit to 
 support the VFS? The VFS needs to be created for most/all of the 
 FileManagers that get created, and I’m a bit worried by the sheer number 
 of FileManager and SourceManager creations that I needed to plug up.
 
 Ben
 
 astunit.patch

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Ben Langmuir

On Apr 14, 2014, at 11:27 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:

 
 On Apr 14, 2014, at 10:27 AM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 14, 2014, at 9:16 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
 
 On Apr 14, 2014, at 8:45 AM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com 
 wrote:
 
 IntrusiveRefCntPtrLangOptions LangOpts;
 IntrusiveRefCntPtrDiagnosticsEngine   Diagnostics;
 +  IntrusiveRefCntPtrvfs::FileSystem VFS;
 IntrusiveRefCntPtrFileManager FileMgr;
 IntrusiveRefCntPtrSourceManager   SourceMgr;
 
 …
 
   DiagnosticsEngine Diag, LangOptions LangOpts,
   SourceManager SourceMgr, FileManager FileMgr,
 +vfs::FileSystem VFS,
 
 Why do we need to keep the VFS separately, isn’t it owned by the 
 FileManager ?
 
 
 No, it is conceptually owned by the CompilerInstance.  The FileManager is 
 a user (albeit the only user right now). I say conceptually owned, because 
 it is a ref-counted object that doesn’t really have a single owner.
 
 So taking into account that it is a ref-counted object with no single 
 owner, and FileManager already has reference to it (I think considering the 
 FileManager as one of its owners makes sense IMO), why do we need it as a 
 field in ASTUnit class and passing around as parameter when a FileManager 
 parameter is already there ?
 
 Sure, I can drop the field.  I will change ASTUnit, but keep 
 CompilerInstance the way it is for now, since you can reuse a VFS without 
 reusing the FileManager, so it makes sense to have a separate field in that 
 case.  Updated patch attached.
 
 astunit.patch
 
 
 
 
 Would it be better if a
   IntrusiveRefCntPtrvfs::FileSystem FS;
 is part of FileSystemOptions ? And created at the time with get the 
 FileSystemOptions for the compiler invocation ?
 
 It seems it would simplify a bunch of code.
 
 This would confuse the division of responsibilities between the compiler 
 invocation (which owns the FileSystemOptions) and the compiler instance. I 
 don’t think that the constructed VFS belongs in the compiler invocation.  
 I’m also not sure we should be reading and parsing VFS files during 
 command-line argument parsing.
 
 Fair enough, but on a related note, doesn’t the “VFSOverlayFiles” belong to 
 the FileSystemOptions and not the HeaderSearchOptions ?
 
 Yeah that makes sense.  I will move them in a separate patch, since it is 
 not directly relevant to this change.
 
 After you make this change how about changing:
 
 -  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts);
 +  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts,
 + vfs::FileSystem VFS);
 
 And have it accept only ‘FileSystemOptions’ which will then use it to create 
 a VFS object out of it ?

Do we actually want to create a new VFS object (including parsing the VFS 
files)?  It seems pointless when we already have one in ASTUnit’s file manager.
 
 Also nitpicking, isn’t better to pass the VFS here by ref-pointer so that the 
 API is clear that it is accepts and retains a reference to it ? Otherwise 
 it’s unclear if the AllocatedCXCodeCompleteResults will outlive the 
 FileSystem you pass to it or not.

Sure, will do.

 
 Otherwise LGTM!
 
 
 Ben
 
 
 
 Ben
 
 
 On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:
 
 Hi Dmitri and Argyrios,
 
 Could one (or both) of you take a look at my changes to the ASTUnit to 
 support the VFS? The VFS needs to be created for most/all of the 
 FileManagers that get created, and I’m a bit worried by the sheer number 
 of FileManager and SourceManager creations that I needed to plug up.
 
 Ben
 
 astunit.patch

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206027 - Add -fmodules-strict-decluse to check that all headers are in modules

2014-04-14 Thread Richard Smith
Why is this a -f option rather than a diagnostic? Why is it coupled to
-fmodules-decluse? See also Ben Langmuir's patch that does the same thing
for framework modules (also, oddly, with a language option).


On Fri, Apr 11, 2014 at 4:47 AM, Daniel Jasper djas...@google.com wrote:

 Author: djasper
 Date: Fri Apr 11 06:47:45 2014
 New Revision: 206027

 URL: http://llvm.org/viewvc/llvm-project?rev=206027view=rev
 Log:
 Add -fmodules-strict-decluse to check that all headers are in modules

 Review: http://reviews.llvm.org/D3335

 Added:
 cfe/trunk/test/Modules/strict-decluse.cpp
 Modified:
 cfe/trunk/include/clang/Basic/LangOptions.def
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/lib/Driver/Tools.cpp
 cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 cfe/trunk/lib/Lex/ModuleMap.cpp

 Modified: cfe/trunk/include/clang/Basic/LangOptions.def
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
 +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Apr 11 06:47:45 2014
 @@ -96,6 +96,7 @@ LANGOPT(MathErrno , 1, 1, errno
  BENIGN_LANGOPT(HeinousExtensions , 1, 0, Extensions that we really don't
 like and may be ripped out at any time)
  LANGOPT(Modules   , 1, 0, modules extension to C)
  LANGOPT(ModulesDeclUse, 1, 0, require declaration of module uses)
 +LANGOPT(ModulesStrictDeclUse, 1, 0, require declaration of module uses
 and all headers to be in modules)
  LANGOPT(Optimize  , 1, 0, __OPTIMIZE__ predefined macro)
  LANGOPT(OptimizeSize  , 1, 0, __OPTIMIZE_SIZE__ predefined macro)
  LANGOPT(Static, 1, 0, __STATIC__ predefined macro (as
 opposed to __DYNAMIC__))

 Modified: cfe/trunk/include/clang/Driver/Options.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/include/clang/Driver/Options.td (original)
 +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 11 06:47:45 2014
 @@ -607,6 +607,9 @@ def fmodules_ignore_macro : Joined[-]
  def fmodules_decluse : Flag [-], fmodules-decluse, Groupf_Group,
Flags[DriverOption,CC1Option],
HelpTextRequire declaration of modules used within a module;
 +def fmodules_strict_decluse : Flag [-], fmodules-strict-decluse,
 Groupf_Group,
 +  Flags[DriverOption,CC1Option],
 +  HelpTextLike -fmodules-decluse but requires all headers to be in
 modules;
  def fretain_comments_from_system_headers : Flag[-],
 fretain-comments-from-system-headers, Groupf_Group, Flags[CC1Option];

  def fmudflapth : Flag[-], fmudflapth, Groupf_Group;
 @@ -666,6 +669,8 @@ def fno_module_maps : Flag [-], fno-
Flags[DriverOption];
  def fno_modules_decluse : Flag [-], fno-modules-decluse,
 Groupf_Group,
Flags[DriverOption];
 +def fno_modules_strict_decluse : Flag [-],
 fno-strict-modules-decluse, Groupf_Group,
 +  Flags[DriverOption];
  def fno_ms_extensions : Flag[-], fno-ms-extensions, Groupf_Group;
  def fno_ms_compatibility : Flag[-], fno-ms-compatibility,
 Groupf_Group;
  def fno_delayed_template_parsing : Flag[-],
 fno-delayed-template-parsing, Groupf_Group;

 Modified: cfe/trunk/lib/Driver/Tools.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/lib/Driver/Tools.cpp (original)
 +++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr 11 06:47:45 2014
 @@ -3469,6 +3469,14 @@ void Clang::ConstructJob(Compilation C,
  CmdArgs.push_back(-fmodules-decluse);
}

 +  // -fmodules-strict-decluse is like -fmodule-decluse, but also checks
 that
 +  // all #included headers are part of modules.
 +  if (Args.hasFlag(options::OPT_fmodules_strict_decluse,
 +   options::OPT_fno_modules_strict_decluse,
 +   false)) {
 +CmdArgs.push_back(-fmodules-strict-decluse);
 +  }
 +
// -fmodule-name specifies the module that is currently being built (or
// used for header checking by -fmodule-maps).
if (Arg *A = Args.getLastArg(options::OPT_fmodule_name)) {

 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
 +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Apr 11 06:47:45 2014
 @@ -1343,7 +1343,9 @@ static void ParseLangArgs(LangOptions O
Opts.Blocks = Args.hasArg(OPT_fblocks);
Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
Opts.Modules = 

Re: [PATCH] don't diagnose -Wchar-subscript for safe char literal

2014-04-14 Thread Richard Smith
This doesn't look like it's quite enough: if the index's type is Char_S,
you should also check whether the value of the character literal is
negative.


On Fri, Apr 11, 2014 at 10:58 AM, Daniel Marjamäki 
daniel.marjam...@evidente.se wrote:

 Hello!

 I have made a fix for this bug:
 http://llvm.org/bugs/show_bug.cgi?id=18389

 Please review.

 Best regards,
 Daniel Marjamäki


 ..
 Daniel Marjamäki Senior Engineer
 Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

 Mobile: +46 (0)709 12 42 62
 E-mail: daniel.marjam...@evidente.se

 www.evidente.se

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206027 - Add -fmodules-strict-decluse to check that all headers are in modules

2014-04-14 Thread Ben Langmuir
To be clear, my patch does not involve decluse, so not quite the same.  Also 
(by way of review), I think this patch doesn’t handle umbrella directories 
correctly, since it only looks for known headers.

Ben

On Apr 14, 2014, at 11:42 AM, Richard Smith rich...@metafoo.co.uk wrote:

 Why is this a -f option rather than a diagnostic? Why is it coupled to 
 -fmodules-decluse? See also Ben Langmuir's patch that does the same thing for 
 framework modules (also, oddly, with a language option).
 
 
 On Fri, Apr 11, 2014 at 4:47 AM, Daniel Jasper djas...@google.com wrote:
 Author: djasper
 Date: Fri Apr 11 06:47:45 2014
 New Revision: 206027
 
 URL: http://llvm.org/viewvc/llvm-project?rev=206027view=rev
 Log:
 Add -fmodules-strict-decluse to check that all headers are in modules
 
 Review: http://reviews.llvm.org/D3335
 
 Added:
 cfe/trunk/test/Modules/strict-decluse.cpp
 Modified:
 cfe/trunk/include/clang/Basic/LangOptions.def
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/lib/Driver/Tools.cpp
 cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 cfe/trunk/lib/Lex/ModuleMap.cpp
 
 Modified: cfe/trunk/include/clang/Basic/LangOptions.def
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=206027r1=206026r2=206027view=diff
 ==
 --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
 +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Apr 11 06:47:45 2014
 @@ -96,6 +96,7 @@ LANGOPT(MathErrno , 1, 1, errno
  BENIGN_LANGOPT(HeinousExtensions , 1, 0, Extensions that we really don't 
 like and may be ripped out at any time)
  LANGOPT(Modules   , 1, 0, modules extension to C)
  LANGOPT(ModulesDeclUse, 1, 0, require declaration of module uses)
 +LANGOPT(ModulesStrictDeclUse, 1, 0, require declaration of module uses and 
 all headers to be in modules)
  LANGOPT(Optimize  , 1, 0, __OPTIMIZE__ predefined macro)
  LANGOPT(OptimizeSize  , 1, 0, __OPTIMIZE_SIZE__ predefined macro)
  LANGOPT(Static, 1, 0, __STATIC__ predefined macro (as opposed 
 to __DYNAMIC__))
 
 Modified: cfe/trunk/include/clang/Driver/Options.td
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=206027r1=206026r2=206027view=diff
 ==
 --- cfe/trunk/include/clang/Driver/Options.td (original)
 +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 11 06:47:45 2014
 @@ -607,6 +607,9 @@ def fmodules_ignore_macro : Joined[-]
  def fmodules_decluse : Flag [-], fmodules-decluse, Groupf_Group,
Flags[DriverOption,CC1Option],
HelpTextRequire declaration of modules used within a module;
 +def fmodules_strict_decluse : Flag [-], fmodules-strict-decluse, 
 Groupf_Group,
 +  Flags[DriverOption,CC1Option],
 +  HelpTextLike -fmodules-decluse but requires all headers to be in 
 modules;
  def fretain_comments_from_system_headers : Flag[-], 
 fretain-comments-from-system-headers, Groupf_Group, Flags[CC1Option];
 
  def fmudflapth : Flag[-], fmudflapth, Groupf_Group;
 @@ -666,6 +669,8 @@ def fno_module_maps : Flag [-], fno-
Flags[DriverOption];
  def fno_modules_decluse : Flag [-], fno-modules-decluse, 
 Groupf_Group,
Flags[DriverOption];
 +def fno_modules_strict_decluse : Flag [-], fno-strict-modules-decluse, 
 Groupf_Group,
 +  Flags[DriverOption];
  def fno_ms_extensions : Flag[-], fno-ms-extensions, Groupf_Group;
  def fno_ms_compatibility : Flag[-], fno-ms-compatibility, 
 Groupf_Group;
  def fno_delayed_template_parsing : Flag[-], 
 fno-delayed-template-parsing, Groupf_Group;
 
 Modified: cfe/trunk/lib/Driver/Tools.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=206027r1=206026r2=206027view=diff
 ==
 --- cfe/trunk/lib/Driver/Tools.cpp (original)
 +++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr 11 06:47:45 2014
 @@ -3469,6 +3469,14 @@ void Clang::ConstructJob(Compilation C,
  CmdArgs.push_back(-fmodules-decluse);
}
 
 +  // -fmodules-strict-decluse is like -fmodule-decluse, but also checks that
 +  // all #included headers are part of modules.
 +  if (Args.hasFlag(options::OPT_fmodules_strict_decluse,
 +   options::OPT_fno_modules_strict_decluse,
 +   false)) {
 +CmdArgs.push_back(-fmodules-strict-decluse);
 +  }
 +
// -fmodule-name specifies the module that is currently being built (or
// used for header checking by -fmodule-maps).
if (Arg *A = Args.getLastArg(options::OPT_fmodule_name)) {
 
 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=206027r1=206026r2=206027view=diff
 ==
 --- 

Re: r206202 - Add clang:: qualifier back to Module

2014-04-14 Thread Nick Lewycky
On 14 April 2014 11:21, Ben Langmuir blangm...@apple.com wrote:

 Author: benlangmuir
 Date: Mon Apr 14 13:21:04 2014
 New Revision: 206202

 URL: http://llvm.org/viewvc/llvm-project?rev=206202view=rev
 Log:
 Add clang:: qualifier back to Module

 Apparently this was required by some compilers.


I don't believe this fix is correct, I think the code is still invalid even
if it happens to compile, since it's still changing the meaning of the name
Module inside a class scope.

The compilers which issued these errors were certainly correct, I've filed
PR19427 for clang to detect this some day.

Nick


 Modified:
 cfe/trunk/include/clang/Frontend/FrontendActions.h

 Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206202r1=206201r2=206202view=diff

 ==
 --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
 +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Apr 14 13:21:04
 2014
 @@ -93,7 +93,7 @@ public:
  };

  class GenerateModuleAction : public ASTFrontendAction {
 -  Module *Module;
 +  clang::Module *Module;
const FileEntry *ModuleMapForUniquing;
bool IsSystem;



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206203 - Fix find command in test/Modules/prune.m broken by r206201

2014-04-14 Thread Ben Langmuir
Author: benlangmuir
Date: Mon Apr 14 13:50:28 2014
New Revision: 206203

URL: http://llvm.org/viewvc/llvm-project?rev=206203view=rev
Log:
Fix find command in test/Modules/prune.m broken by r206201

Modified:
cfe/trunk/test/Modules/prune.m

Modified: cfe/trunk/test/Modules/prune.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/prune.m?rev=206203r1=206202r2=206203view=diff
==
--- cfe/trunk/test/Modules/prune.m (original)
+++ cfe/trunk/test/Modules/prune.m Mon Apr 14 13:50:28 2014
@@ -37,7 +37,7 @@
 // Set both timestamp and DependsOnModule.pcm back beyond the cutoff.
 // This should trigger pruning, which will remove DependsOnModule but not 
Module.
 // RUN: touch -m -a -t 20110101 %t/modules.timestamp 
-// RUN: find %t -name DependsOnModule..pcm | xargs touch -a -t 20110101
+// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 20110101
 // RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules 
-fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
 // RUN: ls %t | grep modules.timestamp
 // RUN: ls -R %t | grep ^Module.*pcm


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206202 - Add clang:: qualifier back to Module

2014-04-14 Thread Ben Langmuir

On Apr 14, 2014, at 11:53 AM, Nick Lewycky nlewy...@google.com wrote:

 On 14 April 2014 11:21, Ben Langmuir blangm...@apple.com wrote:
 Author: benlangmuir
 Date: Mon Apr 14 13:21:04 2014
 New Revision: 206202
 
 URL: http://llvm.org/viewvc/llvm-project?rev=206202view=rev
 Log:
 Add clang:: qualifier back to Module
 
 Apparently this was required by some compilers.
 
 I don't believe this fix is correct, I think the code is still invalid even 
 if it happens to compile, since it's still changing the meaning of the name 
 Module inside a class scope.

Fair enough. I’ll take a look at renaming this later if no one beats me to it.  
I just wanted to make sure it built for the time being.

Ben

 
 The compilers which issued these errors were certainly correct, I've filed 
 PR19427 for clang to detect this some day.
 
 Nick
  
 Modified:
 cfe/trunk/include/clang/Frontend/FrontendActions.h
 
 Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206202r1=206201r2=206202view=diff
 ==
 --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
 +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Apr 14 13:21:04 
 2014
 @@ -93,7 +93,7 @@ public:
  };
 
  class GenerateModuleAction : public ASTFrontendAction {
 -  Module *Module;
 +  clang::Module *Module;
const FileEntry *ModuleMapForUniquing;
bool IsSystem;
 
 
 
 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Use -ivfsoverlay in ASTUnit

2014-04-14 Thread Argyrios Kyrtzidis

On Apr 14, 2014, at 11:30 AM, Ben Langmuir blangm...@apple.com wrote:

 
 On Apr 14, 2014, at 11:27 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
 
 On Apr 14, 2014, at 10:27 AM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 14, 2014, at 9:16 AM, Argyrios Kyrtzidis kyrtzi...@apple.com wrote:
 
 
 On Apr 14, 2014, at 8:45 AM, Ben Langmuir blangm...@apple.com wrote:
 
 
 On Apr 11, 2014, at 5:45 PM, Argyrios Kyrtzidis kyrtzi...@apple.com 
 wrote:
 
 IntrusiveRefCntPtrLangOptions LangOpts;
 IntrusiveRefCntPtrDiagnosticsEngine   Diagnostics;
 +  IntrusiveRefCntPtrvfs::FileSystem VFS;
 IntrusiveRefCntPtrFileManager FileMgr;
 IntrusiveRefCntPtrSourceManager   SourceMgr;
 
 …
 
   DiagnosticsEngine Diag, LangOptions LangOpts,
   SourceManager SourceMgr, FileManager FileMgr,
 +vfs::FileSystem VFS,
 
 Why do we need to keep the VFS separately, isn’t it owned by the 
 FileManager ?
 
 
 No, it is conceptually owned by the CompilerInstance.  The FileManager is 
 a user (albeit the only user right now). I say conceptually owned, 
 because it is a ref-counted object that doesn’t really have a single 
 owner.
 
 So taking into account that it is a ref-counted object with no single 
 owner, and FileManager already has reference to it (I think considering 
 the FileManager as one of its owners makes sense IMO), why do we need it 
 as a field in ASTUnit class and passing around as parameter when a 
 FileManager parameter is already there ?
 
 Sure, I can drop the field.  I will change ASTUnit, but keep 
 CompilerInstance the way it is for now, since you can reuse a VFS without 
 reusing the FileManager, so it makes sense to have a separate field in that 
 case.  Updated patch attached.
 
 astunit.patch
 
 
 
 
 Would it be better if a
  IntrusiveRefCntPtrvfs::FileSystem FS;
 is part of FileSystemOptions ? And created at the time with get the 
 FileSystemOptions for the compiler invocation ?
 
 It seems it would simplify a bunch of code.
 
 This would confuse the division of responsibilities between the compiler 
 invocation (which owns the FileSystemOptions) and the compiler instance. 
 I don’t think that the constructed VFS belongs in the compiler 
 invocation.  I’m also not sure we should be reading and parsing VFS files 
 during command-line argument parsing.
 
 Fair enough, but on a related note, doesn’t the “VFSOverlayFiles” belong 
 to the FileSystemOptions and not the HeaderSearchOptions ?
 
 Yeah that makes sense.  I will move them in a separate patch, since it is 
 not directly relevant to this change.
 
 After you make this change how about changing:
 
 -  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts);
 +  AllocatedCXCodeCompleteResults(const FileSystemOptions FileSystemOpts,
 + vfs::FileSystem VFS);
 
 And have it accept only ‘FileSystemOptions’ which will then use it to create 
 a VFS object out of it ?
 
 Do we actually want to create a new VFS object (including parsing the VFS 
 files)?  It seems pointless when we already have one in ASTUnit’s file 
 manager.

Hmm, ok maybe this should accept a FileManager then (and it internally can pick 
up what it needs from it) but I’m fine as it is now.

 
 Also nitpicking, isn’t better to pass the VFS here by ref-pointer so that 
 the API is clear that it is accepts and retains a reference to it ? 
 Otherwise it’s unclear if the AllocatedCXCodeCompleteResults will outlive 
 the FileSystem you pass to it or not.
 
 Sure, will do.
 
 
 Otherwise LGTM!
 
 
 Ben
 
 
 
 Ben
 
 
 On Apr 11, 2014, at 2:14 PM, Ben Langmuir blangm...@apple.com wrote:
 
 Hi Dmitri and Argyrios,
 
 Could one (or both) of you take a look at my changes to the ASTUnit to 
 support the VFS? The VFS needs to be created for most/all of the 
 FileManagers that get created, and I’m a bit worried by the sheer 
 number of FileManager and SourceManager creations that I needed to plug 
 up.
 
 Ben
 
 astunit.patch

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Suggest fix-it ':' when '=' used in for-range-declaration while initializing an auto

2014-04-14 Thread Ismail Pazarbasi
Hi dblaikie, bkramer,

I patched this during an evening at ACCU 2014 last week, but seems like I 
forgot to send it.

This is fix for PR19176:

  int arr[] = {1, 2, 3, 4};
  for (auto i = arr)
(void)i;

possibly meant:
  for (auto i : arr)

This is going to be issued iff for range declaration begins with auto keyword 
in C++11 mode.

http://reviews.llvm.org/D3370

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseStmt.cpp
  test/Parser/cxx0x-for-range.cpp

Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -204,6 +204,8 @@
 def err_expected_semi_after_static_assert : Error
   expected ';' after static_assert;
 def err_expected_semi_for : Errorexpected ';' in 'for' statement specifier;
+def note_invalid_for_range : Note
+  range based for statement requires ':' after range declaration;
 def warn_missing_selector_name : Warning
   %0 used as the name of the previous parameter rather than as part 
   of the selector,
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1469,8 +1469,16 @@
 if (!C99orCXXorObjC)   // Use of C99-style for loops in C90 mode?
   Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
 
+const bool RangeInitIsAuto = Tok.is(tok::kw_auto);
 // In C++0x, for (T NS:a might not be a typo for ::
-bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
+const bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
+SourceLocation EqualLoc;
+if (MightBeForRangeStmt  RangeInitIsAuto) {
+  TentativeParsingAction FindEqual(*this);
+  if (SkipUntil(tok::equal, StopAtSemi | StopBeforeMatch))
+EqualLoc = Tok.getLocation();
+  FindEqual.Revert();
+}
 ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
 
 SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
@@ -1501,6 +1509,9 @@
   Collection = ParseExpression();
 } else {
   Diag(Tok, diag::err_expected_semi_for);
+  if (getLangOpts().CPlusPlus11  RangeInitIsAuto  EqualLoc.isValid())
+Diag(EqualLoc, diag::note_invalid_for_range)
+ FixItHint::CreateReplacement(EqualLoc, :);
 }
   } else {
 ProhibitAttributes(attrs);
Index: test/Parser/cxx0x-for-range.cpp
===
--- test/Parser/cxx0x-for-range.cpp
+++ test/Parser/cxx0x-for-range.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++11 
%s 21 | FileCheck %s
 
 templatetypename T, typename U
 struct pair {};
@@ -28,3 +28,31 @@
 
   return n;
 }
+
+namespace PR19176 {
+struct Vector {
+  struct iterator {
+int operator*();
+iterator operator++();
+iterator operator++(int);
+bool operator==(const iterator ) const;
+  };
+  iterator begin();
+  iterator end();
+};
+
+void f() {
+  Vector v;
+  int a[] = {1, 2, 3, 4};
+  for (auto foo = a) // expected-error {{expected ';' in 'for' statement 
specifier}}
+// expected-note@-1 {{range based for statement requires ':' after range 
declaration}}
+// expected-error@-2 {{expected ';' in 'for' statement specifier}}
+// CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:18}::
+(void)foo;
+  for (auto i = v)  // expected-error {{expected ';' in 'for' statement 
specifier}}
+// expected-note@-1 {{range based for statement requires ':' after range 
declaration}}
+// expected-error@-2 {{expected ';' in 'for' statement specifier}}
+// CHECK: fix-it:{{.*}}:{[[@LINE-3]]:15-[[@LINE-3]]:16}::
+(void)i;
+}
+}
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -204,6 +204,8 @@
 def err_expected_semi_after_static_assert : Error
   expected ';' after static_assert;
 def err_expected_semi_for : Errorexpected ';' in 'for' statement specifier;
+def note_invalid_for_range : Note
+  range based for statement requires ':' after range declaration;
 def warn_missing_selector_name : Warning
   %0 used as the name of the previous parameter rather than as part 
   of the selector,
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1469,8 +1469,16 @@
 if (!C99orCXXorObjC)   // Use of C99-style for loops in C90 mode?
   Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
 
+const bool RangeInitIsAuto = Tok.is(tok::kw_auto);
 // In C++0x, for (T NS:a might not be a typo for ::
-bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
+const bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
+ 

Re: r205651 - DebugInfo: PR19298: function local const variables duplicated in the root scope

2014-04-14 Thread Eric Christopher
On Fri, Apr 4, 2014 at 3:23 PM, David Blaikie dblai...@gmail.com wrote:
 Hmm - this might not be the right long-term fix.

 We still have basically the same bug for a global const int:

 const int i = 3;
 void func(int*);
 int main() {
   func(i); // references the global variable
   return i; // references the Constant
 }

 from this Clang describes two global variables and LLVM produces debug
 info describing both...

 I suppose what we want is to emit the constant location description
 when the variable itself is not emitted (such as when the address
 doesn't escape) and otherwise emit the global memory location
 perhaps a simple frontend lookup-and-replacement would suffice. Except
 in cases where the global variable is emitted initially and then
 optimized away by LLVM...

 oh, and we don't put the constant in the right namespace - but I'll
 probably just fix that immediately, even if the broader issue still
 stands :/


Hrm. I think, ideally at least, what we'd want is for the variable
emission to be cached (as we've discussed offline, just repeating for
public benefit).

Thanks for the patch though. :)

-eric

 On Fri, Apr 4, 2014 at 1:56 PM, David Blaikie dblai...@gmail.com wrote:
 Author: dblaikie
 Date: Fri Apr  4 15:56:17 2014
 New Revision: 205651

 URL: http://llvm.org/viewvc/llvm-project?rev=205651view=rev
 Log:
 DebugInfo: PR19298: function local const variables duplicated in the root 
 scope

 See the comment for CodeGenFunction::tryEmitAsConstant that describes
 how in some contexts (lambdas) we must not emit references to the
 variable, but instead use the constant directly - because of this we end
 up emitting a constant for the variable, as well as emitting the
 variable itself.

 Should we just skip putting the variable on the stack at all and omit
 the debug info for the constant? It's not clear to me - what if the
 address of the local is taken?

 Modified:
 cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
 cfe/trunk/test/CodeGenCXX/debug-info.cpp

 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=205651r1=205650r2=205651view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr  4 15:56:17 2014
 @@ -3227,6 +3227,9 @@ void CGDebugInfo::EmitGlobalVariable(con
// Do not use DIGlobalVariable for enums.
if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type)
  return;
 +  // Do not emit separate definitions for function local const/statics.
 +  if (isaFunctionDecl(VD-getDeclContext()))
 +return;
llvm::DIGlobalVariable GV = DBuilder.createStaticVariable(
Unit, Name, Name, Unit, getLineNumber(VD-getLocation()), Ty, true, 
 Init,
getOrCreateStaticDataMemberDeclarationOrNull(castVarDecl(VD)));

 Modified: cfe/trunk/test/CodeGenCXX/debug-info.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info.cpp?rev=205651r1=205650r2=205651view=diff
 ==
 --- cfe/trunk/test/CodeGenCXX/debug-info.cpp (original)
 +++ cfe/trunk/test/CodeGenCXX/debug-info.cpp Fri Apr  4 15:56:17 2014
 @@ -51,11 +51,6 @@ namespace VirtualBase {
}
  }

 -void foo() {
 -  const wchar_t c = L'x';
 -  wchar_t d = c;
 -}
 -
  namespace b5249287 {
  template typename T class A {
struct B;
 @@ -88,6 +83,13 @@ foo func(foo f) {
  // CHECK: [[FUNC:![0-9]*]] = {{.*}} metadata !_ZN7pr147634funcENS_3fooE, 
 i32 {{[0-9]*}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram 
 ] {{.*}} [def] [func]
  }

 +void foo() {
 +  const wchar_t c = L'x';
 +  wchar_t d = c;
 +}
 +
 +// CHECK-NOT: ; [ DW_TAG_variable ] [c]
 +
  namespace pr9608 { // also pr9600
  struct incomplete;
  incomplete (*x)[3];
 @@ -96,9 +98,11 @@ incomplete (*x)[3];
  // CHECK: [[INCARRAY]] = {{.*}}metadata !_ZTSN6pr960810incompleteE, 
 metadata {{![0-9]*}}, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 
 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE]
  }

 -// For some reason the argument for PR14763 ended up all the way down here
 +// For some reason function arguments ended up down here
  // CHECK: = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], {{.*}}, metadata 
 ![[FOO]], i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f]

 +// CHECK: ; [ DW_TAG_auto_variable ] [c]
 +
  namespace pr16214 {
  struct a {
int i;


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206202 - Add clang:: qualifier back to Module

2014-04-14 Thread Nick Lewycky
On 14 April 2014 11:59, Ben Langmuir blangm...@apple.com wrote:


 On Apr 14, 2014, at 11:53 AM, Nick Lewycky nlewy...@google.com wrote:

 On 14 April 2014 11:21, Ben Langmuir blangm...@apple.com wrote:

 Author: benlangmuir
 Date: Mon Apr 14 13:21:04 2014
 New Revision: 206202

 URL: http://llvm.org/viewvc/llvm-project?rev=206202view=rev
 Log:
 Add clang:: qualifier back to Module

 Apparently this was required by some compilers.


 I don't believe this fix is correct, I think the code is still invalid
 even if it happens to compile, since it's still changing the meaning of the
 name Module inside a class scope.


 Fair enough. I’ll take a look at renaming this later if no one beats me to
 it.  I just wanted to make sure it built for the time being.


Richard pointed out to me offline that your fix is indeed correct, but it's
not entirely clear me to me how fragile that fact is. In particular, it's
okay to create such a conflict (where the name means two different things)
as long as no name lookup is performed on that name. After the class is
complete (before delayed parsing), the name lookup on Module will simply
find the variable and not the type.

So this is okay:
struct X { clang::Module *Module; };

and so is this, in the sense that it's a clear error both clang and gcc
diagnose:
struct X { clang::Module *Module; Module *M; }; // second Module is a use
of the variable name, never the type

Nick

 The compilers which issued these errors were certainly correct, I've filed
 PR19427 for clang to detect this some day.

 Nick


 Modified:
 cfe/trunk/include/clang/Frontend/FrontendActions.h

 Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206202r1=206201r2=206202view=diff

 ==
 --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
 +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Apr 14
 13:21:04 2014
 @@ -93,7 +93,7 @@ public:
  };

  class GenerateModuleAction : public ASTFrontendAction {
 -  Module *Module;
 +  clang::Module *Module;
const FileEntry *ModuleMapForUniquing;
bool IsSystem;



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH][REVIEW REQUEST] Fix for libclang completion of already declared template friends.

2014-04-14 Thread Francisco Lopes
Hi Richard, as can be checked in the bug history, there's a side effect if
I don't call getCanonicalDecl. Also, this patch fixes an issue that's
specially related to template friends and lookup. Please take a look at the
history, since it looks like following your advices, I would end up with
regressions.


2014-04-11 17:10 GMT-03:00 Richard Smith rich...@metafoo.co.uk:

 On Fri, Mar 14, 2014 at 6:59 AM, Francisco Lopes 
 francisco.mailing.li...@oblita.com wrote:

 hi, thanks for the comment but, for example, as I want to add the call to
 getCanonicalDecl
 for this situation of friends solely, don't I need to check whether it's
 in friend name space too?

 I'm not sure whether you meant to replace the two first checks, or just
 the second.


 I meant to replace all the checks. I don't see why you would want to call
 getCanonicalDecl here, or why you'd care whether the name has ever been
 declared as a friend. All you should check is, is the name visible now?

 Regards.



 2014-03-13 20:59 GMT-03:00 Richard Smith rich...@metafoo.co.uk:

 Your visibility check seems more complex than necessary. I think this
 should do what you want:

  if
 (ND-getMostRecentDecl()-isInIdentifierNamespace(Decl::IDNS_Ordinary |
 Decl::IDNS_Tag))
   // visible


 On Wed, Mar 12, 2014 at 2:12 PM, Francisco Lopes 
 francisco.mailing.li...@oblita.com wrote:

 Ping


 2014-03-07 14:47 GMT-03:00 Francisco Lopes 
 francisco.mailing.li...@oblita.com:

 Hi,

 attached is a patch that tries to fix libclang bug 
 13699http://llvm.org/bugs/show_bug.cgi?id=13699
 .
 Please review.

 --
 Francisco Lopes

 PS:
 I have requested commit access in late 2012 but never made a test
 commit or anything.

 At the time I have received from Chris Lattner:
 I'm sorry for the delay, I've been fighting mailing list issues.
 Commit after approval access is granted.  Please try a test commit!

 I'm not sure whether it's still valid.



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Sema: Add dll attribute tests for variable templates

2014-04-14 Thread Reid Kleckner
On Thu, Apr 3, 2014 at 2:40 AM, Hans Wennborg h...@chromium.org wrote:

 On Wed, Apr 2, 2014 at 8:37 AM, Nico Rieck nico.ri...@gmail.com wrote:
  With all the previous patches applied, imported/exported variable
  templates only need tests.

 Looks good as far as I can tell.


Yep, me too.
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206204 - PR19411: Walk lexical parents, not semantic parents, when determining whether a

2014-04-14 Thread Richard Smith
Author: rsmith
Date: Mon Apr 14 15:23:58 2014
New Revision: 206204

URL: http://llvm.org/viewvc/llvm-project?rev=206204view=rev
Log:
PR19411: Walk lexical parents, not semantic parents, when determining whether a
DeclContext is (lexically) within a C language linkage specification.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/test/CodeGenCXX/extern-c.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=206204r1=206203r2=206204view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Apr 14 15:23:58 2014
@@ -837,7 +837,7 @@ static bool isLinkageSpecContext(const D
   while (DC-getDeclKind() != Decl::TranslationUnit) {
 if (DC-getDeclKind() == Decl::LinkageSpec)
   return castLinkageSpecDecl(DC)-getLanguage() == ID;
-DC = DC-getParent();
+DC = DC-getLexicalParent();
   }
   return false;
 }

Modified: cfe/trunk/test/CodeGenCXX/extern-c.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/extern-c.cpp?rev=206204r1=206203r2=206204view=diff
==
--- cfe/trunk/test/CodeGenCXX/extern-c.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/extern-c.cpp Mon Apr 14 15:23:58 2014
@@ -66,3 +66,10 @@ extern C {
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
 }
+
+namespace PR19411 {
+  struct A { void f(); };
+  extern C void A::f() { void g(); g(); }
+  // CHECK-LABEL: @_ZN7PR194111A1fEv(
+  // CHECK: call void @g()
+}


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH][cxxabi] ARM EHABI zero-cost exception handling for libc++abi

2014-04-14 Thread Nick Kledzik

On Apr 13, 2014, at 3:16 AM, Logan Chien tzuhsiang.ch...@gmail.com wrote:

 Hi,
 
 I have worked on ARM EHABI zero-cost exception handling for libc++abi.
 
 With the attached patch, I can compile and run all libc++abi unittests on ARM 
 Linux.
 
 Is it OK to commit?  Thanks.
 

 diff --git a/include/unwind.h b/include/unwind.h
 index c5acd93..e57d756 100644
 --- a/include/unwind.h
 +++ b/include/unwind.h
 @@ -23,8 +23,24 @@
  #define LIBUNWIND_UNAVAIL
  #endif
  
 +#if !defined(LIBCXXABI_SJLJ)
 +#  if defined(__arm__)
 +#if defined(__APPLE__)
 +#  define LIBCXXABI_ARM_EHABI 0
 +#  define LIBCXXABI_SJLJ 1
 +#else
 +#  define LIBCXXABI_ARM_EHABI 1
 +#  define LIBCXXABI_SJLJ 0
 +#endif
 +#  else
 +#define LIBCXXABI_ARM_EHABI 0
 +#define LIBCXXABI_SJLJ 0
 +#  endif
 +#endif
I recently found that the compiler has a built-in define  
__USING_SJLJ_EXCEPTIONS__ that is set when compiling for setjump/longjump based 
exceptions.  Is there are similar built-in for ARM EHABI?  If so, we can set 
these up without testing for __arm__ or __APPLE__.  In fact, LIBCXXABI_SJLJ can 
be replaced with __USING_SJLJ_EXCEPTIONS__.  And perhaps LIBCXXABI_ARM_EHABI 
can be replaced with some built-in?

 diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
 index 744..27a55c5 100644
 --- a/src/cxa_exception.cpp
 +++ b/src/cxa_exception.cpp
 @@ -232,7 +232,7 @@ __cxa_throw(void* thrown_object, std::type_info* tinfo, 
 void (*dest)(void*))
  globals-uncaughtExceptions += 1;   // Not atomically, since globals are 
 thread-local
  
  exception_header-unwindHeader.exception_cleanup = 
 exception_cleanup_func;
 -#if __arm__
 +#if LIBCXXABI_SJLJ
  _Unwind_SjLj_RaiseException(exception_header-unwindHeader);
  #else
I like the conditional test for SJLJ instead of the processor, but as I 
recently discovered, most of the existing __arm__ tests can be changed to 
__USING_SJLJ_EXCEPTIONS__ tests.

-Nick


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206205 - PR19415: Converting 'constexpr' to 'const' in a non-static data member can fail

2014-04-14 Thread Richard Smith
Author: rsmith
Date: Mon Apr 14 16:00:40 2014
New Revision: 206205

URL: http://llvm.org/viewvc/llvm-project?rev=206205view=rev
Log:
PR19415: Converting 'constexpr' to 'const' in a non-static data member can fail
if the member is already 'const'. Don't assert in that case.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/FixIt/fixit-cxx0x.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=206205r1=206204r2=206205view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Apr 14 16:00:40 2014
@@ -1960,14 +1960,19 @@ Sema::ActOnCXXMemberDeclarator(Scope *S,
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr_member);
 SourceLocation ConstexprLoc = DS.getConstexprSpecLoc();
 if (InitStyle == ICIS_NoInit) {
-  B  0  0  FixItHint::CreateReplacement(ConstexprLoc, const);
-  D.getMutableDeclSpec().ClearConstexprSpec();
-  const char *PrevSpec;
-  unsigned DiagID;
-  bool Failed = D.getMutableDeclSpec().SetTypeQual(DeclSpec::TQ_const, 
ConstexprLoc,
- PrevSpec, DiagID, getLangOpts());
-  (void)Failed;
-  assert(!Failed  Making a constexpr member const shouldn't fail);
+  B  0  0;
+  if (D.getDeclSpec().getTypeQualifiers()  DeclSpec::TQ_const)
+B  FixItHint::CreateRemoval(ConstexprLoc);
+  else {
+B  FixItHint::CreateReplacement(ConstexprLoc, const);
+D.getMutableDeclSpec().ClearConstexprSpec();
+const char *PrevSpec;
+unsigned DiagID;
+bool Failed = D.getMutableDeclSpec().SetTypeQual(
+DeclSpec::TQ_const, ConstexprLoc, PrevSpec, DiagID, getLangOpts());
+(void)Failed;
+assert(!Failed  Making a constexpr member const shouldn't fail);
+  }
 } else {
   B  1;
   const char *PrevSpec;

Modified: cfe/trunk/test/FixIt/fixit-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-cxx0x.cpp?rev=206205r1=206204r2=206205view=diff
==
--- cfe/trunk/test/FixIt/fixit-cxx0x.cpp (original)
+++ cfe/trunk/test/FixIt/fixit-cxx0x.cpp Mon Apr 14 16:00:40 2014
@@ -125,7 +125,8 @@ namespace NonStaticConstexpr {
   struct foo {
 constexpr int i; // expected-error {{non-static data member cannot be 
constexpr; did you intend to make it const?}}
 constexpr int j = 7; // expected-error {{non-static data member cannot be 
constexpr; did you intend to make it static?}}
-foo() : i(3) {
+constexpr const int k; // expected-error {{non-static data member cannot 
be constexpr; did you intend to make it const?}}
+foo() : i(3), k(4) {
 }
 static int get_j() {
   return j;


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r205653 - Try harder about not suggesting methods as corrections when they

2014-04-14 Thread Kaelyn Takata
On Sun, Apr 13, 2014 at 3:57 PM, Richard Smith rich...@metafoo.co.ukwrote:

 On Fri, Apr 4, 2014 at 3:16 PM, Kaelyn Takata ri...@google.com wrote:

 Author: rikka
 Date: Fri Apr  4 17:16:30 2014
 New Revision: 205653

 URL: http://llvm.org/viewvc/llvm-project?rev=205653view=rev
 Log:
 Try harder about not suggesting methods as corrections when they
 obviously won't work. Specifically, don't suggest methods (static or
 not) from unrelated classes when the expression is a method call
 through a specific object.


 Why only member functions? This seems like the right logic for data
 members too.


Because data members aren't affected by the problem this change addresses.
Typo correction can occur on member function names in two separate
contexts: when looking up the member reference, and when handling the
function call itself. The typo correction that occurred when looking up the
member reference (e.g. because there's no member named Foo but there is
one named foo) already had the right logic, and works for both function
and data members. This change fixed the second context, when typo
correction occurred during the handling of the actual function call (well
after the member reference was resolved), e.g. when the member function was
called with the wrong number of arguments.



 Modified:
 cfe/trunk/include/clang/Sema/TypoCorrection.h
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaLookup.cpp
 cfe/trunk/lib/Sema/SemaOverload.cpp
 cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp

 Modified: cfe/trunk/include/clang/Sema/TypoCorrection.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TypoCorrection.h?rev=205653r1=205652r2=205653view=diff

 ==
 --- cfe/trunk/include/clang/Sema/TypoCorrection.h (original)
 +++ cfe/trunk/include/clang/Sema/TypoCorrection.h Fri Apr  4 17:16:30 2014
 @@ -306,15 +306,15 @@ class FunctionCallFilterCCC : public Cor
  public:
FunctionCallFilterCCC(Sema SemaRef, unsigned NumArgs,
  bool HasExplicitTemplateArgs,
 -bool AllowNonStaticMethods = true);
 +MemberExpr *ME = 0);

bool ValidateCandidate(const TypoCorrection candidate) override;

   private:
unsigned NumArgs;
bool HasExplicitTemplateArgs;
 -  bool AllowNonStaticMethods;
DeclContext *CurContext;
 +  MemberExpr *MemberFn;
  };

  // @brief Callback class that effectively disabled typo correction

 Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=205653r1=205652r2=205653view=diff

 ==
 --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Apr  4 17:16:30 2014
 @@ -3974,8 +3974,8 @@ namespace {
  class FunctionCallCCC : public FunctionCallFilterCCC {
  public:
FunctionCallCCC(Sema SemaRef, const IdentifierInfo *FuncName,
 -  unsigned NumArgs, bool HasExplicitTemplateArgs)
 -  : FunctionCallFilterCCC(SemaRef, NumArgs, HasExplicitTemplateArgs),
 +  unsigned NumArgs, MemberExpr *ME)
 +  : FunctionCallFilterCCC(SemaRef, NumArgs, false, ME),
  FunctionName(FuncName) {}

bool ValidateCandidate(const TypoCorrection candidate) override {
 @@ -3992,17 +3992,20 @@ private:
  };
  }

 -static TypoCorrection TryTypoCorrectionForCall(Sema S,
 -   DeclarationNameInfo
 FuncName,
 +static TypoCorrection TryTypoCorrectionForCall(Sema S, Expr *Fn,
 +   FunctionDecl *FDecl,
 ArrayRefExpr * Args) {
 -  FunctionCallCCC CCC(S, FuncName.getName().getAsIdentifierInfo(),
 -  Args.size(), false);
 -  if (TypoCorrection Corrected =
 -  S.CorrectTypo(FuncName, Sema::LookupOrdinaryName,
 -S.getScopeForContext(S.CurContext), NULL, CCC)) {
 +  MemberExpr *ME = dyn_castMemberExpr(Fn);
 +  DeclarationName FuncName = FDecl-getDeclName();
 +  SourceLocation NameLoc = ME ? ME-getMemberLoc() : Fn-getLocStart();
 +  FunctionCallCCC CCC(S, FuncName.getAsIdentifierInfo(), Args.size(),
 ME);
 +
 +  if (TypoCorrection Corrected = S.CorrectTypo(
 +  DeclarationNameInfo(FuncName, NameLoc),
 Sema::LookupOrdinaryName,
 +  S.getScopeForContext(S.CurContext), NULL, CCC)) {
  if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
if (Corrected.isOverloaded()) {
 -OverloadCandidateSet OCS(FuncName.getLoc());
 +OverloadCandidateSet OCS(NameLoc);
  OverloadCandidateSet::iterator Best;
  for (TypoCorrection::decl_iterator CD = Corrected.begin(),
 CDEnd = Corrected.end();
 @@ -4011,7 +4014,7 @@ static TypoCorrection TryTypoCorrectionF
  

Re: [PATCH][cxxabi] ARM EHABI zero-cost exception handling for libc++abi

2014-04-14 Thread Jonathan Roelofs



On 4/14/14, 1:51 PM, Nick Kledzik wrote:


On Apr 13, 2014, at 3:16 AM, Logan Chien tzuhsiang.ch...@gmail.com wrote:


Hi,

I have worked on ARM EHABI zero-cost exception handling for libc++abi.

With the attached patch, I can compile and run all libc++abi unittests on ARM 
Linux.

Is it OK to commit?  Thanks.




diff --git a/include/unwind.h b/include/unwind.h
index c5acd93..e57d756 100644
--- a/include/unwind.h
+++ b/include/unwind.h
@@ -23,8 +23,24 @@
  #define LIBUNWIND_UNAVAIL
  #endif

+#if !defined(LIBCXXABI_SJLJ)
+#  if defined(__arm__)
+#if defined(__APPLE__)
+#  define LIBCXXABI_ARM_EHABI 0
+#  define LIBCXXABI_SJLJ 1
+#else
+#  define LIBCXXABI_ARM_EHABI 1
+#  define LIBCXXABI_SJLJ 0
+#endif
+#  else
+#define LIBCXXABI_ARM_EHABI 0
+#define LIBCXXABI_SJLJ 0
+#  endif
+#endif

I recently found that the compiler has a built-in define  
__USING_SJLJ_EXCEPTIONS__ that is set when compiling for setjump/longjump based 
exceptions.  Is there are similar built-in for ARM EHABI?  If so, we can set 
these up without testing for __arm__ or __APPLE__.  In fact, LIBCXXABI_SJLJ can 
be replaced with __USING_SJLJ_EXCEPTIONS__.  And perhaps LIBCXXABI_ARM_EHABI 
can be replaced with some built-in?
__ARM_EABI_UNWINDER__ perhaps?  I'm not exactly sure what the semantics of it 
are, and I don't see a definition for it in Clang.  In libgcc's unwinder it's 
defined in one of the arm config files. I suppose that makes it not a builtin 
then



diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
index 744..27a55c5 100644
--- a/src/cxa_exception.cpp
+++ b/src/cxa_exception.cpp
@@ -232,7 +232,7 @@ __cxa_throw(void* thrown_object, std::type_info* tinfo, 
void (*dest)(void*))
  globals-uncaughtExceptions += 1;   // Not atomically, since globals are 
thread-local

  exception_header-unwindHeader.exception_cleanup = exception_cleanup_func;
-#if __arm__
+#if LIBCXXABI_SJLJ
  _Unwind_SjLj_RaiseException(exception_header-unwindHeader);
  #else

I like the conditional test for SJLJ instead of the processor, but as I 
recently discovered, most of the existing __arm__ tests can be changed to 
__USING_SJLJ_EXCEPTIONS__ tests.

-Nick


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206217 - Add module name and module map file to -module-file-info

2014-04-14 Thread Ben Langmuir
Author: benlangmuir
Date: Mon Apr 14 17:12:44 2014
New Revision: 206217

URL: http://llvm.org/viewvc/llvm-project?rev=206217view=rev
Log:
Add module name and module map file to -module-file-info

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=206217r1=206216r2=206217view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Apr 14 17:12:44 2014
@@ -109,6 +109,9 @@ public:
 return FullVersion != getClangFullRepositoryVersion();
   }
 
+  virtual void ReadModuleName(StringRef ModuleName) {}
+  virtual void ReadModuleMapFile(StringRef ModuleMapPath) {}
+
   /// \brief Receives the language options.
   ///
   /// \returns true to indicate the options are invalid or false otherwise.
@@ -203,6 +206,8 @@ public:
   : First(First), Second(Second) { }
 
   bool ReadFullVersionInformation(StringRef FullVersion) override;
+  void ReadModuleName(StringRef ModuleName) override;
+  void ReadModuleMapFile(StringRef ModuleMapPath) override;
   bool ReadLanguageOptions(const LangOptions LangOpts, bool Complain) 
override;
   bool ReadTargetOptions(const TargetOptions TargetOpts,
  bool Complain) override;

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=206217r1=206216r2=206217view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Apr 14 17:12:44 2014
@@ -416,6 +416,13 @@ namespace {
   return ASTReaderListener::ReadFullVersionInformation(FullVersion);
 }
 
+void ReadModuleName(StringRef ModuleName) override {
+  Out.indent(2)  Module name:   ModuleName  \n;
+}
+void ReadModuleMapFile(StringRef ModuleMapPath) override {
+  Out.indent(2)  Module map file:   ModuleMapPath  \n;
+}
+
 bool ReadLanguageOptions(const LangOptions LangOpts,
  bool Complain) override {
   Out.indent(2)  Language options:\n;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=206217r1=206216r2=206217view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Apr 14 17:12:44 2014
@@ -70,6 +70,14 @@ ChainedASTReaderListener::ReadFullVersio
   return First-ReadFullVersionInformation(FullVersion) ||
  Second-ReadFullVersionInformation(FullVersion);
 }
+void ChainedASTReaderListener::ReadModuleName(StringRef ModuleName) {
+  First-ReadModuleName(ModuleName);
+  Second-ReadModuleName(ModuleName);
+}
+void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
+  First-ReadModuleMapFile(ModuleMapPath);
+  Second-ReadModuleMapFile(ModuleMapPath);
+}
 bool ChainedASTReaderListener::ReadLanguageOptions(const LangOptions LangOpts,
bool Complain) {
   return First-ReadLanguageOptions(LangOpts, Complain) ||
@@ -2313,6 +2321,8 @@ ASTReader::ReadControlBlock(ModuleFile 
 
 case MODULE_NAME:
   F.ModuleName = Blob;
+  if (Listener)
+Listener-ReadModuleName(F.ModuleName);
   break;
 
 case MODULE_MAP_FILE:
@@ -2347,6 +2357,9 @@ ASTReader::ReadControlBlock(ModuleFile 
   return OutOfDate;
 }
   }
+
+  if (Listener)
+Listener-ReadModuleMapFile(F.ModuleMapPath);
   break;
 
 case INPUT_FILE_OFFSETS:
@@ -3952,6 +3965,12 @@ bool ASTReader::readASTFileControlBlock(
   
   break;
 }
+case MODULE_NAME:
+  Listener.ReadModuleName(Blob);
+  break;
+case MODULE_MAP_FILE:
+  Listener.ReadModuleMapFile(Blob);
+  break;
 case LANGUAGE_OPTIONS:
   if (ParseLanguageOptions(Record, false, Listener))
 return true;

Modified: cfe/trunk/test/Modules/module_file_info.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module_file_info.m?rev=206217r1=206216r2=206217view=diff
==
--- cfe/trunk/test/Modules/module_file_info.m (original)
+++ cfe/trunk/test/Modules/module_file_info.m Mon Apr 14 17:12:44 2014
@@ -7,6 +7,9 @@
 
 // CHECK: Generated by this Clang:
 
+// CHECK: Module name: DependsOnModule
+// CHECK: Module map file: {{.*}}DependsOnModule.framework{{[/\\]}}module.map
+
 // CHECK: Language 

r206221 - Make sure these two files are distinct, or else the modules system may, on certain file systems, treat them as if they were the same file.

2014-04-14 Thread Nick Lewycky
Author: nicholas
Date: Mon Apr 14 17:30:21 2014
New Revision: 206221

URL: http://llvm.org/viewvc/llvm-project?rev=206221view=rev
Log:
Make sure these two files are distinct, or else the modules system may, on 
certain file systems, treat them as if they were the same file.

Modified:

cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap

cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap

Modified: 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap?rev=206221r1=206220r2=206221view=diff
==
--- 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap 
(original)
+++ 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap 
Mon Apr 14 17:30:21 2014
@@ -1,3 +1,5 @@
+// path1. This comment keeps this file from being identical to
+// path2/A/module.modulemap.
 module A {
   header a.h
 }

Modified: 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap?rev=206221r1=206220r2=206221view=diff
==
--- 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap 
(original)
+++ 
cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap 
Mon Apr 14 17:30:21 2014
@@ -1,3 +1,5 @@
+// path2. This comment keeps this file from being identical to
+// path1/A/module.modulemap.
 module A {
   header a.h
 }


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Adding diversity for security

2014-04-14 Thread Julian Lettner
  Update patch alongside with issue D1802 (http://reviews.llvm.org/D1802).

Hi rinon,

http://reviews.llvm.org/D1803

CHANGE SINCE LAST DIFF
  http://reviews.llvm.org/D1803?vs=6620id=8500#toc

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -167,6 +167,8 @@
   HelpTextTurn off Type Based Alias Analysis;
 def no_struct_path_tbaa : Flag[-], no-struct-path-tbaa,
   HelpTextTurn off struct-path aware Type Based Alias Analysis;
+def nop_insertion : Flag[-], nop-insertion,
+  HelpTextRandomly insert NOPs;
 def masm_verbose : Flag[-], masm-verbose,
   HelpTextGenerate verbose assembly output;
 def mcode_model : Separate[-], mcode-model,
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -436,6 +436,7 @@
 def fdiagnostics_show_template_tree : Flag[-], fdiagnostics-show-template-tree,
 Groupf_Group, Flags[CC1Option],
 HelpTextPrint a template comparison tree for differing templates;
+def fdiversify : Flag[-], fdiversify, Groupf_clang_Group;
 def fdollars_in_identifiers : Flag[-], fdollars-in-identifiers, Groupf_Group,
   HelpTextAllow '$' in identifiers, Flags[CC1Option];
 def fdwarf2_cfi_asm : Flag[-], fdwarf2-cfi-asm, Groupf_Group;
@@ -765,7 +766,7 @@
 def fprofile_arcs : Flag[-], fprofile-arcs, Groupf_Group;
 def fprofile_generate : Flag[-], fprofile-generate, Groupf_Group;
 def framework : Separate[-], framework, Flags[LinkerInput];
-def frandom_seed_EQ : Joined[-], frandom-seed=, Groupclang_ignored_f_Group;
+def frandom_seed_EQ : Joined[-], frandom-seed=, Groupf_Group, Flags[CC1Option];
 def freg_struct_return : Flag[-], freg-struct-return, Groupf_Group, Flags[CC1Option],
   HelpTextOverride the default ABI to return small structs in registers;
 def frtti : Flag[-], frtti, Groupf_Group;
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -155,6 +155,8 @@
 CODEGENOPT(SanitizeRecover, 1, 1) /// Attempt to recover from sanitizer checks
   /// by continuing execution when possible
 
+CODEGENOPT(NOPInsertion, 1, 0) /// Randomly add NOPs
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -119,6 +119,9 @@
   /// file, for example with -save-temps.
   std::string MainFileName;
 
+  /// Random seed used for the random number generator
+  uint64_t RandomSeed;
+
   /// The name for the split debug info file that we'll break out. This is used
   /// in the backend for setting the name in the skeleton cu.
   std::string SplitDwarfFile;
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -492,6 +492,7 @@
   Options.TrapFuncName = CodeGenOpts.TrapFuncName;
   Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
   Options.EnableSegmentedStacks = CodeGenOpts.EnableSegmentedStacks;
+  Options.NOPInsertion = CodeGenOpts.NOPInsertion;
 
   TargetMachine *TM = TheTarget-createTargetMachine(Triple, TargetOpts.CPU,
  FeaturesStr, Options,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3391,6 +3391,20 @@
 }
   }
 
+  // Translate -frandom-seed to seed the LLVM RNG
+  if (Args.hasArg(options::OPT_frandom_seed_EQ)) {
+StringRef seed = Args.getLastArgValue(options::OPT_frandom_seed_EQ);
+CmdArgs.push_back(-backend-option);
+CmdArgs.push_back(Args.MakeArgString(-rng-seed= + seed));
+  }
+
+  if (Args.hasArg(options::OPT_fdiversify)) {
+CmdArgs.push_back(-nop-insertion);
+
+CmdArgs.push_back(-backend-option);
+CmdArgs.push_back(-sched-randomize);
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
options::OPT_mno_restrict_it)) {
 if (A-getOption().matches(options::OPT_mrestrict_it)) {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -32,6 +32,7 @@
 #include llvm/Support/Host.h
 #include 

Re: [PATCH] Add -L args for sanitizers

2014-04-14 Thread Greg Fitzgerald

   It looks like this patch might be against clang?  If so,
   please move to cfe-commits.

  Adding cfe-commits

http://reviews.llvm.org/D3327



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a new flag -fmodules-require-modular-includes

2014-04-14 Thread Ben Langmuir
Fair point. In that case how about we add all -Werror= and -Wfatal-error= 
options to the module hash? That way we are consistent about any diagnostic 
options that would prevent us from building the module.  We don’t need/want to 
include regular warning flags, since we won’t get warnings anyway after the 
module is built the first time.  I suppose we would want to track only the 
canonical (last) options and sort them to avoid spurious hash changes.

Then we could replace -f with -Werror= for this option.

Ben


On Apr 14, 2014, at 11:24 AM, Richard Smith rich...@metafoo.co.uk wrote:

 I don't see why this is a special case. We have that same issue with *all* 
 warning flags.
 
 On Mon, Apr 14, 2014 at 9:22 AM, Ben Langmuir blangm...@apple.com wrote:
 The primary reason I didn’t go that route is that this flag should show up in 
 the module hash so that we don’t load modules that depend on non-modular 
 content simply because they are already built.
 
 Ben
 
 On Apr 13, 2014, at 6:15 PM, Richard Smith rich...@metafoo.co.uk wrote:
 
 Have you considered making this be a normal warning flag, instead of a 
 language options and an error?
 
 
 On Thu, Apr 10, 2014 at 6:43 AM, Ben Langmuir blangm...@apple.com wrote:
 As suggested off-list, this updated patch only affects frameworks for now, 
 although the intent is to include all modules in the future.  It also has 
 small fix for submodules including non-modular content and files that are 
 nested inside umbrella directories.
 
 Ben
 
 
 
 
 On Apr 8, 2014, at 5:09 PM, Ben Langmuir blangm...@apple.com wrote:
 
  When set, the new flag enforces that all of the files included by a module 
  are themselves part of a module, or are explicitly excluded by some 
  module. This will not affect headers that are part of the module being 
  built, nor files included outside of the module build (e.g. in an 
  implementation file with -fmodule-name set).
 
  Ben
 
  non-modular-includes.patch___
  cfe-commits mailing list
  cfe-commits@cs.uiuc.edu
  http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 
 
 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
 
 
 
 

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] PR19095 Undefined reference to friend template function defined inside template class

2014-04-14 Thread Richard Smith
On Mon, Apr 14, 2014 at 1:09 AM, suyog sarda sardas...@gmail.com wrote:

 Hi Richard,

 Thanks for the review. I Agree to your explaination. Following are the
 points what i understood :

 1. setInstantiatedFromMemberTemplate call should not be skipped since it
 causes mix up of  template parameter list numbering and wrong
 substitutions,
 which is clearly visible in the test case as well.


More fundamentally, it shouldn't be skipped because this function is
instantiated from a member template (it's not actually a member, but this
really means class-scope template, not member template).


 2. When C is instantiated twice, it should throw re-definition error of
 function f, which is not done (with or without my patch).


That should be handled by the 'if (isFriend) {' loop starting at around
line 1424.


 3. In the same function call
 'TemplateDeclInstantiator::VisitFunctionDecl', there is a check 'if
 (isFriend)'.
 There is a standard described '[temp.friend] p4 (DR329)' inside that
 check, which checks if the *FunctionDecl D *is Declared as well as
 Defined (isThisDeclarationADefintion).
 In my opinion, at this point the function defintion is not being set
 for friend function defined inside the class template.


There's also something strange going on in VisitFunctionTemplateDecl --
that code is also calling setInstantiatedFromMemberTemplate for a friend
template definition. So at least there appears to be some redundancy here.

4. While debugging, it is seen that, the *FunctionDecl D *is *defined *holds
 true but '*Function-isDefined(Definition)*' evaluates to false (I did
 not get why it evaluates to false), because of which
 re-defintion error is not emitted.


The function isn't defined because we've not instantiated its definition
yet; that's probably to be expected.


 There is a similar bug for operator overloading - Bug 14785. There also
 same case is happening - not able to identify if friend function (in 14785
 its operator overloading function) is defined inside class template.

 Can you please help me out if my above analysis is correct as well as
 indicate where/how to set the definition of the declared function? Your
 help is highly appreciated.


I don't get see what's going wrong, but I suspect something in
FunctionDecl::getTemplateInstantiationPattern() is broken.


 On Sat, Apr 12, 2014 at 1:57 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Hi!

 I'm afraid this patch is incorrect; it even does the wrong thing in your
 test case. Skipping the setInstantiatedFromMemberTemplate call causes us to
 mix up the template parameter list numbering -- we substitute the argument
 given for T as the value U, and we don't substitute anything for T. For
 instance, in the definition of f instantiated for the f(3.0) call, we
 should have T=double, U=int, but we actually have T=no value, U=double,
 as can be seen in the AST dump.

 This also does the wrong thing if C is instantiated twice -- such a case
 should be an error, because f would have multiple definitions.


  On Mon, Mar 24, 2014 at 5:29 AM, suyog sarda sardas...@gmail.comwrote:

  Gentle Ping!!


 On Thu, Mar 20, 2014 at 9:46 AM, suyog sarda sardas...@gmail.comwrote:

 Gentle Ping!!


 On Fri, Mar 14, 2014 at 10:29 PM, suyog sarda sardas...@gmail.comwrote:

 Hi,

 Attaching patch for bug 19095. Please help in reviewing the same.

 Also, I haven't attached a test case yet in the patch as i am not sure
 how it should be and in which file it should be.

 In my opinion, the test case would go into 
 *tools/clang/test/SemaCXX/friend.cpp
 *would be something like below (similar to that mentioned in the bug)




























 * template class Tvoid f(T);template class Uclass C{  template
 class T  friend void f(T)  { CU c; c.i = 3;  }  public :
 void g()  {   f(3.0); // OK }int i;};void h (){  f(7); //
 OK  Cdouble c;  c.g();}*


 Please help in reviewing the patch as well as the test case.
 --
 With regards,
 Suyog Sarda




 --
 With regards,
 Suyog Sarda




 --
 With regards,
 Suyog Sarda

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





 --
 With regards,
 Suyog Sarda

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Partial revert of 183015

2014-04-14 Thread Richard Smith

  Looks OK as a short-term fix for the ones with the j flag. Do we really 
need to do this for the fn ones?

http://reviews.llvm.org/D3369



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206223 - Ensure we evaluate VLA bounds if a variably-modified type is used as the

2014-04-14 Thread Richard Smith
Author: rsmith
Date: Mon Apr 14 18:47:48 2014
New Revision: 206223

URL: http://llvm.org/viewvc/llvm-project?rev=206223view=rev
Log:
Ensure we evaluate VLA bounds if a variably-modified type is used as the
argument to __builtin_va_arg. Patch by Rahul Jain, some test massaging and
IR emission order changes by me.

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/varargs.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=206223r1=206222r2=206223view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Apr 14 18:47:48 2014
@@ -3199,6 +3199,10 @@ Value *ScalarExprEmitter::VisitChooseExp
 }
 
 Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
+  QualType Ty = VE-getType();
+  if (Ty-isVariablyModifiedType())
+CGF.EmitVariablyModifiedType(Ty);
+
   llvm::Value *ArgValue = CGF.EmitVAListRef(VE-getSubExpr());
   llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE-getType());
 

Modified: cfe/trunk/test/CodeGen/varargs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/varargs.c?rev=206223r1=206222r2=206223view=diff
==
--- cfe/trunk/test/CodeGen/varargs.c (original)
+++ cfe/trunk/test/CodeGen/varargs.c Mon Apr 14 18:47:48 2014
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
-
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck 
%s
 
 // PR6433 - Don't crash on va_arg(typedef).
 typedef double gdouble;
@@ -15,3 +14,10 @@ void function_as_vararg() {
   // CHECK-NOT: llvm.trap
   vararg(0, focus_changed_cb);
 }
+
+void vla(int n, ...)
+{
+  __builtin_va_list ap;
+  void *p;
+  p = __builtin_va_arg(ap, typeof (int (*)[++n])); // CHECK: add nsw i32 
{{.*}}, 1
+}


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [Patch] Missed evaluation in type parameter of va_arg

2014-04-14 Thread Richard Smith
Slightly tweaked and committed as r206223. Thanks!


On Mon, Apr 14, 2014 at 7:55 AM, Rahul Jain 1989.rahulj...@gmail.comwrote:


 Hi Richard,

 Thanks for your valuable input.
 Updated the patch accordingly.

 Please if you could commit the same for me.

 Thanks,
 Rahul


 On Mon, Apr 14, 2014 at 5:08 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Please add a triple to your test (right now, it'd fail on targets where
 'int' isn't i32). Otherwise, LGTM.


 On Mon, Apr 7, 2014 at 11:26 AM, Rahul Jain 1989.rahulj...@gmail.comwrote:


 Hi Dmitri,

 Thanks for replying.

 Updated patch with test case.
 Please help review the same.

 Thanks,
 Rahul


 On Fri, Apr 4, 2014 at 8:46 PM, Dmitri Gribenko griboz...@gmail.comwrote:

 On Wed, Apr 2, 2014 at 6:55 AM, Rahul Jain 1989.rahulj...@gmail.com
 wrote:
  Gentle ping!
 
  Please if someone could help review this small patch!

 Hello Rahul,

 This patch needs a testcase.

 Dmitri

 --
 main(i,j){for(i=2;;i++){for(j=2;ji;j++){if(!(i%j)){j=0;break;}}if
 (j){printf(%d\n,i);}}} /*Dmitri Gribenko griboz...@gmail.com*/





___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206224 - Fix warning in ms-x86-vtordisp test case

2014-04-14 Thread Reid Kleckner
Author: rnk
Date: Mon Apr 14 18:49:17 2014
New Revision: 206224

URL: http://llvm.org/viewvc/llvm-project?rev=206224view=rev
Log:
Fix warning in ms-x86-vtordisp test case

Modified:
cfe/trunk/test/Layout/ms-x86-vtordisp.cpp

Modified: cfe/trunk/test/Layout/ms-x86-vtordisp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-vtordisp.cpp?rev=206224r1=206223r2=206224view=diff
==
--- cfe/trunk/test/Layout/ms-x86-vtordisp.cpp (original)
+++ cfe/trunk/test/Layout/ms-x86-vtordisp.cpp Mon Apr 14 18:49:17 2014
@@ -386,10 +386,10 @@ struct HA {
 };
 #pragma vtordisp(push, 2)
 struct HB : virtual HA {};
-#pragma vtordisp(pop, 2)
+#pragma vtordisp(pop)
 #pragma vtordisp(push, 0)
 struct HC : virtual HB {};
-#pragma vtordisp(pop, 0)
+#pragma vtordisp(pop)
 
 // CHECK: *** Dumping AST Record Layout
 // CHECK: *** Dumping AST Record Layout


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206124 - MS ABI: #pragma vtordisp(0) only disables new vtordisps

2014-04-14 Thread Reid Kleckner
Thanks, fixed in r206224.


On Mon, Apr 14, 2014 at 7:02 AM, Keith Walker kwal...@arm.com wrote:

 David,

 The changes in the test ms_x86-vtordisp.cpp

  +#pragma vtordisp(pop, 2)
  +#pragma vtordisp(pop, 0)

 are causing this test to fail on our build system because clang is
 generating the following warnings which the cause the FileCheck to fail as
 this is not expected output.

  llvm/tools/clang/test/Layout/ms-x86-vtordisp.cpp:389:9: warning: missing
 ')' after '#pragma vtordisp' - ignoring
  #pragma vtordisp(pop, 2)
  ^
  llvm/tools/clang/test/Layout/ms-x86-vtordisp.cpp:392:9: warning: missing
 ')' after '#pragma vtordisp' - ignoring
  #pragma vtordisp(pop, 0)
  ^
  2 warnings generated.

 I assume that removing the 2nd parameter is the correct fix.

 Keith

  -Original Message-
  From: cfe-commits-boun...@cs.uiuc.edu [mailto:cfe-commits-
  boun...@cs.uiuc.edu] On Behalf Of David Majnemer
  Sent: 13 April 2014 03:28
  To: cfe-commits@cs.uiuc.edu
  Subject: r206124 - MS ABI: #pragma vtordisp(0) only disables new
  vtordisps
 
  Author: majnemer
  Date: Sat Apr 12 21:27:32 2014
  New Revision: 206124
 
  URL: http://llvm.org/viewvc/llvm-project?rev=206124view=rev
  Log:
  MS ABI: #pragma vtordisp(0) only disables new vtordisps
 
  Previously, it was believed that #pragma vtordisp(0) would prohibit the
  generation of any and all vtordisps.
 
  In actuality, it only disables the generation of additional vtordisps.
 
  This fixes PR19413.
 
  Modified:
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/test/Layout/ms-x86-vtordisp.cpp
 
  Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  URL: http://llvm.org/viewvc/llvm-
  project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206124r1=206123
  r2=206124view=diff
  ===
  ===
  --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
  +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sat Apr 12 21:27:32 2014
  @@ -2674,10 +2674,6 @@ llvm::SmallPtrSetconst CXXRecordDecl *,
   MicrosoftRecordLayoutBuilder::computeVtorDispSet(const CXXRecordDecl
  *RD) {
 llvm::SmallPtrSetconst CXXRecordDecl *, 2 HasVtordispSet;
 
  -  // /vd0 or #pragma vtordisp(0): Never use vtordisps when used as a
  vbase.
  -  if (RD-getMSVtorDispMode() == MSVtorDispAttr::Never)
  -return HasVtordispSet;
  -
 // /vd2 or #pragma vtordisp(2): Always use vtordisps for virtual
  bases with
 // vftables.
 if (RD-getMSVtorDispMode() == MSVtorDispAttr::ForVFTable) {
  @@ -2690,11 +2686,6 @@ MicrosoftRecordLayoutBuilder::computeVto
   return HasVtordispSet;
 }
 
  -  // /vd1 or #pragma vtordisp(1): Try to guess based on whether we
  think it's
  -  // possible for a partially constructed object with virtual base
  overrides to
  -  // escape a non-trivial constructor.
  -  assert(RD-getMSVtorDispMode() == MSVtorDispAttr::ForVBaseOverride);
  -
 // If any of our bases need a vtordisp for this type, so do we.
  Check our
 // direct bases for vtordisp requirements.
 for (const auto I : RD-bases()) {
  @@ -2704,10 +2695,16 @@ MicrosoftRecordLayoutBuilder::computeVto
 if (bi.second.hasVtorDisp())
   HasVtordispSet.insert(bi.first);
 }
  -  // If we do not have a user declared constructor or destructor then
  we don't
  -  // introduce any additional vtordisps.
  -  if (!RD-hasUserDeclaredConstructor()  !RD-
  hasUserDeclaredDestructor())
  +  // We don't introduce any additional vtordisps if either:
  +  // * A user declared constructor or destructor aren't declared.
  +  // * #pragma vtordisp(0) or the /vd0 flag are in use.
  +  if ((!RD-hasUserDeclaredConstructor()  !RD-
  hasUserDeclaredDestructor()) ||
  +  RD-getMSVtorDispMode() == MSVtorDispAttr::Never)
   return HasVtordispSet;
  +  // /vd1 or #pragma vtordisp(1): Try to guess based on whether we
  think it's
  +  // possible for a partially constructed object with virtual base
  overrides to
  +  // escape a non-trivial constructor.
  +  assert(RD-getMSVtorDispMode() == MSVtorDispAttr::ForVBaseOverride);
 // Compute a set of base classes which define methods we override.
  A virtual
 // base in this set will require a vtordisp.  A virtual base that
  transitively
 // contains one of these bases as a non-virtual base will also
  require a
 
  Modified: cfe/trunk/test/Layout/ms-x86-vtordisp.cpp
  URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-
  vtordisp.cpp?rev=206124r1=206123r2=206124view=diff
  ===
  ===
  --- cfe/trunk/test/Layout/ms-x86-vtordisp.cpp (original)
  +++ cfe/trunk/test/Layout/ms-x86-vtordisp.cpp Sat Apr 12 21:27:32 2014
  @@ -381,6 +381,41 @@ struct GD: public virtual GC, public vir
   // CHECK-X64-NEXT:  | [sizeof=40, align=8
   // CHECK-X64-NEXT:  |  nvsize=8, nvalign=8]
 
  +struct HA {
  +  virtual void fun() {}
  +};
  +#pragma 

Re: [PATCH] Add support for optimization reports.

2014-04-14 Thread Richard Smith



Comment at: lib/Frontend/CompilerInvocation.cpp:526
@@ +525,3 @@
+std::string RegexError;
+Opts.OptimizationRemarkPattern = new llvm::Regex(Val);
+if (!Opts.OptimizationRemarkPattern-isValid(RegexError)) {

Diego Novillo wrote:
 Richard Smith wrote:
  It looks like this is leaked. Maybe use an `llvm::Optionalllvm::Regex` 
  instead?
 I tried but llvm::Regex has an explicitly deleted constructor. I'm not sure 
 how to deal with that, so I ended up using regular pointer semantics.
`llvm::Optional` shouldn't call the `llvm::Regex` default constructor.


Comment at: lib/CodeGen/CodeGenAction.cpp:433
@@ +432,3 @@
+  return;
+ComputeDiagRemarkID(Severity, backend_optimization_remark, DiagID);
+break;

It looks like we get here (and potentially use the error/warning forms of the 
remark diagnostic) if the diagnostic severity isn't `DS_Remark`. I don't think 
this is what we want -- maybe the severity check in `OptimizationRemarkHandler` 
should be an assert?


Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:40-42
@@ +39,5 @@
+def note_fe_backend_optimization_remark : Note%0, CatBackend;
+def note_fe_backend_optimization_remark_missing_loc : Noteoptimization 
+  remarks cannot show source location information (use -gline-tables-only 
+  -gcolumn-info to enable it);
+

Maybe better phrased as:

  use -gline-tables-only -gcolumn-info to track source location information 
for this optimization remark


http://reviews.llvm.org/D3226



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Added support for CUDA __launch_bounds__ attribute to CodeGen.

2014-04-14 Thread Reid Kleckner

  lgtm



Comment at: lib/CodeGen/TargetInfo.cpp:4770
@@ -4768,1 +4769,3 @@
+  static void addNVVMMetadata(llvm::Function *F, StringRef Name,
+  const int Operand);
 };

Having const ints feels silly, since the caller really doesn't care.


Comment at: lib/CodeGen/TargetInfo.cpp:4848
@@ +4847,3 @@
+  addNVVMMetadata(F, maxntidx,
+   FD-getAttrCUDALaunchBoundsAttr()-getMaxThreads());
+  // min blocks is a default argument for CUDALaunchBoundsAttr, so getting 
a

nit: indentation


Comment at: lib/CodeGen/TargetInfo.cpp:4853
@@ +4852,3 @@
+  // don't have to add a PTX directive.
+  int minctasm = FD-getAttrCUDALaunchBoundsAttr()-getMinBlocks();
+  if (minctasm  0) {

The naming for local variables is StudlyCaps.


http://reviews.llvm.org/D3318



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206186 - Properly diagnose standard C++ attributes which have optional argument lists when the arguments are elided. eg)

2014-04-14 Thread Richard Smith
On Mon, Apr 14, 2014 at 9:03 AM, Aaron Ballman aa...@aaronballman.comwrote:

 Author: aaronballman
 Date: Mon Apr 14 11:03:22 2014
 New Revision: 206186

 URL: http://llvm.org/viewvc/llvm-project?rev=206186view=rev
 Log:
 Properly diagnose standard C++ attributes which have optional argument
 lists when the arguments are elided. eg)

 [[deprecated()]] // error
 [[deprecated]] // OK
 [[deprecated()]] // OK
 [[gnu::deprecated()]] // OK

 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/include/clang/Parse/Parser.h
 cfe/trunk/lib/Parse/ParseDecl.cpp
 cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 cfe/trunk/test/Parser/attributes.c
 cfe/trunk/test/Parser/cxx0x-attributes.cpp

 Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 14
 11:03:22 2014
 @@ -526,7 +526,9 @@ def warn_cxx98_compat_attribute : Warnin
C++11 attribute syntax is incompatible with C++98,
InGroupCXX98Compat, DefaultIgnore;
  def err_cxx11_attribute_forbids_arguments : Error
 -  attribute '%0' cannot have an argument list;
 +  attribute %0 cannot have an argument list;
 +def err_attribute_requires_arguements : Error


Typo 'arguements'


 +  attribute %0 requires a nonempty argument list;


It'd be nicer to say something more like parentheses must be omitted if %0
attribute's argument list is empty. The user probably didn't want to give
an argument here, and we shouldn't suggest that one is necessary.


  def err_cxx11_attribute_forbids_ellipsis : Error
attribute '%0' cannot be used as an attribute pack;
  def err_cxx11_attribute_repeated : Error

 Modified: cfe/trunk/include/clang/Parse/Parser.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Parse/Parser.h (original)
 +++ cfe/trunk/include/clang/Parse/Parser.h Mon Apr 14 11:03:22 2014
 @@ -2012,13 +2012,13 @@ private:

/// \brief Parses syntax-generic attribute arguments for attributes
 which are
/// known to the implementation, and adds them to the given
 ParsedAttributes
 -  /// list with the given attribute syntax.
 -  void ParseAttributeArgsCommon(IdentifierInfo *AttrName,
 -SourceLocation AttrNameLoc,
 -ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 -IdentifierInfo *ScopeName,
 -SourceLocation ScopeLoc,
 -AttributeList::Syntax Syntax);
 +  /// list with the given attribute syntax. Returns the number of
 arguments
 +  /// parsed for the attribute.
 +  unsigned
 +  ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation
 AttrNameLoc,
 +   ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 +   IdentifierInfo *ScopeName, SourceLocation
 ScopeLoc,
 +   AttributeList::Syntax Syntax);

void MaybeParseGNUAttributes(Declarator D,
 LateParsedAttrList *LateAttrs = 0) {

 Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
 +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 11:03:22 2014
 @@ -261,7 +261,7 @@ void Parser::ParseAttributeWithTypeArg(I
   0, AttrNameLoc, 0, 0, AttributeList::AS_GNU);
  }

 -void Parser::ParseAttributeArgsCommon(
 +unsigned Parser::ParseAttributeArgsCommon(
  IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
  ParsedAttributes Attrs, SourceLocation *EndLoc, IdentifierInfo
 *ScopeName,
  SourceLocation ScopeLoc, AttributeList::Syntax Syntax) {
 @@ -302,7 +302,7 @@ void Parser::ParseAttributeArgsCommon(
ExprResult ArgExpr(ParseAssignmentExpression());
if (ArgExpr.isInvalid()) {
  SkipUntil(tok::r_paren, StopAtSemi);
 -return;
 +return 0;
}
ArgExprs.push_back(ArgExpr.release());
// Eat the comma, move to the next argument
 @@ -318,6 +318,8 @@ void Parser::ParseAttributeArgsCommon(

if (EndLoc)
  *EndLoc = RParen;
 +
 +  return static_castunsigned(ArgExprs.size());
  }

  /// Parse the arguments to a parameterized GNU attribute or

 Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 URL:
 

Re: r205226 - Introduced an attribute syntax-neutral method for parsing attribute arguments that is currently being used by GNU and C++-style attributes. This allows C++11 attributes with argument lis

2014-04-14 Thread Richard Smith
On Mon, Apr 14, 2014 at 9:21 AM, Aaron Ballman aa...@aaronballman.comwrote:

 On Fri, Apr 11, 2014 at 5:40 PM, Aaron Ballman aa...@aaronballman.com
 wrote:
  On Fri, Apr 11, 2014 at 5:38 PM, Richard Smith rich...@metafoo.co.uk
 wrote:
  Thanks for doing this!
 
  Looks like this won't reject the ill-formed construct [[deprecated()]].
  (Both [[gnu::deprecated()]] and __attribute__((deprecated())) are OK,
 IIRC.)
 
  Good point! I'll add that on my TODO list. :-)

 Fixed in r206186, but I have a question -- I think
 IsBuiltInOrStandardCXX11Attribute should actually be implemented more
 in terms of the scope name. If there's no scope name, it must be a
 standard C++ attribute. If the scope name is clang, then it is one of
 our built-in attributes and we can reason about it. But anything else
 doesn't qualify. Would you agree with the attached patch?


Seems like this function is really now just checking whether an attribute
can be repeated within the same attribute list? I don't see why that rule
should necessarily apply to all clang:: attributes, and there are some
capability-related attributes where it almost certainly should not apply.

Maybe this should be another tablegen-generated property?
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206227 - [Driver][ARM64] Make sure the default CPU is passed to the assembler.

2014-04-14 Thread Quentin Colombet
Author: qcolombet
Date: Mon Apr 14 19:27:35 2014
New Revision: 206227

URL: http://llvm.org/viewvc/llvm-project?rev=206227view=rev
Log:
[Driver][ARM64] Make sure the default CPU is passed to the assembler.

rdar://problem/16573920

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=206227r1=206226r2=206227view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Apr 14 19:27:35 2014
@@ -1336,6 +1336,9 @@ static std::string getCPUName(const ArgL
   case llvm::Triple::aarch64_be:
 return getAArch64TargetCPU(Args, T);
 
+  case llvm::Triple::arm64:
+return getARM64TargetCPU(Args);
+
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Allow overriding -split-dwarf-file

2014-04-14 Thread Reid Kleckner
On Fri, Apr 11, 2014 at 2:12 PM, Eric Christopher echri...@gmail.comwrote:

 On Fri, Apr 4, 2014 at 9:07 AM, Lubos Lunak l.lu...@centrum.cz wrote:
   -Xclang and the underlying driver arguments aren't really a
   stable/guaranteed interface. I'd be more inclined to accept this
   change if it were just for some debugging, but since it sounds like
   you want to rely on it, it's good for us to understand the goal and
   perhaps suggest or provide the best way of achieving it long-term.
 
   It's stable/guaranteed enough for me, and I'd rather have a clean
 solution
  that maybe breaks one day than something hackish the whole time.
 

 I'm guessing you mean that the actual output file name differs? I.e.
 some sort of temporary cached file ala ccache that doesn't have the
 same name as the file that you've just compiled? The directory ends up
 being the same here (or can be set with, as you surmised
 -fdebug-compilation-dir).

 If so, I don't mind an option to set here necessarily, but would like
 to see it plumbed through and not rely on Xclang options.


(Reading email backlog...)

Can we just bubble up a driver option for this?  I bet we'd take a patch
for that.
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Added support for CUDA __launch_bounds__ attribute to CodeGen.

2014-04-14 Thread Manjunath Kudlur



Comment at: lib/CodeGen/TargetInfo.cpp:4770
@@ -4768,1 +4769,3 @@
+  static void addNVVMMetadata(llvm::Function *F, StringRef Name,
+  const int Operand);
 };

Reid Kleckner wrote:
 Having const ints feels silly, since the caller really doesn't care.
const removed.


Comment at: lib/CodeGen/TargetInfo.cpp:4848
@@ +4847,3 @@
+  addNVVMMetadata(F, maxntidx,
+   FD-getAttrCUDALaunchBoundsAttr()-getMaxThreads());
+  // min blocks is a default argument for CUDALaunchBoundsAttr, so getting 
a

Reid Kleckner wrote:
 nit: indentation
Fixed.


Comment at: lib/CodeGen/TargetInfo.cpp:4853
@@ +4852,3 @@
+  // don't have to add a PTX directive.
+  int minctasm = FD-getAttrCUDALaunchBoundsAttr()-getMinBlocks();
+  if (minctasm  0) {

Reid Kleckner wrote:
 The naming for local variables is StudlyCaps.
Fixed.


http://reviews.llvm.org/D3318



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Added support for CUDA __launch_bounds__ attribute to CodeGen.

2014-04-14 Thread Manjunath Kudlur
  Addressed rnk@'s comments.

Hi rnk, eliben, jholewinski,

http://reviews.llvm.org/D3318

CHANGE SINCE LAST DIFF
  http://reviews.llvm.org/D3318?vs=8439id=8519#toc

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenCUDA/launch-bounds.cu
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4762,7 +4762,9 @@
   void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule M) const override;
 private:
-  static void addKernelMetadata(llvm::Function *F);
+  // Adds a NamedMDNode with F, Name, and Operand as operands, and adds the
+  // resulting MDNode to the nvvm.annotations MDNode.
+  static void addNVVMMetadata(llvm::Function *F, StringRef Name, int Operand);
 };
 
 ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType RetTy) const {
@@ -4821,7 +4823,8 @@
 // By default, all functions are device functions
 if (FD-hasAttrOpenCLKernelAttr()) {
   // OpenCL __kernel functions get kernel metadata
-  addKernelMetadata(F);
+  // Create !{func-ref, metadata !kernel, i32 1} node
+  addNVVMMetadata(F, kernel, 1);
   // And kernel functions are not subject to inlining
   F-addFnAttr(llvm::Attribute::NoInline);
 }
@@ -4832,28 +4835,43 @@
 // CUDA __global__ functions get a kernel metadata entry.  Since
 // __global__ functions cannot be called from the device, we do not
 // need to set the noinline attribute.
-if (FD-hasAttrCUDAGlobalAttr())
-  addKernelMetadata(F);
+if (FD-hasAttrCUDAGlobalAttr()) {
+  // Create !{func-ref, metadata !kernel, i32 1} node
+  addNVVMMetadata(F, kernel, 1);
+}
+if (FD-hasAttrCUDALaunchBoundsAttr()) {
+  // Create !{func-ref, metadata !maxntidx, i32 val} node
+  addNVVMMetadata(F, maxntidx,
+  FD-getAttrCUDALaunchBoundsAttr()-getMaxThreads());
+  // min blocks is a default argument for CUDALaunchBoundsAttr, so getting a
+  // zero value from getMinBlocks either means it was not specified in
+  // __launch_bounds__ or the user specified a 0 value. In both cases, we
+  // don't have to add a PTX directive.
+  int MinCTASM = FD-getAttrCUDALaunchBoundsAttr()-getMinBlocks();
+  if (MinCTASM  0) {
+// Create !{func-ref, metadata !minctasm, i32 val} node
+addNVVMMetadata(F, minctasm, MinCTASM);
+  }
+}
   }
 }
 
-void NVPTXTargetCodeGenInfo::addKernelMetadata(llvm::Function *F) {
+void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::Function *F, StringRef Name,
+ int Operand) {
   llvm::Module *M = F-getParent();
   llvm::LLVMContext Ctx = M-getContext();
 
   // Get nvvm.annotations metadata node
   llvm::NamedMDNode *MD = M-getOrInsertNamedMetadata(nvvm.annotations);
 
-  // Create !{func-ref, metadata !kernel, i32 1} node
   llvm::SmallVectorllvm::Value *, 3 MDVals;
   MDVals.push_back(F);
-  MDVals.push_back(llvm::MDString::get(Ctx, kernel));
-  MDVals.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), 1));
-
+  MDVals.push_back(llvm::MDString::get(Ctx, Name));
+  MDVals.push_back(
+  llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), Operand));
   // Append metadata to nvvm.annotations
   MD-addOperand(llvm::MDNode::get(Ctx, MDVals));
 }
-
 }
 
 //===--===//
Index: test/CodeGenCUDA/launch-bounds.cu
===
--- /dev/null
+++ test/CodeGenCUDA/launch-bounds.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
+
+#include ../SemaCUDA/cuda.h
+
+#define MAX_THREADS_PER_BLOCK 256
+#define MIN_BLOCKS_PER_MP 2
+
+// Test both max threads per block and Min cta per sm.
+extern C {
+__global__ void
+__launch_bounds__( MAX_THREADS_PER_BLOCK, MIN_BLOCKS_PER_MP )
+Kernel1()
+{
+}
+}
+
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel1, metadata !maxntidx, i32 256}
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel1, metadata !minctasm, i32 2}
+
+// Test only max threads per block. Min cta per sm defaults to 0, and
+// CodeGen doesn't output a zero value for minctasm.
+extern C {
+__global__ void
+__launch_bounds__( MAX_THREADS_PER_BLOCK )
+Kernel2()
+{
+}
+}
+
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @Kernel2, metadata !maxntidx, i32 256}
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206229 - Fixing a typo, updating the diagnostic wording and logic based on post-commit review feedback. Amends r206186.

2014-04-14 Thread Aaron Ballman
Author: aaronballman
Date: Mon Apr 14 19:36:39 2014
New Revision: 206229

URL: http://llvm.org/viewvc/llvm-project?rev=206229view=rev
Log:
Fixing a typo, updating the diagnostic wording and logic based on post-commit 
review feedback. Amends r206186.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.c
cfe/trunk/test/Parser/cxx0x-attributes.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=206229r1=206228r2=206229view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 14 19:36:39 
2014
@@ -527,8 +527,8 @@ def warn_cxx98_compat_attribute : Warnin
   InGroupCXX98Compat, DefaultIgnore;
 def err_cxx11_attribute_forbids_arguments : Error
   attribute %0 cannot have an argument list;
-def err_attribute_requires_arguements : Error
-  attribute %0 requires a nonempty argument list;
+def err_attribute_requires_arguments : Error
+  parentheses must be omitted if %0 attribute's argument list is empty;
 def err_cxx11_attribute_forbids_ellipsis : Error
   attribute '%0' cannot be used as an attribute pack;
 def err_cxx11_attribute_repeated : Error

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206229r1=206228r2=206229view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 19:36:39 2014
@@ -517,7 +517,7 @@ bool Parser::ParseMicrosoftDeclSpecArgs(
   // arguments but none were provided, emit a diagnostic.
   const AttributeList *Attr = Attrs.getList();
   if (Attr  Attr-getMaxArgs()  !NumArgs) {
-Diag(OpenParenLoc, diag::err_attribute_requires_arguements)  AttrName;
+Diag(OpenParenLoc, diag::err_attribute_requires_arguments)  AttrName;
 return false;
   }
   return true;

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=206229r1=206228r2=206229view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Apr 14 19:36:39 2014
@@ -3254,12 +3254,12 @@ bool Parser::ParseCXX11AttributeArgs(Ide
   // parsing an argument list, we need to determine whether this attribute
   // was allowed to have an argument list (such as [[deprecated]]), and how
   // many arguments were parsed (so we can diagnose on [[deprecated()]]).
-  if (Attr-getMaxArgs()  !NumArgs) {
-// The attribute was allowed to have arguments, but none were provided
-// even though the attribute parsed successfully. This is an error.
-Diag(LParenLoc, diag::err_attribute_requires_arguements)  AttrName;
+  if (!NumArgs) {
+// Diagnose an empty argument list when parenthesis are present.
+// FIXME: This is a good place for a fixit which removes the parens.
+Diag(LParenLoc, diag::err_attribute_requires_arguments)  AttrName;
 return false;
-  } else if (!Attr-getMaxArgs()) {
+  } else if (NumArgs  !Attr-getMaxArgs()) {
 // The attribute parsed successfully, but was not allowed to have any
 // arguments. It doesn't matter whether any were provided -- the
 // presence of the argument list (even if empty) is diagnosed.

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=206229r1=206228r2=206229view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Mon Apr 14 19:36:39 2014
@@ -104,7 +104,7 @@ struct __declspec(testing) S3 {}; /* e
 
 /* declspecs with arguments cannot have an empty argument list, even if the
arguments are optional. */
-__declspec(deprecated()) void dep_func_test(void); /* expected-error 
{{attribute 'deprecated' requires a nonempty argument list}} */
+__declspec(deprecated()) void dep_func_test(void); /* expected-error 
{{parentheses must be omitted if 'deprecated' attribute's argument list is 
empty}} */
 __declspec(deprecated) void dep_func_test2(void);
 __declspec(deprecated()) void dep_func_test3(void);
 

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=206229r1=206228r2=206229view=diff
==
--- 

Re: r206186 - Properly diagnose standard C++ attributes which have optional argument lists when the arguments are elided. eg)

2014-04-14 Thread Aaron Ballman
All good comments -- I've applied everything but the fixit in r206229
(I put in a fixme for the fixit).

Thanks!

~Aaron

On Mon, Apr 14, 2014 at 8:20 PM, Richard Smith rich...@metafoo.co.uk wrote:
 On Mon, Apr 14, 2014 at 9:03 AM, Aaron Ballman aa...@aaronballman.com
 wrote:

 Author: aaronballman
 Date: Mon Apr 14 11:03:22 2014
 New Revision: 206186

 URL: http://llvm.org/viewvc/llvm-project?rev=206186view=rev
 Log:
 Properly diagnose standard C++ attributes which have optional argument
 lists when the arguments are elided. eg)

 [[deprecated()]] // error
 [[deprecated]] // OK
 [[deprecated()]] // OK
 [[gnu::deprecated()]] // OK

 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/include/clang/Parse/Parser.h
 cfe/trunk/lib/Parse/ParseDecl.cpp
 cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 cfe/trunk/test/Parser/attributes.c
 cfe/trunk/test/Parser/cxx0x-attributes.cpp

 Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 14
 11:03:22 2014
 @@ -526,7 +526,9 @@ def warn_cxx98_compat_attribute : Warnin
C++11 attribute syntax is incompatible with C++98,
InGroupCXX98Compat, DefaultIgnore;
  def err_cxx11_attribute_forbids_arguments : Error
 -  attribute '%0' cannot have an argument list;
 +  attribute %0 cannot have an argument list;
 +def err_attribute_requires_arguements : Error


 Typo 'arguements'


 +  attribute %0 requires a nonempty argument list;


 It'd be nicer to say something more like parentheses must be omitted if %0
 attribute's argument list is empty. The user probably didn't want to give
 an argument here, and we shouldn't suggest that one is necessary.


  def err_cxx11_attribute_forbids_ellipsis : Error
attribute '%0' cannot be used as an attribute pack;
  def err_cxx11_attribute_repeated : Error

 Modified: cfe/trunk/include/clang/Parse/Parser.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Parse/Parser.h (original)
 +++ cfe/trunk/include/clang/Parse/Parser.h Mon Apr 14 11:03:22 2014
 @@ -2012,13 +2012,13 @@ private:

/// \brief Parses syntax-generic attribute arguments for attributes
 which are
/// known to the implementation, and adds them to the given
 ParsedAttributes
 -  /// list with the given attribute syntax.
 -  void ParseAttributeArgsCommon(IdentifierInfo *AttrName,
 -SourceLocation AttrNameLoc,
 -ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 -IdentifierInfo *ScopeName,
 -SourceLocation ScopeLoc,
 -AttributeList::Syntax Syntax);
 +  /// list with the given attribute syntax. Returns the number of
 arguments
 +  /// parsed for the attribute.
 +  unsigned
 +  ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation
 AttrNameLoc,
 +   ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 +   IdentifierInfo *ScopeName, SourceLocation
 ScopeLoc,
 +   AttributeList::Syntax Syntax);

void MaybeParseGNUAttributes(Declarator D,
 LateParsedAttrList *LateAttrs = 0) {

 Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
 +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 11:03:22 2014
 @@ -261,7 +261,7 @@ void Parser::ParseAttributeWithTypeArg(I
   0, AttrNameLoc, 0, 0, AttributeList::AS_GNU);
  }

 -void Parser::ParseAttributeArgsCommon(
 +unsigned Parser::ParseAttributeArgsCommon(
  IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
  ParsedAttributes Attrs, SourceLocation *EndLoc, IdentifierInfo
 *ScopeName,
  SourceLocation ScopeLoc, AttributeList::Syntax Syntax) {
 @@ -302,7 +302,7 @@ void Parser::ParseAttributeArgsCommon(
ExprResult ArgExpr(ParseAssignmentExpression());
if (ArgExpr.isInvalid()) {
  SkipUntil(tok::r_paren, StopAtSemi);
 -return;
 +return 0;
}
ArgExprs.push_back(ArgExpr.release());
// Eat the comma, move to the next argument
 @@ -318,6 +318,8 @@ void Parser::ParseAttributeArgsCommon(

if (EndLoc)
  *EndLoc = RParen;
 +
 +  return static_castunsigned(ArgExprs.size());
  

Re: __is_constructible return true for abstract types PR19178

2014-04-14 Thread Richard Smith
I'd like a little more test coverage (for the other two type traits that
hit this codepath), but otherwise LGTM.

It doesn't matter whether we call RequireNonAbstractType or just
isAbstract() here, because we don't need to complete the type (we did that
a few lines above) and we don't care about its ability to produce nice
diagnostics. Using isAbstract() is more consistent with the
isIncompleteType() call immediately above, so the code change seems fine as
is.

I forget, do you have commit access?


On Mon, Apr 14, 2014 at 10:16 AM, Alp Toker a...@nuanti.com wrote:


 On 14/04/2014 11:59, Nikola Smiljanic wrote:

 Please review.

 pr19178.patch


 diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
 index 8b9c0e2..2ff501f 100644
 --- a/lib/Sema/SemaExprCXX.cpp
 +++ b/lib/Sema/SemaExprCXX.cpp
 @@ -3656,6 +3656,12 @@ static bool evaluateTypeTrait(Sema S, TypeTrait
 Kind, SourceLocation KWLoc,
   if (Args[0]-getType()-isIncompleteType())
 return false;
   +// Make sure the first argument is not an abstract type.
 +
 +CXXRecordDecl *RD = Args[0]-getType()-getAsCXXRecordDecl();
 +if (RD  RD-isAbstract())
 +  return false;
 +


 The fix is correct. Perhaps you could use RequireNonAbstractType() instead
 of checking for CXXRecordDecl directly, something like this taken from the
 counterpart in BTT_IsConvertible:


 -// Make sure the first argument is a complete type.
 -if (Args[0]-getType()-isIncompleteType())
 +// Make sure the first argument is a complete non-abstract type.
 +if (S.RequireCompleteType(KWLoc, Args[0]-getType(), 0) ||
 +S.RequireNonAbstractType(KWLoc, Args[0]-getType(), 0))
return false;

 Either way looks good to me, thanks!

 Alp.


SmallVectorOpaqueValueExpr, 2 OpaqueArgExprs;
   SmallVectorExpr *, 2 ArgExprs;
   ArgExprs.reserve(Args.size() - 1);
 diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
 index 28fb8dc..b8557c4 100644
 --- a/test/SemaCXX/type-traits.cpp
 +++ b/test/SemaCXX/type-traits.cpp
 @@ -1964,6 +1964,8 @@ void constructible_checks() {
   { int arr[T(__is_constructible(NonPOD, int))]; }
 { int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
 +
 +  { int arr[F(__is_constructible(Abstract))]; } // PR19178
   }
 // Instantiation of __is_trivially_constructible


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


 --
 http://www.nuanti.com
 the browser experts

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206027 - Add -fmodules-strict-decluse to check that all headers are in modules

2014-04-14 Thread Richard Smith
On Mon, Apr 14, 2014 at 11:53 AM, Ben Langmuir blangm...@apple.com wrote:

 To be clear, my patch does not involve decluse, so not quite the same.


There's no reason for this patch to be restricted to decluse (just as
there's no reason for yours to be restricted to framework modules in the
long term). The underlying intent is the same, and it doesn't make sense to
have two different implementations of it.

Also (by way of review), I think this patch doesn’t handle umbrella
 directories correctly, since it only looks for known headers.


Hmm, if we're getting that part wrong, we'll be getting it wrong for the
decluse checking in general. Nice catch =)


 On Apr 14, 2014, at 11:42 AM, Richard Smith rich...@metafoo.co.uk wrote:

 Why is this a -f option rather than a diagnostic? Why is it coupled to
 -fmodules-decluse? See also Ben Langmuir's patch that does the same thing
 for framework modules (also, oddly, with a language option).


 On Fri, Apr 11, 2014 at 4:47 AM, Daniel Jasper djas...@google.com wrote:

 Author: djasper
 Date: Fri Apr 11 06:47:45 2014
 New Revision: 206027

 URL: http://llvm.org/viewvc/llvm-project?rev=206027view=rev
 Log:
 Add -fmodules-strict-decluse to check that all headers are in modules

 Review: http://reviews.llvm.org/D3335

 Added:
 cfe/trunk/test/Modules/strict-decluse.cpp
 Modified:
 cfe/trunk/include/clang/Basic/LangOptions.def
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/lib/Driver/Tools.cpp
 cfe/trunk/lib/Frontend/CompilerInvocation.cpp
 cfe/trunk/lib/Lex/ModuleMap.cpp

 Modified: cfe/trunk/include/clang/Basic/LangOptions.def
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
 +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Apr 11 06:47:45 2014
 @@ -96,6 +96,7 @@ LANGOPT(MathErrno , 1, 1, errno
  BENIGN_LANGOPT(HeinousExtensions , 1, 0, Extensions that we really
 don't like and may be ripped out at any time)
  LANGOPT(Modules   , 1, 0, modules extension to C)
  LANGOPT(ModulesDeclUse, 1, 0, require declaration of module uses)
 +LANGOPT(ModulesStrictDeclUse, 1, 0, require declaration of module uses
 and all headers to be in modules)
  LANGOPT(Optimize  , 1, 0, __OPTIMIZE__ predefined macro)
  LANGOPT(OptimizeSize  , 1, 0, __OPTIMIZE_SIZE__ predefined macro)
  LANGOPT(Static, 1, 0, __STATIC__ predefined macro (as
 opposed to __DYNAMIC__))

 Modified: cfe/trunk/include/clang/Driver/Options.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/include/clang/Driver/Options.td (original)
 +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 11 06:47:45 2014
 @@ -607,6 +607,9 @@ def fmodules_ignore_macro : Joined[-]
  def fmodules_decluse : Flag [-], fmodules-decluse, Groupf_Group,
Flags[DriverOption,CC1Option],
HelpTextRequire declaration of modules used within a module;
 +def fmodules_strict_decluse : Flag [-], fmodules-strict-decluse,
 Groupf_Group,
 +  Flags[DriverOption,CC1Option],
 +  HelpTextLike -fmodules-decluse but requires all headers to be in
 modules;
  def fretain_comments_from_system_headers : Flag[-],
 fretain-comments-from-system-headers, Groupf_Group, Flags[CC1Option];

  def fmudflapth : Flag[-], fmudflapth, Groupf_Group;
 @@ -666,6 +669,8 @@ def fno_module_maps : Flag [-], fno-
Flags[DriverOption];
  def fno_modules_decluse : Flag [-], fno-modules-decluse,
 Groupf_Group,
Flags[DriverOption];
 +def fno_modules_strict_decluse : Flag [-],
 fno-strict-modules-decluse, Groupf_Group,
 +  Flags[DriverOption];
  def fno_ms_extensions : Flag[-], fno-ms-extensions, Groupf_Group;
  def fno_ms_compatibility : Flag[-], fno-ms-compatibility,
 Groupf_Group;
  def fno_delayed_template_parsing : Flag[-],
 fno-delayed-template-parsing, Groupf_Group;

 Modified: cfe/trunk/lib/Driver/Tools.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=206027r1=206026r2=206027view=diff

 ==
 --- cfe/trunk/lib/Driver/Tools.cpp (original)
 +++ cfe/trunk/lib/Driver/Tools.cpp Fri Apr 11 06:47:45 2014
 @@ -3469,6 +3469,14 @@ void Clang::ConstructJob(Compilation C,
  CmdArgs.push_back(-fmodules-decluse);
}

 +  // -fmodules-strict-decluse is like -fmodule-decluse, but also checks
 that
 +  // all #included headers are part of modules.
 +  if (Args.hasFlag(options::OPT_fmodules_strict_decluse,
 +   options::OPT_fno_modules_strict_decluse,
 +   false)) {
 +CmdArgs.push_back(-fmodules-strict-decluse);
 +  }
 +
// -fmodule-name specifies the module that is currently 

Re: [PATCH] Suggest fix-it ':' when '=' used in for-range-declaration while initializing an auto

2014-04-14 Thread Richard Smith



Comment at: lib/Parse/ParseStmt.cpp:1476-1481
@@ -1474,1 +1475,8 @@
+SourceLocation EqualLoc;
+if (MightBeForRangeStmt  RangeInitIsAuto) {
+  TentativeParsingAction FindEqual(*this);
+  if (SkipUntil(tok::equal, StopAtSemi | StopBeforeMatch))
+EqualLoc = Tok.getLocation();
+  FindEqual.Revert();
+}
 ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);

It's not really OK to use a tentative parse every time you see `for (auto`. 
Tentative parses aren't free, and that's a really common pattern.

An alternative approach would be to track (possibly on Declarator) whether 
we're parsing the first variable declared in a `for` statement. In that case, 
when we get to the end of the initializer, if the next token is `)`, then 
recover by correcting the `=` to a `:`.

That'll do the wrong thing for cases like `int x[] = {1, 2, 3}; for (auto x = 
x)` (name lookup will find the wrong `x`), but it's close enough.


http://reviews.llvm.org/D3370



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: __is_constructible return true for abstract types PR19178

2014-04-14 Thread Nikola Smiljanic
I had a quick look at RequireNonAbstractType but as you said it only
provides diagnostic and completes the type which we already did.

I'll add tests for other two traits. I have commit access.

Thanks.


On Tue, Apr 15, 2014 at 10:44 AM, Richard Smith rich...@metafoo.co.ukwrote:

 I'd like a little more test coverage (for the other two type traits that
 hit this codepath), but otherwise LGTM.

 It doesn't matter whether we call RequireNonAbstractType or just
 isAbstract() here, because we don't need to complete the type (we did that
 a few lines above) and we don't care about its ability to produce nice
 diagnostics. Using isAbstract() is more consistent with the
 isIncompleteType() call immediately above, so the code change seems fine as
 is.

 I forget, do you have commit access?


 On Mon, Apr 14, 2014 at 10:16 AM, Alp Toker a...@nuanti.com wrote:


 On 14/04/2014 11:59, Nikola Smiljanic wrote:

 Please review.

 pr19178.patch


 diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
 index 8b9c0e2..2ff501f 100644
 --- a/lib/Sema/SemaExprCXX.cpp
 +++ b/lib/Sema/SemaExprCXX.cpp
 @@ -3656,6 +3656,12 @@ static bool evaluateTypeTrait(Sema S, TypeTrait
 Kind, SourceLocation KWLoc,
   if (Args[0]-getType()-isIncompleteType())
 return false;
   +// Make sure the first argument is not an abstract type.
 +
 +CXXRecordDecl *RD = Args[0]-getType()-getAsCXXRecordDecl();
 +if (RD  RD-isAbstract())
 +  return false;
 +


 The fix is correct. Perhaps you could use RequireNonAbstractType()
 instead of checking for CXXRecordDecl directly, something like this taken
 from the counterpart in BTT_IsConvertible:


 -// Make sure the first argument is a complete type.
 -if (Args[0]-getType()-isIncompleteType())
 +// Make sure the first argument is a complete non-abstract type.
 +if (S.RequireCompleteType(KWLoc, Args[0]-getType(), 0) ||
 +S.RequireNonAbstractType(KWLoc, Args[0]-getType(), 0))
return false;

 Either way looks good to me, thanks!

 Alp.


SmallVectorOpaqueValueExpr, 2 OpaqueArgExprs;
   SmallVectorExpr *, 2 ArgExprs;
   ArgExprs.reserve(Args.size() - 1);
 diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
 index 28fb8dc..b8557c4 100644
 --- a/test/SemaCXX/type-traits.cpp
 +++ b/test/SemaCXX/type-traits.cpp
 @@ -1964,6 +1964,8 @@ void constructible_checks() {
   { int arr[T(__is_constructible(NonPOD, int))]; }
 { int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
 +
 +  { int arr[F(__is_constructible(Abstract))]; } // PR19178
   }
 // Instantiation of __is_trivially_constructible


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


 --
 http://www.nuanti.com
 the browser experts

 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206231 - CodeGen: Handle CapturedStmt in instrumentation based profiling

2014-04-14 Thread Justin Bogner
Author: bogner
Date: Mon Apr 14 19:50:54 2014
New Revision: 206231

URL: http://llvm.org/viewvc/llvm-project?rev=206231view=rev
Log:
CodeGen: Handle CapturedStmt in instrumentation based profiling

CapturedStmt was being ignored by instrumentation based profiling, and
its counters attributed to the containing function. Instead, we need
to treat this as a top level entity, like we do with blocks.

Added:
cfe/trunk/test/Profile/Inputs/c-captured.profdata
cfe/trunk/test/Profile/c-captured.c
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=206231r1=206230r2=206231view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Apr 14 19:50:54 2014
@@ -1962,8 +1962,11 @@ CodeGenFunction::GenerateCapturedStmtFun
 CXXThisValue = EmitLoadOfLValue(ThisLValue, Loc).getScalarVal();
   }
 
+  PGO.assignRegionCounters(CD, F);
   CapturedStmtInfo-EmitBody(*this, CD-getBody());
   FinishFunction(CD-getBodyRBrace());
+  PGO.emitInstrumentationData();
+  PGO.destroyRegionCounters();
 
   return F;
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=206231r1=206230r2=206231view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Apr 14 19:50:54 2014
@@ -195,6 +195,8 @@ public:
 
 /// \brief Emit the captured statement body.
 virtual void EmitBody(CodeGenFunction CGF, Stmt *S) {
+  RegionCounter Cnt = CGF.getPGORegionCounter(S);
+  Cnt.beginRegion(CGF.Builder);
   CGF.EmitStmt(S);
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206231r1=206230r2=206231view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Mon Apr 14 19:50:54 2014
@@ -335,6 +335,7 @@ namespace {
 // traverse them in the parent context.
 bool TraverseBlockExpr(BlockExpr *BE) { return true; }
 bool TraverseLambdaBody(LambdaExpr *LE) { return true; }
+bool TraverseCapturedStmt(CapturedStmt *CS) { return true; }
 
 bool VisitDecl(const Decl *D) {
   switch (D-getKind()) {
@@ -347,6 +348,7 @@ namespace {
   case Decl::CXXConversion:
   case Decl::ObjCMethod:
   case Decl::Block:
+  case Decl::Captured:
 CounterMap[D-getBody()] = NextCounter++;
 break;
   }
@@ -437,6 +439,14 @@ namespace {
 // parent context.
 void VisitLambdaExpr(const LambdaExpr *LE) {}
 
+void VisitCapturedDecl(const CapturedDecl *D) {
+  // Counter tracks entry to the capture body.
+  RegionCounter Cnt(PGO, D-getBody());
+  Cnt.beginRegion();
+  CountMap[D-getBody()] = PGO.getCurrentRegionCount();
+  Visit(D-getBody());
+}
+
 void VisitObjCMethodDecl(const ObjCMethodDecl *D) {
   // Counter tracks entry to the method body.
   RegionCounter Cnt(PGO, D-getBody());
@@ -838,6 +848,8 @@ void CodeGenPGO::mapRegionCounters(const
 Walker.TraverseDecl(const_castObjCMethodDecl *(MD));
   else if (const BlockDecl *BD = dyn_cast_or_nullBlockDecl(D))
 Walker.TraverseDecl(const_castBlockDecl *(BD));
+  else if (const CapturedDecl *CD = dyn_cast_or_nullCapturedDecl(D))
+Walker.TraverseDecl(const_castCapturedDecl *(CD));
   NumRegionCounters = Walker.NextCounter;
   // FIXME: The number of counters isn't sufficient for the hash
   FunctionHash = NumRegionCounters;
@@ -852,6 +864,8 @@ void CodeGenPGO::computeRegionCounts(con
 Walker.VisitObjCMethodDecl(MD);
   else if (const BlockDecl *BD = dyn_cast_or_nullBlockDecl(D))
 Walker.VisitBlockDecl(BD);
+  else if (const CapturedDecl *CD = dyn_cast_or_nullCapturedDecl(D))
+Walker.VisitCapturedDecl(const_castCapturedDecl *(CD));
 }
 
 void CodeGenPGO::applyFunctionAttributes(PGOProfileData *PGOData,

Added: cfe/trunk/test/Profile/Inputs/c-captured.profdata
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/c-captured.profdata?rev=206231view=auto
==
--- cfe/trunk/test/Profile/Inputs/c-captured.profdata (added)
+++ cfe/trunk/test/Profile/Inputs/c-captured.profdata Mon Apr 14 19:50:54 2014
@@ -0,0 +1,25 @@
+c-captured.c:__captured_stmt
+2
+2
+1
+1
+
+c-captured.c:__captured_stmt1
+3
+3
+1
+10
+1
+
+main
+1
+1
+1
+
+debug_captured
+3
+3
+1
+1
+1
+

Added: cfe/trunk/test/Profile/c-captured.c
URL: 

Re: r206081 - CodeGen: Fix handling of C++11 lambdas in profiling

2014-04-14 Thread Justin Bogner
Good catch! Turns out CapturedStmt wasn't being handled *at all* by
instrumentation based profiling. I've fixed that in r206231.

On that note, what are CapturedStmts for? Is the test in r206231
sufficient?

Richard Smith rich...@metafoo.co.uk writes:
 Should we do the same for CapturedStmt?

 On 11 Apr 2014 16:14, Justin Bogner m...@justinbogner.com wrote:

 Author: bogner
 Date: Fri Apr 11 18:06:35 2014
 New Revision: 206081

 URL: http://llvm.org/viewvc/llvm-project?rev=206081view=rev
 Log:
 CodeGen: Fix handling of C++11 lambdas in profiling

 Until now we were generating duplicate counters for lambdas: one set
 in the function where the lambda was declared and another for the
 lambda itself. Instead, we should skip over the bodies of lambdas in
 their containing contexts.

 Added:
     cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata
     cfe/trunk/test/Profile/cxx-lambda.cpp
 Modified:
     cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

 Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
 CodeGenPGO.cpp?rev=206081r1=206080r2=206081view=diff
 ==
 
 --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 18:06:35 2014
 @@ -331,9 +331,10 @@ namespace {
      MapRegionCounters(llvm::DenseMapconst Stmt *, unsigned CounterMap)
          : NextCounter(0), CounterMap(CounterMap) {}

 -    // Do not traverse the BlockDecl inside a BlockExpr since each
 BlockDecl
 -    // is handled as a separate function.
 -    bool TraverseBlockExpr(BlockExpr *block) { return true; }
 +    // Blocks and lambdas are handled as separate functions, so we need
 not
 +    // traverse them in the parent context.
 +    bool TraverseBlockExpr(BlockExpr *BE) { return true; }
 +    bool TraverseLambdaBody(LambdaExpr *LE) { return true; }

      bool VisitDecl(const Decl *D) {
        switch (D-getKind()) {
 @@ -431,6 +432,11 @@ namespace {
        Visit(D-getBody());
      }

 +    // Skip lambda expressions. We visit these as FunctionDecls when
 we're
 +    // generating them and aren't interested in the body when generating
 a
 +    // parent context.
 +    void VisitLambdaExpr(const LambdaExpr *LE) {}
 +
      void VisitObjCMethodDecl(const ObjCMethodDecl *D) {
        // Counter tracks entry to the method body.
        RegionCounter Cnt(PGO, D-getBody());

 Added: cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/
 cxx-lambda.profdata?rev=206081view=auto
 ==
 
 --- cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata (added)
 +++ cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata Fri Apr 11 18:06:35
 2014
 @@ -0,0 +1,20 @@
 +cxx-lambda.cpp:_ZZ7lambdasvENK3$_0clEi
 +3
 +3
 +10
 +9
 +9
 +
 +main
 +1
 +1
 +1
 +
 +_Z7lambdasv
 +4
 +4
 +1
 +1
 +10
 +1
 +

 Added: cfe/trunk/test/Profile/cxx-lambda.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/
 cxx-lambda.cpp?rev=206081view=auto
 ==
 
 --- cfe/trunk/test/Profile/cxx-lambda.cpp (added)
 +++ cfe/trunk/test/Profile/cxx-lambda.cpp Fri Apr 11 18:06:35 2014
 @@ -0,0 +1,57 @@
 +// Tests for instrumentation of C++11 lambdas
 +
 +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name
 cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate  %tgen
 +// RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s
 +// RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 +
 +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name
 cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%S/Inputs/
 cxx-lambda.profdata  %tuse
 +// RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s
 +// RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s
 +
 +// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = global [4 x
 i64] zeroinitializer
 +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = global [1 x i64]
 zeroinitializer
 +// LMBGEN: @[[LFC:__llvm_profile_counters__ZZ7lambdasvENK3\$_0clEi]] =
 internal global [3 x i64] zeroinitializer
 +
 +// PGOGEN-LABEL: define void @_Z7lambdasv()
 +// PGOUSE-LABEL: define void @_Z7lambdasv()
 +// PGOGEN: store {{.*}} @[[LWC]], i64 0, i64 0
 +void lambdas() {
 +  int i = 1;
 +
 +  // LMBGEN-LABEL: define 

r206232 - Fix a bad interaction between -Wtautological-overlap-compare and delayed

2014-04-14 Thread Richard Trieu
Author: rtrieu
Date: Mon Apr 14 19:57:50 2014
New Revision: 206232

URL: http://llvm.org/viewvc/llvm-project?rev=206232view=rev
Log:
Fix a bad interaction between -Wtautological-overlap-compare and delayed
diagnostics which caused delayed diagnostics on dead paths to be emitted.

Modified:
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/Sema/warn-overlap.c

Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=206232r1=206231r2=206232view=diff
==
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Mon Apr 14 19:57:50 2014
@@ -189,6 +189,9 @@ CFG *AnalysisDeclContext::getCFG() {
 
 if (PM)
   addParentsForSyntheticStmts(cfg.get(), *PM);
+
+// The Obersver should only observe one build of the CFG.
+getCFGBuildOptions().Observer = 0;
   }
   return cfg.get();
 }
@@ -205,6 +208,9 @@ CFG *AnalysisDeclContext::getUnoptimized
 
 if (PM)
   addParentsForSyntheticStmts(completeCFG.get(), *PM);
+
+// The Obersver should only observe one build of the CFG.
+getCFGBuildOptions().Observer = 0;
   }
   return completeCFG.get();
 }

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=206232r1=206231r2=206232view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Apr 14 19:57:50 2014
@@ -1838,12 +1838,12 @@ AnalysisBasedWarnings::IssueWarnings(sem
   .setAlwaysAdd(Stmt::AttributedStmtClass);
   }
 
+  // Install the logical handler for -Wtautological-overlap-compare
+  std::unique_ptrLogicalErrorHandler LEH;
   if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
D-getLocStart())) {
-LogicalErrorHandler LEH(S);
-AC.getCFGBuildOptions().Observer = LEH;
-AC.getCFG();
-AC.getCFGBuildOptions().Observer = 0;
+LEH.reset(new LogicalErrorHandler(S));
+AC.getCFGBuildOptions().Observer = LEH.get();
   }
 
   // Emit delayed diagnostics.
@@ -1991,6 +1991,13 @@ AnalysisBasedWarnings::IssueWarnings(sem
 }
   }
 
+  // If none of the previous checks caused a CFG build, trigger one here
+  // for -Wtautological-overlap-compare
+  if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
+   D-getLocStart())) {
+AC.getCFG();
+  }
+
   // Collect statistics about the CFG if it was built.
   if (S.CollectStats  AC.isCFGBuilt()) {
 ++NumFunctionsAnalyzed;

Modified: cfe/trunk/test/Sema/warn-overlap.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-overlap.c?rev=206232r1=206231r2=206232view=diff
==
--- cfe/trunk/test/Sema/warn-overlap.c (original)
+++ cfe/trunk/test/Sema/warn-overlap.c Mon Apr 14 19:57:50 2014
@@ -56,3 +56,9 @@ void f(int x) {
   if (x == (mydefine + 1)  x  3) { }
 }
 
+// Don't generate a warning here.
+void array_out_of_bounds() {
+  int x;
+  int buffer[4];
+  x = (-7  0) ? (buffer[-7]) : 0;
+}


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206232 - Fix a bad interaction between -Wtautological-overlap-compare and delayed

2014-04-14 Thread Nick Lewycky
On 14 April 2014 17:57, Richard Trieu rtr...@google.com wrote:

 Author: rtrieu
 Date: Mon Apr 14 19:57:50 2014
 New Revision: 206232

 URL: http://llvm.org/viewvc/llvm-project?rev=206232view=rev
 Log:
 Fix a bad interaction between -Wtautological-overlap-compare and delayed
 diagnostics which caused delayed diagnostics on dead paths to be emitted.

 Modified:
 cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
 cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
 cfe/trunk/test/Sema/warn-overlap.c

 Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=206232r1=206231r2=206232view=diff

 ==
 --- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
 +++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Mon Apr 14 19:57:50 2014
 @@ -189,6 +189,9 @@ CFG *AnalysisDeclContext::getCFG() {

  if (PM)
addParentsForSyntheticStmts(cfg.get(), *PM);
 +
 +// The Obersver should only observe one build of the CFG.


Typo, Obersver.


 +getCFGBuildOptions().Observer = 0;
}
return cfg.get();
  }
 @@ -205,6 +208,9 @@ CFG *AnalysisDeclContext::getUnoptimized

  if (PM)
addParentsForSyntheticStmts(completeCFG.get(), *PM);
 +
 +// The Obersver should only observe one build of the CFG.


Typo again!

Nick


 +getCFGBuildOptions().Observer = 0;
}
return completeCFG.get();
  }

 Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=206232r1=206231r2=206232view=diff

 ==
 --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
 +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Apr 14 19:57:50 2014
 @@ -1838,12 +1838,12 @@ AnalysisBasedWarnings::IssueWarnings(sem
.setAlwaysAdd(Stmt::AttributedStmtClass);
}

 +  // Install the logical handler for -Wtautological-overlap-compare
 +  std::unique_ptrLogicalErrorHandler LEH;
if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
 D-getLocStart())) {
 -LogicalErrorHandler LEH(S);
 -AC.getCFGBuildOptions().Observer = LEH;
 -AC.getCFG();
 -AC.getCFGBuildOptions().Observer = 0;
 +LEH.reset(new LogicalErrorHandler(S));
 +AC.getCFGBuildOptions().Observer = LEH.get();
}

// Emit delayed diagnostics.
 @@ -1991,6 +1991,13 @@ AnalysisBasedWarnings::IssueWarnings(sem
  }
}

 +  // If none of the previous checks caused a CFG build, trigger one here
 +  // for -Wtautological-overlap-compare
 +  if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
 +   D-getLocStart())) {
 +AC.getCFG();
 +  }
 +
// Collect statistics about the CFG if it was built.
if (S.CollectStats  AC.isCFGBuilt()) {
  ++NumFunctionsAnalyzed;

 Modified: cfe/trunk/test/Sema/warn-overlap.c
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-overlap.c?rev=206232r1=206231r2=206232view=diff

 ==
 --- cfe/trunk/test/Sema/warn-overlap.c (original)
 +++ cfe/trunk/test/Sema/warn-overlap.c Mon Apr 14 19:57:50 2014
 @@ -56,3 +56,9 @@ void f(int x) {
if (x == (mydefine + 1)  x  3) { }
  }

 +// Don't generate a warning here.
 +void array_out_of_bounds() {
 +  int x;
 +  int buffer[4];
 +  x = (-7  0) ? (buffer[-7]) : 0;
 +}


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r206234 - Fix typo from r206232

2014-04-14 Thread Richard Trieu
Author: rtrieu
Date: Mon Apr 14 20:06:38 2014
New Revision: 206234

URL: http://llvm.org/viewvc/llvm-project?rev=206234view=rev
Log:
Fix typo from r206232

Modified:
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp

Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=206234r1=206233r2=206234view=diff
==
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Mon Apr 14 20:06:38 2014
@@ -190,7 +190,7 @@ CFG *AnalysisDeclContext::getCFG() {
 if (PM)
   addParentsForSyntheticStmts(cfg.get(), *PM);
 
-// The Obersver should only observe one build of the CFG.
+// The Observer should only observe one build of the CFG.
 getCFGBuildOptions().Observer = 0;
   }
   return cfg.get();
@@ -209,7 +209,7 @@ CFG *AnalysisDeclContext::getUnoptimized
 if (PM)
   addParentsForSyntheticStmts(completeCFG.get(), *PM);
 
-// The Obersver should only observe one build of the CFG.
+// The Observer should only observe one build of the CFG.
 getCFGBuildOptions().Observer = 0;
   }
   return completeCFG.get();


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206186 - Properly diagnose standard C++ attributes which have optional argument lists when the arguments are elided. eg)

2014-04-14 Thread Aaron Ballman
On Mon, Apr 14, 2014 at 8:43 PM, Aaron Ballman aa...@aaronballman.com wrote:
 All good comments -- I've applied everything but the fixit in r206229
 (I put in a fixme for the fixit).

 Thanks!

 ~Aaron

 On Mon, Apr 14, 2014 at 8:20 PM, Richard Smith rich...@metafoo.co.uk wrote:
 On Mon, Apr 14, 2014 at 9:03 AM, Aaron Ballman aa...@aaronballman.com
 wrote:

 Author: aaronballman
 Date: Mon Apr 14 11:03:22 2014
 New Revision: 206186

 URL: http://llvm.org/viewvc/llvm-project?rev=206186view=rev
 Log:
 Properly diagnose standard C++ attributes which have optional argument
 lists when the arguments are elided. eg)

 [[deprecated()]] // error
 [[deprecated]] // OK
 [[deprecated()]] // OK
 [[gnu::deprecated()]] // OK

 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/include/clang/Parse/Parser.h
 cfe/trunk/lib/Parse/ParseDecl.cpp
 cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 cfe/trunk/test/Parser/attributes.c
 cfe/trunk/test/Parser/cxx0x-attributes.cpp

 Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 14
 11:03:22 2014
 @@ -526,7 +526,9 @@ def warn_cxx98_compat_attribute : Warnin
C++11 attribute syntax is incompatible with C++98,
InGroupCXX98Compat, DefaultIgnore;
  def err_cxx11_attribute_forbids_arguments : Error
 -  attribute '%0' cannot have an argument list;
 +  attribute %0 cannot have an argument list;
 +def err_attribute_requires_arguements : Error


 Typo 'arguements'


 +  attribute %0 requires a nonempty argument list;


 It'd be nicer to say something more like parentheses must be omitted if %0
 attribute's argument list is empty. The user probably didn't want to give
 an argument here, and we shouldn't suggest that one is necessary.


  def err_cxx11_attribute_forbids_ellipsis : Error
attribute '%0' cannot be used as an attribute pack;
  def err_cxx11_attribute_repeated : Error

 Modified: cfe/trunk/include/clang/Parse/Parser.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/include/clang/Parse/Parser.h (original)
 +++ cfe/trunk/include/clang/Parse/Parser.h Mon Apr 14 11:03:22 2014
 @@ -2012,13 +2012,13 @@ private:

/// \brief Parses syntax-generic attribute arguments for attributes
 which are
/// known to the implementation, and adds them to the given
 ParsedAttributes
 -  /// list with the given attribute syntax.
 -  void ParseAttributeArgsCommon(IdentifierInfo *AttrName,
 -SourceLocation AttrNameLoc,
 -ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 -IdentifierInfo *ScopeName,
 -SourceLocation ScopeLoc,
 -AttributeList::Syntax Syntax);
 +  /// list with the given attribute syntax. Returns the number of
 arguments
 +  /// parsed for the attribute.
 +  unsigned
 +  ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation
 AttrNameLoc,
 +   ParsedAttributes Attrs, SourceLocation
 *EndLoc,
 +   IdentifierInfo *ScopeName, SourceLocation
 ScopeLoc,
 +   AttributeList::Syntax Syntax);

void MaybeParseGNUAttributes(Declarator D,
 LateParsedAttrList *LateAttrs = 0) {

 Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=206186r1=206185r2=206186view=diff

 ==
 --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
 +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 14 11:03:22 2014
 @@ -261,7 +261,7 @@ void Parser::ParseAttributeWithTypeArg(I
   0, AttrNameLoc, 0, 0, AttributeList::AS_GNU);
  }

 -void Parser::ParseAttributeArgsCommon(
 +unsigned Parser::ParseAttributeArgsCommon(
  IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
  ParsedAttributes Attrs, SourceLocation *EndLoc, IdentifierInfo
 *ScopeName,
  SourceLocation ScopeLoc, AttributeList::Syntax Syntax) {
 @@ -302,7 +302,7 @@ void Parser::ParseAttributeArgsCommon(
ExprResult ArgExpr(ParseAssignmentExpression());
if (ArgExpr.isInvalid()) {
  SkipUntil(tok::r_paren, StopAtSemi);
 -return;
 +return 0;
}
ArgExprs.push_back(ArgExpr.release());
// Eat the comma, move to the next argument
 @@ -318,6 +318,8 @@ void Parser::ParseAttributeArgsCommon(

if 

r206237 - Partial revert of r206229, to get the build bots green again.

2014-04-14 Thread Aaron Ballman
Author: aaronballman
Date: Mon Apr 14 20:19:35 2014
New Revision: 206237

URL: http://llvm.org/viewvc/llvm-project?rev=206237view=rev
Log:
Partial revert of r206229, to get the build bots green again.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=206237r1=206236r2=206237view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Apr 14 20:19:35 2014
@@ -3254,14 +3254,15 @@ bool Parser::ParseCXX11AttributeArgs(Ide
   // parsing an argument list, we need to determine whether this attribute
   // was allowed to have an argument list (such as [[deprecated]]), and how
   // many arguments were parsed (so we can diagnose on [[deprecated()]]).
-  if (!NumArgs) {
-// Diagnose an empty argument list when parenthesis are present.
-// FIXME: This is a good place for a fixit which removes the parens.
-Diag(LParenLoc, diag::err_attribute_requires_arguments)  AttrName;
-return false;
-  } else if (NumArgs  !Attr-getMaxArgs()) {
-// The attribute parsed successfully, but was not allowed to have any
-// arguments. It doesn't matter whether any were provided -- the
+  if (Attr-getMaxArgs()  !NumArgs) {
+// The attribute was allowed to have arguments, but none were provided
+// even though the attribute parsed successfully. This is an error.
+// FIXME: This is a good place for a fixit which removes the parens.
+Diag(LParenLoc, diag::err_attribute_requires_arguments)  AttrName;
+return false;
+  } else if (!Attr-getMaxArgs()) {
+// The attribute parsed successfully, but was not allowed to have any
+// arguments. It doesn't matter whether any were provided -- the
 // presence of the argument list (even if empty) is diagnosed.
 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
  AttrName;


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH][REVIEW REQUEST] Fix for libclang completion of already declared template friends.

2014-04-14 Thread Richard Smith
Hmm, I've looked into this a bit more, and it's unclear to me why we have
an IDNS check here at all. If LookupVisibleDecls is working properly, it
should only return declarations that are actually visible anyway.

On Mon, Apr 14, 2014 at 1:15 PM, Francisco Lopes 
francisco.mailing.li...@oblita.com wrote:

 Hi Richard, as can be checked in the bug history, there's a side effect if
 I don't call getCanonicalDecl. Also, this patch fixes an issue that's
 specially related to template friends and lookup. Please take a look at the
 history, since it looks like following your advices, I would end up with
 regressions.


 2014-04-11 17:10 GMT-03:00 Richard Smith rich...@metafoo.co.uk:

 On Fri, Mar 14, 2014 at 6:59 AM, Francisco Lopes 
 francisco.mailing.li...@oblita.com wrote:

 hi, thanks for the comment but, for example, as I want to add the call
 to getCanonicalDecl
 for this situation of friends solely, don't I need to check whether it's
 in friend name space too?

 I'm not sure whether you meant to replace the two first checks, or just
 the second.


 I meant to replace all the checks. I don't see why you would want to call
 getCanonicalDecl here, or why you'd care whether the name has ever been
 declared as a friend. All you should check is, is the name visible now?

 Regards.



 2014-03-13 20:59 GMT-03:00 Richard Smith rich...@metafoo.co.uk:

 Your visibility check seems more complex than necessary. I think this
 should do what you want:

  if
 (ND-getMostRecentDecl()-isInIdentifierNamespace(Decl::IDNS_Ordinary |
 Decl::IDNS_Tag))
   // visible


 On Wed, Mar 12, 2014 at 2:12 PM, Francisco Lopes 
 francisco.mailing.li...@oblita.com wrote:

 Ping


 2014-03-07 14:47 GMT-03:00 Francisco Lopes 
 francisco.mailing.li...@oblita.com:

 Hi,

 attached is a patch that tries to fix libclang bug 
 13699http://llvm.org/bugs/show_bug.cgi?id=13699
 .
 Please review.

 --
 Francisco Lopes

 PS:
 I have requested commit access in late 2012 but never made a test
 commit or anything.

 At the time I have received from Chris Lattner:
 I'm sorry for the delay, I've been fighting mailing list issues.
 Commit after approval access is granted.  Please try a test commit!

 I'm not sure whether it's still valid.



 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits






___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a new flag -fmodules-require-modular-includes

2014-04-14 Thread Richard Smith
Sure, this sounds like a good idea to me.

On Mon, Apr 14, 2014 at 4:24 PM, Ben Langmuir blangm...@apple.com wrote:

 Fair point. In that case how about we add all -Werror= and -Wfatal-error=
 options to the module hash? That way we are consistent about any diagnostic
 options that would prevent us from building the module.  We don’t need/want
 to include regular warning flags, since we won’t get warnings anyway after
 the module is built the first time.  I suppose we would want to track only
 the canonical (last) options and sort them to avoid spurious hash changes.

 Then we could replace -f with -Werror= for this option.

 Ben



 On Apr 14, 2014, at 11:24 AM, Richard Smith rich...@metafoo.co.uk wrote:

 I don't see why this is a special case. We have that same issue with *all*
 warning flags.

 On Mon, Apr 14, 2014 at 9:22 AM, Ben Langmuir blangm...@apple.com wrote:

 The primary reason I didn’t go that route is that this flag should show
 up in the module hash so that we don’t load modules that depend on
 non-modular content simply because they are already built.

 Ben

 On Apr 13, 2014, at 6:15 PM, Richard Smith rich...@metafoo.co.uk wrote:

 Have you considered making this be a normal warning flag, instead of a
 language options and an error?


 On Thu, Apr 10, 2014 at 6:43 AM, Ben Langmuir blangm...@apple.comwrote:

 As suggested off-list, this updated patch only affects frameworks for
 now, although the intent is to include all modules in the future.  It also
 has small fix for submodules including non-modular content and files that
 are nested inside umbrella directories.

 Ben




 On Apr 8, 2014, at 5:09 PM, Ben Langmuir blangm...@apple.com wrote:

  When set, the new flag enforces that all of the files included by a
 module are themselves part of a module, or are explicitly excluded by some
 module. This will not affect headers that are part of the module being
 built, nor files included outside of the module build (e.g. in an
 implementation file with -fmodule-name set).
 
  Ben
 
 
 non-modular-includes.patch___
  cfe-commits mailing list
  cfe-commits@cs.uiuc.edu
  http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


 ___
 cfe-commits mailing list
 cfe-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits






___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r206081 - CodeGen: Fix handling of C++11 lambdas in profiling

2014-04-14 Thread Richard Smith
They're intended for use by OpenMP, but I think the CodeGen parts of that
haven't quite landed yet. In the mean time, the pragma you found is a good
way to get test coverage here. Thanks!

On Mon, Apr 14, 2014 at 6:00 PM, Justin Bogner m...@justinbogner.comwrote:

 Good catch! Turns out CapturedStmt wasn't being handled *at all* by
 instrumentation based profiling. I've fixed that in r206231.

 On that note, what are CapturedStmts for? Is the test in r206231
 sufficient?

 Richard Smith rich...@metafoo.co.uk writes:
  Should we do the same for CapturedStmt?
 
  On 11 Apr 2014 16:14, Justin Bogner m...@justinbogner.com wrote:
 
  Author: bogner
  Date: Fri Apr 11 18:06:35 2014
  New Revision: 206081
 
  URL: http://llvm.org/viewvc/llvm-project?rev=206081view=rev
  Log:
  CodeGen: Fix handling of C++11 lambdas in profiling
 
  Until now we were generating duplicate counters for lambdas: one set
  in the function where the lambda was declared and another for the
  lambda itself. Instead, we should skip over the bodies of lambdas in
  their containing contexts.
 
  Added:
  cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata
  cfe/trunk/test/Profile/cxx-lambda.cpp
  Modified:
  cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
 
  Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
  URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
  CodeGenPGO.cpp?rev=206081r1=206080r2=206081view=diff
 
 ==
  
  --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
  +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 18:06:35 2014
  @@ -331,9 +331,10 @@ namespace {
   MapRegionCounters(llvm::DenseMapconst Stmt *, unsigned
 CounterMap)
   : NextCounter(0), CounterMap(CounterMap) {}
 
  -// Do not traverse the BlockDecl inside a BlockExpr since each
  BlockDecl
  -// is handled as a separate function.
  -bool TraverseBlockExpr(BlockExpr *block) { return true; }
  +// Blocks and lambdas are handled as separate functions, so we
 need
  not
  +// traverse them in the parent context.
  +bool TraverseBlockExpr(BlockExpr *BE) { return true; }
  +bool TraverseLambdaBody(LambdaExpr *LE) { return true; }
 
   bool VisitDecl(const Decl *D) {
 switch (D-getKind()) {
  @@ -431,6 +432,11 @@ namespace {
 Visit(D-getBody());
   }
 
  +// Skip lambda expressions. We visit these as FunctionDecls when
  we're
  +// generating them and aren't interested in the body when
 generating
  a
  +// parent context.
  +void VisitLambdaExpr(const LambdaExpr *LE) {}
  +
   void VisitObjCMethodDecl(const ObjCMethodDecl *D) {
 // Counter tracks entry to the method body.
 RegionCounter Cnt(PGO, D-getBody());
 
  Added: cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata
  URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/
  cxx-lambda.profdata?rev=206081view=auto
 
 ==
  
  --- cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata (added)
  +++ cfe/trunk/test/Profile/Inputs/cxx-lambda.profdata Fri Apr 11
 18:06:35
  2014
  @@ -0,0 +1,20 @@
  +cxx-lambda.cpp:_ZZ7lambdasvENK3$_0clEi
  +3
  +3
  +10
  +9
  +9
  +
  +main
  +1
  +1
  +1
  +
  +_Z7lambdasv
  +4
  +4
  +1
  +1
  +10
  +1
  +
 
  Added: cfe/trunk/test/Profile/cxx-lambda.cpp
  URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/
  cxx-lambda.cpp?rev=206081view=auto
 
 ==
  
  --- cfe/trunk/test/Profile/cxx-lambda.cpp (added)
  +++ cfe/trunk/test/Profile/cxx-lambda.cpp Fri Apr 11 18:06:35 2014
  @@ -0,0 +1,57 @@
  +// Tests for instrumentation of C++11 lambdas
  +
  +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple
 -main-file-name
  cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate 
 %tgen
  +// RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s
  +// RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
  +
  +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple
 -main-file-name
  cxx-lambda.cpp -std=c++11 -o - -emit-llvm
 -fprofile-instr-use=%S/Inputs/
  cxx-lambda.profdata  %tuse
  +// RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s
  +// RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s
  +
  +// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = global [4
 x
  i64] zeroinitializer
  +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = global [1 x i64]
  zeroinitializer
  +// LMBGEN:
 

Re: [Patch] Missed evaluation in type parameter of va_arg

2014-04-14 Thread Rahul Jain
Thanks Richard for helping out! Very much appreciated!

Also thanks to Rahul Singh, who originally worked out the fix.


Thanks,
Rahul


On Tue, Apr 15, 2014 at 5:24 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Slightly tweaked and committed as r206223. Thanks!


 On Mon, Apr 14, 2014 at 7:55 AM, Rahul Jain 1989.rahulj...@gmail.comwrote:


 Hi Richard,

 Thanks for your valuable input.
 Updated the patch accordingly.

 Please if you could commit the same for me.

 Thanks,
 Rahul


 On Mon, Apr 14, 2014 at 5:08 AM, Richard Smith rich...@metafoo.co.ukwrote:

 Please add a triple to your test (right now, it'd fail on targets where
 'int' isn't i32). Otherwise, LGTM.


 On Mon, Apr 7, 2014 at 11:26 AM, Rahul Jain 1989.rahulj...@gmail.comwrote:


 Hi Dmitri,

 Thanks for replying.

 Updated patch with test case.
 Please help review the same.

 Thanks,
 Rahul


 On Fri, Apr 4, 2014 at 8:46 PM, Dmitri Gribenko griboz...@gmail.comwrote:

 On Wed, Apr 2, 2014 at 6:55 AM, Rahul Jain 1989.rahulj...@gmail.com
 wrote:
  Gentle ping!
 
  Please if someone could help review this small patch!

 Hello Rahul,

 This patch needs a testcase.

 Dmitri

 --
 main(i,j){for(i=2;;i++){for(j=2;ji;j++){if(!(i%j)){j=0;break;}}if
 (j){printf(%d\n,i);}}} /*Dmitri Gribenko griboz...@gmail.com*/






___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] PR19095 Undefined reference to friend template function defined inside template class

2014-04-14 Thread suyog sarda
On Tue, Apr 15, 2014 at 5:01 AM, Richard Smith rich...@metafoo.co.ukwrote:

 On Mon, Apr 14, 2014 at 1:09 AM, suyog sarda sardas...@gmail.com wrote:

 Hi Richard,

 Thanks for the review. I Agree to your explaination. Following are the
 points what i understood :

 1. setInstantiatedFromMemberTemplate call should not be skipped since it
 causes mix up of  template parameter list numbering and wrong
 substitutions,
 which is clearly visible in the test case as well.


 More fundamentally, it shouldn't be skipped because this function is
 instantiated from a member template (it's not actually a member, but this
 really means class-scope template, not member template).


 2. When C is instantiated twice, it should throw re-definition error of
 function f, which is not done (with or without my patch).


 That should be handled by the 'if (isFriend) {' loop starting at around
 line 1424.


  3. In the same function call
 'TemplateDeclInstantiator::VisitFunctionDecl', there is a check 'if
 (isFriend)'.
 There is a standard described '[temp.friend] p4 (DR329)' inside that
 check, which checks if the *FunctionDecl D *is Declared as well as
 Defined (isThisDeclarationADefintion).
 In my opinion, at this point the function defintion is not being set
 for friend function defined inside the class template.


 There's also something strange going on in VisitFunctionTemplateDecl --
 that code is also calling setInstantiatedFromMemberTemplate for a friend
 template definition. So at least there appears to be some redundancy here.

 4. While debugging, it is seen that, the *FunctionDecl D *is *defined *holds
 true but '*Function-isDefined(Definition)*' evaluates to false (I did
 not get why it evaluates to false), because of which
 re-defintion error is not emitted.


 The function isn't defined because we've not instantiated its definition
 yet; that's probably to be expected.


The whole point of conflict is happening because of this only - the
function isn't defined because its not instantiated yet, because of which
the call to function cannot find the definition, even though the definition
should be independent to instantiation of class template.




 There is a similar bug for operator overloading - Bug 14785. There also
 same case is happening - not able to identify if friend function (in 14785
 its operator overloading function) is defined inside class template.

 Can you please help me out if my above analysis is correct as well as
 indicate where/how to set the definition of the declared function? Your
 help is highly appreciated.


 I don't get see what's going wrong, but I suspect something in
 FunctionDecl::getTemplateInstantiationPattern() is broken.


I will look at this and try to see i can find something in it. (Though Use
case wise its always better to define friend function outside the class.)



-- 
With regards,
Suyog Sarda
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits