[cfe-commits] r166171 - /cfe/trunk/lib/AST/DumpXML.cpp

2012-10-18 Thread Nick Lewycky
Author: nicholas
Date: Thu Oct 18 02:55:46 2012
New Revision: 166171

URL: http://llvm.org/viewvc/llvm-project?rev=166171view=rev
Log:
Put used=1 on all used declarations in the XML dumper. This allows us to
start seeing the bit so that we can find bugs and write tests for it.

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

Modified: cfe/trunk/lib/AST/DumpXML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=166171r1=166170r2=166171view=diff
==
--- cfe/trunk/lib/AST/DumpXML.cpp (original)
+++ cfe/trunk/lib/AST/DumpXML.cpp Thu Oct 18 02:55:46 2012
@@ -1,4 +1,4 @@
-//===--- DumpXML.cpp - Detailed XML dumping -*- C++ 
-*-===//
+//===--- DumpXML.cpp - Detailed XML dumping 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -64,6 +64,8 @@
   static_castImpl*(this)-NAME(static_castCLASS*(D))
 
   void dispatch(Decl *D) {
+if (D-isUsed())
+  static_castImpl*(this)-set(used, 1);
 switch (D-getKind()) {
 #define DECL(DERIVED, BASE) \
   case Decl::DERIVED: \


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


[cfe-commits] [Patch] compiler-rt: SPARC64-optimized multiply/divide

2012-10-18 Thread Ed Schouten
Hi all,

Attached is the latest version of a patch we use at FreeBSD to add
optimized multiply/divide functions on SPARC64. Description from the
original bug report[1]:

According to a developer at the FreeBSD project, FreeBSD's total compilation
time increases by 2.6% when the host system is built against compiler-rt
instead of libgcc. This is likely due to the fact that GCC has assembly-written
versions of the division and modulo routines, while compiler-rt does not.

The division and modulo routines used by GCC can easily be re-used by
compiler-rt. They are provided for free in The SPARC Architecture Manual
Version 8. Attached to this bug report is a patch that I have written for
compiler-rt. It contains the M4 file that is listed in the manual, with some
small modifications:

- The M4 file uses exponentiation (2^N). This seems to be a Sun-specific
extension to M4, as I cannot reproduce it with GNU and BSD m4. Fix this similar
to OpenBSD's version by replacing 2^N with TWOSUPN.

- Use the same register layout as GCC's version.

- Integrate into compiler-rt's codebase by using DEFINE_COMPILERRT_FUNCTION().

The diff includes a `generate.sh', which generates the actual assembly
files. I guess we don't want to depend on M4 to build compiler-rt, so
it may be easier to run generate.sh and store the resulting C files in
the repository as well. Sorry for not providing a CMakefile. At
FreeBSD, we never build compiler-rt with CMake, as we imported
compiler-rt into our own build infrastructure.

-- 
Ed Schouten e...@80386.nl

[1] http://llvm.org/bugs/show_bug.cgi?id=11667
Index: lib/sparc64/divmod.m4
===
--- lib/sparc64/divmod.m4   (Revision 0)
+++ lib/sparc64/divmod.m4   (Arbeitskopie)
@@ -0,0 +1,259 @@
+//===-- lib/sparc64/divmod.m4 - Integer division and modulo *- asm -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements division and modulo routines in SPARC64
+// assembly for the compiler-rt library.  This m4 code has been taken
+// from The SPARC Architecture Manual Version 8.
+//
+//===--===//
+
+/*
+ * Division/Remainder
+ *
+ * Input is:
+ *   dividend -- the thing being divided
+ *   divisor -- how many ways to divide it
+ * Important parameters:
+ *   N -- how many bits per iteration we try to get
+ *as our current guess: define(N, 4) define(TWOSUPN, 16)
+ *   WORDSIZE -- how many bits altogether we're talking about:
+ *   obviously: define(WORDSIZE, 32)
+ * A derived constant:
+ *   TOPBITS -- how many bits are in the top decade of a number:
+ *define(TOPBITS, eval( WORDSIZE - N*((WORDSIZE-1)/N) ) )
+ * Important variables are:
+ *   Q -- the partial quotient under development -- initially 0
+ *   R -- the remainder so far -- initially == the dividend
+ *   ITER -- number of iterations of the main division loop which will
+ *   be required. Equal to CEIL( lg2(quotient)/N )
+ *   Note that this is log_base_(2ˆN) of the quotient.
+ *   V -- the current comparand -- initially divisor*2ˆ(ITER*N-1)
+ * Cost:
+ *   current estimate for non-large dividend is
+ *CEIL( lg2(quotient) / N ) x ( 10 + 7N/2 ) + C
+ *   a large dividend is one greater than 2ˆ(31-TOPBITS) and takes a
+ *   different path, as the upper bits of the quotient must be developed
+ *   one bit at a time.
+ *   This uses the m4 and cpp macro preprocessors.
+ */
+
+define(dividend, `%o0')
+define(divisor,`%o1')
+define(Q, `%o2')
+define(R, `%o3')
+define(ITER, `%o4')
+define(V, `%o5')
+define(SIGN, `%g3')
+define(T, `%g1')
+define(SC,`%g2')
+/*
+ * This is the recursive definition of how we develop quotient digits.
+ * It takes three important parameters:
+ *   $1 -- the current depth, 1=$1=N
+ *   $2 -- the current accumulation of quotient bits
+ *   N -- max depth
+ * We add a new bit to $2 and either recurse or insert the bits in the 
quotient.
+ * Dynamic input:
+ *   R -- current remainder
+ *   Q -- current quotient
+ *   V -- current comparand
+ *   cc -- set on current value of R
+ * Dynamic output:
+ *   R', Q', V', cc'
+ */
+
+#include ../assembly.h
+
+define(DEVELOP_QUOTIENT_BITS,
+`  !depth $1, accumulated bits $2
+   bl  L.$1.eval(TWOSUPN+$2)
+   srl V,1,V
+   ! remainder is nonnegative
+   subcc   R,V,R
+   ifelse( $1, N,
+   `   b   9f
+   add Q, ($2*2+1), Q
+   ',` DEVELOP_QUOTIENT_BITS( incr($1), `eval(2*$2+1)')
+   ')
+L.$1.eval(TWOSUPN+$2):
+   ! remainder is negative
+   addcc   R,V,R
+   ifelse( $1, N,
+   `   b   9f
+   add Q, ($2*2-1), Q
+   ',` 

Re: [cfe-commits] r166171 - /cfe/trunk/lib/AST/DumpXML.cpp

2012-10-18 Thread Chandler Carruth
On Thu, Oct 18, 2012 at 12:55 AM, Nick Lewycky nicho...@mxc.ca wrote:

 Author: nicholas
 Date: Thu Oct 18 02:55:46 2012
 New Revision: 166171

 URL: http://llvm.org/viewvc/llvm-project?rev=166171view=rev
 Log:
 Put used=1 on all used declarations in the XML dumper. This allows us to
 start seeing the bit so that we can find bugs and write tests for it.


Note, likely the best way to test this bit is to use the AST unit testing
facilities we now have, similar to the discussion of the SourceLocation
unit tests.

I still think dumping this bit is crazy useful of course... =]



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

 Modified: cfe/trunk/lib/AST/DumpXML.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=166171r1=166170r2=166171view=diff

 ==
 --- cfe/trunk/lib/AST/DumpXML.cpp (original)
 +++ cfe/trunk/lib/AST/DumpXML.cpp Thu Oct 18 02:55:46 2012
 @@ -1,4 +1,4 @@
 -//===--- DumpXML.cpp - Detailed XML dumping -*- C++
 -*-===//
 +//===--- DumpXML.cpp - Detailed XML dumping
 ---===//
  //
  // The LLVM Compiler Infrastructure
  //
 @@ -64,6 +64,8 @@
static_castImpl*(this)-NAME(static_castCLASS*(D))

void dispatch(Decl *D) {
 +if (D-isUsed())
 +  static_castImpl*(this)-set(used, 1);
  switch (D-getKind()) {
  #define DECL(DERIVED, BASE) \
case Decl::DERIVED: \


 ___
 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] r166174 - /cfe/trunk/lib/AST/TypeLoc.cpp

2012-10-18 Thread Abramo Bagnara
Author: abramo
Date: Thu Oct 18 03:29:37 2012
New Revision: 166174

URL: http://llvm.org/viewvc/llvm-project?rev=166174view=rev
Log:
Fixed some corner cases due to implicit int TypeLoc and simplified the logic.

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

Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=166174r1=166173r2=166174view=diff
==
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Thu Oct 18 03:29:37 2012
@@ -98,27 +98,38 @@
 
 SourceLocation TypeLoc::getBeginLoc() const {
   TypeLoc Cur = *this;
+  TypeLoc LeftMost = Cur;
   while (true) {
 switch (Cur.getTypeLocClass()) {
+case Elaborated:
+  LeftMost = Cur;
+  break;
 case FunctionProto:
-  if (castFunctionProtoTypeLoc(Cur)-getTypePtr()-hasTrailingReturn())
-return Cur.getLocalSourceRange().getBegin();
+  if (castFunctionProtoTypeLoc(Cur)-getTypePtr()-hasTrailingReturn()) 
{
+LeftMost = Cur;
+break;
+  }
+  /* Fall through */
+case FunctionNoProto:
+case ConstantArray:
+case DependentSizedArray:
+case IncompleteArray:
+case VariableArray:
+  // FIXME: Currently QualifiedTypeLoc does not have a source range
+case Qualified:
   Cur = Cur.getNextTypeLoc();
-  assert(!Cur.isNull());
   continue;
-
-// FIXME: Currently QualifiedTypeLoc does not have a source range
-// case Qualified:
-case Elaborated:
-  return Cur.getLocalSourceRange().getBegin();
-
 default:
-  if (Cur.getNextTypeLoc().isNull())
-return Cur.getLocalSourceRange().getBegin();
+  if (!Cur.getLocalSourceRange().getBegin().isInvalid())
+LeftMost = Cur;
   Cur = Cur.getNextTypeLoc();
+  if (Cur.isNull())
+break;
   continue;
 } // switch
+break;
   } // while
+  return LeftMost.getLocalSourceRange().getBegin();
 }
 
 SourceLocation TypeLoc::getEndLoc() const {


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


Re: [cfe-commits] r166174 - /cfe/trunk/lib/AST/TypeLoc.cpp

2012-10-18 Thread Chandler Carruth
On Thu, Oct 18, 2012 at 1:29 AM, Abramo Bagnara
abramo.bagn...@bugseng.comwrote:

 Author: abramo
 Date: Thu Oct 18 03:29:37 2012
 New Revision: 166174

 URL: http://llvm.org/viewvc/llvm-project?rev=166174view=rev
 Log:
 Fixed some corner cases due to implicit int TypeLoc and simplified the
 logic.


Did anything ever become of the idea of writing unittests for source
location corner cases like these? (Did I just drop the ball on the email
thread?)



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

 Modified: cfe/trunk/lib/AST/TypeLoc.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=166174r1=166173r2=166174view=diff

 ==
 --- cfe/trunk/lib/AST/TypeLoc.cpp (original)
 +++ cfe/trunk/lib/AST/TypeLoc.cpp Thu Oct 18 03:29:37 2012
 @@ -98,27 +98,38 @@

  SourceLocation TypeLoc::getBeginLoc() const {
TypeLoc Cur = *this;
 +  TypeLoc LeftMost = Cur;
while (true) {
  switch (Cur.getTypeLocClass()) {
 +case Elaborated:
 +  LeftMost = Cur;
 +  break;
  case FunctionProto:
 -  if
 (castFunctionProtoTypeLoc(Cur)-getTypePtr()-hasTrailingReturn())
 -return Cur.getLocalSourceRange().getBegin();
 +  if
 (castFunctionProtoTypeLoc(Cur)-getTypePtr()-hasTrailingReturn()) {
 +LeftMost = Cur;
 +break;
 +  }
 +  /* Fall through */
 +case FunctionNoProto:
 +case ConstantArray:
 +case DependentSizedArray:
 +case IncompleteArray:
 +case VariableArray:
 +  // FIXME: Currently QualifiedTypeLoc does not have a source range
 +case Qualified:
Cur = Cur.getNextTypeLoc();
 -  assert(!Cur.isNull());
continue;
 -
 -// FIXME: Currently QualifiedTypeLoc does not have a source range
 -// case Qualified:
 -case Elaborated:
 -  return Cur.getLocalSourceRange().getBegin();
 -
  default:
 -  if (Cur.getNextTypeLoc().isNull())
 -return Cur.getLocalSourceRange().getBegin();
 +  if (!Cur.getLocalSourceRange().getBegin().isInvalid())
 +LeftMost = Cur;
Cur = Cur.getNextTypeLoc();
 +  if (Cur.isNull())
 +break;
continue;
  } // switch
 +break;
} // while
 +  return LeftMost.getLocalSourceRange().getBegin();
  }

  SourceLocation TypeLoc::getEndLoc() const {


 ___
 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: [cfe-commits] Bug 11709 Fix: va_list on ARM is not following AAPCS 7.1.4

2012-10-18 Thread Logan Chien
Hi,

  Here's another attempt to solve __builtin_va_arg issue.
In this patch, there is a special check for C++ and va_list as
record type:

  } else if (VaListType-isRecordType()  getLangOpts().CPlusPlus) {
// If va_list is a record type and we are compiling under C++ mode,
// then we should check the argument by copy assignment operator.
InitializedEntity Entity
  = InitializedEntity::InitializeParameter(Context,
  Context.getLValueReferenceType(VaListType), false);
ExprResult Init = PerformCopyInitialization(Entity, SourceLocation(),
E);
if (Init.isInvalid())
  return ExprError();
E = Init.takeAsExpr();

With this patch, I can get the same assembly result.  However, I'm not
familiar with InitializedEntity.  Please have a look.

Sincerely,
Logan


On Thu, Oct 18, 2012 at 9:22 AM, Eli Friedman eli.fried...@gmail.comwrote:

 On Wed, Oct 17, 2012 at 6:00 PM, Weiming Zhao weimi...@codeaurora.org
 wrote:
  Hi Eli,
 
  Thanks for your info.
 
  Do you mean, in ActOnVAArg or BuildVAArgExpr, it needs
  InitializationSequence, InitializedEntity if va_list is a record type?
 (I'm
  not familiar with this)

 In C++, yes; it's the same sort of check we would perform if you
 called a function like void f(va_list);.  (In C, the existing check
 is fine.)

 A testcase would be to make sure we print a reasonable error message
 for the following in C++:

 __builtin_va_list a();
 int b() {
   return __builtin_va_arg(a(), int);
 }

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



0001-Fix-__builtin_va_arg-assertion-failure-in-ARM-AAPCS.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] r166174 - /cfe/trunk/lib/AST/TypeLoc.cpp

2012-10-18 Thread Abramo Bagnara
Il 18/10/2012 10:37, Chandler Carruth ha scritto:
 On Thu, Oct 18, 2012 at 1:29 AM, Abramo Bagnara
 abramo.bagn...@bugseng.com mailto:abramo.bagn...@bugseng.com wrote:
 
 Author: abramo
 Date: Thu Oct 18 03:29:37 2012
 New Revision: 166174
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166174view=rev
 Log:
 Fixed some corner cases due to implicit int TypeLoc and simplified
 the logic.
 
 
 Did anything ever become of the idea of writing unittests for source
 location corner cases like these? (Did I just drop the ball on the email
 thread?)
  

Unfortunately not. We are still missing a way to check the source range
in unit test.

-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagn...@bugseng.com
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] r166171 - /cfe/trunk/lib/AST/DumpXML.cpp

2012-10-18 Thread Nick Lewycky

Chandler Carruth wrote:

On Thu, Oct 18, 2012 at 12:55 AM, Nick Lewycky nicho...@mxc.ca
mailto:nicho...@mxc.ca wrote:

Author: nicholas
Date: Thu Oct 18 02:55:46 2012
New Revision: 166171

URL: http://llvm.org/viewvc/llvm-project?rev=166171view=rev
http://llvm.org/viewvc/llvm-project?rev=166171view=rev
Log:
Put used=1 on all used declarations in the XML dumper. This allows
us to
start seeing the bit so that we can find bugs and write tests for it.


Note, likely the best way to test this bit is to use the AST unit
testing facilities we now have, similar to the discussion of the
SourceLocation unit tests.

I still think dumping this bit is crazy useful of course... =]


It occurred to me immediately after committing that writing tests using 
-ast-dump-xml is a very bad idea because it's compiled out in release 
builds. Regardless, I really want this for bug reports :)


Nick




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

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

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=166171r1=166170r2=166171view=diff

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=166171r1=166170r2=166171view=diff

==
--- cfe/trunk/lib/AST/DumpXML.cpp (original)
+++ cfe/trunk/lib/AST/DumpXML.cpp Thu Oct 18 02:55:46 2012
@@ -1,4 +1,4 @@
-//===--- DumpXML.cpp - Detailed XML dumping -*-
C++ -*-===//
+//===--- DumpXML.cpp - Detailed XML dumping
---===//
  //
  // The LLVM Compiler Infrastructure
  //
@@ -64,6 +64,8 @@
static_castImpl*(this)-NAME(static_castCLASS*(D))

void dispatch(Decl *D) {
+if (D-isUsed())
+  static_castImpl*(this)-set(used, 1);
  switch (D-getKind()) {
  #define DECL(DERIVED, BASE) \
case Decl::DERIVED: \


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu mailto: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: [cfe-commits] r165256 - /cfe/trunk/lib/Sema/SemaDecl.cpp

2012-10-18 Thread Philip Craig
On Sat, Oct 6, 2012 at 3:55 PM, Enea Zaffanella zaffane...@cs.unipr.it wrote:
 On 10/06/2012 01:44 AM, Philip Craig wrote:

 On Fri, Oct 5, 2012 at 2:40 PM, Abramo Bagnara
 abramo.bagn...@bugseng.com wrote:

 Il 05/10/2012 00:15, Chandler Carruth ha scritto:

 On Thu, Oct 4, 2012 at 3:12 PM, Chandler Carruth chandl...@google.com
 mailto:chandl...@google.com wrote:

  Can we get a test case for this?


 Also, not just for this, but for all of the source location fixes you're
 making?


 This problem has been discussed a few time in past, but after discussion
 on the list we failed to find a nice (and easy) solution for testing.

 If things are now changed with tooling infrastructure, this would be
 nice to hear. If someone is so kind to write a test for this patch we
 will be happy to add the others replicating the same mechanism shown.

 The testcase if very simple void f(i) { }, what it should be tested is
 that source range for ParamDecl matches the 'i'.


 Here's a patch for the test. I don't know whether you want to keep
 these tests from the other RAV tests or not.


 +TEST(RecursiveASTVisitor, KNRParamLoc) {
 +  VarDeclVisitor Visitor;
 +  Visitor.ExpectMatch(i, 1, 8);
 +  EXPECT_TRUE(Visitor.runOver(void f(i) { }, VarDeclVisitor::Lang_C));
 +}


 Is this going (or can be modified) to also check for the end location of the
 parameter source range?

Sorry for the late reply. It should be fairly straightforward to
create a visitor that checks the range, based on the existing
ExpectedLocationVisitor in TestVisitor.h. I can try to update the
patch for that in the next few days unless someone else is keen to.
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] [Patch] Add -Wmissing-variable-declarations

2012-10-18 Thread Ed Schouten
Hi Eli,

2012/8/1 Eli Friedman eli.fried...@gmail.com:
 On Tue, Jul 24, 2012 at 7:06 AM, Ed Schouten e...@80386.nl wrote:
 I've updated the patch. As usual, it can be downloaded from:

 http://80386.nl/pub/wmissing-variable-declarations.txt

 @@ -6839,8 +6839,10 @@
}

// Record the tentative definition; we're done.
 -  if (!Var-isInvalidDecl())
 +  if (!Var-isInvalidDecl()) {
  TentativeDefinitions.push_back(Var);
 +CheckCompleteVariableDeclaration(Var);
 +  }
return;
  }

 Calling CheckCompleteVariableDeclaration here doesn't make sense; the
 variable isn't complete at this point.  If we're going to call it, it
 should be from Sema::ActOnEndOfTranslationUnit.

 Otherwise, looks fine.

Great! Care to take another look?

http://80386.nl/pub/wmissing-variable-declarations.txt

(Be sure to refresh)

-- 
Ed Schouten e...@80386.nl
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] Bug 11709 Fix: va_list on ARM is not following AAPCS 7.1.4

2012-10-18 Thread Eli Friedman
On Thu, Oct 18, 2012 at 1:40 AM, Logan Chien tzuhsiang.ch...@gmail.com wrote:
 Hi,

   Here's another attempt to solve __builtin_va_arg issue.
 In this patch, there is a special check for C++ and va_list as
 record type:

   } else if (VaListType-isRecordType()  getLangOpts().CPlusPlus) {
 // If va_list is a record type and we are compiling under C++ mode,
 // then we should check the argument by copy assignment operator.
 InitializedEntity Entity
   = InitializedEntity::InitializeParameter(Context,
   Context.getLValueReferenceType(VaListType), false);
 ExprResult Init = PerformCopyInitialization(Entity, SourceLocation(),
 E);
 if (Init.isInvalid())
   return ExprError();
 E = Init.takeAsExpr();

 With this patch, I can get the same assembly result.  However, I'm not
 familiar with InitializedEntity.  Please have a look.

Please include a testcase where PerformCopyInitialization fails.

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


Re: [cfe-commits] [LLVMdev] [cfe-dev] OpenMP support in CLANG: A proposal

2012-10-18 Thread Mahesha HS
Hi Eli,

Thanks for all your comments.

I have taken care of all your review comments. Yes, after I gone
through your review
comments, I also came to the conclusion that the addition of a new
class for OpenMP
pragma handling (class PragmaOmpHandler) is not necessarily required.
However, initially, when  started, I my-self had an opinion that this
class may required.
Now, I removed this class, and moved the omp pragma registration directly into
Preprocessor class.

I have attached following two patches along with this mail. The
patches also contains
 relevant *test cases*.

patch 1:  fopenmp_option_support.patch
patch 2:  omp_pragma_registration.patch

In patch 1, I have taken care of all your earlier review comments
related to -fopenmp option
support. Patch 2 contains the implementation for the omp pragma
registration with
Preprocessor.

Following files are changed respectively.

patch 1:

#.  clang/include/clang/Driver/Options.td
#.  clang/include/clang/Basic/LangOptions.def
#.  clang/lib/Driver/Tools.cpp
#.  clang/lib/Frontend/CompilerInvocation.cpp
#.  clang/test/Driver/clang_fopenmp_opt.c

patch 2:

#.  clang/include/clang/Lex/Preprocessor.h
#.  clang/lib/Lex/Preprocessor.cpp
#.  clang/lib/Lex/Pragma.cpp
#.  clang/test/Preprocessor/pragma_omp_ignored_warning.c

--
mahesha


On Wed, Oct 17, 2012 at 7:00 AM, Eli Friedman eli.fried...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 4:11 AM, Mahesha HS mahesha.l...@gmail.com wrote:
 Hi Eli,

 Attached is the next patch in the line. This patch
 (class_pragma_omp_handler_support.patch) contains the implementation
 of the class class PragmaOmpHandler.  I also attached the test case
 (openmp_syntax_test.c).  This test case is actually to test the
 syntactically legal simple OpenMP constructs. However, we can *really*
 test it only after submitting the next two patches - one related to
 PragmaOmpHandler object construction and the another related to OpenMP
 parsing.

 Please, let me know, if you need to know any additional information.

 If you think that some other mechanism is required to speed-up the
 review process, I will really welcome it.

 At this point, it's just a matter of finding time to review it.

 +  // \Brief: Holds all the OpenMP clause name strings.
 +  // \Brief: These strings are referenced while parsing OpenMP clauses.
 +  // Note that we won't introduce new *tokens* for openMP clause names
 +  // as these will get conflict with *identifier* token, and is very tricky
 +  // to handle. Instead, we reference below strings to recognize the OpenMP
 +  // clause names.
 +  StringRef* Clause[END_CLAUSE];

 This isn't correct documentation comment syntax; clang trunk has a
 warning -Wdocumentation to catch this.

 It's almost never appropriate to construct a StringRef*; a StringRef
 is already essentially a pointer.

 Is this array even necessary?  It's not clear what you're using it
 for.  If you want to convert from the enum to a string, just implement
 a method like static StringRef StringForDefaultKind(ClauseKind
 Kind); or something like that.

 +  // Note: These enum values *must* be in consistant in *size* and *order* 
 with
 +  // that of enum values defined in the AST node class OmpClause.

 If you want to share an enum, put it into a header in
 include/clang/Basic/.  (A new header if no existing one is
 appropriate.)  Having the same enum in multiple places is asking for
 trouble.

 This patch has a lot of copy-paste code; can you write a single
 PragmaHandler subclass which is parameterized based on the pragma in
 question?  (Or maybe a few, since it looks like some of them need
 special handling which is not yet implemented?)

 It looks like the only members of PragmaOmpHandler which actually need
 to be in a header are PragmaOmpUnknownWarning, initialize method, and
 the enums; please move PragmaOmpUnknownWarning and initialize onto the
 Preprocessor class, the enums into a new header in
 include/clang/Basic/, and everything else into the .cpp file, and
 remove include/clang/Lex/PragmaOmpHandler.h.

 -Eli



-- 
mahesha


fopenmp_option_support.patch
Description: Binary data


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


Re: [cfe-commits] r165771 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Comment.h lib/AST/ASTContext.cpp lib/AST/Comment.cpp lib/AST/CommentSema.cpp test/Index/overriding-method-co

2012-10-18 Thread Dmitri Gribenko
On Fri, Oct 12, 2012 at 2:52 AM, Fariborz Jahanian fjahan...@apple.com wrote:
 +comments::FullComment *ASTContext::cloneFullComment(comments::FullComment 
 *FC,
 +const Decl *D) const {
 +  comments::DeclInfo *ThisDeclInfo = new (*this) comments::DeclInfo;
 +  ThisDeclInfo-CommentDecl = D;
 +  ThisDeclInfo-IsFilled = false;
 +  ThisDeclInfo-fill();
 +  ThisDeclInfo-CommentDecl = FC-getDecl();
 +  comments::FullComment *CFC =
 +new (*this) comments::FullComment(FC-getBlocks(),
 +  ThisDeclInfo);
 +  return CFC;
 +
 +}

Hi Fariborz,

I think that cloneFullComment() is evil -- it breaks some assumptions
about DeclInfo and does not properly introduce a concept of a comment
being reused for a redeclaration.

(1) DeclInfo is intended to be immutable once filled; here we are just
replacing the original decl that provided all the information with
some other declaration.  I see that it apparently did not break
anything, but it is not the best solution.  Should we better keep two
DeclInfos per FullComment?

(2) ParamCommandComment::getParamName and others used to return the
parameter name *as written* in \param command, without any regard to
resolving the name to an index in function parameter list.  Now they
serve dual purpose of returning that parameter name or rewriting it.
This also breaks the purpose of getParamNameRange() nearby.  I think
that getParamName should be split into two getter functions -- to get
parameter name as written (getParamName() as it was) or with some
magic rewriting (getParamNameInDecl()).

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


[cfe-commits] [PATCH] Fix pretty-printing of decl group stmts

2012-10-18 Thread Richard Membarth
Attached is a patch that fixes pretty-printing of decl stmt groups.

The example below shows that the current type pretty-printer does
not print the variable name if Policy.SuppressSpecifiers is set.

~  cat test.cc
int main(int argc, const char **argv) {
int x=0, y=5;
for (int i=x, j=y; ij; i++) {
;
}
}

~  clang -cc1 -ast-print test.cc
int main(int argc, const char **argv) {
int x = 0,  = 5;
for (int i = x,  = y; i  j; i++) {
;
}
}

Please let me know if this is ok.

Richard

diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index 2c00246..937d16f 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -142,8 +142,10 @@ void TypePrinter::print(const Type *T, Qualifiers Quals, raw_ostream OS,
 return;
   }
   
-  if (Policy.SuppressSpecifiers  T-isSpecifierType())
+  if (Policy.SuppressSpecifiers  T-isSpecifierType()) {
+OS  PlaceHolder;
 return;
+  }
 
   SaveAndRestorebool PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
 


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


[cfe-commits] [PATCH] When using make VERBOSE=1, make sure compiler-rt is also build verbosely.

2012-10-18 Thread Jean-Daniel Dupas
When building clang+compiler-rt verbosely, the build commands of compiler-rt 
are not output in the terminal as expected.
This patch fixes the issue by forwarding the VERBOSE flag to the compiler-rt 
make.

http://llvm-reviews.chandlerc.com/D67

Files:
  runtime/compiler-rt/Makefile

Index: runtime/compiler-rt/Makefile
===
--- runtime/compiler-rt/Makefile
+++ runtime/compiler-rt/Makefile
@@ -121,6 +121,12 @@
 # modified based on changes in the compiler-rt layout or build system.
 
 
+ifdef VERBOSE
+   RUNTIME_VERBOSE := VERBOSE=$(VERBOSE)
+else
+   RUNTIME_VERBOSE :=
+endif
+
 # Rule to build the compiler-rt libraries we need.
 #
 # We build all the libraries in a single shot to avoid recursive make as much 
as
@@ -130,12 +136,14 @@
  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
  ProjObjRoot=$(PROJ_OBJ_DIR) \
  CC=$(ToolDir)/clang \
+ $(RUNTIME_VERBOSE) \
  $(RuntimeDirs:%=clang_%)
 .PHONY: BuildRuntimeLibraries
 CleanRuntimeLibraries:
$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
  ProjObjRoot=$(PROJ_OBJ_DIR) \
+ $(RUNTIME_VERBOSE) \
  clean
 .PHONY: CleanRuntimeLibraries
Index: runtime/compiler-rt/Makefile
===
--- runtime/compiler-rt/Makefile
+++ runtime/compiler-rt/Makefile
@@ -121,6 +121,12 @@
 # modified based on changes in the compiler-rt layout or build system.
 
 
+ifdef VERBOSE
+	RUNTIME_VERBOSE := VERBOSE=$(VERBOSE)
+else
+	RUNTIME_VERBOSE :=
+endif
+
 # Rule to build the compiler-rt libraries we need.
 #
 # We build all the libraries in a single shot to avoid recursive make as much as
@@ -130,12 +136,14 @@
 	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
 	  ProjObjRoot=$(PROJ_OBJ_DIR) \
 	  CC=$(ToolDir)/clang \
+	  $(RUNTIME_VERBOSE) \
 	  $(RuntimeDirs:%=clang_%)
 .PHONY: BuildRuntimeLibraries
 CleanRuntimeLibraries:
 	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
 	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
 	  ProjObjRoot=$(PROJ_OBJ_DIR) \
+	  $(RUNTIME_VERBOSE) \
 	  clean
 .PHONY: CleanRuntimeLibraries
 
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] [PATCH] clang/test/Index: 3 of tests require libxml2, following up to r166130.

2012-10-18 Thread Dmitri Gribenko
Hi Takumi,

About the patch, adding the feature is not required here.  The correct
fix is to remove the CommentXMLValid from CHECK lines.  (The test
checks that there are no CommentXMLInvalid lines, so it is OK).

Please tell me if you want me to make this change.

On Thu, Oct 18, 2012 at 5:30 AM, NAKAMURA Takumi geek4ci...@gmail.com wrote:
 FIXME: Could we add the feature 'libxml2' or rename 'xmllint' to one?

Given my suggestion above, is this still required?

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: [cfe-commits] [patch] Forward VERBOSE flag to compiler-rt Makefile.

2012-10-18 Thread Jean-Daniel Dupas
Le 16 oct. 2012 à 10:14, Jean-Daniel Dupas devli...@shadowlab.org a écrit :

 Hello,
 
 Using the autoconf build system, it is possible to build clang in verbose 
 mode to get the full transcript of the build (using make VERBOSE=1).
 This is useful to track issues with the build system. Unfortunately, it does 
 not work when you want to find an issue in the compiler-rt compilation (that 
 is automatically done while compiling clang).
 
 This patch try to solve this issue by forwarding the VERBOSE flag to 
 compiler-rt build.
 
 Please, can someone review it.
 Thanks.
 
 -- Jean-Daniel
 


I moved this patch to phabricator ( http://llvm-reviews.chandlerc.com/D67 ) to 
experiment with the system. 

So this previous mail can be ignored.

-- Jean-Daniel


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


Re: [cfe-commits] [PATCH] clang/test/Index: 3 of tests require libxml2, following up to r166130.

2012-10-18 Thread NAKAMURA Takumi
Dmitri, I'm ok for you to update!

2012/10/18 Dmitri Gribenko griboz...@gmail.com:
 Hi Takumi,

 About the patch, adding the feature is not required here.  The correct
 fix is to remove the CommentXMLValid from CHECK lines.  (The test
 checks that there are no CommentXMLInvalid lines, so it is OK).

 Please tell me if you want me to make this change.

 On Thu, Oct 18, 2012 at 5:30 AM, NAKAMURA Takumi geek4ci...@gmail.com wrote:
 FIXME: Could we add the feature 'libxml2' or rename 'xmllint' to one?

 Given my suggestion above, is this still required?

 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: [cfe-commits] [LLVMdev] [cfe-dev] OpenMP support in CLANG: A proposal

2012-10-18 Thread Mahesha HS
Sorry, in my previous mail,  I had missed to attach changes to
clang/include/clang/Basic/TokenKinds.def in the patch 2. Please
refer to the patch (2) attached in *this* mail, instead of the one
sent in the previous mail. Patch 1 is fine.

--
mahesha


On Thu, Oct 18, 2012 at 5:02 PM, Mahesha HS mahesha.l...@gmail.com wrote:
 Hi Eli,

 Thanks for all your comments.

 I have taken care of all your review comments. Yes, after I gone
 through your review
 comments, I also came to the conclusion that the addition of a new
 class for OpenMP
 pragma handling (class PragmaOmpHandler) is not necessarily required.
 However, initially, when  started, I my-self had an opinion that this
 class may required.
 Now, I removed this class, and moved the omp pragma registration directly into
 Preprocessor class.

 I have attached following two patches along with this mail. The
 patches also contains
  relevant *test cases*.

 patch 1:  fopenmp_option_support.patch
 patch 2:  omp_pragma_registration.patch

 In patch 1, I have taken care of all your earlier review comments
 related to -fopenmp option
 support. Patch 2 contains the implementation for the omp pragma
 registration with
 Preprocessor.

 Following files are changed respectively.

 patch 1:
 
 #.  clang/include/clang/Driver/Options.td
 #.  clang/include/clang/Basic/LangOptions.def
 #.  clang/lib/Driver/Tools.cpp
 #.  clang/lib/Frontend/CompilerInvocation.cpp
 #.  clang/test/Driver/clang_fopenmp_opt.c

 patch 2:
 
 #.  clang/include/clang/Lex/Preprocessor.h
 #.  clang/lib/Lex/Preprocessor.cpp
 #.  clang/lib/Lex/Pragma.cpp
 #.  clang/test/Preprocessor/pragma_omp_ignored_warning.c

 --
 mahesha


 On Wed, Oct 17, 2012 at 7:00 AM, Eli Friedman eli.fried...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 4:11 AM, Mahesha HS mahesha.l...@gmail.com wrote:
 Hi Eli,

 Attached is the next patch in the line. This patch
 (class_pragma_omp_handler_support.patch) contains the implementation
 of the class class PragmaOmpHandler.  I also attached the test case
 (openmp_syntax_test.c).  This test case is actually to test the
 syntactically legal simple OpenMP constructs. However, we can *really*
 test it only after submitting the next two patches - one related to
 PragmaOmpHandler object construction and the another related to OpenMP
 parsing.

 Please, let me know, if you need to know any additional information.

 If you think that some other mechanism is required to speed-up the
 review process, I will really welcome it.

 At this point, it's just a matter of finding time to review it.

 +  // \Brief: Holds all the OpenMP clause name strings.
 +  // \Brief: These strings are referenced while parsing OpenMP clauses.
 +  // Note that we won't introduce new *tokens* for openMP clause names
 +  // as these will get conflict with *identifier* token, and is very tricky
 +  // to handle. Instead, we reference below strings to recognize the OpenMP
 +  // clause names.
 +  StringRef* Clause[END_CLAUSE];

 This isn't correct documentation comment syntax; clang trunk has a
 warning -Wdocumentation to catch this.

 It's almost never appropriate to construct a StringRef*; a StringRef
 is already essentially a pointer.

 Is this array even necessary?  It's not clear what you're using it
 for.  If you want to convert from the enum to a string, just implement
 a method like static StringRef StringForDefaultKind(ClauseKind
 Kind); or something like that.

 +  // Note: These enum values *must* be in consistant in *size* and *order* 
 with
 +  // that of enum values defined in the AST node class OmpClause.

 If you want to share an enum, put it into a header in
 include/clang/Basic/.  (A new header if no existing one is
 appropriate.)  Having the same enum in multiple places is asking for
 trouble.

 This patch has a lot of copy-paste code; can you write a single
 PragmaHandler subclass which is parameterized based on the pragma in
 question?  (Or maybe a few, since it looks like some of them need
 special handling which is not yet implemented?)

 It looks like the only members of PragmaOmpHandler which actually need
 to be in a header are PragmaOmpUnknownWarning, initialize method, and
 the enums; please move PragmaOmpUnknownWarning and initialize onto the
 Preprocessor class, the enums into a new header in
 include/clang/Basic/, and everything else into the .cpp file, and
 remove include/clang/Lex/PragmaOmpHandler.h.

 -Eli



 --
 mahesha



-- 
mahesha


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


[cfe-commits] r166179 - in /cfe/trunk/test/Index: annotate-comments-availability-attrs.cpp overriding-ftemplate-comments.cpp overriding-method-comments.mm

2012-10-18 Thread Dmitri Gribenko
Author: gribozavr
Date: Thu Oct 18 09:33:01 2012
New Revision: 166179

URL: http://llvm.org/viewvc/llvm-project?rev=166179view=rev
Log:
Un-XFAIL some tests for comment to XML conversion.  This reverts r166151 and
fixes the tests for builds without libxml2.

Modified:
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
cfe/trunk/test/Index/overriding-ftemplate-comments.cpp
cfe/trunk/test/Index/overriding-method-comments.mm

Modified: cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp?rev=166179r1=166178r2=166179view=diff
==
--- cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp (original)
+++ cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp Thu Oct 18 
09:33:01 2012
@@ -8,7 +8,6 @@
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG  %t/out
 // WRONG-NOT: CommentXMLInvalid
-// XFAIL: *
 
 /// Aaa.
 void attr_availability_1() 
__attribute__((availability(macosx,obsoleted=10.0,introduced=8.0,deprecated=9.0,
 message=use availability_test in foo.h)))
@@ -29,17 +28,17 @@
 /// Aaa.
 void attr_unavailable_2() __attribute__((unavailable(message 2 foo.h)));
 
-// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=13 
column=6Nameattr_availability_1/NameUSRc:@F@attr_availability_1#/USRDeclarationvoid
 attr_availability_1()/DeclarationAbstractPara 
Aaa./Para/AbstractAvailability distribution=iOSDeprecationSummarynot 
for iOS/DeprecationSummaryUnavailable//AvailabilityAvailability 
distribution=OS 
XIntroducedInVersion8.0/IntroducedInVersionDeprecatedInVersion9.0/DeprecatedInVersionRemovedAfterVersion10.0/RemovedAfterVersionDeprecationSummaryuse
 availability_test in 
lt;foo.hgt;/DeprecationSummary/Availability/Function] CommentXMLValid
+// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=13 
column=6Nameattr_availability_1/NameUSRc:@F@attr_availability_1#/USRDeclarationvoid
 attr_availability_1()/DeclarationAbstractPara 
Aaa./Para/AbstractAvailability distribution=iOSDeprecationSummarynot 
for iOS/DeprecationSummaryUnavailable//AvailabilityAvailability 
distribution=OS 
XIntroducedInVersion8.0/IntroducedInVersionDeprecatedInVersion9.0/DeprecatedInVersionRemovedAfterVersion10.0/RemovedAfterVersionDeprecationSummaryuse
 availability_test in 
lt;foo.hgt;/DeprecationSummary/Availability/Function]
 
 
-// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=17 
column=6Nameattr_availability_2/NameUSRc:@F@attr_availability_2#/USRDeclarationvoid
 attr_availability_2()/DeclarationAbstractPara 
Aaa./Para/AbstractAvailability distribution=OS 
XIntroducedInVersion8.0.1/IntroducedInVersionDeprecatedInVersion9.0.1/DeprecatedInVersionRemovedAfterVersion10.0.1/RemovedAfterVersion/Availability/Function]
 CommentXMLValid
+// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=17 
column=6Nameattr_availability_2/NameUSRc:@F@attr_availability_2#/USRDeclarationvoid
 attr_availability_2()/DeclarationAbstractPara 
Aaa./Para/AbstractAvailability distribution=OS 
XIntroducedInVersion8.0.1/IntroducedInVersionDeprecatedInVersion9.0.1/DeprecatedInVersionRemovedAfterVersion10.0.1/RemovedAfterVersion/Availability/Function]
 
-// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=20 
column=6Nameattr_deprecated_1/NameUSRc:@F@attr_deprecated_1#/USRDeclarationvoid
 attr_deprecated_1()/DeclarationAbstractPara 
Aaa./Para/AbstractDeprecated//Function] CommentXMLValid
+// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=20 
column=6Nameattr_deprecated_1/NameUSRc:@F@attr_deprecated_1#/USRDeclarationvoid
 attr_deprecated_1()/DeclarationAbstractPara 
Aaa./Para/AbstractDeprecated//Function]
 
-// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=23 
column=6Nameattr_deprecated_2/NameUSRc:@F@attr_deprecated_2#/USRDeclarationvoid
 attr_deprecated_2()/DeclarationAbstractPara 
Aaa./Para/AbstractDeprecatedmessage 1 
lt;foo.hgt;/Deprecated/Function] CommentXMLValid
+// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=23 
column=6Nameattr_deprecated_2/NameUSRc:@F@attr_deprecated_2#/USRDeclarationvoid
 attr_deprecated_2()/DeclarationAbstractPara 
Aaa./Para/AbstractDeprecatedmessage 1 
lt;foo.hgt;/Deprecated/Function]
 
 
-// CHECK: FullCommentAsXML=[Function 
file={{[^]+}}annotate-comments-availability-attrs.cpp line=26 
column=6Nameattr_unavailable_1/NameUSRc:@F@attr_unavailable_1#/USRDeclarationvoid
 attr_unavailable_1()/DeclarationAbstractPara 
Aaa./Para/AbstractUnavailable//Function] CommentXMLValid
+// CHECK: FullCommentAsXML=[Function 

Re: [cfe-commits] [PATCH] clang/test/Index: 3 of tests require libxml2, following up to r166130.

2012-10-18 Thread Dmitri Gribenko
On Thu, Oct 18, 2012 at 3:55 PM, NAKAMURA Takumi geek4ci...@gmail.com wrote:
 Dmitri, I'm ok for you to update!

Committed r166179, hopefully it fixes mingw and win32 buildbots!

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: [cfe-commits] [PATCH] 3 small static analyzer patches

2012-10-18 Thread Sean McBride
On Fri, 21 Sep 2012 09:51:32 -0700, Jordan Rose said:

The reallocf change looks good. The place to add a test is unix-fns.c,
which you probably already found. I'll let you come up with a test case
just to practice. ;-) Welcome to the static analyzer!

Hi,

Here's a new patch with test.  I confirmed that it builds, and that the build 
result detects reallocf(zero-size).  I didn't run all the unit/regression tests 
though, because, despite their being instructions, I couldn't figure out how.  
I suspect one must built with autotools and not cmake to be able to run them?

Cheers,

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


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


Re: [cfe-commits] [llvm-commits] (autoconf) Build ASan runtime for ARM/Android

2012-10-18 Thread Evgeniy Stepanov
ping

On Wed, Oct 17, 2012 at 6:34 PM, Evgeniy Stepanov
eugeni.stepa...@gmail.com wrote:
 OK, let's get rid of the configure option for the sake of progress.
 Please take another look.
 This way android runtime can be built with an extra make invocation in
 the same build tree.
 make -C tools/clang/runtime/ LLVM_ANDROID_TOOLCHAIN_DIR=/path/to/ndk/toolchain


 On Thu, Oct 11, 2012 at 1:50 AM, Eric Christopher echri...@gmail.com wrote:

 Otherwise I think it starts to become an unwieldy set of configure flags
 to set any sdk/sysroot that any particular target triple needs in building
 any of the runtime libraries (libcxx will necessarily have this problem 
 too).

 Thoughts?


 FWIW Jim, Chandler and I have been discussing this as well. Been going
 over how to deal with in versus out of tree builds and options for a full
 toolchain. Just wanted to let you know it's more than just a couple of
 people chatting :)

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


[cfe-commits] Fwd: Bug 11709 Fix: va_list on ARM is not following AAPCS 7.1.4

2012-10-18 Thread Logan Chien
-- Forwarded message --
From: Logan Chien tzuhsiang.ch...@gmail.com
Date: Thu, Oct 18, 2012 at 11:20 PM
Subject: Re: [cfe-commits] Bug 11709 Fix: va_list on ARM is not following
AAPCS 7.1.4
To: Eli Friedman eli.fried...@gmail.com


Thanks for your review.

I have added new test to test/SemaCXX/builtins-arm.cpp to
specify the error message when PerformCopyInitialization fails.

BTW, is the InitializedEntity related code correct?  I hope I can
get a modifiable Lvalue reference after initialization (not a copy
of the value in the structure.)  I'm not very confident with this.

Thanks.

Sincerely,
Logan


On Thu, Oct 18, 2012 at 6:11 PM, Eli Friedman eli.fried...@gmail.comwrote:

 On Thu, Oct 18, 2012 at 1:40 AM, Logan Chien tzuhsiang.ch...@gmail.com
 wrote:
  Hi,
 
Here's another attempt to solve __builtin_va_arg issue.
  In this patch, there is a special check for C++ and va_list as
  record type:
 
} else if (VaListType-isRecordType()  getLangOpts().CPlusPlus) {
  // If va_list is a record type and we are compiling under C++ mode,
  // then we should check the argument by copy assignment operator.
  InitializedEntity Entity
= InitializedEntity::InitializeParameter(Context,
Context.getLValueReferenceType(VaListType), false);
  ExprResult Init = PerformCopyInitialization(Entity, SourceLocation(),
  E);
  if (Init.isInvalid())
return ExprError();
  E = Init.takeAsExpr();
 
  With this patch, I can get the same assembly result.  However, I'm not
  familiar with InitializedEntity.  Please have a look.

 Please include a testcase where PerformCopyInitialization fails.

 -Eli



0001-Fix-__builtin_va_arg-assertion-failure-in-ARM-AAPCS.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[cfe-commits] r166181 - /cfe/trunk/NOTES.txt

2012-10-18 Thread Andy Gibbs
Author: andyg
Date: Thu Oct 18 10:24:46 2012
New Revision: 166181

URL: http://llvm.org/viewvc/llvm-project?rev=166181view=rev
Log:
Fix typo (test commit)

Modified:
cfe/trunk/NOTES.txt

Modified: cfe/trunk/NOTES.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/NOTES.txt?rev=166181r1=166180r2=166181view=diff
==
--- cfe/trunk/NOTES.txt (original)
+++ cfe/trunk/NOTES.txt Thu Oct 18 10:24:46 2012
@@ -44,7 +44,7 @@
2. Instead of stat'ing the file in FileManager::getFile, check to see if 
   the dir has been read.  If so, fail immediately, if not, read the dir,
   then retry.
-   3. Reading the dir uses the getdirentries syscall, creating an FileEntry
+   3. Reading the dir uses the getdirentries syscall, creating a FileEntry
   for all files found.
 
 //===-===//


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


[cfe-commits] r166184 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaStmtAsm.cpp test/CodeGen/ms-inline-asm.c

2012-10-18 Thread Chad Rosier
Author: mcrosier
Date: Thu Oct 18 10:49:40 2012
New Revision: 166184

URL: http://llvm.org/viewvc/llvm-project?rev=166184view=rev
Log:
[ms-inline asm] Move most of the AsmParsing logic in clang back into the MC
layer.  Use the new ParseMSInlineAsm() API and add an implementation of the
MCAsmParserSemaCallback interface.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=166184r1=166183r2=166184view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 18 10:49:40 2012
@@ -2601,6 +2601,7 @@
  Expr *AsmString, MultiExprArg Clobbers,
  SourceLocation RParenLoc);
 
+  NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc);
   StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
 ArrayRefToken AsmToks, SourceLocation EndLoc);
 

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=166184r1=166183r2=166184view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Oct 18 10:49:40 2012
@@ -24,19 +24,12 @@
 #include llvm/ADT/SmallString.h
 #include llvm/MC/MCAsmInfo.h
 #include llvm/MC/MCContext.h
-#include llvm/MC/MCExpr.h
-#include llvm/MC/MCInst.h
-#include llvm/MC/MCInstPrinter.h
-#include llvm/MC/MCInstrInfo.h
 #include llvm/MC/MCObjectFileInfo.h
 #include llvm/MC/MCRegisterInfo.h
 #include llvm/MC/MCStreamer.h
 #include llvm/MC/MCSubtargetInfo.h
-#include llvm/MC/MCSymbol.h
 #include llvm/MC/MCTargetAsmParser.h
-#include llvm/MC/MCParser/MCAsmLexer.h
 #include llvm/MC/MCParser/MCAsmParser.h
-#include llvm/MC/MCParser/MCParsedAsmOperand.h
 #include llvm/Support/SourceMgr.h
 #include llvm/Support/TargetRegistry.h
 #include llvm/Support/TargetSelect.h
@@ -367,55 +360,73 @@
   return false;
 }
 
-namespace {
-enum AsmOpRewriteKind {
-   AOK_Imm,
-   AOK_Input,
-   AOK_Output
-};
-
-struct AsmOpRewrite {
-  AsmOpRewriteKind Kind;
-  llvm::SMLoc Loc;
-  unsigned Len;
+class MCAsmParserSemaCallbackImpl : public llvm::MCAsmParserSemaCallback {
+  Sema *SemaRef;
 
 public:
-  AsmOpRewrite(AsmOpRewriteKind kind, llvm::SMLoc loc, unsigned len)
-: Kind(kind), Loc(loc), Len(len) { }
+  MCAsmParserSemaCallbackImpl(class Sema *Ref) { SemaRef = Ref; }
+  ~MCAsmParserSemaCallbackImpl() {}
+
+  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc,
+  void **IdentifierInfoPtr) {
+SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc);
+NamedDecl *OpDecl = SemaRef-LookupInlineAsmIdentifier(Name, Loc);
+DeclarationNameInfo NameInfo(OpDecl-getDeclName(), Loc);
+ExprResult OpExpr = SemaRef-BuildDeclarationNameExpr(CXXScopeSpec(),
+  NameInfo,
+  OpDecl);
+if (OpExpr.isInvalid())
+  return 0;
+
+*IdentifierInfoPtr = static_castvoid*(OpDecl-getIdentifier());
+return static_castvoid *(OpExpr.take());
+  }
 };
 
+NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc) 
{
+  LookupResult Result(*this, Context.Idents.get(Name), Loc,
+  Sema::LookupOrdinaryName);
+
+  if (!LookupName(Result, getCurScope())) {
+// If we don't find anything, return null; the AsmParser will assume
+// it is a label of some sort.
+return 0;
+  }
+
+  if (!Result.isSingleResult()) {
+// FIXME: Diagnose result.
+return 0;
+  }
+
+  NamedDecl *ND = Result.getFoundDecl();
+  if (isaVarDecl(ND) || isaFunctionDecl(ND)) {
+return ND;
+  }
+
+  // FIXME: Handle other kinds of results? (FieldDecl, etc.)
+  // FIXME: Diagnose if we find something we can't handle, like a typedef.
+  return 0;
 }
 
 StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation 
LBraceLoc,
 ArrayRefToken AsmToks,SourceLocation EndLoc) 
{
-  SmallVectorIdentifierInfo*, 4 Inputs;
-  SmallVectorIdentifierInfo*, 4 Outputs;
   SmallVectorIdentifierInfo*, 4 Names;
-  SmallVectorstd::string, 4 InputConstraints;
-  SmallVectorstd::string, 4 OutputConstraints;
-  SmallVectorStringRef, 4 Constraints;
-  unsigned NumOutputs;
-  unsigned NumInputs;
-  SmallVectorExpr*, 4 InputExprs;
-  SmallVectorExpr*, 4 OutputExprs;
+  SmallVectorStringRef, 4 ConstraintRefs;
   SmallVectorExpr*, 4 Exprs;
-  SmallVectorStringRef, 4 Clobbers;
-  std::setstd::string ClobberRegs;
-
-  SmallVectorstruct AsmOpRewrite, 4 AsmStrRewrites;
+  SmallVectorStringRef, 4 ClobberRefs;

Re: [cfe-commits] [PATCH] clang/test/Index: 3 of tests require libxml2, following up to r166130.

2012-10-18 Thread jahanian

On Oct 18, 2012, at 5:45 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 Hi Takumi,
 
 About the patch, adding the feature is not required here.  The correct
 fix is to remove the CommentXMLValid from CHECK lines.  (The test
 checks that there are no CommentXMLInvalid lines, so it is OK).

Yes, I was about to check in this patch. 

- fariborz


 
 Please tell me if you want me to make this change.
 
 On Thu, Oct 18, 2012 at 5:30 AM, NAKAMURA Takumi geek4ci...@gmail.com wrote:
 FIXME: Could we add the feature 'libxml2' or rename 'xmllint' to one?
 
 Given my suggestion above, is this still required?
 
 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: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread jahanian

On Oct 17, 2012, at 6:45 PM, NAKAMURA Takumi geek4ci...@gmail.com wrote:

 2012/10/18 Fariborz Jahanian fjahan...@apple.com:
 
 Don't escape local std::string with StringRef. Fixed in r166163.

Thanks. It went through couple of revisions and forgot to do this last one. 
- fariborz


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


Re: [cfe-commits] r165771 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Comment.h lib/AST/ASTContext.cpp lib/AST/Comment.cpp lib/AST/CommentSema.cpp test/Index/overriding-method-co

2012-10-18 Thread Douglas Gregor
Hi Dmitri,

On Oct 18, 2012, at 5:03 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 On Fri, Oct 12, 2012 at 2:52 AM, Fariborz Jahanian fjahan...@apple.com 
 wrote:
 +comments::FullComment *ASTContext::cloneFullComment(comments::FullComment 
 *FC,
 +const Decl *D) const {
 +  comments::DeclInfo *ThisDeclInfo = new (*this) comments::DeclInfo;
 +  ThisDeclInfo-CommentDecl = D;
 +  ThisDeclInfo-IsFilled = false;
 +  ThisDeclInfo-fill();
 +  ThisDeclInfo-CommentDecl = FC-getDecl();
 +  comments::FullComment *CFC =
 +new (*this) comments::FullComment(FC-getBlocks(),
 +  ThisDeclInfo);
 +  return CFC;
 +
 +}
 
 Hi Fariborz,
 
 I think that cloneFullComment() is evil -- it breaks some assumptions
 about DeclInfo and does not properly introduce a concept of a comment
 being reused for a redeclaration.
 
 (1) DeclInfo is intended to be immutable once filled; here we are just
 replacing the original decl that provided all the information with
 some other declaration.  I see that it apparently did not break
 anything, but it is not the best solution.  Should we better keep two
 DeclInfos per FullComment?

It's weird to be overwriting CommentDecl in cloneFullComment(), but I don't 
think we need to have two DeclInfos per FullComment. The intent here is that 
CommentDecl is the declaration to which the comment was actually attached (in 
the source), and CurrentDecl would be the declaration with which the 
FullComment is associated. The information in the DeclInfo corresponds to 
CurrentDecl.

 (2) ParamCommandComment::getParamName and others used to return the
 parameter name *as written* in \param command, without any regard to
 resolving the name to an index in function parameter list.  Now they
 serve dual purpose of returning that parameter name or rewriting it.
 This also breaks the purpose of getParamNameRange() nearby.  I think
 that getParamName should be split into two getter functions -- to get
 parameter name as written (getParamName() as it was) or with some
 magic rewriting (getParamNameInDecl()).

I'm fine with splitting it into two functions. In general in the Clang ASTs, we 
have getFoo() be the semantic property and we add a getFooAsWritten() for 
the syntax as written. I suggest we do that.

I think we should also deal with rewriting of \p. Yes, it means some lookup, 
but it'll give a more consistent experience.

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


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread Robert Muth
On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com wrote:
 On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie dblai...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com wrote:
 On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
 rafael.espind...@gmail.com wrote:
 On 15 October 2012 19:02, Robert Muth robe...@google.com wrote:
 No small test, sadly.
 I managed to cut a 10MB reproducer down to 2MB over 2h
 but no further.

 The testcase in the bug report is already a lot smaller than that.
 Running delta a bit more reduced it to the attached file, which I am
 sure can be reduced a bit more.

 The reproducer in the bug has a lot of problems, e.g.
 it is only a fragment - not valid C++ code.
 It is also not a very stable reproducers meaning changing the clang
 command line slightly
 will change clang's memory allocation enough that the bug does not get 
 triggered
 anymore and instead you get a compiler failure because the code is
 only a fragment.

 This stability issue would likely effect any test for this problem,
 even valgrind based ones.

 Having thought  about this a little more think the best way to
 approach the problem of invalidated iterators
 is not by adding tests each time we find one but by addressing it at a
 higher level, e.g. compiling clang or llvm in a
 special debug mode, linking in special debug versions of STL and
 llvm/ADT/ that will cause crashes more reliably.
 Apparently VS has a feature like that, c.f.
 http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid

 Fair point - Howard Hinnant started work on something like this for
 libc++ but it's not been finished yet (put on the back burner). MSVC's
 debug mode has really helped me on several occasions.

 Takumi (who runs most/all of the MSVC bots) - do any of your bots
 already run with MSVC's iterator debugging turned up/on? Would that be
 a reasonable task? ( interestingly: does it catch this bug)

 Without knowing much about how MSVC is accomplishing this,
 it probably relies on extra book keeping inside STL.

 That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
 you can't interoperate STL-using APIs built with differing IDLs, but
 they have some machinery that should usually give you a linker error
 if you try). Howard wanted to implement something that would not be
 ABI-changing and allow libraries with differing iterator debugging
 levels to interoperate in a best-effort manner. This meant using
 side-tables rather than in-structure bookkeeping.

 The container implicated here , DenseMap, is not an STL container,
 though, so some extra
 work would be required to make it fit the MSVC framework.

 Ah, right - yeah, there are ways to plug into it but it's work. We
 might consider implementing our own standalone version for this
 instead.

 Robert - while that would help stabilize the behavior, would it
 actually help catch this bug? Would it be possible for you to create a

 I am pretty sure it would catch this bug *reliably*, because
 the reproducer does add items to  DenseMap while iterating over it which
  invalidates the iterators de jure.

 That's all I'm interested in.

 But this invalidation only becomes visible when it is accompanied by a 
 resizing
 of the DenseMap and that seems to depend on the concrete program run, e.g.
 we can influence the resize trigger by changing the length of strings
 passed on clang command line.

 The visibility I don't mind about right now - that's an infrastructure
 problem we'll need to fix  I wouldn't gate your fix on that.

 What I'm interested in is a reproduction of invalid code according to
 DenseMap's contract, not its implementation. Basically a quick  dirty
 way to do this would be to raise some global flag around the loop in
 Sema::AddOverloadCandidate, then assert that that flag is not raised
 when things are added to the container in Sema::RequireCompleteType (I
 mention these two functions based on your analysis posted in the bug,
 not my own investigation). Then reduce to the simplest (hopefully
 valid) code that triggers the assert.

 You don't need/we won't commit this assert/flag, but we'll know that
 this case reliably violates the DenseMap contract  if/when we add
 some iterator invalidation checking we'll have a repro ready to go.


David,

I attached a set of llvm/clang patches to the bug that makes the
failure reliable.
The patches  work with the existing reproducer (also attached).  A colleague of
mine is preparing a nicer reproducer which he will add to the bug
once it is ready.

Since this activity is independent  of getting my fix into clang: are
there any other reservations
preventing the  fix from being committed?

Cheers,
Robert



 reproduction that always violates the iterator invalidation contract
 but doesn't necessarily crash? I wouldn't mind having that in the test
 suite even in the absence of 

Re: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 4:42 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 12:58 AM, Fariborz Jahanian fjahan...@apple.com 
 wrote:
 Author: fjahanian
 Date: Wed Oct 17 16:58:03 2012
 New Revision: 166130
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166130view=rev
 Log:
 [Doc parsing]: This patch adds Declaration tag to
 XML comment for declarations which pretty-prints
 declaration. I had to XFAIL one test annotate-comments.cpp.
 This test is currently unmaintainable as written.
 Dmitri G., can you see what we can do about this test.
 
 Hi Fariborz,
 
 While I agree that annotate-comments is hard to maintain, but it is
 not just a test, it is *the* test (it tests almost all aspects of
 comments parsing), and thus I disagree with your approach of
 committing a new feature and XFAILing this test -- I think we should
 have discussed this.

I fully agree with Dmitri. Revert, don't XFAIL, if a test is breaking.

 Modified: cfe/trunk/include/clang/AST/Comment.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166130r1=166129r2=166130view=diff
 ==
 --- cfe/trunk/include/clang/AST/Comment.h (original)
 +++ cfe/trunk/include/clang/AST/Comment.h Wed Oct 17 16:58:03 2012
 @@ -905,9 +905,9 @@
   /// Declaration the comment is attached to.  Should not be NULL.
   const Decl *CommentDecl;
 
 -  /// Location of this declaration. Not necessarily same as location of
 -  /// CommentDecl.
 -  SourceLocation Loc;
 +  /// CurrentDecl is the declaration for which comment is being put into an 
 XML comment.
 +  /// Not necessarily same as CommentDecl.
 +  const Decl *CurrentDecl;
 
 I think that this CurrentDecl variable represents (or should
 represent) some bigger concept than what is stated in the comment.  It
 should not be related with XML output at all.  And, I don't see (in
 current code) how it can be different from CommentDecl.

I hope my other message explained it. However, the comment needs to be improved 
to describe this. Fariborz?

- Doug


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


Re: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread jahanian

On Oct 18, 2012, at 9:22 AM, Douglas Gregor dgre...@apple.com wrote:

 
 On Oct 18, 2012, at 4:42 AM, Dmitri Gribenko griboz...@gmail.com wrote:
 
 On Thu, Oct 18, 2012 at 12:58 AM, Fariborz Jahanian fjahan...@apple.com 
 wrote:
 Author: fjahanian
 Date: Wed Oct 17 16:58:03 2012
 New Revision: 166130
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166130view=rev
 Log:
 [Doc parsing]: This patch adds Declaration tag to
 XML comment for declarations which pretty-prints
 declaration. I had to XFAIL one test annotate-comments.cpp.
 This test is currently unmaintainable as written.
 Dmitri G., can you see what we can do about this test.
 
 Hi Fariborz,
 
 While I agree that annotate-comments is hard to maintain, but it is
 not just a test, it is *the* test (it tests almost all aspects of
 comments parsing), and thus I disagree with your approach of
 committing a new feature and XFAILing this test -- I think we should
 have discussed this.
 
 I fully agree with Dmitri. Revert, don't XFAIL, if a test is breaking.

I am working on this before I go out of town.

 
 Modified: cfe/trunk/include/clang/AST/Comment.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166130r1=166129r2=166130view=diff
 ==
 --- cfe/trunk/include/clang/AST/Comment.h (original)
 +++ cfe/trunk/include/clang/AST/Comment.h Wed Oct 17 16:58:03 2012
 @@ -905,9 +905,9 @@
  /// Declaration the comment is attached to.  Should not be NULL.
  const Decl *CommentDecl;
 
 -  /// Location of this declaration. Not necessarily same as location of
 -  /// CommentDecl.
 -  SourceLocation Loc;
 +  /// CurrentDecl is the declaration for which comment is being put into 
 an XML comment.
 +  /// Not necessarily same as CommentDecl.
 +  const Decl *CurrentDecl;
 
 I think that this CurrentDecl variable represents (or should
 represent) some bigger concept than what is stated in the comment.  It
 should not be related with XML output at all.  And, I don't see (in
 current code) how it can be different from CommentDecl.
 
 I hope my other message explained it. However, the comment needs to be 
 improved to describe this. Fariborz?

As you pointed out.CurrentDecl is the decl for which this comment is intended 
for. CommentDecl is the decl. for which
comment was written by the user. I will add more to the comment (no pun 
intended :).
- fariborz

 
   - Doug
 
 

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


Re: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread Dmitri Gribenko
On Thu, Oct 18, 2012 at 7:22 PM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 18, 2012, at 4:42 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 12:58 AM, Fariborz Jahanian fjahan...@apple.com 
 wrote:
 Modified: cfe/trunk/include/clang/AST/Comment.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166130r1=166129r2=166130view=diff
 ==
 --- cfe/trunk/include/clang/AST/Comment.h (original)
 +++ cfe/trunk/include/clang/AST/Comment.h Wed Oct 17 16:58:03 2012
 @@ -905,9 +905,9 @@
   /// Declaration the comment is attached to.  Should not be NULL.
   const Decl *CommentDecl;

 -  /// Location of this declaration. Not necessarily same as location of
 -  /// CommentDecl.
 -  SourceLocation Loc;
 +  /// CurrentDecl is the declaration for which comment is being put into 
 an XML comment.
 +  /// Not necessarily same as CommentDecl.
 +  const Decl *CurrentDecl;

 I think that this CurrentDecl variable represents (or should
 represent) some bigger concept than what is stated in the comment.  It
 should not be related with XML output at all.  And, I don't see (in
 current code) how it can be different from CommentDecl.

 I hope my other message explained it. However, the comment needs to be 
 improved to describe this. Fariborz?

Oh, now I get it -- first CurrentDecl is set to CommentDecl, but after
that CommentDecl gets changed.  That was subtle.

So CommentDecl is the original Decl that the programmer attached the
comment to and CurrentDecl is the same one or some other related Decl?

Maybe some renaming would help?

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: [cfe-commits] [PATCH] Optimize SourceManager::getColumnNumber to fix PR14106

2012-10-18 Thread Douglas Gregor
On Oct 17, 2012, at 6:04 PM, Craig Topper craig.top...@gmail.com wrote:

 This patch uses the line number cache to find the start of the line instead 
 of searching backwards for it. This helps performance in cases where the line 
 is long and have just called getLineNumber for the same position.

This only helps when the FilePos is exactly the same as the FilePos that went 
to getLineNumber:

+  // See if we just calculated the line number for this FilePos and can use
+  // that to lookup the start of the line instead of searching for it.
+  if (LastLineNoFileIDQuery == FID  LastLineNoFilePos == (FilePos + 1)) {

Why not simply check that FilePos  SourceLineCache[LastLineNoResult - 1] and  
SourceLineCache[LastLineNoResult], so anything on the most-recently-queried 
line can be handled efficiently?

- Doug

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


Re: [cfe-commits] r165771 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Comment.h lib/AST/ASTContext.cpp lib/AST/Comment.cpp lib/AST/CommentSema.cpp test/Index/overriding-method-co

2012-10-18 Thread Dmitri Gribenko
On Thu, Oct 18, 2012 at 7:18 PM, Douglas Gregor dgre...@apple.com wrote:
 On Oct 18, 2012, at 5:03 AM, Dmitri Gribenko griboz...@gmail.com wrote:
 I think that cloneFullComment() is evil -- it breaks some assumptions
 about DeclInfo and does not properly introduce a concept of a comment
 being reused for a redeclaration.

 (1) DeclInfo is intended to be immutable once filled; here we are just
 replacing the original decl that provided all the information with
 some other declaration.  I see that it apparently did not break
 anything, but it is not the best solution.  Should we better keep two
 DeclInfos per FullComment?

 It's weird to be overwriting CommentDecl in cloneFullComment(), but I don't 
 think we need to have two DeclInfos per FullComment. The intent here is that 
 CommentDecl is the declaration to which the comment was actually attached (in 
 the source), and CurrentDecl would be the declaration with which the 
 FullComment is associated. The information in the DeclInfo corresponds to 
 CurrentDecl.

I see now, thank you for the explanation.  Maybe improving comments or
renaming CommentDecl/CurrentDecl could help to make this clear.

 I'm fine with splitting it into two functions. In general in the Clang ASTs, 
 we have getFoo() be the semantic property and we add a getFooAsWritten() 
 for the syntax as written. I suggest we do that.

I agree.

 I think we should also deal with rewriting of \p. Yes, it means some lookup, 
 but it'll give a more consistent experience.

My main concern is not the additional lookup (it is even useful -- we
could catch more bugs in comments), but the fact that there are
unannotated references to parameters, and sometimes both annotated and
unannotated references in the same comment (some will get rewritten,
some will not).

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


[cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread David Blaikie
Author: dblaikie
Date: Thu Oct 18 11:57:32 2012
New Revision: 166188

URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
Log:
PR14021: Copy lookup results to ensure safe iteration.

Within the body of the loop the underlying map may be modified via

  Sema::AddOverloadCandidate
- Sema::CompareReferenceRelationship
- Sema::RequireCompleteType

to avoid the use of invalid iterators the sequence is copied first.

A reliable, though large, test case is available - it will be reduced and
committed shortly.

Patch by Robert Muth. Review by myself, Nico Weber, and Rafael Espindola.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=166188r1=166187r2=166188view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Oct 18 11:57:32 2012
@@ -3700,8 +3700,14 @@
 
 // Try to complete the type we're converting to.
 if (!S.RequireCompleteType(Kind.getLocation(), DestType, 0)) {
-  DeclContext::lookup_iterator Con, ConEnd;
-  for (llvm::tie(Con, ConEnd) = S.LookupConstructors(DestRecordDecl);
+  DeclContext::lookup_iterator ConOrig, ConEndOrig;
+  llvm::tie(ConOrig, ConEndOrig) = S.LookupConstructors(DestRecordDecl);
+  // The container holding the constructors can under certain conditions
+  // be changed while iterating. To be safe we copy the lookup results
+  // to a new container.
+  SmallVectorNamedDecl*, 8 CopyOfCon(ConOrig, ConEndOrig);
+  for (SmallVectorNamedDecl*, 8::iterator
+ Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end();
Con != ConEnd; ++Con) {
 NamedDecl *D = *Con;
 DeclAccessPair FoundDecl = DeclAccessPair::make(D, D-getAccess());


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


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread David Blaikie
On Thu, Oct 18, 2012 at 9:22 AM, Robert Muth robe...@google.com wrote:
 On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com wrote:
 On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie dblai...@gmail.com wrote:
 On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com wrote:
 On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
 rafael.espind...@gmail.com wrote:
 On 15 October 2012 19:02, Robert Muth robe...@google.com wrote:
 No small test, sadly.
 I managed to cut a 10MB reproducer down to 2MB over 2h
 but no further.

 The testcase in the bug report is already a lot smaller than that.
 Running delta a bit more reduced it to the attached file, which I am
 sure can be reduced a bit more.

 The reproducer in the bug has a lot of problems, e.g.
 it is only a fragment - not valid C++ code.
 It is also not a very stable reproducers meaning changing the clang
 command line slightly
 will change clang's memory allocation enough that the bug does not get 
 triggered
 anymore and instead you get a compiler failure because the code is
 only a fragment.

 This stability issue would likely effect any test for this problem,
 even valgrind based ones.

 Having thought  about this a little more think the best way to
 approach the problem of invalidated iterators
 is not by adding tests each time we find one but by addressing it at a
 higher level, e.g. compiling clang or llvm in a
 special debug mode, linking in special debug versions of STL and
 llvm/ADT/ that will cause crashes more reliably.
 Apparently VS has a feature like that, c.f.
 http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid

 Fair point - Howard Hinnant started work on something like this for
 libc++ but it's not been finished yet (put on the back burner). MSVC's
 debug mode has really helped me on several occasions.

 Takumi (who runs most/all of the MSVC bots) - do any of your bots
 already run with MSVC's iterator debugging turned up/on? Would that be
 a reasonable task? ( interestingly: does it catch this bug)

 Without knowing much about how MSVC is accomplishing this,
 it probably relies on extra book keeping inside STL.

 That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
 you can't interoperate STL-using APIs built with differing IDLs, but
 they have some machinery that should usually give you a linker error
 if you try). Howard wanted to implement something that would not be
 ABI-changing and allow libraries with differing iterator debugging
 levels to interoperate in a best-effort manner. This meant using
 side-tables rather than in-structure bookkeeping.

 The container implicated here , DenseMap, is not an STL container,
 though, so some extra
 work would be required to make it fit the MSVC framework.

 Ah, right - yeah, there are ways to plug into it but it's work. We
 might consider implementing our own standalone version for this
 instead.

 Robert - while that would help stabilize the behavior, would it
 actually help catch this bug? Would it be possible for you to create a

 I am pretty sure it would catch this bug *reliably*, because
 the reproducer does add items to  DenseMap while iterating over it which
  invalidates the iterators de jure.

 That's all I'm interested in.

 But this invalidation only becomes visible when it is accompanied by a 
 resizing
 of the DenseMap and that seems to depend on the concrete program run, e.g.
 we can influence the resize trigger by changing the length of strings
 passed on clang command line.

 The visibility I don't mind about right now - that's an infrastructure
 problem we'll need to fix  I wouldn't gate your fix on that.

 What I'm interested in is a reproduction of invalid code according to
 DenseMap's contract, not its implementation. Basically a quick  dirty
 way to do this would be to raise some global flag around the loop in
 Sema::AddOverloadCandidate, then assert that that flag is not raised
 when things are added to the container in Sema::RequireCompleteType (I
 mention these two functions based on your analysis posted in the bug,
 not my own investigation). Then reduce to the simplest (hopefully
 valid) code that triggers the assert.

 You don't need/we won't commit this assert/flag, but we'll know that
 this case reliably violates the DenseMap contract  if/when we add
 some iterator invalidation checking we'll have a repro ready to go.


 David,

 I attached a set of llvm/clang patches to the bug that makes the
 failure reliable.

Thanks - they look roughly like what I had in mind. (I won't nitpick
them because they won't be committed - just a simple test hack)

 The patches  work with the existing reproducer (also attached).  A colleague 
 of
 mine is preparing a nicer reproducer which he will add to the bug
 once it is ready.

Sounds good.

 Since this activity is independent  of getting my fix into clang: are
 there any other reservations
 

Re: [cfe-commits] [PATCH] Optimize SourceManager::getColumnNumber to fix PR14106

2012-10-18 Thread Craig Topper
Sure, I can make that change. After that is it ok to commit?

On Thu, Oct 18, 2012 at 9:43 AM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 17, 2012, at 6:04 PM, Craig Topper craig.top...@gmail.com wrote:

  This patch uses the line number cache to find the start of the line
 instead of searching backwards for it. This helps performance in cases
 where the line is long and have just called getLineNumber for the same
 position.

 This only helps when the FilePos is exactly the same as the FilePos that
 went to getLineNumber:

 +  // See if we just calculated the line number for this FilePos and can
 use
 +  // that to lookup the start of the line instead of searching for it.
 +  if (LastLineNoFileIDQuery == FID  LastLineNoFilePos == (FilePos + 1))
 {

 Why not simply check that FilePos  SourceLineCache[LastLineNoResult - 1]
 and  SourceLineCache[LastLineNoResult], so anything on the
 most-recently-queried line can be handled efficiently?

 - Doug




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


Re: [cfe-commits] [PATCH] External Sema Source

2012-10-18 Thread Douglas Gregor

On Oct 11, 2012, at 8:02 AM, Vassil Vassilev vasil.georgiev.vasi...@cern.ch 
wrote:

 Hi,
 We need to attach multiple ExternalSources to Sema, to provide modules /and/ 
 last resort lookup. Right now that's a pain. The attached patch makes this 
 much easier, at (almost?) no runtime cost for the compiler. Okay to commit?

Yes, this looks fine to me.

- Doug


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


Re: [cfe-commits] [PATCH] Optimize SourceManager::getColumnNumber to fix PR14106

2012-10-18 Thread Douglas Gregor
Yes.

On Oct 18, 2012, at 10:02 AM, Craig Topper craig.top...@gmail.com wrote:

 Sure, I can make that change. After that is it ok to commit?
 
 On Thu, Oct 18, 2012 at 9:43 AM, Douglas Gregor dgre...@apple.com wrote:
 On Oct 17, 2012, at 6:04 PM, Craig Topper craig.top...@gmail.com wrote:
 
  This patch uses the line number cache to find the start of the line instead 
  of searching backwards for it. This helps performance in cases where the 
  line is long and have just called getLineNumber for the same position.
 
 This only helps when the FilePos is exactly the same as the FilePos that went 
 to getLineNumber:
 
 +  // See if we just calculated the line number for this FilePos and can use
 +  // that to lookup the start of the line instead of searching for it.
 +  if (LastLineNoFileIDQuery == FID  LastLineNoFilePos == (FilePos + 1)) {
 
 Why not simply check that FilePos  SourceLineCache[LastLineNoResult - 1] and 
  SourceLineCache[LastLineNoResult], so anything on the most-recently-queried 
 line can be handled efficiently?
 
 - Doug
 
 
 
 
 -- 
 ~Craig

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


Re: [cfe-commits] r165771 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Comment.h lib/AST/ASTContext.cpp lib/AST/Comment.cpp lib/AST/CommentSema.cpp test/Index/overriding-method-co

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 9:56 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 7:18 PM, Douglas Gregor dgre...@apple.com wrote:
 On Oct 18, 2012, at 5:03 AM, Dmitri Gribenko griboz...@gmail.com wrote:
 I think that cloneFullComment() is evil -- it breaks some assumptions
 about DeclInfo and does not properly introduce a concept of a comment
 being reused for a redeclaration.
 
 (1) DeclInfo is intended to be immutable once filled; here we are just
 replacing the original decl that provided all the information with
 some other declaration.  I see that it apparently did not break
 anything, but it is not the best solution.  Should we better keep two
 DeclInfos per FullComment?
 
 It's weird to be overwriting CommentDecl in cloneFullComment(), but I don't 
 think we need to have two DeclInfos per FullComment. The intent here is that 
 CommentDecl is the declaration to which the comment was actually attached 
 (in the source), and CurrentDecl would be the declaration with which the 
 FullComment is associated. The information in the DeclInfo corresponds to 
 CurrentDecl.
 
 I see now, thank you for the explanation.  Maybe improving comments or
 renaming CommentDecl/CurrentDecl could help to make this clear.
 
 I'm fine with splitting it into two functions. In general in the Clang ASTs, 
 we have getFoo() be the semantic property and we add a getFooAsWritten() 
 for the syntax as written. I suggest we do that.
 
 I agree.
 
 I think we should also deal with rewriting of \p. Yes, it means some lookup, 
 but it'll give a more consistent experience.
 
 My main concern is not the additional lookup (it is even useful -- we
 could catch more bugs in comments), but the fact that there are
 unannotated references to parameters, and sometimes both annotated and
 unannotated references in the same comment (some will get rewritten,
 some will not).

It's a very reasonable concern. Personally, I'm more interested in people being 
able to do the right thing (mark their parameters with \p), so they'll get 
proper documentation across all redeclarations/overrides even if the names have 
changed.

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


Re: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread Douglas Gregor

On Oct 17, 2012, at 2:58 PM, Fariborz Jahanian fjahan...@apple.com wrote:

 Author: fjahanian
 Date: Wed Oct 17 16:58:03 2012
 New Revision: 166130
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166130view=rev
 Log:
 [Doc parsing]: This patch adds Declaration tag to 
 XML comment for declarations which pretty-prints
 declaration. I had to XFAIL one test annotate-comments.cpp.
 This test is currently unmaintainable as written.
 Dmitri G., can you see what we can do about this test.
 We should change this test such that adding a new tag does not wreck
 havoc to the test.
 
 Modified:
cfe/trunk/bindings/xml/comment-xml-schema.rng
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
cfe/trunk/test/Index/annotate-comments.cpp
cfe/trunk/test/Index/overriding-ftemplate-comments.cpp
cfe/trunk/test/Index/overriding-method-comments.mm
cfe/trunk/tools/libclang/CXComment.cpp
 
 Modified: cfe/trunk/tools/libclang/CXComment.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=166130r1=166129r2=166130view=diff
 ==
 --- cfe/trunk/tools/libclang/CXComment.cpp (original)
 +++ cfe/trunk/tools/libclang/CXComment.cpp Wed Oct 17 16:58:03 2012
 @@ -16,6 +16,7 @@
 #include CXComment.h
 #include CXCursor.h
 
 +#include clang/AST/PrettyPrinter.h
 #include clang/AST/CommentVisitor.h
 #include clang/AST/CommentCommandTraits.h
 #include clang/AST/Decl.h
 @@ -1027,6 +1028,20 @@
   Result  /Verbatim;
 }
 
 +static StringRef getSourceTextOfDeclaration(const DeclInfo *ThisDecl) {
 +  
 +  ASTContext Context = ThisDecl-CurrentDecl-getASTContext();
 +  const LangOptions LangOpts = Context.getLangOpts();
 +  std::string SStr;
 +  llvm::raw_string_ostream S(SStr);
 +  PrintingPolicy PPolicy(LangOpts);
 +  PPolicy.SuppressAttributes = true;
 +  PPolicy.TerseOutput = true;
 +  ThisDecl-CurrentDecl-print(S, PPolicy,
 +   /*Indentation*/0, /*PrintInstantiation*/true);
 +  return S.str();
 +}

The declaration printer is going to need a lot of work. We'll need to have 
tests for essentially every kind of AST node.

- Doug


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


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Rafael Espíndola
I still think this should include a testcase.

On 18 October 2012 12:57, David Blaikie dblai...@gmail.com wrote:
 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188

 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.

 Within the body of the loop the underlying map may be modified via

   Sema::AddOverloadCandidate
 - Sema::CompareReferenceRelationship
 - Sema::RequireCompleteType

 to avoid the use of invalid iterators the sequence is copied first.

 A reliable, though large, test case is available - it will be reduced and
 committed shortly.

 Patch by Robert Muth. Review by myself, Nico Weber, and Rafael Espindola.

 Modified:
 cfe/trunk/lib/Sema/SemaInit.cpp

 Modified: cfe/trunk/lib/Sema/SemaInit.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=166188r1=166187r2=166188view=diff
 ==
 --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Oct 18 11:57:32 2012
 @@ -3700,8 +3700,14 @@

  // Try to complete the type we're converting to.
  if (!S.RequireCompleteType(Kind.getLocation(), DestType, 0)) {
 -  DeclContext::lookup_iterator Con, ConEnd;
 -  for (llvm::tie(Con, ConEnd) = S.LookupConstructors(DestRecordDecl);
 +  DeclContext::lookup_iterator ConOrig, ConEndOrig;
 +  llvm::tie(ConOrig, ConEndOrig) = S.LookupConstructors(DestRecordDecl);
 +  // The container holding the constructors can under certain conditions
 +  // be changed while iterating. To be safe we copy the lookup results
 +  // to a new container.
 +  SmallVectorNamedDecl*, 8 CopyOfCon(ConOrig, ConEndOrig);
 +  for (SmallVectorNamedDecl*, 8::iterator
 + Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end();
 Con != ConEnd; ++Con) {
  NamedDecl *D = *Con;
  DeclAccessPair FoundDecl = DeclAccessPair::make(D, D-getAccess());


 ___
 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: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread jahanian

On Oct 18, 2012, at 10:21 AM, Douglas Gregor dgre...@apple.com wrote:

 
 On Oct 17, 2012, at 2:58 PM, Fariborz Jahanian fjahan...@apple.com wrote:
 
 Author: fjahanian
 Date: Wed Oct 17 16:58:03 2012
 New Revision: 166130
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166130view=rev
 Log:
 [Doc parsing]: This patch adds Declaration tag to 
 XML comment for declarations which pretty-prints
 declaration. I had to XFAIL one test annotate-comments.cpp.
 This test is currently unmaintainable as written.
 Dmitri G., can you see what we can do about this test.
 We should change this test such that adding a new tag does not wreck
 havoc to the test.
 
 Modified:
   cfe/trunk/bindings/xml/comment-xml-schema.rng
   cfe/trunk/include/clang/AST/Comment.h
   cfe/trunk/include/clang/AST/PrettyPrinter.h
   cfe/trunk/lib/AST/Comment.cpp
   cfe/trunk/lib/AST/DeclPrinter.cpp
   cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
   cfe/trunk/test/Index/annotate-comments.cpp
   cfe/trunk/test/Index/overriding-ftemplate-comments.cpp
   cfe/trunk/test/Index/overriding-method-comments.mm
   cfe/trunk/tools/libclang/CXComment.cpp
 
 Modified: cfe/trunk/tools/libclang/CXComment.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=166130r1=166129r2=166130view=diff
 ==
 --- cfe/trunk/tools/libclang/CXComment.cpp (original)
 +++ cfe/trunk/tools/libclang/CXComment.cpp Wed Oct 17 16:58:03 2012
 @@ -16,6 +16,7 @@
 #include CXComment.h
 #include CXCursor.h
 
 +#include clang/AST/PrettyPrinter.h
 #include clang/AST/CommentVisitor.h
 #include clang/AST/CommentCommandTraits.h
 #include clang/AST/Decl.h
 @@ -1027,6 +1028,20 @@
  Result  /Verbatim;
 }
 
 +static StringRef getSourceTextOfDeclaration(const DeclInfo *ThisDecl) {
 +  
 +  ASTContext Context = ThisDecl-CurrentDecl-getASTContext();
 +  const LangOptions LangOpts = Context.getLangOpts();
 +  std::string SStr;
 +  llvm::raw_string_ostream S(SStr);
 +  PrintingPolicy PPolicy(LangOpts);
 +  PPolicy.SuppressAttributes = true;
 +  PPolicy.TerseOutput = true;
 +  ThisDecl-CurrentDecl-print(S, PPolicy,
 +   /*Indentation*/0, 
 /*PrintInstantiation*/true);
 +  return S.str();
 +}
 
 The declaration printer is going to need a lot of work. We'll need to have 
 tests for essentially every kind of AST node.

Yes, this is wip. Test annotate-comments.cpp already has many of them. I need 
to start writing unit tests. 
- Fariborz

 
   - Doug
 
 

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


[cfe-commits] r166192 - /cfe/trunk/include/clang/AST/Comment.h

2012-10-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Thu Oct 18 12:32:05 2012
New Revision: 166192

URL: http://llvm.org/viewvc/llvm-project?rev=166192view=rev
Log:
Improve comment in couple of fields of DeclInfo.


Modified:
cfe/trunk/include/clang/AST/Comment.h

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166192r1=166191r2=166192view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Oct 18 12:32:05 2012
@@ -902,11 +902,12 @@
 
 /// Information about the declaration, useful to clients of FullComment.
 struct DeclInfo {
-  /// Declaration the comment is attached to.  Should not be NULL.
+  /// Declaration the comment is actually attached to (in the source).
+  /// Should not be NULL.
   const Decl *CommentDecl;
   
-  /// CurrentDecl is the declaration for which comment is being put into an 
XML comment.
-  /// Not necessarily same as CommentDecl.
+  /// CurrentDecl is the declaration with which the FullComment is associated.
+  /// The information in the DeclInfo corresponds to CurrentDecl.
   const Decl *CurrentDecl;
   
   /// Parameters that can be referenced by \\param if \c CommentDecl is 
something


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


[cfe-commits] r166193 - /cfe/trunk/test/CodeGen/ms-inline-asm.c

2012-10-18 Thread Chad Rosier
Author: mcrosier
Date: Thu Oct 18 12:51:43 2012
New Revision: 166193

URL: http://llvm.org/viewvc/llvm-project?rev=166193view=rev
Log:
[ms-inline asm] Remove accidental commit.

Modified:
cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=166193r1=166192r2=166193view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Thu Oct 18 12:51:43 2012
@@ -114,20 +114,3 @@
 // CHECK: t12
 // CHECK: call void asm sideeffect inteldialect mov eax, $2\0A\09mov $0, 
eax\0A\09mov eax, $3\0A\09mov $1, eax, 
=*m,=*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}(i32* %{{.*}}, i32* %{{.*}}, 
i32* %{{.*}}, i32* %{{.*}}) nounwind
 }
-
-#if 0
-void t13() {
-  unsigned i = 1, j = 2;
-//  __asm mov eax, [ebx]
-//  __asm mov eax, [4*ecx]
-//  __asm mov eax, [4]
-//  __asm mov eax, [ebx + 4*ecx]
-//  __asm mov eax, [ebx + 4*ecx + 4]
-  __asm mov eax, [i]
-  __asm mov eax, [i + 4*ecx]
-  __asm mov eax, [i + 4*ecx + 4]
-  __asm mov eax, [4*i]
-  __asm mov eax, [ebx + 4*i]
-  __asm mov eax, [ebx + 4*i + 4]
-}
-#endif


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


[cfe-commits] r166194 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Sema/Sema.h lib/AST/ExprCXX.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaOverload.cpp lib/Serialization/ASTReaderStmt.cpp l

2012-10-18 Thread Richard Smith
Author: rsmith
Date: Thu Oct 18 12:56:02 2012
New Revision: 166194

URL: http://llvm.org/viewvc/llvm-project?rev=166194view=rev
Log:
DR1442: In a range-based for statement, namespace 'std' is not an associated
namespace.

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
cfe/trunk/test/CodeGenCXX/for-range.cpp
cfe/trunk/test/PCH/cxx-for-range.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=166194r1=166193r2=166194view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Oct 18 12:56:02 2012
@@ -2441,10 +2441,6 @@
   /// call.
   bool RequiresADL;
 
-  /// True if namespace ::std should be considered an associated namespace
-  /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1.
-  bool StdIsAssociatedNamespace;
-
   /// True if these lookup results are overloaded.  This is pretty
   /// trivially rederivable if we urgently need to kill this field.
   bool Overloaded;
@@ -2463,19 +2459,16 @@
const DeclarationNameInfo NameInfo,
bool RequiresADL, bool Overloaded,
const TemplateArgumentListInfo *TemplateArgs,
-   UnresolvedSetIterator Begin, UnresolvedSetIterator End,
-   bool StdIsAssociatedNamespace)
+   UnresolvedSetIterator Begin, UnresolvedSetIterator End)
 : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, TemplateKWLoc,
NameInfo, TemplateArgs, Begin, End, false, false, false),
   RequiresADL(RequiresADL),
-  StdIsAssociatedNamespace(StdIsAssociatedNamespace),
   Overloaded(Overloaded), NamingClass(NamingClass)
   {}
 
   UnresolvedLookupExpr(EmptyShell Empty)
 : OverloadExpr(UnresolvedLookupExprClass, Empty),
-  RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false),
-  NamingClass(0)
+  RequiresADL(false), Overloaded(false), NamingClass(0)
   {}
 
   friend class ASTStmtReader;
@@ -2487,14 +2480,10 @@
   const DeclarationNameInfo NameInfo,
   bool ADL, bool Overloaded,
   UnresolvedSetIterator Begin,
-  UnresolvedSetIterator End,
-  bool StdIsAssociatedNamespace = false) {
-assert((ADL || !StdIsAssociatedNamespace) 
-   std considered associated namespace when not performing ADL);
+  UnresolvedSetIterator End) {
 return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc,
SourceLocation(), NameInfo,
-   ADL, Overloaded, 0, Begin, End,
-   StdIsAssociatedNamespace);
+   ADL, Overloaded, 0, Begin, End);
   }
 
   static UnresolvedLookupExpr *Create(ASTContext C,
@@ -2515,10 +2504,6 @@
   /// argument-dependent lookup.
   bool requiresADL() const { return RequiresADL; }
 
-  /// True if namespace \::std should be artificially added to the set of
-  /// associated namespaces for argument-dependent lookup purposes.
-  bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; }
-
   /// True if this lookup is overloaded.
   bool isOverloaded() const { return Overloaded; }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=166194r1=166193r2=166194view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 18 12:56:02 2012
@@ -1894,8 +1894,7 @@
 llvm::ArrayRefExpr * Args,
 TemplateArgumentListInfo *ExplicitTemplateArgs,
 OverloadCandidateSet CandidateSet,
-bool PartialOverloading = false,
-bool StdNamespaceIsAssociated = false);
+bool PartialOverloading = false);
 
   // Emit as a 'note' the specific overload candidate
   void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType = QualType());
@@ -2188,8 +2187,7 @@
   void ArgumentDependentLookup(DeclarationName Name, bool Operator,

[cfe-commits] r166195 - in /cfe/trunk: include/clang/Serialization/ASTBitCodes.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 12:58:09 2012
New Revision: 166195

URL: http://llvm.org/viewvc/llvm-project?rev=166195view=rev
Log:
Split the target options out into their own record within the AST
file's control block.

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

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=166195r1=166194r2=166195view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 18 12:58:09 2012
@@ -242,20 +242,23 @@
   /// actually important to check.
   LANGUAGE_OPTIONS = 3,
 
+  /// \brief Record code for the target options table.
+  TARGET_OPTIONS = 4,
+
   /// \brief Record code for the original file that was used to
   /// generate the AST file.
-  ORIGINAL_FILE_NAME = 4,
+  ORIGINAL_FILE_NAME = 5,
 
   /// \brief Record code for the file ID of the original file used to 
   /// generate the AST file.
-  ORIGINAL_FILE_ID = 5,
+  ORIGINAL_FILE_ID = 6,
   
   /// \brief The directory that the PCH was originally created in.
-  ORIGINAL_PCH_DIR = 6,
+  ORIGINAL_PCH_DIR = 7,
 
   /// \brief Record code for the version control branch and revision
   /// information of the compiler used to build this AST file.
-  VERSION_CONTROL_BRANCH_REVISION = 7
+  VERSION_CONTROL_BRANCH_REVISION = 8
 };
 
 /// \brief Record types that occur within the AST block itself.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166195r1=166194r2=166195view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 12:58:09 2012
@@ -1800,24 +1800,6 @@
   }
 
   RelocatablePCH = Record[4];
-  if (Listener  F == *ModuleMgr.begin()) {
-unsigned Idx = 6;
-TargetOptions TargetOpts;
-TargetOpts.Triple = ReadString(Record, Idx);
-TargetOpts.CPU = ReadString(Record, Idx);
-TargetOpts.ABI = ReadString(Record, Idx);
-TargetOpts.CXXABI = ReadString(Record, Idx);
-TargetOpts.LinkerVersion = ReadString(Record, Idx);
-for (unsigned N = Record[Idx++]; N; --N) {
-  TargetOpts.FeaturesAsWritten.push_back(ReadString(Record, Idx));
-}
-for (unsigned N = Record[Idx++]; N; --N) {
-  TargetOpts.Features.push_back(ReadString(Record, Idx));
-}
-
-if (Listener-ReadTargetOptions(F, TargetOpts))
-  return IgnorePCH;
-  }
   break;
 }
 
@@ -1849,6 +1831,28 @@
 return IgnorePCH;
   break;
 
+case TARGET_OPTIONS: {
+  if (Listener  F == *ModuleMgr.begin()) {
+unsigned Idx = 0;
+TargetOptions TargetOpts;
+TargetOpts.Triple = ReadString(Record, Idx);
+TargetOpts.CPU = ReadString(Record, Idx);
+TargetOpts.ABI = ReadString(Record, Idx);
+TargetOpts.CXXABI = ReadString(Record, Idx);
+TargetOpts.LinkerVersion = ReadString(Record, Idx);
+for (unsigned N = Record[Idx++]; N; --N) {
+  TargetOpts.FeaturesAsWritten.push_back(ReadString(Record, Idx));
+}
+for (unsigned N = Record[Idx++]; N; --N) {
+  TargetOpts.Features.push_back(ReadString(Record, Idx));
+}
+
+if (Listener-ReadTargetOptions(F, TargetOpts))
+  return IgnorePCH;
+  }
+  break;
+}
+
 case ORIGINAL_FILE_NAME:
   // Only record from the primary AST file.
   if (F == *ModuleMgr.begin()) {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=166195r1=166194r2=166195view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 18 12:58:09 2012
@@ -994,19 +994,6 @@
   Record.push_back(CLANG_VERSION_MINOR);
   Record.push_back(!isysroot.empty());
   Record.push_back(ASTHasCompilerErrors);
-  AddString(TargetOpts.Triple, Record);
-  AddString(TargetOpts.CPU, Record);
-  AddString(TargetOpts.ABI, Record);
-  AddString(TargetOpts.CXXABI, Record);
-  AddString(TargetOpts.LinkerVersion, Record);
-  Record.push_back(TargetOpts.FeaturesAsWritten.size());
-  for (unsigned I = 0, N = TargetOpts.FeaturesAsWritten.size(); I != N; ++I) {
-AddString(TargetOpts.FeaturesAsWritten[I], Record);
-  }
-  Record.push_back(TargetOpts.Features.size());
-  for (unsigned I = 0, N = 

Re: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread Dmitri Gribenko
On Thu, Oct 18, 2012 at 8:25 PM, jahanian fjahan...@apple.com wrote:

 On Oct 18, 2012, at 10:21 AM, Douglas Gregor dgre...@apple.com wrote:
 The declaration printer is going to need a lot of work. We'll need to have 
 tests for essentially every kind of AST node.

 Yes, this is wip. Test annotate-comments.cpp already has many of them. I need 
 to start writing unit tests.

Just wanted to point out that for decl printer tests I started
unittests/AST/DeclPrinterTest.cpp so that we can test decl printer
directly without going through comment machinery.  (And producing
unmaintainable tests like annotate-comments.cpp.)

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: [cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/anno

2012-10-18 Thread jahanian

On Oct 18, 2012, at 11:01 AM, Dmitri Gribenko griboz...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 8:25 PM, jahanian fjahan...@apple.com wrote:
 
 On Oct 18, 2012, at 10:21 AM, Douglas Gregor dgre...@apple.com wrote:
 The declaration printer is going to need a lot of work. We'll need to have 
 tests for essentially every kind of AST node.
 
 Yes, this is wip. Test annotate-comments.cpp already has many of them. I 
 need to start writing unit tests.
 
 Just wanted to point out that for decl printer tests I started
 unittests/AST/DeclPrinterTest.cpp so that we can test decl printer
 directly without going through comment machinery.  (And producing
 unmaintainable tests like annotate-comments.cpp.)

Great to know. I will look into it. Thanks.
- fariborz

 
 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


[cfe-commits] r166202 - /cfe/trunk/include/clang/AST/Comment.h

2012-10-18 Thread Dmitri Gribenko
Author: gribozavr
Date: Thu Oct 18 13:18:26 2012
New Revision: 166202

URL: http://llvm.org/viewvc/llvm-project?rev=166202view=rev
Log:
Expand the comment for DeclInfo::CurrentDecl.

Modified:
cfe/trunk/include/clang/AST/Comment.h

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166202r1=166201r2=166202view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Oct 18 13:18:26 2012
@@ -907,6 +907,12 @@
   const Decl *CommentDecl;
   
   /// CurrentDecl is the declaration with which the FullComment is associated.
+  ///
+  /// It can be different from \c CommentDecl.  It happens when we we decide
+  /// that the comment originally attached to \c CommentDecl is fine for
+  /// \c CurrentDecl too (for example, for a redeclaration or an overrider of
+  /// \c CommentDecl).
+  ///
   /// The information in the DeclInfo corresponds to CurrentDecl.
   const Decl *CurrentDecl;
   


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


[cfe-commits] r166203 - /cfe/trunk/include/clang/AST/Comment.h

2012-10-18 Thread Dmitri Gribenko
Author: gribozavr
Date: Thu Oct 18 13:21:40 2012
New Revision: 166203

URL: http://llvm.org/viewvc/llvm-project?rev=166203view=rev
Log:
Fix more documentation comments in Comment.h

Modified:
cfe/trunk/include/clang/AST/Comment.h

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166203r1=166202r2=166203view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Oct 18 13:21:40 2012
@@ -981,7 +981,7 @@
   /// If false, only \c CommentDecl is valid.
   unsigned IsFilled : 1;
 
-  /// Simplified kind of \c CommentDecl, see\c DeclKind enum.
+  /// Simplified kind of \c CommentDecl, see \c DeclKind enum.
   unsigned Kind : 3;
 
   /// Is \c CommentDecl a template declaration.
@@ -990,7 +990,7 @@
   /// Is \c CommentDecl an ObjCMethodDecl.
   unsigned IsObjCMethod : 1;
 
-  /// Is \c ThisDecl a non-static member function of C++ class or
+  /// Is \c CommentDecl a non-static member function of C++ class or
   /// instance method of ObjC class.
   /// Can be true only if \c IsFunctionDecl is true.
   unsigned IsInstanceMethod : 1;


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


[cfe-commits] r166204 - in /cfe/trunk: include/clang/Serialization/ASTBitCodes.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 13:27:37 2012
New Revision: 166204

URL: http://llvm.org/viewvc/llvm-project?rev=166204view=rev
Log:
Collapse the version control revision/tag AST file record into the
metadata record, which already had other version information. Clean up
the block info block along the way.

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

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=166204r1=166203r2=166204view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 18 13:27:37 2012
@@ -227,7 +227,7 @@
 /// \brief Record types that occur within the control block.
 enum ControlRecordTypes {
   /// \brief AST file metadata, including the AST file version number
-  /// and the target triple used to build the AST file.
+  /// and information about the compiler used to build this AST file.
   METADATA = 1,
 
   /// \brief Record code for the list of other AST files imported by
@@ -254,11 +254,7 @@
   ORIGINAL_FILE_ID = 6,
   
   /// \brief The directory that the PCH was originally created in.
-  ORIGINAL_PCH_DIR = 7,
-
-  /// \brief Record code for the version control branch and revision
-  /// information of the compiler used to build this AST file.
-  VERSION_CONTROL_BRANCH_REVISION = 8
+  ORIGINAL_PCH_DIR = 7
 };
 
 /// \brief Record types that occur within the AST block itself.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166204r1=166203r2=166204view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 13:27:37 2012
@@ -1800,6 +1800,13 @@
   }
 
   RelocatablePCH = Record[4];
+
+  const std::string CurBranch = getClangFullRepositoryVersion();
+  StringRef ASTBranch(BlobStart, BlobLen);
+  if (StringRef(CurBranch) != ASTBranch  !DisableValidation) {
+Diag(diag::warn_pch_different_branch)  ASTBranch  CurBranch;
+return IgnorePCH;
+  }
   break;
 }
 
@@ -1877,16 +1884,6 @@
 OriginalDir.assign(BlobStart, BlobLen);
   }
   break;
-
-case VERSION_CONTROL_BRANCH_REVISION: {
-  const std::string CurBranch = getClangFullRepositoryVersion();
-  StringRef ASTBranch(BlobStart, BlobLen);
-  if (StringRef(CurBranch) != ASTBranch  !DisableValidation) {
-Diag(diag::warn_pch_different_branch)  ASTBranch  CurBranch;
-return IgnorePCH;
-  }
-  break;
-}
 }
   }
 
@@ -3069,7 +3066,7 @@
 
 unsigned BlockID = Stream.ReadSubBlockID();
 
-// We only know the AST subblock ID.
+// We only know the control subblock ID.
 switch (BlockID) {
 case llvm::bitc::BLOCKINFO_BLOCK_ID:
   if (Stream.ReadBlockInfoBlock()) {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=166204r1=166203r2=166204view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 18 13:27:37 2012
@@ -767,14 +767,20 @@
 #define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
 #define RECORD(X) EmitRecordID(X, #X, Stream, Record)
 
-  // AST Top-Level Block.
-  BLOCK(AST_BLOCK);
+  // Control Block.
+  BLOCK(CONTROL_BLOCK);
+  RECORD(METADATA);
+  RECORD(IMPORTS);
+  RECORD(LANGUAGE_OPTIONS);
+  RECORD(TARGET_OPTIONS);
   RECORD(ORIGINAL_FILE_NAME);
   RECORD(ORIGINAL_FILE_ID);
+  RECORD(ORIGINAL_PCH_DIR);
+
+  // AST Top-Level Block.
+  BLOCK(AST_BLOCK);
   RECORD(TYPE_OFFSET);
   RECORD(DECL_OFFSET);
-  RECORD(LANGUAGE_OPTIONS);
-  RECORD(METADATA);
   RECORD(IDENTIFIER_OFFSET);
   RECORD(IDENTIFIER_TABLE);
   RECORD(EXTERNAL_DEFINITIONS);
@@ -790,9 +796,7 @@
   RECORD(SOURCE_LOCATION_PRELOADS);
   RECORD(STAT_CACHE);
   RECORD(EXT_VECTOR_DECLS);
-  RECORD(VERSION_CONTROL_BRANCH_REVISION);
   RECORD(PPD_ENTITIES_OFFSETS);
-  RECORD(IMPORTS);
   RECORD(REFERENCED_SELECTOR_POOL);
   RECORD(TU_UPDATE_LEXICAL);
   RECORD(LOCAL_REDECLARATIONS_MAP);
@@ -807,7 +811,6 @@
   RECORD(DIAG_PRAGMA_MAPPINGS);
   RECORD(CUDA_SPECIAL_DECL_REFS);
   RECORD(HEADER_SEARCH_TABLE);
-  RECORD(ORIGINAL_PCH_DIR);
   RECORD(FP_PRAGMA_OPTIONS);
   RECORD(OPENCL_EXTENSIONS);
   RECORD(DELEGATING_CTORS);
@@ -982,19 +985,29 @@
 void ASTWriter::WriteControlBlock(ASTContext Context, StringRef isysroot,
   

[cfe-commits] r166206 - in /cfe/trunk: include/clang/Serialization/ASTBitCodes.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 13:36:53 2012
New Revision: 166206

URL: http://llvm.org/viewvc/llvm-project?rev=166206view=rev
Log:
Collapse the original file name and original file ID records into a
single record. 

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

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=166206r1=166205r2=166206view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 18 13:36:53 2012
@@ -246,15 +246,12 @@
   TARGET_OPTIONS = 4,
 
   /// \brief Record code for the original file that was used to
-  /// generate the AST file.
-  ORIGINAL_FILE_NAME = 5,
-
-  /// \brief Record code for the file ID of the original file used to 
-  /// generate the AST file.
-  ORIGINAL_FILE_ID = 6,
+  /// generate the AST file, including both its file ID and its
+  /// name.
+  ORIGINAL_FILE = 5,
   
   /// \brief The directory that the PCH was originally created in.
-  ORIGINAL_PCH_DIR = 7
+  ORIGINAL_PCH_DIR = 6
 };
 
 /// \brief Record types that occur within the AST block itself.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166206r1=166205r2=166206view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 13:36:53 2012
@@ -1860,24 +1860,17 @@
   break;
 }
 
-case ORIGINAL_FILE_NAME:
+case ORIGINAL_FILE:
   // Only record from the primary AST file.
   if (F == *ModuleMgr.begin()) {
-// The primary AST will be the last to get here, so it will be the one
-// that's used.
+OriginalFileID = FileID::get(Record[0]);
+
 ActualOriginalFileName.assign(BlobStart, BlobLen);
 OriginalFileName = ActualOriginalFileName;
 MaybeAddSystemRootToFilename(OriginalFileName);
   }
   break;
 
-case ORIGINAL_FILE_ID:
-  // Only record from the primary AST file.
-  if (F == *ModuleMgr.begin()) {
-OriginalFileID = FileID::get(Record[0]);
-  }
-  break;
-
 case ORIGINAL_PCH_DIR:
   // Only record from the primary AST file.
   if (F == *ModuleMgr.begin()) {
@@ -3323,8 +3316,7 @@
 Record.clear();
 const char *BlobStart = 0;
 unsigned BlobLen = 0;
-if (Stream.ReadRecord(Code, Record, BlobStart, BlobLen)
-  == ORIGINAL_FILE_NAME)
+if (Stream.ReadRecord(Code, Record, BlobStart, BlobLen) == ORIGINAL_FILE)
   return std::string(BlobStart, BlobLen);
   }
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=166206r1=166205r2=166206view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 18 13:36:53 2012
@@ -773,8 +773,7 @@
   RECORD(IMPORTS);
   RECORD(LANGUAGE_OPTIONS);
   RECORD(TARGET_OPTIONS);
-  RECORD(ORIGINAL_FILE_NAME);
-  RECORD(ORIGINAL_FILE_ID);
+  RECORD(ORIGINAL_FILE);
   RECORD(ORIGINAL_PCH_DIR);
 
   // AST Top-Level Block.
@@ -1070,7 +1069,8 @@
   SourceManager SM = Context.getSourceManager();
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
 BitCodeAbbrev *FileAbbrev = new BitCodeAbbrev();
-FileAbbrev-Add(BitCodeAbbrevOp(ORIGINAL_FILE_NAME));
+FileAbbrev-Add(BitCodeAbbrevOp(ORIGINAL_FILE));
+FileAbbrev-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
 FileAbbrev-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
 unsigned FileAbbrevCode = Stream.EmitAbbrev(FileAbbrev);
 
@@ -1082,12 +1082,10 @@
 MainFileNameStr = adjustFilenameForRelocatablePCH(MainFileNameStr,
   isysroot);
 RecordData Record;
-Record.push_back(ORIGINAL_FILE_NAME);
+Record.push_back(ORIGINAL_FILE);
+Record.push_back(SM.getMainFileID().getOpaqueValue());
 Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr);
-
 Record.clear();
-Record.push_back(SM.getMainFileID().getOpaqueValue());
-Stream.EmitRecord(ORIGINAL_FILE_ID, Record);
   }
 
   // Original PCH directory


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


Re: [cfe-commits] r166190 - /cfe/trunk/test/Index/annotate-comments.cpp

2012-10-18 Thread Dmitri Gribenko
On Thu, Oct 18, 2012 at 8:19 PM, Fariborz Jahanian fjahan...@apple.com wrote:
 Author: fjahanian
 Date: Thu Oct 18 12:19:41 2012
 New Revision: 166190

 URL: http://llvm.org/viewvc/llvm-project?rev=166190view=rev
 Log:
 Fix this test to match recent addition of declaration tag.

Thank you!

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


[cfe-commits] [PATCH] c++11 type attribute fix

2012-10-18 Thread Michael Han
Hi,

This patch enables Clang to apply C++11 attributes present after declaration 
specifiers to types instead of declarators, and warn on attributes that appear 
at wrong place (like carries_dependency which can't be applied to types). 
Please review, thanks!

Michael


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


[cfe-commits] r166208 - in /cfe/trunk: include/clang/Sema/MultiplexExternalSemaSource.h include/clang/Sema/Sema.h lib/Sema/CMakeLists.txt lib/Sema/MultiplexExternalSemaSource.cpp lib/Sema/Sema.cpp lib

2012-10-18 Thread Axel Naumann
Author: axel
Date: Thu Oct 18 14:05:02 2012
New Revision: 166208

URL: http://llvm.org/viewvc/llvm-project?rev=166208view=rev
Log:
From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.

Added:
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h   (with props)
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/CMakeLists.txt
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Added: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h?rev=166208view=auto
==
--- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h (added)
+++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h Thu Oct 18 
14:05:02 2012
@@ -0,0 +1,367 @@
+//===--- MultiplexExternalSemaSource.h - External Sema Interface-*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines ExternalSemaSource interface, dispatching to all clients
+//
+//===--===//
+#ifndef LLVM_CLANG_SEMA_MULTIPLEX_EXTERNAL_SEMA_SOURCE_H
+#define LLVM_CLANG_SEMA_MULTIPLEX_EXTERNAL_SEMA_SOURCE_H
+
+#include clang/Sema/ExternalSemaSource.h
+#include clang/Sema/Weak.h
+
+#include llvm/ADT/SmallVector.h
+
+#include utility
+
+namespace clang {
+
+  class CXXConstructorDecl;
+  class CXXRecordDecl;
+  class DeclaratorDecl;
+  struct ExternalVTableUse;
+  class LookupResult;
+  class NamespaceDecl;
+  class Scope;
+  class Sema;
+  class TypedefNameDecl;
+  class ValueDecl;
+  class VarDecl;
+
+
+/// \brief An abstract interface that should be implemented by
+/// external AST sources that also provide information for semantic
+/// analysis.
+class MultiplexExternalSemaSource : public ExternalSemaSource {
+
+private:
+  llvm::SmallVectorExternalSemaSource*, 2 Sources; // doesn't own them.
+
+public:
+  
+  ///\brief Constructs a new multiplexing external sema source and appends the
+  /// given element to it.
+  ///
+  ///\param[in] s1 - A non-null (old) ExternalSemaSource.
+  ///\param[in] s2 - A non-null (new) ExternalSemaSource.
+  ///
+  MultiplexExternalSemaSource(ExternalSemaSource s1, ExternalSemaSource s2);
+
+  ~MultiplexExternalSemaSource();
+
+  ///\brief Appends new source to the source list.
+  ///
+  ///\param[in] source - An ExternalSemaSource.
+  ///
+  void addSource(ExternalSemaSource source);
+
+  
//======//
+  // ExternalASTSource.
+  
//======//
+
+  /// \brief Resolve a declaration ID into a declaration, potentially
+  /// building a new declaration.
+  ///
+  /// This method only needs to be implemented if the AST source ever
+  /// passes back decl sets as VisibleDeclaration objects.
+  ///
+  /// The default implementation of this method is a no-op.
+  virtual Decl *GetExternalDecl(uint32_t ID);
+
+  /// \brief Resolve a selector ID into a selector.
+  ///
+  /// This operation only needs to be implemented if the AST source
+  /// returns non-zero for GetNumKnownSelectors().
+  ///
+  /// The default implementation of this method is a no-op.
+  virtual Selector GetExternalSelector(uint32_t ID);
+
+  /// \brief Returns the number of selectors known to the external AST
+  /// source.
+  ///
+  /// The default implementation of this method is a no-op.
+  virtual uint32_t GetNumExternalSelectors();
+
+  /// \brief Resolve the offset of a statement in the decl stream into
+  /// a statement.
+  ///
+  /// This operation is meant to be used via a LazyOffsetPtr.  It only
+  /// needs to be implemented if the AST source uses methods like
+  /// FunctionDecl::setLazyBody when building decls.
+  ///
+  /// The default implementation of this method is a no-op.
+  virtual Stmt *GetExternalDeclStmt(uint64_t Offset);
+
+  /// \brief Resolve the offset of a set of C++ base specifiers in the decl
+  /// stream into an array of specifiers.
+  ///
+  /// The default implementation of this method is a no-op.
+  virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
+
+  /// \brief Finds all declarations with the given name in the
+  /// given context.
+  ///
+  /// Generally the final step of this method is either to call
+  /// SetExternalVisibleDeclsForName or to recursively call lookup on
+  /// the DeclContext after calling SetExternalVisibleDecls.
+  

[cfe-commits] r166211 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp test/Analysis/objc_invalidation.m

2012-10-18 Thread Anna Zaks
Author: zaks
Date: Thu Oct 18 14:17:57 2012
New Revision: 166211

URL: http://llvm.org/viewvc/llvm-project?rev=166211view=rev
Log:
[analyzer] Ivar invalidation: identify properties declared in protocols.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
cfe/trunk/test/Analysis/objc_invalidation.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp?rev=166211r1=166210r2=166211view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp Thu Oct 
18 14:17:57 2012
@@ -327,10 +327,13 @@
   MethToIvarMapTy PropGetterToIvarMap;
   PropToIvarMapTy PropertyToIvarMap;
   IvarToPropMapTy IvarToPopertyMap;
-  for (ObjCInterfaceDecl::prop_iterator
-  I = InterfaceD-prop_begin(),
-  E = InterfaceD-prop_end(); I != E; ++I) {
-const ObjCPropertyDecl *PD = *I;
+
+  ObjCInterfaceDecl::PropertyMap PropMap;
+  InterfaceD-collectPropertiesToImplement(PropMap);
+
+  for (ObjCInterfaceDecl::PropertyMap::iterator
+  I = PropMap.begin(), E = PropMap.end(); I != E; ++I) {
+const ObjCPropertyDecl *PD = I-second;
 
 const ObjCIvarDecl *ID = findPropertyBackingIvar(PD, InterfaceD, Ivars);
 if (!ID) {
@@ -386,7 +389,8 @@
 const ObjCPropertyDecl *PD = IvarToPopertyMap[IvarDecl];
 assert(PD 
Do we synthesize ivars for something other than properties?);
-os  Property  PD-getName()   needs to be invalidated;
+os  Property  PD-getName() 
+   needs to be invalidated or set to nil;
   } else {
 os  Instance variable  IvarDecl-getName()
needs to be invalidated or set to nil;

Modified: cfe/trunk/test/Analysis/objc_invalidation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc_invalidation.m?rev=166211r1=166210r2=166211view=diff
==
--- cfe/trunk/test/Analysis/objc_invalidation.m (original)
+++ cfe/trunk/test/Analysis/objc_invalidation.m Thu Oct 18 14:17:57 2012
@@ -63,6 +63,7 @@
   SomeInvalidationImplementingObject *_Prop3; // property, invalidate via 
sending a message to a getter method
   SomeInvalidationImplementingObject *_Prop4; // property with @synthesize, 
invalidate via property
   SomeInvalidationImplementingObject *_Prop5; // property with @synthesize, 
invalidate via getter method
+  SomeInvalidationImplementingObject *_Prop8;
   
   // No warnings on these as they are not invalidatable.
   NSObject *NIvar1;
@@ -106,6 +107,7 @@
 @synthesize Prop3 = _Prop3;
 @synthesize Prop5 = _Prop5;
 @synthesize Prop4 = _Prop4;
+@synthesize Prop8 = _Prop8;
 
 
 - (void) setProp1: (SomeInvalidationImplementingObject*) InObj {
@@ -133,6 +135,7 @@
[self setProp3:0];
[[self Prop5] invalidate2];
[self.Prop4 invalidate];
+   [self.Prop8 invalidate];
self.Prop6 = 0;
[[self Prop7] invalidate];
 
@@ -143,9 +146,8 @@
 // expected-warning@-1 {{Instance variable Ivar1 needs to be invalidated}}
  // expected-warning@-2 {{Instance variable MultipleProtocols needs to be 
invalidated}}
  // expected-warning@-3 {{Instance variable MultInheritance needs to be 
invalidated}}
- // expected-warning@-4 {{Property SynthIvarProp needs to be invalidated}}
+ // expected-warning@-4 {{Property SynthIvarProp needs to be invalidated or 
set to nil}}
  // expected-warning@-5 {{Instance variable _Ivar3 needs to be invalidated}}
  // expected-warning@-6 {{Instance variable _Ivar4 needs to be invalidated}}
  // expected-warning@-7 {{Instance variable Ivar5 needs to be invalidated or 
set to nil}}
- // expected-warning@-8 {{Property Prop8 needs to be invalidated}}
 @end


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


[cfe-commits] r166210 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaObjCProperty.cpp

2012-10-18 Thread Anna Zaks
Author: zaks
Date: Thu Oct 18 14:17:53 2012
New Revision: 166210

URL: http://llvm.org/viewvc/llvm-project?rev=166210view=rev
Log:
Factor CollectClassPropertyImplementations out of Sema into AST

This would make it possible for the analyzer to use the function.

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=166210r1=166209r2=166210view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Oct 18 14:17:53 2012
@@ -541,6 +541,12 @@
 
   ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
 
+  typedef llvm::DenseMapIdentifierInfo *, ObjCPropertyDecl* PropertyMap;
+
+  /// This routine collects list of properties to be implemented in the class.
+  /// This includes, class's and its conforming protocols' properties.
+  virtual void collectPropertiesToImplement(PropertyMap PM) const {}
+
   SourceLocation getAtStartLoc() const { return AtStart; }
   void setAtStartLoc(SourceLocation Loc) { AtStart = Loc; }
 
@@ -900,6 +906,8 @@
   ObjCPropertyDecl
 *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const;
 
+  virtual void collectPropertiesToImplement(PropertyMap PM) const;
+
   /// isSuperClassOf - Return true if this class is the specified class or is a
   /// super class of the specified interface class.
   bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
@@ -1294,6 +1302,8 @@
 return getFirstDeclaration();
   }
 
+  virtual void collectPropertiesToImplement(PropertyMap PM) const;
+
   static bool classof(const Decl *D) { return classofKind(D-getKind()); }
   static bool classofKind(Kind K) { return K == ObjCProtocol; }
 

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=166210r1=166209r2=166210view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Oct 18 14:17:53 2012
@@ -190,6 +190,18 @@
   return 0;
 }
 
+void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap PM) const {
+  for (ObjCContainerDecl::prop_iterator P = prop_begin(),
+  E = prop_end(); P != E; ++P) {
+ObjCPropertyDecl *Prop = *P;
+PM[Prop-getIdentifier()] = Prop;
+  }
+  for (ObjCInterfaceDecl::all_protocol_iterator
+  PI = all_referenced_protocol_begin(),
+  E = all_referenced_protocol_end(); PI != E; ++PI)
+(*PI)-collectPropertiesToImplement(PM);
+}
+
 void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
   ObjCProtocolDecl *const* ExtList, unsigned 
ExtNum,
   ASTContext C)
@@ -1313,6 +1325,20 @@
 RD-Data = this-Data;
 }
 
+void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap PM) const {
+  for (ObjCProtocolDecl::prop_iterator P = prop_begin(),
+  E = prop_end(); P != E; ++P) {
+ObjCPropertyDecl *Prop = *P;
+// Insert into PM if not there already.
+PM.insert(std::make_pair(Prop-getIdentifier(), Prop));
+  }
+  // Scan through protocol's protocols.
+  for (ObjCProtocolDecl::protocol_iterator PI = protocol_begin(),
+  E = protocol_end(); PI != E; ++PI)
+(*PI)-collectPropertiesToImplement(PM);
+}
+
+
 
//===--===//
 // ObjCCategoryDecl
 
//===--===//

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=166210r1=166209r2=166210view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Oct 18 14:17:53 2012
@@ -1435,8 +1435,8 @@
 /// CollectImmediateProperties - This routine collects all properties in
 /// the class and its conforming protocols; but not those it its super class.
 void Sema::CollectImmediateProperties(ObjCContainerDecl *CDecl,
-llvm::DenseMapIdentifierInfo *, ObjCPropertyDecl* PropMap,
-llvm::DenseMapIdentifierInfo *, ObjCPropertyDecl* SuperPropMap) 
{
+ObjCContainerDecl::PropertyMap PropMap,
+ObjCContainerDecl::PropertyMap SuperPropMap) {
   if (ObjCInterfaceDecl *IDecl = dyn_castObjCInterfaceDecl(CDecl)) {
 for (ObjCContainerDecl::prop_iterator P = IDecl-prop_begin(),
  E = IDecl-prop_end(); P != E; ++P) {
@@ -1482,44 +1482,14 @@
   }
 }
 
-/// CollectClassPropertyImplementations - This routine collects list of
-/// properties to be implemented in the class. This includes, class's
-/// and its conforming 

[cfe-commits] r166213 - /cfe/trunk/lib/Sema/SemaStmtAsm.cpp

2012-10-18 Thread Chad Rosier
Author: mcrosier
Date: Thu Oct 18 14:39:37 2012
New Revision: 166213

URL: http://llvm.org/viewvc/llvm-project?rev=166213view=rev
Log:
[ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return a
*NamedDecl.  In turn, build the expressions after we're finished parsing the
asm.  This avoids a crasher if the lookup fails.

Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=166213r1=166212r2=166213view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Oct 18 14:39:37 2012
@@ -367,19 +367,10 @@
   MCAsmParserSemaCallbackImpl(class Sema *Ref) { SemaRef = Ref; }
   ~MCAsmParserSemaCallbackImpl() {}
 
-  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc,
-  void **IdentifierInfoPtr) {
+  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc) {
 SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc);
 NamedDecl *OpDecl = SemaRef-LookupInlineAsmIdentifier(Name, Loc);
-DeclarationNameInfo NameInfo(OpDecl-getDeclName(), Loc);
-ExprResult OpExpr = SemaRef-BuildDeclarationNameExpr(CXXScopeSpec(),
-  NameInfo,
-  OpDecl);
-if (OpExpr.isInvalid())
-  return 0;
-
-*IdentifierInfoPtr = static_castvoid*(OpDecl-getIdentifier());
-return static_castvoid *(OpExpr.take());
+return static_castvoid *(OpDecl);
   }
 };
 
@@ -468,14 +459,13 @@
   unsigned NumOutputs;
   unsigned NumInputs;
   std::string AsmStringIR;
-  SmallVectorvoid *, 4 VoidNames;
+  SmallVectorvoid *, 4 OpDecls;
   SmallVectorstd::string, 4 Constraints;
-  SmallVectorvoid *, 4 VoidExprs;
   SmallVectorstd::string, 4 Clobbers;
   MCAsmParserSemaCallbackImpl MCAPSI(this);
   if (Parser-ParseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR,
-   NumOutputs, NumInputs, VoidNames, Constraints,
-   VoidExprs, Clobbers, MII, IP, MCAPSI))
+   NumOutputs, NumInputs, OpDecls, Constraints,
+   Clobbers, MII, IP, MCAPSI))
 return StmtError();
 
   // Build the vector of clobber StringRefs.
@@ -486,15 +476,23 @@
 
   // Recast the void pointers and build the vector of constraint StringRefs.
   unsigned NumExprs = NumOutputs + NumInputs;
-  assert (VoidNames.size() == NumExprs  Unexpected number of names!);
-  assert (VoidExprs.size() == NumExprs  Unexpected number of exprs!);
   Names.resize(NumExprs);
   ConstraintRefs.resize(NumExprs);
   Exprs.resize(NumExprs);
   for (unsigned i = 0, e = NumExprs; i != e; ++i) {
-Names[i] = static_castIdentifierInfo *(VoidNames[i]);
+NamedDecl *OpDecl = static_castNamedDecl *(OpDecls[i]);
+if (!OpDecl)
+  return StmtError();
+
+DeclarationNameInfo NameInfo(OpDecl-getDeclName(), AsmLoc);
+ExprResult OpExpr = BuildDeclarationNameExpr(CXXScopeSpec(), NameInfo,
+ OpDecl);
+if (OpExpr.isInvalid())
+  return StmtError();
+
+Names[i] = OpDecl-getIdentifier();
 ConstraintRefs[i] = StringRef(Constraints[i]);
-Exprs[i] = static_castExpr *(VoidExprs[i]);
+Exprs[i] = OpExpr.take();
   }
 
   bool IsSimple = NumExprs  0;


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


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread Jan Voung
Attached is a creduce'd test case which compiles without any clang errors,
but would have broken the assertion that lock_hack == 0 that was
in Robert's patch.  Well, I changed it to a print and grepped for the print
so that it wouldn't crash clang before clang had a chance to print other
errors.






On Thu, Oct 18, 2012 at 9:59 AM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 9:22 AM, Robert Muth robe...@google.com wrote:
  On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com
 wrote:
  On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com
 wrote:
  On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie dblai...@gmail.com
 wrote:
  On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com
 wrote:
  On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
  rafael.espind...@gmail.com wrote:
  On 15 October 2012 19:02, Robert Muth robe...@google.com wrote:
  No small test, sadly.
  I managed to cut a 10MB reproducer down to 2MB over 2h
  but no further.
 
  The testcase in the bug report is already a lot smaller than that.
  Running delta a bit more reduced it to the attached file, which I am
  sure can be reduced a bit more.
 
  The reproducer in the bug has a lot of problems, e.g.
  it is only a fragment - not valid C++ code.
  It is also not a very stable reproducers meaning changing the clang
  command line slightly
  will change clang's memory allocation enough that the bug does not
 get triggered
  anymore and instead you get a compiler failure because the code is
  only a fragment.
 
  This stability issue would likely effect any test for this problem,
  even valgrind based ones.
 
  Having thought  about this a little more think the best way to
  approach the problem of invalidated iterators
  is not by adding tests each time we find one but by addressing it at
 a
  higher level, e.g. compiling clang or llvm in a
  special debug mode, linking in special debug versions of STL and
  llvm/ADT/ that will cause crashes more reliably.
  Apparently VS has a feature like that, c.f.
 
 http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid
 
  Fair point - Howard Hinnant started work on something like this for
  libc++ but it's not been finished yet (put on the back burner). MSVC's
  debug mode has really helped me on several occasions.
 
  Takumi (who runs most/all of the MSVC bots) - do any of your bots
  already run with MSVC's iterator debugging turned up/on? Would that be
  a reasonable task? ( interestingly: does it catch this bug)
 
  Without knowing much about how MSVC is accomplishing this,
  it probably relies on extra book keeping inside STL.
 
  That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
  you can't interoperate STL-using APIs built with differing IDLs, but
  they have some machinery that should usually give you a linker error
  if you try). Howard wanted to implement something that would not be
  ABI-changing and allow libraries with differing iterator debugging
  levels to interoperate in a best-effort manner. This meant using
  side-tables rather than in-structure bookkeeping.
 
  The container implicated here , DenseMap, is not an STL container,
  though, so some extra
  work would be required to make it fit the MSVC framework.
 
  Ah, right - yeah, there are ways to plug into it but it's work. We
  might consider implementing our own standalone version for this
  instead.
 
  Robert - while that would help stabilize the behavior, would it
  actually help catch this bug? Would it be possible for you to create a
 
  I am pretty sure it would catch this bug *reliably*, because
  the reproducer does add items to  DenseMap while iterating over it
 which
   invalidates the iterators de jure.
 
  That's all I'm interested in.
 
  But this invalidation only becomes visible when it is accompanied by a
 resizing
  of the DenseMap and that seems to depend on the concrete program run,
 e.g.
  we can influence the resize trigger by changing the length of strings
  passed on clang command line.
 
  The visibility I don't mind about right now - that's an infrastructure
  problem we'll need to fix  I wouldn't gate your fix on that.
 
  What I'm interested in is a reproduction of invalid code according to
  DenseMap's contract, not its implementation. Basically a quick  dirty
  way to do this would be to raise some global flag around the loop in
  Sema::AddOverloadCandidate, then assert that that flag is not raised
  when things are added to the container in Sema::RequireCompleteType (I
  mention these two functions based on your analysis posted in the bug,
  not my own investigation). Then reduce to the simplest (hopefully
  valid) code that triggers the assert.
 
  You don't need/we won't commit this assert/flag, but we'll know that
  this case reliably violates the DenseMap contract  if/when we add
  some iterator invalidation checking we'll have a repro ready to go.
 
 
  David,
 
  I attached a set of 

[cfe-commits] r166219 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaObjCProperty.cpp test/SemaObjCXX/property-synthesis-error.mm

2012-10-18 Thread Eli Friedman
Author: efriedma
Date: Thu Oct 18 15:14:08 2012
New Revision: 166219

URL: http://llvm.org/viewvc/llvm-project?rev=166219view=rev
Log:
Fix Objective-C implicit property synthesis for C++ classes so we use valid 
source locations in places where it is necessary for diagnostics.  By itself,
this causes assertions, so while I'm here, also fix property synthesis
for properties of C++ class type so we use so we properly set up a scope
and mark variable declarations.

rdar://problem/12514189.


Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=166219r1=166218r2=166219view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 18 15:14:08 2012
@@ -466,6 +466,26 @@
 }
   };
 
+  /// \brief RAII object to handle the state changes required to synthesize
+  /// a function body.
+  class SynthesizedFunctionScope {
+Sema S;
+Sema::ContextRAII SavedContext;
+
+  public:
+SynthesizedFunctionScope(Sema S, DeclContext *DC)
+  : S(S), SavedContext(S, DC) 
+{
+  S.PushFunctionScope();
+  S.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated);
+}
+
+~SynthesizedFunctionScope() {
+  S.PopExpressionEvaluationContext();
+  S.PopFunctionScopeInfo();
+}
+  };
+
   /// WeakUndeclaredIdentifiers - Identifiers contained in
   /// \#pragma weak before declared. rare. may alias another
   /// identifier, declared or undeclared

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=166219r1=166218r2=166219view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Oct 18 15:14:08 2012
@@ -6816,28 +6816,6 @@
   return AliasDecl;
 }
 
-namespace {
-  /// \brief Scoped object used to handle the state changes required in Sema
-  /// to implicitly define the body of a C++ member function;
-  class ImplicitlyDefinedFunctionScope {
-Sema S;
-Sema::ContextRAII SavedContext;
-
-  public:
-ImplicitlyDefinedFunctionScope(Sema S, CXXMethodDecl *Method)
-  : S(S), SavedContext(S, Method) 
-{
-  S.PushFunctionScope();
-  S.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated);
-}
-
-~ImplicitlyDefinedFunctionScope() {
-  S.PopExpressionEvaluationContext();
-  S.PopFunctionScopeInfo();
-}
-  };
-}
-
 Sema::ImplicitExceptionSpecification
 Sema::ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc,
CXXMethodDecl *MD) {
@@ -6981,7 +6959,7 @@
   CXXRecordDecl *ClassDecl = Constructor-getParent();
   assert(ClassDecl  DefineImplicitDefaultConstructor - invalid 
constructor);
 
-  ImplicitlyDefinedFunctionScope Scope(*this, Constructor);
+  SynthesizedFunctionScope Scope(*this, Constructor);
   DiagnosticErrorTrap Trap(Diags);
   if (SetCtorInitializers(Constructor, 0, 0, /*AnyErrors=*/false) ||
   Trap.hasErrorOccurred()) {
@@ -7293,7 +7271,7 @@
   if (Destructor-isInvalidDecl())
 return;
 
-  ImplicitlyDefinedFunctionScope Scope(*this, Destructor);
+  SynthesizedFunctionScope Scope(*this, Destructor);
 
   DiagnosticErrorTrap Trap(Diags);
   MarkBaseAndMemberDestructorsReferenced(Destructor-getLocation(),
@@ -7774,7 +7752,7 @@
   
   CopyAssignOperator-setUsed();
 
-  ImplicitlyDefinedFunctionScope Scope(*this, CopyAssignOperator);
+  SynthesizedFunctionScope Scope(*this, CopyAssignOperator);
   DiagnosticErrorTrap Trap(Diags);
 
   // C++0x [class.copy]p30:
@@ -8315,7 +8293,7 @@
   
   MoveAssignOperator-setUsed();
 
-  ImplicitlyDefinedFunctionScope Scope(*this, MoveAssignOperator);
+  SynthesizedFunctionScope Scope(*this, MoveAssignOperator);
   DiagnosticErrorTrap Trap(Diags);
 
   // C++0x [class.copy]p28:
@@ -8811,7 +8789,7 @@
   CXXRecordDecl *ClassDecl = CopyConstructor-getParent();
   assert(ClassDecl  DefineImplicitCopyConstructor - invalid constructor);
 
-  ImplicitlyDefinedFunctionScope Scope(*this, CopyConstructor);
+  SynthesizedFunctionScope Scope(*this, CopyConstructor);
   DiagnosticErrorTrap Trap(Diags);
 
   if (SetCtorInitializers(CopyConstructor, 0, 0, /*AnyErrors=*/false) ||
@@ -8994,7 +8972,7 @@
   CXXRecordDecl *ClassDecl = MoveConstructor-getParent();
   assert(ClassDecl  DefineImplicitMoveConstructor - invalid constructor);
 
-  ImplicitlyDefinedFunctionScope Scope(*this, MoveConstructor);
+  SynthesizedFunctionScope Scope(*this, MoveConstructor);
   DiagnosticErrorTrap Trap(Diags);
 
   if (SetCtorInitializers(MoveConstructor, 0, 0, /*AnyErrors=*/false) ||

[cfe-commits] r166218 - /cfe/trunk/lib/Frontend/TextDiagnostic.cpp

2012-10-18 Thread Benjamin Kramer
Author: d0k
Date: Thu Oct 18 15:09:54 2012
New Revision: 166218

URL: http://llvm.org/viewvc/llvm-project?rev=166218view=rev
Log:
Emit diagnostics in chunks even when we're trying to print colored template 
diffs.

char-by-char is really slow on an unbuffered stream.

Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=166218r1=166217r2=166218view=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Thu Oct 18 15:09:54 2012
@@ -43,19 +43,22 @@
 /// \brief Add highlights to differences in template strings.
 static void applyTemplateHighlighting(raw_ostream OS, StringRef Str,
   bool Normal, bool Bold) {
-  for (unsigned i = 0, e = Str.size(); i  e; ++i)
-if (Str[i] != ToggleHighlight) {
-  OS  Str[i];
-} else {
-  if (Normal)
-OS.changeColor(templateColor, true);
-  else {
-OS.resetColor();
-if (Bold)
-  OS.changeColor(savedColor, true);
-  }
-  Normal = !Normal;
+  while (1) {
+size_t Pos = Str.find(ToggleHighlight);
+OS  Str.slice(0, Pos);
+if (Pos == StringRef::npos)
+  break;
+
+Str = Str.substr(Pos + 1);
+if (Normal)
+  OS.changeColor(templateColor, true);
+else {
+  OS.resetColor();
+  if (Bold)
+OS.changeColor(savedColor, true);
 }
+Normal = !Normal;
+  }
 }
 
 /// \brief Number of spaces to indent when word-wrapping.


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


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread David Blaikie
On Thu, Oct 18, 2012 at 1:15 PM, Jan Voung jvo...@chromium.org wrote:
 Attached is a creduce'd test case which compiles without any clang errors,
 but would have broken the assertion that lock_hack == 0 that was in
 Robert's patch.

Better - and certainly not something that's totally unreasonable to
commit, but it's helpful if the test case is as simple as possible so
that, should it fail, there's not a lot of unrelated noise to
investigate. Could you reduce this (by hand or automatically) further?
I assume that's not the simplest it could possibly be. (though I'm
happy to be corrected on that matter)

 Well, I changed it to a print and grepped for the print so
 that it wouldn't crash clang before clang had a chance to print other
 errors.

I'm not quite sure what you mean by this. We don't intend to commit
that hack  so an assert seems like it'd be fine... the simplest
program that produces that assertion is what we want for this test
case I think.







 On Thu, Oct 18, 2012 at 9:59 AM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 9:22 AM, Robert Muth robe...@google.com wrote:
  On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com
  wrote:
  On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com
  wrote:
  On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie dblai...@gmail.com
  wrote:
  On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com
  wrote:
  On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
  rafael.espind...@gmail.com wrote:
  On 15 October 2012 19:02, Robert Muth robe...@google.com wrote:
  No small test, sadly.
  I managed to cut a 10MB reproducer down to 2MB over 2h
  but no further.
 
  The testcase in the bug report is already a lot smaller than that.
  Running delta a bit more reduced it to the attached file, which I
  am
  sure can be reduced a bit more.
 
  The reproducer in the bug has a lot of problems, e.g.
  it is only a fragment - not valid C++ code.
  It is also not a very stable reproducers meaning changing the clang
  command line slightly
  will change clang's memory allocation enough that the bug does not
  get triggered
  anymore and instead you get a compiler failure because the code is
  only a fragment.
 
  This stability issue would likely effect any test for this problem,
  even valgrind based ones.
 
  Having thought  about this a little more think the best way to
  approach the problem of invalidated iterators
  is not by adding tests each time we find one but by addressing it at
  a
  higher level, e.g. compiling clang or llvm in a
  special debug mode, linking in special debug versions of STL and
  llvm/ADT/ that will cause crashes more reliably.
  Apparently VS has a feature like that, c.f.
 
  http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid
 
  Fair point - Howard Hinnant started work on something like this for
  libc++ but it's not been finished yet (put on the back burner).
  MSVC's
  debug mode has really helped me on several occasions.
 
  Takumi (who runs most/all of the MSVC bots) - do any of your bots
  already run with MSVC's iterator debugging turned up/on? Would that
  be
  a reasonable task? ( interestingly: does it catch this bug)
 
  Without knowing much about how MSVC is accomplishing this,
  it probably relies on extra book keeping inside STL.
 
  That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
  you can't interoperate STL-using APIs built with differing IDLs, but
  they have some machinery that should usually give you a linker error
  if you try). Howard wanted to implement something that would not be
  ABI-changing and allow libraries with differing iterator debugging
  levels to interoperate in a best-effort manner. This meant using
  side-tables rather than in-structure bookkeeping.
 
  The container implicated here , DenseMap, is not an STL container,
  though, so some extra
  work would be required to make it fit the MSVC framework.
 
  Ah, right - yeah, there are ways to plug into it but it's work. We
  might consider implementing our own standalone version for this
  instead.
 
  Robert - while that would help stabilize the behavior, would it
  actually help catch this bug? Would it be possible for you to create
  a
 
  I am pretty sure it would catch this bug *reliably*, because
  the reproducer does add items to  DenseMap while iterating over it
  which
   invalidates the iterators de jure.
 
  That's all I'm interested in.
 
  But this invalidation only becomes visible when it is accompanied by a
  resizing
  of the DenseMap and that seems to depend on the concrete program run,
  e.g.
  we can influence the resize trigger by changing the length of strings
  passed on clang command line.
 
  The visibility I don't mind about right now - that's an infrastructure
  problem we'll need to fix  I wouldn't gate your fix on that.
 
  What I'm interested in is a reproduction of invalid code according to
  DenseMap's contract, not its 

[cfe-commits] r166221 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaStmtAsm.cpp

2012-10-18 Thread Chad Rosier
Author: mcrosier
Date: Thu Oct 18 15:27:06 2012
New Revision: 166221

URL: http://llvm.org/viewvc/llvm-project?rev=166221view=rev
Log:
[ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback,
which will be used by the asm matcher in the near future.

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

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=166221r1=166220r2=166221view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 18 15:27:06 2012
@@ -2631,7 +2631,8 @@
  Expr *AsmString, MultiExprArg Clobbers,
  SourceLocation RParenLoc);
 
-  NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc);
+  NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
+   unsigned Size);
   StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
 ArrayRefToken AsmToks, SourceLocation EndLoc);
 

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=166221r1=166220r2=166221view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Oct 18 15:27:06 2012
@@ -367,14 +367,16 @@
   MCAsmParserSemaCallbackImpl(class Sema *Ref) { SemaRef = Ref; }
   ~MCAsmParserSemaCallbackImpl() {}
 
-  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc) {
+  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc, unsigned 
Size){
 SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc);
-NamedDecl *OpDecl = SemaRef-LookupInlineAsmIdentifier(Name, Loc);
+NamedDecl *OpDecl = SemaRef-LookupInlineAsmIdentifier(Name, Loc, Size);
 return static_castvoid *(OpDecl);
   }
 };
 
-NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc) 
{
+NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
+   unsigned Size) {
+  Size = 0;
   LookupResult Result(*this, Context.Idents.get(Name), Loc,
   Sema::LookupOrdinaryName);
 
@@ -391,6 +393,9 @@
 
   NamedDecl *ND = Result.getFoundDecl();
   if (isaVarDecl(ND) || isaFunctionDecl(ND)) {
+if (VarDecl *Var = dyn_castVarDecl(ND))
+  Size = Context.getTypeInfo(Var-getType()).first;
+
 return ND;
   }
 


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


[cfe-commits] r166223 - in /cfe/trunk: include/clang/Driver/Arg.h include/clang/Driver/ArgList.h include/clang/Driver/OptTable.h include/clang/Driver/Option.h lib/Driver/Arg.cpp lib/Driver/ArgList.cpp

2012-10-18 Thread Michael J. Spencer
Author: mspencer
Date: Thu Oct 18 15:33:42 2012
New Revision: 166223

URL: http://llvm.org/viewvc/llvm-project?rev=166223view=rev
Log:
[Options] make Option a value type.

Modified:
cfe/trunk/include/clang/Driver/Arg.h
cfe/trunk/include/clang/Driver/ArgList.h
cfe/trunk/include/clang/Driver/OptTable.h
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/lib/Driver/Arg.cpp
cfe/trunk/lib/Driver/ArgList.cpp
cfe/trunk/lib/Driver/OptTable.cpp
cfe/trunk/lib/Driver/Option.cpp
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Arg.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Arg.h?rev=166223r1=166222r2=166223view=diff
==
--- cfe/trunk/include/clang/Driver/Arg.h (original)
+++ cfe/trunk/include/clang/Driver/Arg.h Thu Oct 18 15:33:42 2012
@@ -15,6 +15,8 @@
 #ifndef CLANG_DRIVER_ARG_H_
 #define CLANG_DRIVER_ARG_H_
 
+#include clang/Driver/Option.h
+
 #include Util.h
 #include llvm/ADT/SmallVector.h
 #include llvm/ADT/StringRef.h
@@ -23,7 +25,6 @@
 namespace clang {
 namespace driver {
   class ArgList;
-  class Option;
 
   /// \brief A concrete instance of a particular driver option.
   ///
@@ -38,7 +39,7 @@
 
   private:
 /// \brief The option this argument is an instance of.
-const Option *Opt;
+const Option Opt;
 
 /// \brief The argument this argument was derived from (during tool chain
 /// argument translation), if any.
@@ -60,14 +61,14 @@
 SmallVectorconst char *, 2 Values;
 
   public:
-Arg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0);
-Arg(const Option *Opt, unsigned Index,
+Arg(const Option Opt, unsigned Index, const Arg *BaseArg = 0);
+Arg(const Option Opt, unsigned Index,
 const char *Value0, const Arg *BaseArg = 0);
-Arg(const Option *Opt, unsigned Index,
+Arg(const Option Opt, unsigned Index,
 const char *Value0, const char *Value1, const Arg *BaseArg = 0);
 ~Arg();
 
-const Option getOption() const { return *Opt; }
+const Option getOption() const { return Opt; }
 unsigned getIndex() const { return Index; }
 
 /// \brief Return the base argument which generated this arg.

Modified: cfe/trunk/include/clang/Driver/ArgList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ArgList.h?rev=166223r1=166222r2=166223view=diff
==
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Thu Oct 18 15:33:42 2012
@@ -11,6 +11,7 @@
 #define CLANG_DRIVER_ARGLIST_H_
 
 #include clang/Basic/LLVM.h
+#include clang/Driver/Option.h
 #include clang/Driver/OptSpecifier.h
 #include clang/Driver/Util.h
 #include llvm/ADT/SmallVector.h
@@ -374,14 +375,14 @@
 
 /// AddFlagArg - Construct a new FlagArg for the given option \p Id and
 /// append it to the argument list.
-void AddFlagArg(const Arg *BaseArg, const Option *Opt) {
+void AddFlagArg(const Arg *BaseArg, const Option Opt) {
   append(MakeFlagArg(BaseArg, Opt));
 }
 
 /// AddPositionalArg - Construct a new Positional arg for the given option
 /// \p Id, with the provided \p Value and append it to the argument
 /// list.
-void AddPositionalArg(const Arg *BaseArg, const Option *Opt,
+void AddPositionalArg(const Arg *BaseArg, const Option Opt,
   StringRef Value) {
   append(MakePositionalArg(BaseArg, Opt, Value));
 }
@@ -390,7 +391,7 @@
 /// AddSeparateArg - Construct a new Positional arg for the given option
 /// \p Id, with the provided \p Value and append it to the argument
 /// list.
-void AddSeparateArg(const Arg *BaseArg, const Option *Opt,
+void AddSeparateArg(const Arg *BaseArg, const Option Opt,
 StringRef Value) {
   append(MakeSeparateArg(BaseArg, Opt, Value));
 }
@@ -398,28 +399,28 @@
 
 /// AddJoinedArg - Construct a new Positional arg for the given option
 /// \p Id, with the provided \p Value and append it to the argument list.
-void AddJoinedArg(const Arg *BaseArg, const Option *Opt,
+void AddJoinedArg(const Arg *BaseArg, const Option Opt,
   StringRef Value) {
   append(MakeJoinedArg(BaseArg, Opt, Value));
 }
 
 
 /// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
-Arg *MakeFlagArg(const Arg *BaseArg, const Option *Opt) const;
+Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
 
 /// MakePositionalArg - Construct a new Positional arg for the
 /// given option \p Id, with the provided \p Value.
-Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt,
+Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const;
 
 /// MakeSeparateArg - Construct a new Positional arg for 

Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:

 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.
 
 Within the body of the loop the underlying map may be modified via
 
  Sema::AddOverloadCandidate
- Sema::CompareReferenceRelationship
- Sema::RequireCompleteType
 
 to avoid the use of invalid iterators the sequence is copied first.

Did you audit other uses of LookupConstructors to ensure that this is the only 
ticking time bomb in this area?

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


Re: [cfe-commits] [Patch] Improve handling of __has_include

2012-10-18 Thread Douglas Gregor
LGTM!

On Oct 10, 2012, at 6:16 PM, Richard Trieu rtr...@google.com wrote:

 Prevent crashes on malformed uses of __has_include.  This fixes the cases 
 outlined PR13334.  Some diagnostic locations were changed and a bit of error 
 recovery was added. 
 has_include.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


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Richard Smith
On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:


 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:

  Author: dblaikie
  Date: Thu Oct 18 11:57:32 2012
  New Revision: 166188
 
  URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
  Log:
  PR14021: Copy lookup results to ensure safe iteration.
 
  Within the body of the loop the underlying map may be modified via
 
   Sema::AddOverloadCandidate
 - Sema::CompareReferenceRelationship
 - Sema::RequireCompleteType
 
  to avoid the use of invalid iterators the sequence is copied first.

 Did you audit other uses of LookupConstructors to ensure that this is the
 only ticking time bomb in this area?


Perhaps we can fix all of these by taking a different approach (declaring
all the implicit special members whenever we declare any of them).
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread David Blaikie
On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:

 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188

 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.

 Within the body of the loop the underlying map may be modified via

  Sema::AddOverloadCandidate
- Sema::CompareReferenceRelationship
- Sema::RequireCompleteType

 to avoid the use of invalid iterators the sequence is copied first.

 Did you audit other uses of LookupConstructors to ensure that this is the 
 only ticking time bomb in this area?

[+Robert Muth]

I've not performed any such audit, no. With the hack debug check
inserted we could just run the whole test suite to see if anything
pops up.
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 1:48 PM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:
 
 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:
 
 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.
 
 Within the body of the loop the underlying map may be modified via
 
 Sema::AddOverloadCandidate
   - Sema::CompareReferenceRelationship
   - Sema::RequireCompleteType
 
 to avoid the use of invalid iterators the sequence is copied first.
 
 Did you audit other uses of LookupConstructors to ensure that this is the 
 only ticking time bomb in this area?
 
 [+Robert Muth]
 
 I've not performed any such audit, no. With the hack debug check
 inserted we could just run the whole test suite to see if anything
 pops up.

That seems unlikely to help; this is only a problem when the underlying 
StoredDeclsList has to reallocate.

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


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 1:48 PM, Richard Smith rich...@metafoo.co.uk wrote:

 On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:
 
 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:
 
  Author: dblaikie
  Date: Thu Oct 18 11:57:32 2012
  New Revision: 166188
 
  URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
  Log:
  PR14021: Copy lookup results to ensure safe iteration.
 
  Within the body of the loop the underlying map may be modified via
 
   Sema::AddOverloadCandidate
 - Sema::CompareReferenceRelationship
 - Sema::RequireCompleteType
 
  to avoid the use of invalid iterators the sequence is copied first.
 
 Did you audit other uses of LookupConstructors to ensure that this is the 
 only ticking time bomb in this area?
 
 Perhaps we can fix all of these by taking a different approach (declaring all 
 the implicit special members whenever we declare any of them).


Yes, that would work.

- Doug

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


[cfe-commits] r166226 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/ast-print.cpp

2012-10-18 Thread Eli Friedman
Author: efriedma
Date: Thu Oct 18 15:54:37 2012
New Revision: 166226

URL: http://llvm.org/viewvc/llvm-project?rev=166226view=rev
Log:
Fix AST pretty-printing for C++ new expressions with placement arguments with 
default values.

Based on patch by Grzegorz Jablonski.


Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=166226r1=166225r2=166226view=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Oct 18 15:54:37 2012
@@ -1415,10 +1415,12 @@
 OS  ::;
   OS  new ;
   unsigned NumPlace = E-getNumPlacementArgs();
-  if (NumPlace  0) {
+  if (NumPlace  0  !isaCXXDefaultArgExpr(E-getPlacementArg(0))) {
 OS  (;
 PrintExpr(E-getPlacementArg(0));
 for (unsigned i = 1; i  NumPlace; ++i) {
+  if (isaCXXDefaultArgExpr(E-getPlacementArg(i)))
+break;
   OS  , ;
   PrintExpr(E-getPlacementArg(i));
 }

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=166226r1=166225r2=166226view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct 18 15:54:37 2012
@@ -30,3 +30,14 @@
 switch (int a = 1) { }
 }
 
+// CHECK: new (1) int;
+void *operator new (typeof(sizeof(1)), int, int = 2);
+void f2() {
+  new (1) int;
+}
+
+// CHECK: new X;
+struct X {
+  void *operator new (typeof(sizeof(1)), int = 2);
+};
+void f2() { new X; }


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


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread David Blaikie
On Thu, Oct 18, 2012 at 1:50 PM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 18, 2012, at 1:48 PM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:

 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188

 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.

 Within the body of the loop the underlying map may be modified via

 Sema::AddOverloadCandidate
   - Sema::CompareReferenceRelationship
   - Sema::RequireCompleteType

 to avoid the use of invalid iterators the sequence is copied first.

 Did you audit other uses of LookupConstructors to ensure that this is the 
 only ticking time bomb in this area?

 [+Robert Muth]

 I've not performed any such audit, no. With the hack debug check
 inserted we could just run the whole test suite to see if anything
 pops up.

 That seems unlikely to help; this is only a problem when the underlying 
 StoredDeclsList has to reallocate.

The hack attached to the bug is to raise a flag on the DenseMap at the
start of the loop  assert within DenseMap if that flag is raised
while any mutation operation is done - so it should fire even without
having to coax a reallocation into the operation. Not something to
commit, but useful for reducing the test case to represent the
problem, even if it doesn't actually fail. (one day it'd be nice to
add some debug checked iterators in - and on that day the test case
will make more sense (test case still hasn't been committed, working
with Robert  folks to get something of a reasonable size/reduction to
commit - see the review thread for more detail/discussion))

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


[cfe-commits] r166227 - in /cfe/trunk: lib/AST/TypePrinter.cpp test/SemaCXX/ast-print.cpp

2012-10-18 Thread Eli Friedman
Author: efriedma
Date: Thu Oct 18 15:58:58 2012
New Revision: 166227

URL: http://llvm.org/viewvc/llvm-project?rev=166227view=rev
Log:
Remove check which incorrectly suppressed printing an identifier in type 
printing.  Patch by Benoit Perrot.


Modified:
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=166227r1=166226r2=166227view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Thu Oct 18 15:58:58 2012
@@ -141,9 +141,6 @@
 OS  NULL TYPE;
 return;
   }
-  
-  if (Policy.SuppressSpecifiers  T-isSpecifierType())
-return;
 
   SaveAndRestorebool PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
 

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=166227r1=166226r2=166227view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct 18 15:58:58 2012
@@ -41,3 +41,8 @@
   void *operator new (typeof(sizeof(1)), int = 2);
 };
 void f2() { new X; }
+
+// CHECK: for (int i = 2097, j = 42; false;)
+void forInit() {
+  for (int i = 2097, j = 42; false;) {}
+}


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


Re: [cfe-commits] [PATCH] Pretty print identifiers even while suppressing specifiers

2012-10-18 Thread Eli Friedman
On Wed, Oct 17, 2012 at 5:41 AM, Benoit Perrot ben...@lrde.epita.fr wrote:
 Hi,


 Please include a testcase with a patch where appropriate.  (In this
 case, see test/SemaCXX/ast-print.cpp .)


 Of course.
 Here is the patch completed with a test.

r166227.

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


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread Jan Voung
On Thu, Oct 18, 2012 at 1:20 PM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 1:15 PM, Jan Voung jvo...@chromium.org wrote:
  Attached is a creduce'd test case which compiles without any clang
 errors,
  but would have broken the assertion that lock_hack == 0 that was in
  Robert's patch.

 Better - and certainly not something that's totally unreasonable to
 commit, but it's helpful if the test case is as simple as possible so
 that, should it fail, there's not a lot of unrelated noise to
 investigate. Could you reduce this (by hand or automatically) further?
 I assume that's not the simplest it could possibly be. (though I'm
 happy to be corrected on that matter)


Okay, making some progress manually reducing the test.  I'll upload another
version when I get it even smaller.


  Well, I changed it to a print and grepped for the print so
  that it wouldn't crash clang before clang had a chance to print other
  errors.

 I'm not quite sure what you mean by this. We don't intend to commit
 that hack  so an assert seems like it'd be fine... the simplest
 program that produces that assertion is what we want for this test
 case I think.


Oh, I just meant that I tweaked Robert's patch locally, to know when the
assert *would have* fired without actually having clang stop, so that clang
could continue and check that the rest of the test-case was still valid
c++.  That was just for the purpose of reducing the test case.

- Jan


 
 
 
 
 
 
  On Thu, Oct 18, 2012 at 9:59 AM, David Blaikie dblai...@gmail.com
 wrote:
 
  On Thu, Oct 18, 2012 at 9:22 AM, Robert Muth robe...@google.com
 wrote:
   On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com
   wrote:
   On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com
   wrote:
   On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie dblai...@gmail.com
 
   wrote:
   On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com
   wrote:
   On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
   rafael.espind...@gmail.com wrote:
   On 15 October 2012 19:02, Robert Muth robe...@google.com
 wrote:
   No small test, sadly.
   I managed to cut a 10MB reproducer down to 2MB over 2h
   but no further.
  
   The testcase in the bug report is already a lot smaller than
 that.
   Running delta a bit more reduced it to the attached file, which I
   am
   sure can be reduced a bit more.
  
   The reproducer in the bug has a lot of problems, e.g.
   it is only a fragment - not valid C++ code.
   It is also not a very stable reproducers meaning changing the
 clang
   command line slightly
   will change clang's memory allocation enough that the bug does not
   get triggered
   anymore and instead you get a compiler failure because the code is
   only a fragment.
  
   This stability issue would likely effect any test for this
 problem,
   even valgrind based ones.
  
   Having thought  about this a little more think the best way to
   approach the problem of invalidated iterators
   is not by adding tests each time we find one but by addressing it
 at
   a
   higher level, e.g. compiling clang or llvm in a
   special debug mode, linking in special debug versions of STL and
   llvm/ADT/ that will cause crashes more reliably.
   Apparently VS has a feature like that, c.f.
  
  
 http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid
  
   Fair point - Howard Hinnant started work on something like this for
   libc++ but it's not been finished yet (put on the back burner).
   MSVC's
   debug mode has really helped me on several occasions.
  
   Takumi (who runs most/all of the MSVC bots) - do any of your bots
   already run with MSVC's iterator debugging turned up/on? Would that
   be
   a reasonable task? ( interestingly: does it catch this bug)
  
   Without knowing much about how MSVC is accomplishing this,
   it probably relies on extra book keeping inside STL.
  
   That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
   you can't interoperate STL-using APIs built with differing IDLs, but
   they have some machinery that should usually give you a linker error
   if you try). Howard wanted to implement something that would not be
   ABI-changing and allow libraries with differing iterator debugging
   levels to interoperate in a best-effort manner. This meant using
   side-tables rather than in-structure bookkeeping.
  
   The container implicated here , DenseMap, is not an STL container,
   though, so some extra
   work would be required to make it fit the MSVC framework.
  
   Ah, right - yeah, there are ways to plug into it but it's work. We
   might consider implementing our own standalone version for this
   instead.
  
   Robert - while that would help stabilize the behavior, would it
   actually help catch this bug? Would it be possible for you to
 create
   a
  
   I am pretty sure it would catch this bug *reliably*, because
   the reproducer does add items to  DenseMap while iterating over 

Re: [cfe-commits] [PATCH] Fix pretty-printing of decl group stmts

2012-10-18 Thread Eli Friedman
On Thu, Oct 18, 2012 at 5:06 AM, Richard Membarth
richard.memba...@informatik.uni-erlangen.de wrote:
 Attached is a patch that fixes pretty-printing of decl stmt groups.

 The example below shows that the current type pretty-printer does
 not print the variable name if Policy.SuppressSpecifiers is set.

 ~  cat test.cc
 int main(int argc, const char **argv) {
 int x=0, y=5;
 for (int i=x, j=y; ij; i++) {
 ;
 }
 }

 ~  clang -cc1 -ast-print test.cc
 int main(int argc, const char **argv) {
 int x = 0,  = 5;
 for (int i = x,  = y; i  j; i++) {
 ;
 }
 }

 Please let me know if this is ok.

I committed a different fix in r166227.

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


[cfe-commits] r166228 - in /cfe/trunk: include/clang/Serialization/ASTReader.h include/clang/Serialization/Module.h lib/Serialization/ASTReader.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 16:18:25 2012
New Revision: 166228

URL: http://llvm.org/viewvc/llvm-project?rev=166228view=rev
Log:
Move information about the original file from the ASTReader into the
module files.

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

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=166228r1=166227r2=166228view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 18 16:18:25 2012
@@ -645,18 +645,6 @@
   SmallVectorserialization::SubmoduleID, 2 ImportedModules;
   //@}
 
-  /// \brief The original file name that was used to build the primary AST 
file,
-  /// which may have been modified for relocatable-pch support.
-  std::string OriginalFileName;
-
-  /// \brief The actual original file name that was used to build the primary
-  /// AST file.
-  std::string ActualOriginalFileName;
-
-  /// \brief The file ID for the original file that was used to build the
-  /// primary AST file.
-  FileID OriginalFileID;
-
   /// \brief The directory that the PCH was originally created in. Used to
   /// allow resolving headers even after headers+PCH was moved to a new path.
   std::string OriginalDir;
@@ -1106,8 +1094,11 @@
   /// \brief Retrieve the preprocessor.
   Preprocessor getPreprocessor() const { return PP; }
 
-  /// \brief Retrieve the name of the original source file name
-  const std::string getOriginalSourceFile() { return OriginalFileName; }
+  /// \brief Retrieve the name of the original source file name for the primary
+  /// module file.
+  const std::string getOriginalSourceFile() { 
+return ModuleMgr.getPrimaryModule().OriginalSourceFileName; 
+  }
 
   /// \brief Retrieve the name of the original source file name directly from
   /// the AST file, without actually loading the AST file.

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=166228r1=166227r2=166228view=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Oct 18 16:18:25 2012
@@ -75,6 +75,23 @@
   /// \brief The file name of the module file.
   std::string FileName;
 
+  /// \brief The original source file name that was used to build the
+  /// primary AST file, which may have been modified for
+  /// relocatable-pch support.
+  std::string OriginalSourceFileName;
+
+  /// \brief The actual original source file name that was used to
+  /// build this AST file.
+  std::string ActualOriginalSourceFileName;
+
+  /// \brief The file ID for the original source file that was used to
+  /// build this AST file.
+  FileID OriginalSourceFileID;
+
+  /// \brief The directory that the PCH was originally created in. Used to
+  /// allow resolving headers even after headers+PCH was moved to a new path.
+  std::string OriginalDir;
+
   /// \brief The file entry for the module file.
   const FileEntry *File;
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166228r1=166227r2=166228view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 16:18:25 2012
@@ -819,11 +819,14 @@
 
 /// \brief Tell the AST listener about the predefines buffers in the chain.
 bool ASTReader::CheckPredefinesBuffers() {
-  if (Listener)
+  if (Listener) {
+// We only care about the primary module.
+ModuleFile M = ModuleMgr.getPrimaryModule();
 return Listener-ReadPredefinesBuffer(PCHPredefinesBuffers,
-  ActualOriginalFileName,
+  M.ActualOriginalSourceFileName,
   SuggestedPredefines,
   FileMgr);
+  }
   return false;
 }
 
@@ -1833,7 +1836,7 @@
 }
 
 case LANGUAGE_OPTIONS:
-  if (F == *ModuleMgr.begin()  
+  if (Listener  F == *ModuleMgr.begin()  
   ParseLanguageOptions(F, Record)  !DisableValidation)
 return IgnorePCH;
   break;
@@ -1854,7 +1857,7 @@
   TargetOpts.Features.push_back(ReadString(Record, Idx));
 }
 
-if (Listener-ReadTargetOptions(F, TargetOpts))
+if (Listener-ReadTargetOptions(F, TargetOpts)  !DisableValidation)
   return IgnorePCH;
   }
   break;
@@ -1863,11 +1866,10 @@
 case ORIGINAL_FILE:
   // Only record from the 

Re: [cfe-commits] [PATCH] External Sema Source

2012-10-18 Thread Vassil Vassilev

On 10/18/12 7:04 PM, Douglas Gregor wrote:

On Oct 11, 2012, at 8:02 AM, Vassil Vassilev vasil.georgiev.vasi...@cern.ch 
wrote:


Hi,
We need to attach multiple ExternalSources to Sema, to provide modules /and/ 
last resort lookup. Right now that's a pain. The attached patch makes this much 
easier, at (almost?) no runtime cost for the compiler. Okay to commit?

Yes, this looks fine to me.

- Doug



Thanks for reviewing! Committed as r166208.
Vassil
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] clang patch for bug 14021

2012-10-18 Thread David Blaikie
On Thu, Oct 18, 2012 at 2:07 PM, Jan Voung jvo...@chromium.org wrote:

 On Thu, Oct 18, 2012 at 1:20 PM, David Blaikie dblai...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 1:15 PM, Jan Voung jvo...@chromium.org wrote:
  Attached is a creduce'd test case which compiles without any clang
  errors,
  but would have broken the assertion that lock_hack == 0 that was in
  Robert's patch.

 Better - and certainly not something that's totally unreasonable to
 commit, but it's helpful if the test case is as simple as possible so
 that, should it fail, there's not a lot of unrelated noise to
 investigate. Could you reduce this (by hand or automatically) further?
 I assume that's not the simplest it could possibly be. (though I'm
 happy to be corrected on that matter)


 Okay, making some progress manually reducing the test.  I'll upload another
 version when I get it even smaller.

Thanks muchly.



  Well, I changed it to a print and grepped for the print so
  that it wouldn't crash clang before clang had a chance to print other
  errors.

 I'm not quite sure what you mean by this. We don't intend to commit
 that hack  so an assert seems like it'd be fine... the simplest
 program that produces that assertion is what we want for this test
 case I think.


 Oh, I just meant that I tweaked Robert's patch locally, to know when the
 assert *would have* fired without actually having clang stop, so that clang
 could continue and check that the rest of the test-case was still valid c++.
 That was just for the purpose of reducing the test case.

Oh, fair enough - those autoreducers do have a tendency to go off into
the weeds of invalid code.

While you've got that hack applied - have you tried running the entire
regression suite? You might find existing test cases cover this bug,
in which case no test would be required (though a nice reduction might
be handy anyway, if you end up with it).

Doug Gregor mentioned in code review of the commit that we might want
to look at other callers into this function to see if they're doing
similar things (we could temporarily add in the same flag
raising/lowering logic to check that those calls are robust too).

But Richard Smith has some completely other idea about how to fix this
issue, which might invalidate that sort of investigation.


 - Jan


 
 
 
 
 
 
  On Thu, Oct 18, 2012 at 9:59 AM, David Blaikie dblai...@gmail.com
  wrote:
 
  On Thu, Oct 18, 2012 at 9:22 AM, Robert Muth robe...@google.com
  wrote:
   On Tue, Oct 16, 2012 at 1:47 PM, David Blaikie dblai...@gmail.com
   wrote:
   On Tue, Oct 16, 2012 at 10:09 AM, Robert Muth robe...@google.com
   wrote:
   On Tue, Oct 16, 2012 at 11:47 AM, David Blaikie
   dblai...@gmail.com
   wrote:
   On Tue, Oct 16, 2012 at 8:12 AM, Robert Muth robe...@google.com
   wrote:
   On Mon, Oct 15, 2012 at 10:57 PM, Rafael Espíndola
   rafael.espind...@gmail.com wrote:
   On 15 October 2012 19:02, Robert Muth robe...@google.com
   wrote:
   No small test, sadly.
   I managed to cut a 10MB reproducer down to 2MB over 2h
   but no further.
  
   The testcase in the bug report is already a lot smaller than
   that.
   Running delta a bit more reduced it to the attached file, which
   I
   am
   sure can be reduced a bit more.
  
   The reproducer in the bug has a lot of problems, e.g.
   it is only a fragment - not valid C++ code.
   It is also not a very stable reproducers meaning changing the
   clang
   command line slightly
   will change clang's memory allocation enough that the bug does
   not
   get triggered
   anymore and instead you get a compiler failure because the code
   is
   only a fragment.
  
   This stability issue would likely effect any test for this
   problem,
   even valgrind based ones.
  
   Having thought  about this a little more think the best way to
   approach the problem of invalidated iterators
   is not by adding tests each time we find one but by addressing it
   at
   a
   higher level, e.g. compiling clang or llvm in a
   special debug mode, linking in special debug versions of STL and
   llvm/ADT/ that will cause crashes more reliably.
   Apparently VS has a feature like that, c.f.
  
  
   http://stackoverflow.com/questions/2062956/c-best-way-to-check-if-an-iterator-is-valid
  
   Fair point - Howard Hinnant started work on something like this
   for
   libc++ but it's not been finished yet (put on the back burner).
   MSVC's
   debug mode has really helped me on several occasions.
  
   Takumi (who runs most/all of the MSVC bots) - do any of your bots
   already run with MSVC's iterator debugging turned up/on? Would
   that
   be
   a reasonable task? ( interestingly: does it catch this bug)
  
   Without knowing much about how MSVC is accomplishing this,
   it probably relies on extra book keeping inside STL.
  
   That's correct, which means ITERATOR_DEBUG_LEVEL is ABI-changing (so
   you can't interoperate STL-using APIs built with differing IDLs, but
   they have some machinery that should usually give 

[cfe-commits] r166229 - in /cfe/trunk: include/clang/Serialization/ASTReader.h include/clang/Serialization/Module.h lib/Serialization/ASTReader.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 16:31:35 2012
New Revision: 166229

URL: http://llvm.org/viewvc/llvm-project?rev=166229view=rev
Log:
Move the RelocatablePCH bit from the ASTReader to the module file.

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

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=166229r1=166228r2=166229view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 18 16:31:35 2012
@@ -652,9 +652,6 @@
   /// \brief The directory that the PCH we are reading is stored in.
   std::string CurrentDir;
 
-  /// \brief Whether this precompiled header is a relocatable PCH file.
-  bool RelocatablePCH;
-
   /// \brief The system include root to be used when loading the
   /// precompiled header.
   std::string isysroot;
@@ -871,7 +868,7 @@
   /// into account all the necessary relocations.
   const FileEntry *getFileEntry(StringRef filename);
 
-  void MaybeAddSystemRootToFilename(std::string Filename);
+  void MaybeAddSystemRootToFilename(ModuleFile M, std::string Filename);
 
   ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
 ModuleFile *ImportedBy,

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=166229r1=166228r2=166229view=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Oct 18 16:31:35 2012
@@ -92,6 +92,9 @@
   /// allow resolving headers even after headers+PCH was moved to a new path.
   std::string OriginalDir;
 
+  /// \brief Whether this precompiled header is a relocatable PCH file.
+  bool RelocatablePCH;
+
   /// \brief The file entry for the module file.
   const FileEntry *File;
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166229r1=166228r2=166229view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 16:31:35 2012
@@ -848,7 +848,7 @@
 unsigned FilenameLen = Record[Idx++];
 std::string Filename(Record[Idx], Record[Idx] + FilenameLen);
 Idx += FilenameLen;
-MaybeAddSystemRootToFilename(Filename);
+MaybeAddSystemRootToFilename(F, Filename);
 FileIDs[I] = LineTable.getLineTableFilenameID(Filename);
   }
 
@@ -1125,7 +1125,7 @@
 
 std::string OrigFilename(BlobStart, BlobStart + BlobLen);
 std::string Filename = OrigFilename;
-MaybeAddSystemRootToFilename(Filename);
+MaybeAddSystemRootToFilename(*F, Filename);
 const FileEntry *File = 
   OverriddenBuffer? FileMgr.getVirtualFile(Filename, (off_t)Record[4],
(time_t)Record[5])
@@ -1709,7 +1709,7 @@
 
 const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) {
   std::string Filename = filenameStrRef;
-  MaybeAddSystemRootToFilename(Filename);
+  MaybeAddSystemRootToFilename(ModuleMgr.getPrimaryModule(), Filename);
   const FileEntry *File = FileMgr.getFile(Filename);
   if (File == 0  !OriginalDir.empty()  !CurrentDir.empty() 
   OriginalDir != CurrentDir) {
@@ -1726,9 +1726,10 @@
 /// \brief If we are loading a relocatable PCH file, and the filename is
 /// not an absolute path, add the system root to the beginning of the file
 /// name.
-void ASTReader::MaybeAddSystemRootToFilename(std::string Filename) {
+void ASTReader::MaybeAddSystemRootToFilename(ModuleFile M, 
+ std::string Filename) {
   // If this is not a relocatable PCH file, there's nothing to do.
-  if (!RelocatablePCH)
+  if (!M.RelocatablePCH)
 return;
 
   if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
@@ -1802,7 +1803,7 @@
 return IgnorePCH;
   }
 
-  RelocatablePCH = Record[4];
+  F.RelocatablePCH = Record[4];
 
   const std::string CurBranch = getClangFullRepositoryVersion();
   StringRef ASTBranch(BlobStart, BlobLen);
@@ -1869,7 +1870,7 @@
 F.OriginalSourceFileID = FileID::get(Record[0]);
 F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen);
 F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
-MaybeAddSystemRootToFilename(F.OriginalSourceFileName);
+MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName);
   }
   break;
 
@@ -6844,8 +6845,7 @@
 SourceMgr(PP.getSourceManager()), 

[cfe-commits] r166230 - in /cfe/trunk: include/clang/Driver/Option.h lib/Driver/Driver.cpp lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp

2012-10-18 Thread Michael J. Spencer
Author: mspencer
Date: Thu Oct 18 16:36:01 2012
New Revision: 166230

URL: http://llvm.org/viewvc/llvm-project?rev=166230view=rev
Log:
[Options] Make Option non clang specific.

Modified:
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Option.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=166230r1=166229r2=166230view=diff
==
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Thu Oct 18 16:36:01 2012
@@ -21,15 +21,20 @@
   class ArgList;
 
 namespace options {
+  /// Base flags for all options. Custom flags may be added after.
   enum DriverFlag {
-DriverOption = (1  0),
-HelpHidden   = (1  1),
-LinkerInput  = (1  2),
-NoArgumentUnused = (1  3),
-NoForward= (1  4),
-RenderAsInput= (1  5),
-RenderJoined = (1  6),
-RenderSeparate   = (1  7),
+HelpHidden   = (1  0),
+RenderAsInput= (1  1),
+RenderJoined = (1  2),
+RenderSeparate   = (1  3),
+  };
+
+  /// Flags specifically for clang options.
+  enum ClangFlags {
+DriverOption = (1  4),
+LinkerInput  = (1  5),
+NoArgumentUnused = (1  6),
+NoForward= (1  7),
 Unsupported  = (1  8),
 CC1Option= (1  9)
   };
@@ -68,7 +73,7 @@
   RenderValuesStyle
 };
 
-  private:
+  protected:
 const OptTable::Info *Info;
 const OptTable *Owner;
 
@@ -84,23 +89,23 @@
   assert(Info  Must have a valid info!);
   return Info-ID;
 }
-
+
 OptionClass getKind() const {
   assert(Info  Must have a valid info!);
   return OptionClass(Info-Kind);
 }
-
+
 StringRef getName() const {
   assert(Info  Must have a valid info!);
   return Info-Name;
 }
-
+
 const Option getGroup() const {
   assert(Info  Must have a valid info!);
   assert(Owner  Must have a valid owner!);
   return Owner-getOption(Info-GroupID);
 }
-
+
 const Option getAlias() const {
   assert(Info  Must have a valid info!);
   assert(Owner  Must have a valid owner!);
@@ -109,10 +114,6 @@
 
 unsigned getNumArgs() const { return Info-Param; }
 
-bool isUnsupported() const { return Info-Flags  options::Unsupported; }
-
-bool isLinkerInput() const { return Info-Flags  options::LinkerInput; }
-
 bool hasNoOptAsInput() const { return Info-Flags  
options::RenderAsInput;}
 
 RenderStyleKind getRenderStyle() const {
@@ -139,18 +140,9 @@
   llvm_unreachable(Unexpected kind!);
 }
 
-bool isDriverOption() const { return Info-Flags  options::DriverOption; }
-
-bool hasNoArgumentUnused() const {
-  return Info-Flags  options::NoArgumentUnused;
-}
-
-bool hasNoForward() const { return Info-Flags  options::NoForward; }
-
-bool isCC1Option() const { return Info-Flags  options::CC1Option; }
-
-bool hasForwardToGCC() const {
-  return !hasNoForward()  !isDriverOption()  !isLinkerInput();
+/// Test if this option has the flag \a Val.
+bool hasFlag(unsigned Val) const {
+  return Info-Flags  Val;
 }
 
 /// getUnaliasedOption - Return the final option this option

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=166230r1=166229r2=166230view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct 18 16:36:01 2012
@@ -98,7 +98,7 @@
   for (ArgList::const_iterator it = Args-begin(), ie = Args-end();
it != ie; ++it) {
 Arg *A = *it;
-if (A-getOption().isUnsupported()) {
+if (A-getOption().hasFlag(options::Unsupported)) {
   Diag(clang::diag::err_drv_unsupported_opt)  A-getAsString(*Args);
   continue;
 }
@@ -1033,7 +1033,7 @@
   } else
 Inputs.push_back(std::make_pair(Ty, A));
 
-} else if (A-getOption().isLinkerInput()) {
+} else if (A-getOption().hasFlag(options::LinkerInput)) {
   // Just treat as object type, we could make a special type for this if
   // necessary.
   Inputs.push_back(std::make_pair(types::TY_Object, A));
@@ -1300,7 +1300,7 @@
 // DiagnosticsEngine, so that extra values, position, and so on could be
 // printed.
 if (!A-isClaimed()) {
-  if (A-getOption().hasNoArgumentUnused())
+  if (A-getOption().hasFlag(options::NoArgumentUnused))
 continue;
 
   // Suppress the warning automatically if this is just a flag, and it is 
an

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 

[cfe-commits] r166231 - in /cfe/trunk: include/clang/AST/Comment.h lib/AST/Comment.cpp lib/AST/CommentDumper.cpp lib/AST/CommentSema.cpp tools/libclang/CXComment.cpp unittests/AST/CommentParser.cpp

2012-10-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Thu Oct 18 16:42:42 2012
New Revision: 166231

URL: http://llvm.org/viewvc/llvm-project?rev=166231view=rev
Log:
[doc parsing] use getParamName to access parameter 
for current(rewritten) comment and getParamNameAsWritten
to access param name coming with \param marker.

Modified:
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/CommentDumper.cpp
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/tools/libclang/CXComment.cpp
cfe/trunk/unittests/AST/CommentParser.cpp

Modified: cfe/trunk/include/clang/AST/Comment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166231r1=166230r2=166231view=diff
==
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Oct 18 16:42:42 2012
@@ -707,6 +707,10 @@
   }
 
   StringRef getParamName(comments::FullComment *FC) const;
+  
+  StringRef getParamNameAsWritten() const {
+return Args[0].Text;
+  }
 
   SourceRange getParamNameRange() const {
 return Args[0].Range;
@@ -760,6 +764,10 @@
   }
 
   StringRef getParamName(comments::FullComment *FC) const;
+  
+  StringRef getParamNameAsWritten() const {
+return Args[0].Text;
+  }
 
   SourceRange getParamNameRange() const {
 return Args[0].Range;

Modified: cfe/trunk/lib/AST/Comment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=166231r1=166230r2=166231view=diff
==
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Thu Oct 18 16:42:42 2012
@@ -306,24 +306,22 @@
 }
 
 StringRef ParamCommandComment::getParamName(comments::FullComment *FC) const {
-  if (FC  isParamIndexValid())
-return FC-getThisDeclInfo()-ParamVars[getParamIndex()]-getName();
-  return Args[0].Text;
+  assert(isParamIndexValid());
+  return FC-getThisDeclInfo()-ParamVars[getParamIndex()]-getName();
 }
 
 StringRef TParamCommandComment::getParamName(comments::FullComment *FC) const {
-  if (FC  isPositionValid()) {
-const TemplateParameterList *TPL = 
FC-getThisDeclInfo()-TemplateParameters;
-for (unsigned i = 0, e = getDepth(); i != e; ++i) {
-  if (i == e-1)
-return TPL-getParam(getIndex(i))-getName();
-  const NamedDecl *Param = TPL-getParam(getIndex(i));
-  if (const TemplateTemplateParmDecl *TTP =
+  assert(isPositionValid());
+  const TemplateParameterList *TPL = FC-getThisDeclInfo()-TemplateParameters;
+  for (unsigned i = 0, e = getDepth(); i != e; ++i) {
+if (i == e-1)
+  return TPL-getParam(getIndex(i))-getName();
+const NamedDecl *Param = TPL-getParam(getIndex(i));
+if (const TemplateTemplateParmDecl *TTP =
   dyn_castTemplateTemplateParmDecl(Param))
-TPL = TTP-getTemplateParameters();
-}
+  TPL = TTP-getTemplateParameters();
   }
-  return Args[0].Text;
+  return ;
 }
   
 } // end namespace comments

Modified: cfe/trunk/lib/AST/CommentDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentDumper.cpp?rev=166231r1=166230r2=166231view=diff
==
--- cfe/trunk/lib/AST/CommentDumper.cpp (original)
+++ cfe/trunk/lib/AST/CommentDumper.cpp Thu Oct 18 16:42:42 2012
@@ -186,8 +186,12 @@
   else
 OS   implicitly;
 
-  if (C-hasParamName())
-OS   Param=\  C-getParamName(const_castFullComment*(FC))  \;
+  if (C-hasParamName()) {
+if (C-isParamIndexValid())
+  OS   Param=\  C-getParamName(const_castFullComment*(FC))  
\;
+else
+  OS   Param=\  C-getParamNameAsWritten()  \;
+  }
 
   if (C-isParamIndexValid())
 OS   ParamIndex=  C-getParamIndex();
@@ -197,7 +201,10 @@
   dumpComment(C);
 
   if (C-hasParamName()) {
-OS   Param=\  C-getParamName(const_castFullComment*(FC))  \;
+if (C-isPositionValid())
+  OS   Param=\  C-getParamName(const_castFullComment*(FC))  
\;
+else
+  OS   Param=\  C-getParamNameAsWritten()  \;
   }
 
   if (C-isPositionValid()) {

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=166231r1=166230r2=166231view=diff
==
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Thu Oct 18 16:42:42 2012
@@ -574,7 +574,7 @@
 ParamCommandComment *PCC = dyn_castParamCommandComment(*I);
 if (!PCC || !PCC-hasParamName())
   continue;
-StringRef ParamName = PCC-getParamName(0);
+StringRef ParamName = PCC-getParamNameAsWritten();
 
 // Check that referenced parameter name is in the function decl.
 const unsigned ResolvedParamIndex = resolveParmVarReference(ParamName,
@@ -609,7 +609,7 @@
 const ParamCommandComment *PCC = UnresolvedParamCommands[i];
 
 

Re: [cfe-commits] r165771 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Comment.h lib/AST/ASTContext.cpp lib/AST/Comment.cpp lib/AST/CommentSema.cpp test/Index/overriding-method-co

2012-10-18 Thread jahanian

On Oct 18, 2012, at 9:18 AM, Douglas Gregor dgre...@apple.com wrote:

 Hi Dmitri,
 
 On Oct 18, 2012, at 5:03 AM, Dmitri Gribenko griboz...@gmail.com wrote:
 
 
 (2) ParamCommandComment::getParamName and others used to return the
 parameter name *as written* in \param command, without any regard to
 resolving the name to an index in function parameter list.  Now they
 serve dual purpose of returning that parameter name or rewriting it.
 This also breaks the purpose of getParamNameRange() nearby.  I think
 that getParamName should be split into two getter functions -- to get
 parameter name as written (getParamName() as it was) or with some
 magic rewriting (getParamNameInDecl()).
 
 I'm fine with splitting it into two functions. In general in the Clang ASTs, 
 we have getFoo() be the semantic property and we add a getFooAsWritten() 
 for the syntax as written. I suggest we do that.
 
This part is done in r166231.
- fariborz

 I think we should also deal with rewriting of \p. Yes, it means some lookup, 
 but it'll give a more consistent experience.
 
   - Doug

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


[cfe-commits] r166233 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp

2012-10-18 Thread Douglas Gregor
Author: dgregor
Date: Thu Oct 18 16:47:16 2012
New Revision: 166233

URL: http://llvm.org/viewvc/llvm-project?rev=166233view=rev
Log:
Move OriginalDir from ASTReader to ModuleFile.

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

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=166233r1=166232r2=166233view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 18 16:47:16 2012
@@ -645,10 +645,6 @@
   SmallVectorserialization::SubmoduleID, 2 ImportedModules;
   //@}
 
-  /// \brief The directory that the PCH was originally created in. Used to
-  /// allow resolving headers even after headers+PCH was moved to a new path.
-  std::string OriginalDir;
-
   /// \brief The directory that the PCH we are reading is stored in.
   std::string CurrentDir;
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166233r1=166232r2=166233view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 16:47:16 2012
@@ -1130,10 +1130,10 @@
   OverriddenBuffer? FileMgr.getVirtualFile(Filename, (off_t)Record[4],
(time_t)Record[5])
   : FileMgr.getFile(Filename, /*OpenFile=*/false);
-if (File == 0  !OriginalDir.empty()  !CurrentDir.empty() 
-OriginalDir != CurrentDir) {
+if (File == 0  !F-OriginalDir.empty()  !CurrentDir.empty() 
+F-OriginalDir != CurrentDir) {
   std::string resolved = resolveFileRelativeToOriginalDir(Filename,
-  OriginalDir,
+  F-OriginalDir,
   CurrentDir);
   if (!resolved.empty())
 File = FileMgr.getFile(resolved);
@@ -1708,13 +1708,14 @@
 }
 
 const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) {
+  ModuleFile M = ModuleMgr.getPrimaryModule();
   std::string Filename = filenameStrRef;
-  MaybeAddSystemRootToFilename(ModuleMgr.getPrimaryModule(), Filename);
+  MaybeAddSystemRootToFilename(M, Filename);
   const FileEntry *File = FileMgr.getFile(Filename);
-  if (File == 0  !OriginalDir.empty()  !CurrentDir.empty() 
-  OriginalDir != CurrentDir) {
+  if (File == 0  !M.OriginalDir.empty()  !CurrentDir.empty() 
+  M.OriginalDir != CurrentDir) {
 std::string resolved = resolveFileRelativeToOriginalDir(Filename,
-OriginalDir,
+M.OriginalDir,
 CurrentDir);
 if (!resolved.empty())
   File = FileMgr.getFile(resolved);
@@ -1865,20 +1866,14 @@
 }
 
 case ORIGINAL_FILE:
-  // Only record from the primary AST file.
-  if (F == *ModuleMgr.begin()) {
-F.OriginalSourceFileID = FileID::get(Record[0]);
-F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen);
-F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
-MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName);
-  }
+  F.OriginalSourceFileID = FileID::get(Record[0]);
+  F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen);
+  F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
+  MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName);
   break;
 
 case ORIGINAL_PCH_DIR:
-  // Only record from the primary AST file.
-  if (F == *ModuleMgr.begin()) {
-OriginalDir.assign(BlobStart, BlobLen);
-  }
+  F.OriginalDir.assign(BlobStart, BlobLen);
   break;
 }
   }


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


[cfe-commits] r166235 - /cfe/trunk/include/clang/Driver/Option.h

2012-10-18 Thread Eric Christopher
Author: echristo
Date: Thu Oct 18 16:52:10 2012
New Revision: 166235

URL: http://llvm.org/viewvc/llvm-project?rev=166235view=rev
Log:
Remove trailing comma.

Modified:
cfe/trunk/include/clang/Driver/Option.h

Modified: cfe/trunk/include/clang/Driver/Option.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=166235r1=166234r2=166235view=diff
==
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Thu Oct 18 16:52:10 2012
@@ -26,7 +26,7 @@
 HelpHidden   = (1  0),
 RenderAsInput= (1  1),
 RenderJoined = (1  2),
-RenderSeparate   = (1  3),
+RenderSeparate   = (1  3)
   };
 
   /// Flags specifically for clang options.


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


[cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp lib/F

2012-10-18 Thread Eric Christopher
Author: echristo
Date: Thu Oct 18 16:52:18 2012
New Revision: 166236

URL: http://llvm.org/viewvc/llvm-project?rev=166236view=rev
Log:
Add a new option for and disable column number information as there
are no known current users of column info. Robustify and fix up
a few tests in the process. Reduces the size of debug information
by a small amount.

Part of PR14106

Added:
cfe/trunk/test/CodeGen/debug-info-line4.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/debug-info-iv.c
cfe/trunk/test/CodeGen/debug-info-line3.c
cfe/trunk/test/CodeGen/debug-line-1.c
cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp
cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=166236r1=166235r2=166236view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Oct 18 16:52:18 2012
@@ -143,6 +143,8 @@
   HelpTextThe compilation directory to embed in the debug info.;
 def dwarf_debug_flags : Separate-dwarf-debug-flags,
   HelpTextThe string to embed in the Dwarf debug flags record.;
+def dwarf_column_info : Flag-dwarf-column-info,
+  HelpTextTurn on column location information.;
 def fforbid_guard_variables : Flag-fforbid-guard-variables,
   HelpTextEmit an error if a C++ static local initializer would need a guard 
variable;
 def no_implicit_float : Flag-no-implicit-float,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=166236r1=166235r2=166236view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 18 16:52:18 2012
@@ -716,6 +716,7 @@
   Groupg_flags_Group;
 def gstrict_dwarf : Flag-gstrict-dwarf, Groupg_flags_Group;
 def gno_strict_dwarf : Flag-gno-strict-dwarf, Groupg_flags_Group;
+def gcolumn_info : Flag-gcolumn-info, Groupg_flags_Group;
 def headerpad__max__install__names : Joined-headerpad_max_install_names;
 def help : Flag-help, Flags[CC1Option],
   HelpTextDisplay available options;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=166236r1=166235r2=166236view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Thu Oct 18 16:52:18 2012
@@ -145,6 +145,9 @@
   /// The kind of generated debug info.
   DebugInfoKind DebugInfo;
 
+  /// Whether or not to use column information in debug info.
+  bool DebugColumnInfo;
+
   /// The string to embed in the debug information for the compile unit, if
   /// non-empty.
   std::string DwarfDebugFlags;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=166236r1=166235r2=166236view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 18 16:52:18 2012
@@ -259,6 +259,8 @@
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) {
   if (Loc.isInvalid()  CurLoc.isInvalid())
 return 0;
+  if (!CGM.getCodeGenOpts().DebugColumnInfo)
+return 0;
   SourceManager SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
   return PLoc.isValid()? PLoc.getColumn() : 0;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=166236r1=166235r2=166236view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 18 16:52:18 2012
@@ -2050,6 +2050,8 @@
 
   // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
+  if (Args.hasArg(options::OPT_gcolumn_info))
+CmdArgs.push_back(-dwarf-column-info);
 
   Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections);
   Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections);

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

[cfe-commits] r166237 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/ast-print.cpp

2012-10-18 Thread Eli Friedman
Author: efriedma
Date: Thu Oct 18 16:53:46 2012
New Revision: 166237

URL: http://llvm.org/viewvc/llvm-project?rev=166237view=rev
Log:
Use the type as written when pretty-printing C-style casts.  Patch by Grzegorz 
Jablonski.


Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=166237r1=166236r2=166237view=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Oct 18 16:53:46 2012
@@ -936,7 +936,7 @@
   OS  Node-getAccessor().getName();
 }
 void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
-  OS  (  Node-getType().getAsString(Policy)  );
+  OS  (  Node-getTypeAsWritten().getAsString(Policy)  );
   PrintExpr(Node-getSubExpr());
 }
 void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=166237r1=166236r2=166237view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct 18 16:53:46 2012
@@ -13,8 +13,7 @@
 MyClass* operator -() { return object; }
 };
 
-int main()
-{
+void test1() {
 Reference r;
 (r-method());
 }
@@ -23,7 +22,7 @@
 // CHECK:  while (int a = 1)
 // CHECK:  switch (int a = 1)
 
-void f()
+void test2()
 {
 if (int a = 1) { }
 while (int a = 1) { }
@@ -32,7 +31,7 @@
 
 // CHECK: new (1) int;
 void *operator new (typeof(sizeof(1)), int, int = 2);
-void f2() {
+void test3() {
   new (1) int;
 }
 
@@ -40,9 +39,16 @@
 struct X {
   void *operator new (typeof(sizeof(1)), int = 2);
 };
-void f2() { new X; }
+void test4() { new X; }
 
 // CHECK: for (int i = 2097, j = 42; false;)
-void forInit() {
+void test5() {
   for (int i = 2097, j = 42; false;) {}
 }
+
+// CHECK: test6fn((int )y);
+void test6fn(int x);
+void test6() {
+unsigned int y = 0;
+test6fn((int)y);
+}


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


Re: [cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp l

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 2:52 PM, Eric Christopher echri...@gmail.com wrote:

 Author: echristo
 Date: Thu Oct 18 16:52:18 2012
 New Revision: 166236
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166236view=rev
 Log:
 Add a new option for and disable column number information as there
 are no known current users of column info. Robustify and fix up
 a few tests in the process. Reduces the size of debug information
 by a small amount.


I'd rather we try to optimize column-number computation first. If we can make 
it fast enough, we don't need to add this tweaking flag.

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


Re: [cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp l

2012-10-18 Thread Chris Lattner

On Oct 18, 2012, at 2:58 PM, Douglas Gregor dgre...@apple.com wrote:

 
 On Oct 18, 2012, at 2:52 PM, Eric Christopher echri...@gmail.com wrote:
 
 Author: echristo
 Date: Thu Oct 18 16:52:18 2012
 New Revision: 166236
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166236view=rev
 Log:
 Add a new option for and disable column number information as there
 are no known current users of column info. Robustify and fix up
 a few tests in the process. Reduces the size of debug information
 by a small amount.
 
 
 I'd rather we try to optimize column-number computation first. If we can make 
 it fast enough, we don't need to add this tweaking flag.

Did you take a look at the comments in the PR?  There is no known client of 
this information, it bloats debug information, and it forces computation 
(which, yes, could be sped up) that isn't otherwise needed.  It seems like 
clearly the wrong thing to enable by default.

When/if we want to enable it by default, it can be carefully measured and other 
options can be considered (maybe subexpression range info, not just line/col 
info, etc).

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


Re: [cfe-commits] r166188 - /cfe/trunk/lib/Sema/SemaInit.cpp

2012-10-18 Thread Robert Muth
On Thu, Oct 18, 2012 at 4:48 PM, David Blaikie dblai...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 1:45 PM, Douglas Gregor dgre...@apple.com wrote:

 On Oct 18, 2012, at 9:57 AM, David Blaikie dblai...@gmail.com wrote:

 Author: dblaikie
 Date: Thu Oct 18 11:57:32 2012
 New Revision: 166188

 URL: http://llvm.org/viewvc/llvm-project?rev=166188view=rev
 Log:
 PR14021: Copy lookup results to ensure safe iteration.

 Within the body of the loop the underlying map may be modified via

  Sema::AddOverloadCandidate
- Sema::CompareReferenceRelationship
- Sema::RequireCompleteType

 to avoid the use of invalid iterators the sequence is copied first.

 Did you audit other uses of LookupConstructors to ensure that this is the 
 only ticking time bomb in this area?

 [+Robert Muth]

 I've not performed any such audit, no. With the hack debug check
 inserted we could just run the whole test suite to see if anything
 pops up.

I did not  perform any such audit either. I feel those are only of limited use
and the time would be better spend addressing the root of the issue.
If there is interest I could  try add some diagnostic code to the DenseMap
which would only be enabled in Debug mode.
We kicked around some ideas over lunch and here was one suggestion
that could work:
add an atomic timestamp to each DenseMap.
increment the time step whenever iterators are invalidated (e.g. insertions),
Each iterator also holds a copy of the timestamp form when it was created
so we can compare it against the parent container timestamp when\ever
the iterator is used.
I have not thought this through all this much, so it may not work in the end.
Any feedback would be welcome.
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp l

2012-10-18 Thread Eric Christopher

 I'd rather we try to optimize column-number computation first. If we can make 
 it fast enough, we don't need to add this tweaking flag.


I think the two are orthogonal here. Basically there's no reason to
bother emitting them unless someone is using them. We do a reasonable
job of emitting a small representation, but if there's really no
consumer it seems like a bit of a waste of space and time.

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


Re: [cfe-commits] [PATCH] [llvm+clang] memset for non-8-bit bytes

2012-10-18 Thread Chris Lattner

On Oct 18, 2012, at 6:11 AM, Patrik Hägglund H patrik.h.haggl...@ericsson.com 
wrote:

 We have a back-end with 16-bit bytes, and have changed the memset
 intrinsics to be able to work on arbitrary word sizes, just as memcpy.

Hi Patrik,

This is interesting.  Please start a thread on llvmdev about this 
functionality, and outline what other intrinsics will have to change to add 
non-8-bit byte support.  This isn't the sort of feature that we just add 
without understanding the full impact.

Also, to actually roll this out, you'll need to add lib/VMCore/AutoUpgrade.cpp 
support for this change, because we need to be able to read old .bc and .ll 
files that use the previous form of the intrinsic.

-Chris

 
 This patch updates the type of the second parameter of memset in
 Intrinsics.td, from llvm_i8_ty, to llvm_anyint_ty:
 
 def int_memset  : Intrinsic[],
 -[llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
 +[llvm_anyptr_ty, llvm_anyint_ty, llvm_anyint_ty,
  llvm_i32_ty, llvm_i1_ty],
 
 IRBuilder.cpp and LangRef.html is updated accordingly.
 
 To use the intrinsic, the declaration,
 
  declare void @llvm.memset.p0i8.i32(i8* dest, i8 val,
 i32 len, i32 align, i1 isvolatile)
 
 now becomes
 
  declare void @llvm.memset.p0i8.i8.i32(i8* dest, i8 val,
i32 len, i32 align, i1 
 isvolatile)
 
 The bulk of this patch consists of such changes (mainly in tests).
 
 Some tests in clang has to be updated, as shown by the second patch file.
 
 /Patrik Hägglund  
 0002-clang-Change-memset-in-Intrinsics.td-to-take-anyint.patch0001-llvm-Change-memset-in-Intrinsics.td-to-take-anyint.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


Re: [cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp l

2012-10-18 Thread Douglas Gregor

On Oct 18, 2012, at 3:00 PM, Chris Lattner clatt...@apple.com wrote:

 
 On Oct 18, 2012, at 2:58 PM, Douglas Gregor dgre...@apple.com wrote:
 
 
 On Oct 18, 2012, at 2:52 PM, Eric Christopher echri...@gmail.com wrote:
 
 Author: echristo
 Date: Thu Oct 18 16:52:18 2012
 New Revision: 166236
 
 URL: http://llvm.org/viewvc/llvm-project?rev=166236view=rev
 Log:
 Add a new option for and disable column number information as there
 are no known current users of column info. Robustify and fix up
 a few tests in the process. Reduces the size of debug information
 by a small amount.
 
 
 I'd rather we try to optimize column-number computation first. If we can 
 make it fast enough, we don't need to add this tweaking flag.
 
 Did you take a look at the comments in the PR?  There is no known client of 
 this information, it bloats debug information, and it forces computation 
 (which, yes, could be sped up) that isn't otherwise needed.  It seems like 
 clearly the wrong thing to enable by default.


Hrm, I skimmed over the no known current users. I hate such configuration 
flags, but this one makes sense.

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


Re: [cfe-commits] [Patch] compiler-rt: SPARC64-optimized multiply/divide

2012-10-18 Thread Chris Lattner

On Oct 18, 2012, at 1:00 AM, Ed Schouten e...@80386.nl wrote:

 Hi all,
 
 Attached is the latest version of a patch we use at FreeBSD to add
 optimized multiply/divide functions on SPARC64. Description from the
 original bug report[1]:

Very cool.  Please send this to llvm-commits though.

-Chris

 
 According to a developer at the FreeBSD project, FreeBSD's total compilation
 time increases by 2.6% when the host system is built against compiler-rt
 instead of libgcc. This is likely due to the fact that GCC has 
 assembly-written
 versions of the division and modulo routines, while compiler-rt does not.
 
 The division and modulo routines used by GCC can easily be re-used by
 compiler-rt. They are provided for free in The SPARC Architecture Manual
 Version 8. Attached to this bug report is a patch that I have written for
 compiler-rt. It contains the M4 file that is listed in the manual, with some
 small modifications:
 
 - The M4 file uses exponentiation (2^N). This seems to be a Sun-specific
 extension to M4, as I cannot reproduce it with GNU and BSD m4. Fix this 
 similar
 to OpenBSD's version by replacing 2^N with TWOSUPN.
 
 - Use the same register layout as GCC's version.
 
 - Integrate into compiler-rt's codebase by using 
 DEFINE_COMPILERRT_FUNCTION().
 
 The diff includes a `generate.sh', which generates the actual assembly
 files. I guess we don't want to depend on M4 to build compiler-rt, so
 it may be easier to run generate.sh and store the resulting C files in
 the repository as well. Sorry for not providing a CMakefile. At
 FreeBSD, we never build compiler-rt with CMake, as we imported
 compiler-rt into our own build infrastructure.
 
 -- 
 Ed Schouten e...@80386.nl
 
 [1] http://llvm.org/bugs/show_bug.cgi?id=11667
 compiler-rt-sparc64.txt___
 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: [cfe-commits] r166236 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/Tools.cpp l

2012-10-18 Thread Eric Christopher

 Hrm, I skimmed over the no known current users. I hate such configuration 
 flags, but this one makes sense.


Agreed. I just thought it was a waste to remove the code completely
since someone may want the information.

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


[cfe-commits] r166240 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

2012-10-18 Thread Eric Christopher
Author: echristo
Date: Thu Oct 18 17:08:02 2012
New Revision: 166240

URL: http://llvm.org/viewvc/llvm-project?rev=166240view=rev
Log:
Fix up comment and invert order. Most simple check first.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=166240r1=166239r2=166240view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 18 17:08:02 2012
@@ -254,13 +254,15 @@
   return PLoc.isValid()? PLoc.getLine() : 0;
 }
 
-/// getColumnNumber - Get column number for the location. If location is 
-/// invalid then use current location.
+/// getColumnNumber - Get column number for the location.
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) {
-  if (Loc.isInvalid()  CurLoc.isInvalid())
-return 0;
+  // We may not want column information at all.
   if (!CGM.getCodeGenOpts().DebugColumnInfo)
 return 0;
+
+  // If the location is invalid then use the current column.
+  if (Loc.isInvalid()  CurLoc.isInvalid())
+return 0;
   SourceManager SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
   return PLoc.isValid()? PLoc.getColumn() : 0;


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


Re: [cfe-commits] [LLVMdev] [cfe-dev] OpenMP support in CLANG: A proposal

2012-10-18 Thread Eli Friedman
On Thu, Oct 18, 2012 at 4:32 AM, Mahesha HS mahesha.l...@gmail.com wrote:
 Hi Eli,

 Thanks for all your comments.

 I have taken care of all your review comments. Yes, after I gone
 through your review
 comments, I also came to the conclusion that the addition of a new
 class for OpenMP
 pragma handling (class PragmaOmpHandler) is not necessarily required.
 However, initially, when  started, I my-self had an opinion that this
 class may required.
 Now, I removed this class, and moved the omp pragma registration directly into
 Preprocessor class.

 I have attached following two patches along with this mail. The
 patches also contains
  relevant *test cases*.

 patch 1:  fopenmp_option_support.patch
 patch 2:  omp_pragma_registration.patch

 In patch 1, I have taken care of all your earlier review comments
 related to -fopenmp option
 support. Patch 2 contains the implementation for the omp pragma
 registration with
 Preprocessor.

 Following files are changed respectively.

 patch 1:
 
 #.  clang/include/clang/Driver/Options.td
 #.  clang/include/clang/Basic/LangOptions.def
 #.  clang/lib/Driver/Tools.cpp
 #.  clang/lib/Frontend/CompilerInvocation.cpp
 #.  clang/test/Driver/clang_fopenmp_opt.c

+// RUN: %clang -S -v -o %t %s  21 | not grep -w -- -fopenmp
+// RUN: %clang -S -v -o %t %s -fopenmp 21 | grep -w -- -fopenmp

We usually prefer to write tests like this using -### instead of -v.

Otherwise, patch 1 looks fine.

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


Re: [cfe-commits] [LLVMdev] [cfe-dev] OpenMP support in CLANG: A proposal

2012-10-18 Thread Eli Friedman
On Thu, Oct 18, 2012 at 6:34 AM, Mahesha HS mahesha.l...@gmail.com wrote:
 Sorry, in my previous mail,  I had missed to attach changes to
 clang/include/clang/Basic/TokenKinds.def in the patch 2. Please
 refer to the patch (2) attached in *this* mail, instead of the one
 sent in the previous mail. Patch 1 is fine.

+//
+// OpenMP directives
+//
+// \#pragam omp parallel ...
+TOK(pragma_omp_parallel)
+// \#pragam omp for ...
+TOK(pragma_omp_for)

Please use ANNOTATION(pragma_omp_parallel) etc. instead.

+/// PragmaOmpHandler - \#pragma omp 
+templateclass T, tok::TokenKind TKind
+struct PragmaOmpHandler : public PragmaHandler {
+  PragmaOmpHandler() : PragmaHandler(T::Name) {}
+  virtual void HandlePragma(Preprocessor PP, PragmaIntroducerKind Introducer,
+Token OmpTok) {
+PP.HandlePragmaOmp(OmpTok, TKind);
+  }
+};

Something like following would make your patch substantially shorter:

struct PragmaOmpHandler : public PragmaHandler {
  tok::TokenKind TKind;
  PragmaOmpHandler(tok::TokenKind Kind, StringRef Name)
: PragmaHandler(Name), TKind(Kind) {}
  virtual void HandlePragma(Preprocessor PP, PragmaIntroducerKind Introducer,
Token OmpTok) {
PP.HandlePragmaOmp(OmpTok, TKind);
  }
};


Please add a test that the pragmas round-trip correctly through clang -E.

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


  1   2   >