Re: [PATCH] Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Manuel Klimek
I assume this makes something faster? Do you have some numbers?


Comment at: lib/ASTMatchers/ASTMatchFinder.cpp:439
@@ +438,3 @@
+  void match(const ast_type_traits::DynTypedNode Node) {
+// TODO: Improve this with a switch or a visitor pattern.
+if (auto *N = Node.getDecl()) {

FIXME:

http://reviews.llvm.org/D5197



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


r217234 - clang/test/CXX/drs/dr5xx.cpp: Fix up assumption of thiscall. It affects not x64 but x86.

2014-09-05 Thread NAKAMURA Takumi
Author: chapuni
Date: Fri Sep  5 03:18:53 2014
New Revision: 217234

URL: http://llvm.org/viewvc/llvm-project?rev=217234view=rev
Log:
clang/test/CXX/drs/dr5xx.cpp: Fix up assumption of thiscall. It affects not x64 
but x86.

Note, i686-cygwin doesn't use thiscall.

Modified:
cfe/trunk/test/CXX/drs/dr5xx.cpp

Modified: cfe/trunk/test/CXX/drs/dr5xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=217234r1=217233r2=217234view=diff
==
--- cfe/trunk/test/CXX/drs/dr5xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr5xx.cpp Fri Sep  5 03:18:53 2014
@@ -518,10 +518,10 @@ namespace dr546 { // dr546: yes
 }
 
 namespace dr547 { // dr547: yes
-  // When targeting the MS ABI, the type of a member function includes a
+  // When targeting the MS x86 ABI, the type of a member function includes a
   // __thiscall qualifier. This is non-conforming, but we still implement
   // the intent of dr547
-#if defined(_M_IX86) || defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(_M_IX86) || (defined(__MINGW32__)  !defined(__MINGW64__))
 #define THISCALL __thiscall
 #else
 #define THISCALL


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


r217235 - clang-format: [JS] Fix indentation in dict literals.

2014-09-05 Thread Daniel Jasper
Author: djasper
Date: Fri Sep  5 03:29:31 2014
New Revision: 217235

URL: http://llvm.org/viewvc/llvm-project?rev=217235view=rev
Log:
clang-format: [JS] Fix indentation in dict literals.

Before:
  return {
'finish':
//
a
};

After:
  return {
'finish':
//
a
  };

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=217235r1=217234r2=217235view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Sep  5 03:29:31 2014
@@ -1110,12 +1110,16 @@ private:
   /// and other tokens that we treat like binary operators.
   int getCurrentPrecedence() {
 if (Current) {
+  const FormatToken *NextNonComment = Current-getNextNonComment();
   if (Current-Type == TT_ConditionalExpr)
 return prec::Conditional;
+  else if (NextNonComment  NextNonComment-is(tok::colon) 
+   NextNonComment-Type == TT_DictLiteral)
+return prec::Comma;
   else if (Current-is(tok::semi) || Current-Type == TT_InlineASMColon ||
Current-Type == TT_SelectorName ||
-   (Current-is(tok::comment)  Current-getNextNonComment() 
-Current-getNextNonComment()-Type == TT_SelectorName))
+   (Current-is(tok::comment)  NextNonComment 
+NextNonComment-Type == TT_SelectorName))
 return 0;
   else if (Current-Type == TT_RangeBasedForLoopColon)
 return prec::Comma;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=217235r1=217234r2=217235view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Sep  5 03:29:31 2014
@@ -123,6 +123,11 @@ TEST_F(FormatTestJS, ContainerLiterals)
  // comment for tasks\n
  tasks: false\n
};);
+  verifyFormat(return {\n
+ 'finish':\n
+ //\n
+ a\n
+   };);
 }
 
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {


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


r217236 - clang-format: [JS] Better support for empty function literals.

2014-09-05 Thread Daniel Jasper
Author: djasper
Date: Fri Sep  5 03:42:27 2014
New Revision: 217236

URL: http://llvm.org/viewvc/llvm-project?rev=217236view=rev
Log:
clang-format: [JS] Better support for empty function literals.

Before:
  SomeFunction(function(){});

After:
  SomeFunction(function() {});

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=217236r1=217235r2=217236view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Sep  5 03:42:27 2014
@@ -1041,6 +1041,13 @@ void UnwrappedLineParser::parseParens()
   if (FormatTok-Tok.is(tok::l_brace))
 parseBracedList();
   break;
+case tok::identifier:
+  if (Style.Language == FormatStyle::LK_JavaScript 
+  FormatTok-TokenText == function)
+tryToParseJSFunction();
+  else
+nextToken();
+  break;
 default:
   nextToken();
   break;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=217236r1=217235r2=217236view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Sep  5 03:42:27 2014
@@ -167,6 +167,7 @@ TEST_F(FormatTestJS, FormatsFreestanding
 }
 
 TEST_F(FormatTestJS, FunctionLiterals) {
+  verifyFormat(doFoo(function() {}););
   verifyFormat(doFoo(function() { return 1; }););
   verifyFormat(var func = function() { return 1; };);
   verifyFormat(return {\n


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


r217237 - clang-format: [JS] JavaScript does not have the *// madness.

2014-09-05 Thread Daniel Jasper
Author: djasper
Date: Fri Sep  5 03:53:45 2014
New Revision: 217237

URL: http://llvm.org/viewvc/llvm-project?rev=217237view=rev
Log:
clang-format: [JS] JavaScript does not have the *// madness.

Before:
  e e.SomeFunction();

After:
  e  e.SomeFunction();

Yeah, this might be useful for C++, too, but it is not such a frequent
pattern there (plus the fix is much harder).

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=217237r1=217236r2=217237view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Sep  5 03:53:45 2014
@@ -917,6 +917,9 @@ private:
   /// \brief Return the type of the given token assuming it is * or .
   TokenType determineStarAmpUsage(const FormatToken Tok, bool IsExpression,
   bool InTemplateArgument) {
+if (Style.Language == FormatStyle::LK_JavaScript)
+  return TT_BinaryOperator;
+
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
 if (!PrevToken)
   return TT_UnaryOperator;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=217237r1=217236r2=217237view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Sep  5 03:53:45 2014
@@ -83,6 +83,10 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
   verifyFormat(var b = a.map((x) = x + 1););
 }
 
+TEST_F(FormatTestJS, UnderstandsAmpAmp) {
+  verifyFormat(e  e.SomeFunction(););
+}
+
 TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) {
   verifyFormat(not.and.or.not_eq = 1;);
 }


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


r217238 - clang-format: [JS] Format embedded function literals more efficently.

2014-09-05 Thread Daniel Jasper
Author: djasper
Date: Fri Sep  5 04:27:38 2014
New Revision: 217238

URL: http://llvm.org/viewvc/llvm-project?rev=217238view=rev
Log:
clang-format: [JS] Format embedded function literals more efficently.

Before:
  return {
a: a,
link:
function() {
  f();  //
},
link:
function() {
  f();  //
}
  };

After:
  return {
a: a,
link: function() {
  f();  //
},
link: function() {
  f();  //
}
  };

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=217238r1=217237r2=217238view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Sep  5 04:27:38 2014
@@ -643,7 +643,8 @@ unsigned ContinuationIndenter::moveState
   State.Stack[State.Stack.size() - 2].JSFunctionInlined = false;
 }
 if (Current.TokenText == function)
-  State.Stack.back().JSFunctionInlined = !Newline;
+  State.Stack.back().JSFunctionInlined =
+  !Newline  Previous  Previous-Type != TT_DictLiteral;
   }
 
   moveStatePastFakeLParens(State, Newline);

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=217238r1=217237r2=217238view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Sep  5 04:27:38 2014
@@ -110,14 +110,12 @@ TEST_F(FormatTestJS, ContainerLiterals)
};);
   verifyFormat(return {\n
  a: a,\n
- link:\n
- function() {\n
-   f();  //\n
- },\n
- link:\n
- function() {\n
-   f();  //\n
- }\n
+ link: function() {\n
+   f();  //\n
+ },\n
+ link: function() {\n
+   f();  //\n
+ }\n
};);
   verifyFormat(var stuff = {\n
  // comment for update\n


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


Re: r217187 - MS inline asm: Allow __asm blocks to set a return value

2014-09-05 Thread Renato Golin
Hi Reid,

The test is triggering errors on our build, can you restrict it somewhere?

error: MS-style inline assembly is not available: No available targets
are compatible with this triple, see -version for the available
targets.

http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a15/builds/2461/steps/check-all/logs/Clang%3A%3Ams-inline-asm-return.cpp

cheers,
--renato

On 4 September 2014 21:04, Reid Kleckner r...@kleckner.net wrote:
 Author: rnk
 Date: Thu Sep  4 15:04:38 2014
 New Revision: 217187

 URL: http://llvm.org/viewvc/llvm-project?rev=217187view=rev
 Log:
 MS inline asm: Allow __asm blocks to set a return value

 If control falls off the end of a function after an __asm block, MSVC
 assumes that the inline assembly filled the EAX and possibly EDX
 registers with an appropriate return value. This functionality is used
 in inline functions returning 64-bit integers in system headers, so we
 need some amount of compatibility.

 This is implemented in Clang by adding extra output constraints to every
 inline asm block, and storing the resulting output registers into the
 return value slot. If we see an asm block somewhere in the function
 body, we emit a normal epilogue instead of marking the end of the
 function with a return type unreachable.

 Normal returns in functions not using this functionality will overwrite
 the return value slot, and in most cases LLVM should be able to
 eliminate the dead stores.

 Fixes PR17201.

 Reviewed By: majnemer

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

 Added:
 cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp
 Modified:
 cfe/trunk/lib/CodeGen/CGStmt.cpp
 cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 cfe/trunk/lib/CodeGen/CodeGenFunction.h
 cfe/trunk/lib/CodeGen/TargetInfo.cpp
 cfe/trunk/lib/CodeGen/TargetInfo.h
 cfe/trunk/test/CodeGen/ms-inline-asm.c

 Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=217187r1=217186r2=217187view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Sep  4 15:04:38 2014
 @@ -1901,7 +1901,19 @@ void CodeGenFunction::EmitAsmStmt(const
  }
}

 -  unsigned NumConstraints = S.getNumOutputs() + S.getNumInputs();
 +  // If this is a Microsoft-style asm blob, store the return registers 
 (EAX:EDX)
 +  // to the return value slot. Only do this when returning in registers.
 +  if (isaMSAsmStmt(S)) {
 +const ABIArgInfo RetAI = CurFnInfo-getReturnInfo();
 +if (RetAI.isDirect() || RetAI.isExtend()) {
 +  // Make a fake lvalue for the return value slot.
 +  LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy);
 +  CGM.getTargetCodeGenInfo().addReturnRegisterOutputs(
 +  *this, ReturnSlot, Constraints, ResultRegTypes, 
 ResultTruncRegTypes,
 +  ResultRegDests, AsmString, S.getNumOutputs());
 +  SawAsmBlock = true;
 +}
 +  }

for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
  const Expr *InputExpr = S.getInputExpr(i);
 @@ -1974,9 +1986,9 @@ void CodeGenFunction::EmitAsmStmt(const
  StringRef Clobber = S.getClobber(i);

  if (Clobber != memory  Clobber != cc)
 -Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);
 +  Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);

 -if (i != 0 || NumConstraints != 0)
 +if (!Constraints.empty())
Constraints += ',';

  Constraints += ~{;
 @@ -2035,6 +2047,9 @@ void CodeGenFunction::EmitAsmStmt(const
  }
}

 +  assert(RegResults.size() == ResultRegTypes.size());
 +  assert(RegResults.size() == ResultTruncRegTypes.size());
 +  assert(RegResults.size() == ResultRegDests.size());
for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
  llvm::Value *Tmp = RegResults[i];


 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=217187r1=217186r2=217187view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Sep  4 15:04:38 2014
 @@ -39,7 +39,7 @@ CodeGenFunction::CodeGenFunction(CodeGen
CGBuilderInserterTy(this)),
CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
IsSanitizerScope(false), CurFuncIsThunk(false), 
 AutoreleaseResult(false),
 -  BlockInfo(nullptr), BlockPointer(nullptr),
 +  SawAsmBlock(false), BlockInfo(nullptr), BlockPointer(nullptr),
LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
NextCleanupDestIndex(1), FirstBlockInfo(nullptr), 
 EHResumeBlock(nullptr),
ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
 @@ -878,7 +878,7 @@ void CodeGenFunction::GenerateCode(Globa
// C11 6.9.1p12:
//   If the 

Re: r217187 - MS inline asm: Allow __asm blocks to set a return value

2014-09-05 Thread Timur Iskhodzhanov
Looks like r217192 wasn't enough?

2014-09-05 13:41 GMT+04:00 Renato Golin renato.go...@linaro.org:
 Hi Reid,

 The test is triggering errors on our build, can you restrict it somewhere?

 error: MS-style inline assembly is not available: No available targets
 are compatible with this triple, see -version for the available
 targets.

 http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a15/builds/2461/steps/check-all/logs/Clang%3A%3Ams-inline-asm-return.cpp

 cheers,
 --renato

 On 4 September 2014 21:04, Reid Kleckner r...@kleckner.net wrote:
 Author: rnk
 Date: Thu Sep  4 15:04:38 2014
 New Revision: 217187

 URL: http://llvm.org/viewvc/llvm-project?rev=217187view=rev
 Log:
 MS inline asm: Allow __asm blocks to set a return value

 If control falls off the end of a function after an __asm block, MSVC
 assumes that the inline assembly filled the EAX and possibly EDX
 registers with an appropriate return value. This functionality is used
 in inline functions returning 64-bit integers in system headers, so we
 need some amount of compatibility.

 This is implemented in Clang by adding extra output constraints to every
 inline asm block, and storing the resulting output registers into the
 return value slot. If we see an asm block somewhere in the function
 body, we emit a normal epilogue instead of marking the end of the
 function with a return type unreachable.

 Normal returns in functions not using this functionality will overwrite
 the return value slot, and in most cases LLVM should be able to
 eliminate the dead stores.

 Fixes PR17201.

 Reviewed By: majnemer

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

 Added:
 cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp
 Modified:
 cfe/trunk/lib/CodeGen/CGStmt.cpp
 cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 cfe/trunk/lib/CodeGen/CodeGenFunction.h
 cfe/trunk/lib/CodeGen/TargetInfo.cpp
 cfe/trunk/lib/CodeGen/TargetInfo.h
 cfe/trunk/test/CodeGen/ms-inline-asm.c

 Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=217187r1=217186r2=217187view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Sep  4 15:04:38 2014
 @@ -1901,7 +1901,19 @@ void CodeGenFunction::EmitAsmStmt(const
  }
}

 -  unsigned NumConstraints = S.getNumOutputs() + S.getNumInputs();
 +  // If this is a Microsoft-style asm blob, store the return registers 
 (EAX:EDX)
 +  // to the return value slot. Only do this when returning in registers.
 +  if (isaMSAsmStmt(S)) {
 +const ABIArgInfo RetAI = CurFnInfo-getReturnInfo();
 +if (RetAI.isDirect() || RetAI.isExtend()) {
 +  // Make a fake lvalue for the return value slot.
 +  LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy);
 +  CGM.getTargetCodeGenInfo().addReturnRegisterOutputs(
 +  *this, ReturnSlot, Constraints, ResultRegTypes, 
 ResultTruncRegTypes,
 +  ResultRegDests, AsmString, S.getNumOutputs());
 +  SawAsmBlock = true;
 +}
 +  }

for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
  const Expr *InputExpr = S.getInputExpr(i);
 @@ -1974,9 +1986,9 @@ void CodeGenFunction::EmitAsmStmt(const
  StringRef Clobber = S.getClobber(i);

  if (Clobber != memory  Clobber != cc)
 -Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);
 +  Clobber = getTarget().getNormalizedGCCRegisterName(Clobber);

 -if (i != 0 || NumConstraints != 0)
 +if (!Constraints.empty())
Constraints += ',';

  Constraints += ~{;
 @@ -2035,6 +2047,9 @@ void CodeGenFunction::EmitAsmStmt(const
  }
}

 +  assert(RegResults.size() == ResultRegTypes.size());
 +  assert(RegResults.size() == ResultTruncRegTypes.size());
 +  assert(RegResults.size() == ResultRegDests.size());
for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
  llvm::Value *Tmp = RegResults[i];


 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=217187r1=217186r2=217187view=diff
 ==
 --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Sep  4 15:04:38 2014
 @@ -39,7 +39,7 @@ CodeGenFunction::CodeGenFunction(CodeGen
CGBuilderInserterTy(this)),
CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
IsSanitizerScope(false), CurFuncIsThunk(false), 
 AutoreleaseResult(false),
 -  BlockInfo(nullptr), BlockPointer(nullptr),
 +  SawAsmBlock(false), BlockInfo(nullptr), BlockPointer(nullptr),
LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
NextCleanupDestIndex(1), FirstBlockInfo(nullptr), 
 EHResumeBlock(nullptr),
ExceptionSlot(nullptr), 

Re: r217187 - MS inline asm: Allow __asm blocks to set a return value

2014-09-05 Thread Renato Golin
On 5 September 2014 11:05, Timur Iskhodzhanov timur...@google.com wrote:
 Looks like r217192 wasn't enough?

Nope, still failing...

http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a15

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


[PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread Graham Hunter
Hi,

This patch adds support for the 32bit numeric max/min and directed
round-to-integral NEON intrinsics that were added as part of v8, along
with unit tests.

-Graham


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


Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread Tim Northover
Hi Graham,

This mostly looks fine. Just one comment on the tests:

+float32x2_t test_vrnda_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrnda_f32
+  // CHECK-LABEL: call 2 x float @llvm.arm.neon.vrinta.v2f32(2 x float %a)
+  return vrnda_f32(a);
+}

That second CHECK-LABEL should probably be just CHECK. The CHECK-LABEL
directive is there to split the test up into distinct regions (usually
functions) so that we don't accidentally find what we're looking for
in an unrelated piece of output. And to make sure we get told about it
more accurately when things go wrong.

Cheers.

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


RE: [PATCH] Division by zero

2014-09-05 Thread Anders Rönnholm
Hi,

I feel that to change this checker and the null dereference check would take a 
large amount of time compared to what is gained, time which could be used more 
efficiently on other checkers.
The null dereference check is already completed as path sensitive and works 
well. I don't know when we can deliver this as CFG-based (definitely not this 
year),  wouldn't it be better to have it like this now?

For a possible remake of this checker to a CFG-based one in the future, we 
would need more help from you on how to make them CFG-based. What parts of 
LiveVariables and DeadStoresChecker are related to our check? I guess just 
parts of the LiveVariables framework is needed.

So, Anna brought up that the check as implemented is very nearly 
path-independent, i.e. it only depends on flow-sensitive properties of the 
CFG. The path-sensitivity is buying us very little; it catches this case:

int y = x;
int div = z / y;
if (x) { ...}

But also warns here, which doesn't necessarily make sense:

int foo(int x, int y, int z) {
int div = z / y;
if (x) return div;
return 0;
}

foo(a, a, b); // only coincidentally the same symbol

What would you think about turning this (and/or the null dereference check) 
into a CFG-based check instead? We lose the first example (and cases where 
inlining would help), but fix the second, and very possibly speed up analysis. 
CFG analysis is also more capable of proving that something happens on all 
paths rather than just some, since that's just propagating information along 
the graph.

I agree, this can in theory be a false positive but we believe it is an 
unlikely one. Other existing checkers in the Clang static analyser have the 
same problem. I don't have any proposal, but maybe a generic solution for such 
FP would be good. In the long run I think it would be nice to have full flow 
analysis in this checker so we can find deeper bugs that are not limited to a 
single basic block.

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


Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread James Molloy
Hi Graham,

Thanks for working on this. The implementation looks fine to me, but in
your testcase:

+float32x2_t test_vrndx_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndx_f32
+  // CHECK-LABEL: call 2 x float @llvm.arm.neon.vrintx.v2f32(2 x float
%a)
+  return vrndx_f32(a);
+}

Only the first should be a CHECK-LABEL. The other should be a CHECK.

CHECK-LABELs are only hints to FileCheck, used to help isolate individual
testcases and prevent accidental crosstalk (matching one CHECK: line in
another function accidentally).

With those changed, LGTM.

Do you need help committing?

Cheers,

James


On 5 September 2014 12:12, Graham Hunter graham.hun...@arm.com wrote:

 Hi,

 This patch adds support for the 32bit numeric max/min and directed
 round-to-integral NEON intrinsics that were added as part of v8, along
 with unit tests.

 -Graham

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


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


Re: [PATCH] Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Samuel Benzaquen
TODO-FIXME

http://reviews.llvm.org/D5197

Files:
  include/clang/ASTMatchers/ASTMatchFinder.h
  lib/ASTMatchers/ASTMatchFinder.cpp
Index: include/clang/ASTMatchers/ASTMatchFinder.h
===
--- include/clang/ASTMatchers/ASTMatchFinder.h
+++ include/clang/ASTMatchers/ASTMatchFinder.h
@@ -173,11 +173,23 @@
   /// Each call to FindAll(...) will call the closure once.
   void registerTestCallbackAfterParsing(ParsingDoneTestCallback *ParsingDone);
 
-private:
-  /// \brief For each \c DynTypedMatcher a \c MatchCallback that will be called
+  /// \brief For each \c Matcher a \c MatchCallback that will be called
   /// when it matches.
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback * 
-MatcherCallbackPairs;
+  struct MatchersByType {
+std::vectorstd::pairDeclarationMatcher, MatchCallback * Decl;
+std::vectorstd::pairTypeMatcher, MatchCallback * Type;
+std::vectorstd::pairStatementMatcher, MatchCallback * Stmt;
+std::vectorstd::pairNestedNameSpecifierMatcher, MatchCallback *
+NestedNameSpecifier;
+std::vectorstd::pairNestedNameSpecifierLocMatcher, MatchCallback *
+NestedNameSpecifierLoc;
+std::vectorstd::pairTypeLocMatcher, MatchCallback * TypeLoc;
+/// \brief All the callbacks in one container to simplify iteration.
+std::vectorMatchCallback * AllCallbacks;
+  };
+
+private:
+  MatchersByType Matchers;
 
   /// \brief Called when parsing is done.
   ParsingDoneTestCallback *ParsingDone;
Index: lib/ASTMatchers/ASTMatchFinder.cpp
===
--- lib/ASTMatchers/ASTMatchFinder.cpp
+++ lib/ASTMatchers/ASTMatchFinder.cpp
@@ -292,29 +292,17 @@
 class MatchASTVisitor : public RecursiveASTVisitorMatchASTVisitor,
 public ASTMatchFinder {
 public:
-  MatchASTVisitor(
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback *  *
-  MatcherCallbackPairs)
-  : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(nullptr) {}
+ MatchASTVisitor(const MatchFinder::MatchersByType *Matchers)
+ : Matchers(Matchers), ActiveASTContext(nullptr) {}
 
   void onStartOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onStartOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onStartOfTranslationUnit();
   }
 
   void onEndOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onEndOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onEndOfTranslationUnit();
   }
 
   void set_active_ast_context(ASTContext *NewActiveASTContext) {
@@ -447,22 +435,27 @@
 
   // Matches all registered matchers on the given node and calls the
   // result callback for every node that matches.
-  void match(const ast_type_traits::DynTypedNode Node) {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  BoundNodesTreeBuilder Builder;
-  if (I-first.matches(Node, this, Builder)) {
-MatchVisitor Visitor(ActiveASTContext, I-second);
-Builder.visitMatches(Visitor);
-  }
+  void match(const ast_type_traits::DynTypedNode Node) {
+// FIXME: Improve this with a switch or a visitor pattern.
+if (auto *N = Node.getDecl()) {
+  match(*N);
+} else if (auto *N = Node.getStmt()) {
+  match(*N);
+} else if (auto *N = Node.getType()) {
+  match(*N);
+} else if (auto *N = Node.getQualType()) {
+  match(*N);
+} else if (auto *N = Node.getNestedNameSpecifier()) {
+  match(*N);
+} else if (auto *N = Node.getNestedNameSpecifierLoc()) {
+  match(*N);
+} else if (auto *N = Node.getTypeLoc()) {
+  match(*N);
 }
   }
 
   template typename T void match(const T Node) {
-match(ast_type_traits::DynTypedNode::create(Node));
+matchDispatch(Node);
   }
 
   // Implements ASTMatchFinder::getASTContext.
@@ -475,6 +468,40 @@
   bool shouldUseDataRecursionFor(clang::Stmt *S) const { return false; }
 
 private:
+  /// \brief Runs all the \p Matchers on \p Node.
+  ///
+  /// Used by \c matchDispatch() below.
+  template typename T, typename MC
+  void matchImpl(const T Node, const MC Matchers) {
+for (const auto MP : Matchers) {
+  BoundNodesTreeBuilder Builder;
+  if (MP.first.matches(Node, this, Builder)) {
+MatchVisitor 

Re: [PATCH] Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Samuel Benzaquen
Added numbers in the description.

http://reviews.llvm.org/D5197



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


Re: [PATCH] Remove some template instantiations to reduce the number of symbols.

2014-09-05 Thread Samuel Benzaquen
This was resolved with a different CL.

http://reviews.llvm.org/D5072



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


Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread Graham Hunter
Hi James,

Thanks for reviewing. (Tim as well)

Updated patch attached, have retested and confirmed it all still passes.

  Do you need help committing?

Yes please.

-Graham

From: James Molloy ja...@jamesmolloy.co.ukmailto:ja...@jamesmolloy.co.uk
Date: Friday, 5 September 2014 13:35
To: Admin graham.hun...@arm.commailto:graham.hun...@arm.com
Cc: llvm cfe cfe-commits@cs.uiuc.edumailto:cfe-commits@cs.uiuc.edu
Subject: Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and 
directed rounding to integral

Hi Graham,

Thanks for working on this. The implementation looks fine to me, but in your 
testcase:

+float32x2_t test_vrndx_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndx_f32
+  // CHECK-LABEL: call 2 x float @llvm.arm.neon.vrintx.v2f32(2 x float %a)
+  return vrndx_f32(a);
+}

Only the first should be a CHECK-LABEL. The other should be a CHECK.

CHECK-LABELs are only hints to FileCheck, used to help isolate individual 
testcases and prevent accidental crosstalk (matching one CHECK: line in another 
function accidentally).

With those changed, LGTM.

Do you need help committing?

Cheers,

James


On 5 September 2014 12:12, Graham Hunter 
graham.hun...@arm.commailto:graham.hun...@arm.com wrote:
Hi,

This patch adds support for the 32bit numeric max/min and directed
round-to-integral NEON intrinsics that were added as part of v8, along
with unit tests.

-Graham

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



-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England  Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England  Wales, Company No: 2548782

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


r217241 - Mark ms-inline-asm as xfail on ARM

2014-09-05 Thread Renato Golin
Author: rengolin
Date: Fri Sep  5 08:29:23 2014
New Revision: 217241

URL: http://llvm.org/viewvc/llvm-project?rev=217241view=rev
Log:
Mark ms-inline-asm as xfail on ARM

Modified:
cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Modified: cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp?rev=217241r1=217240r2=217241view=diff
==
--- cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp Fri Sep  5 08:29:23 2014
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - 
-fasm-blocks | FileCheck %s
+// XFAIL: arm
 
 // Check that we take EAX or EAX:EDX and return it from these functions for 
MSVC
 // compatibility.


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


Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread Graham Hunter
(Without the disclaimer this time -- oops)

Hi James,

Thanks for reviewing. (Tim as well)

Updated patch attached, have retested and confirmed it all still passes.

  Do you need help committing?

Yes please.

-Graham

From:  James Molloy ja...@jamesmolloy.co.uk
Date:  Friday, 5 September 2014 13:35
To:  Admin graham.hun...@arm.com
Cc:  llvm cfe cfe-commits@cs.uiuc.edu
Subject:  Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and
directed rounding to integral


Hi Graham,
Thanks for working on this. The implementation looks fine to me, but in
your testcase:

+float32x2_t test_vrndx_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndx_f32
+  // CHECK-LABEL: call 2 x float @llvm.arm.neon.vrintx.v2f32(2 x
float %a)
+  return vrndx_f32(a);
+}


Only the first should be a CHECK-LABEL. The other should be a CHECK.

CHECK-LABELs are only hints to FileCheck, used to help isolate individual
testcases and prevent accidental crosstalk (matching one CHECK: line in
another function accidentally).

With those changed, LGTM.

Do you need help committing?

Cheers,

James



On 5 September 2014 12:12, Graham Hunter graham.hun...@arm.com wrote:

Hi,

This patch adds support for the 32bit numeric max/min and directed
round-to-integral NEON intrinsics that were added as part of v8, along
with unit tests.

-Graham

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







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


r217242 - [ARMv8] Add support for 32-bit MIN/MAXNM and directed rounding.

2014-09-05 Thread James Molloy
Author: jamesm
Date: Fri Sep  5 08:50:34 2014
New Revision: 217242

URL: http://llvm.org/viewvc/llvm-project?rev=217242view=rev
Log:
[ARMv8] Add support for 32-bit MIN/MAXNM and directed rounding.

This patch adds support for the 32bit numeric max/min and directed 
round-to-integral NEON intrinsics that were added as part of v8, along with 
unit tests.

Patch by Graham Hunter!


Added:
cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c
cfe/trunk/test/CodeGen/arm-neon-numeric-maxmin.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=217242r1=217241r2=217242view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Sep  5 08:50:34 2014
@@ -944,13 +944,6 @@ def VCVT_F64 : SInstvcvt_f64, Fd,
 def VCVT_HIGH_F64_F32 : SOpInstvcvt_high_f64, wj, f, OP_VCVT_EX_HI_F64;
 def VCVTX_F32_F64 : SInstvcvtx_f32, fj,  d;
 def VCVTX_HIGH_F32_F64 : SOpInstvcvtx_high_f32, qfj, d, OP_VCVTX_HI;
-def FRINTN : SInstvrndn, dd, fdQfQd;
-def FRINTA : SInstvrnda, dd, fdQfQd;
-def FRINTP : SInstvrndp, dd, fdQfQd;
-def FRINTM : SInstvrndm, dd, fdQfQd;
-def FRINTX : SInstvrndx, dd, fdQfQd;
-def FRINTZ : SInstvrnd, dd, fdQfQd;
-def FRINTI : SInstvrndi, dd, fdQfQd;
 def VCVT_S64 : SInstvcvt_s64, xd,  dQd;
 def VCVT_U64 : SInstvcvt_u64, ud,  dQd;
 def FRECPE  : SInstvrecpe, dd, dQd;
@@ -983,11 +976,6 @@ def MAX : SInstvmax, ddd, dQd;
 def MIN : SInstvmin, ddd, dQd;
 
 

-// MaxNum/MinNum Floating Point
-def FMAXNM : SInstvmaxnm, ddd, fdQfQd;
-def FMINNM : SInstvminnm, ddd, fdQfQd;
-
-
 // Pairwise Max/Min
 def MAXP : SInstvpmax, ddd, QcQsQiQUcQUsQUiQfQd;
 def MINP : SInstvpmin, ddd, QcQsQiQUcQUsQUiQfQd;
@@ -1223,6 +1211,41 @@ def FCVTAU_S64 : SInstvcvta_u64, ud
 }
 
 

+// Round to Integral
+
+let ArchGuard = __ARM_ARCH = 8 in {
+def FRINTN_S32 : SInstvrndn, dd, fQf;
+def FRINTA_S32 : SInstvrnda, dd, fQf;
+def FRINTP_S32 : SInstvrndp, dd, fQf;
+def FRINTM_S32 : SInstvrndm, dd, fQf;
+def FRINTX_S32 : SInstvrndx, dd, fQf;
+def FRINTZ_S32 : SInstvrnd, dd, fQf;
+}
+
+let ArchGuard = __ARM_ARCH = 8  defined(__aarch64__) in {
+def FRINTN_S64 : SInstvrndn, dd, dQd;
+def FRINTA_S64 : SInstvrnda, dd, dQd;
+def FRINTP_S64 : SInstvrndp, dd, dQd;
+def FRINTM_S64 : SInstvrndm, dd, dQd;
+def FRINTX_S64 : SInstvrndx, dd, dQd;
+def FRINTZ_S64 : SInstvrnd, dd, dQd;
+def FRINTI_S64 : SInstvrndi, dd, fdQfQd;
+}
+
+
+// MaxNum/MinNum Floating Point
+
+let ArchGuard = __ARM_ARCH = 8 in {
+def FMAXNM_S32 : SInstvmaxnm, ddd, fQf;
+def FMINNM_S32 : SInstvminnm, ddd, fQf;
+}
+
+let ArchGuard = __ARM_ARCH = 8  defined(__aarch64__) in {
+def FMAXNM_S64 : SInstvmaxnm, ddd, dQd;
+def FMINNM_S64 : SInstvminnm, ddd, dQd;
+}
+
+
 // Permutation
 def VTRN1 : SOpInstvtrn1, ddd,
 csiUcUsUifPcPsQcQsQiQlQUcQUsQUiQUlQfQdQPcQPsQPl, 
OP_TRN1;

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=217242r1=217241r2=217242view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep  5 08:50:34 2014
@@ -1995,8 +1995,12 @@ static NeonIntrinsicInfo ARMSIMDIntrinsi
   NEONMAP1(vld4q_lane_v, arm_neon_vld4lane, 0),
   NEONMAP1(vld4q_v, arm_neon_vld4, 0),
   NEONMAP2(vmax_v, arm_neon_vmaxu, arm_neon_vmaxs, Add1ArgType | UnsignedAlts),
+  NEONMAP1(vmaxnm_v, arm_neon_vmaxnm, Add1ArgType),
+  NEONMAP1(vmaxnmq_v, arm_neon_vmaxnm, Add1ArgType),
   NEONMAP2(vmaxq_v, arm_neon_vmaxu, arm_neon_vmaxs, Add1ArgType | 
UnsignedAlts),
   NEONMAP2(vmin_v, arm_neon_vminu, arm_neon_vmins, Add1ArgType | UnsignedAlts),
+  NEONMAP1(vminnm_v, arm_neon_vminnm, Add1ArgType),
+  NEONMAP1(vminnmq_v, arm_neon_vminnm, Add1ArgType),
   NEONMAP2(vminq_v, arm_neon_vminu, arm_neon_vmins, Add1ArgType | 
UnsignedAlts),
   NEONMAP0(vmovl_v),
   NEONMAP0(vmovn_v),
@@ -2043,6 +2047,18 @@ static NeonIntrinsicInfo ARMSIMDIntrinsi
   NEONMAP1(vrecpsq_v, arm_neon_vrecps, Add1ArgType),
   NEONMAP2(vrhadd_v, arm_neon_vrhaddu, arm_neon_vrhadds, Add1ArgType | 
UnsignedAlts),
   NEONMAP2(vrhaddq_v, arm_neon_vrhaddu, arm_neon_vrhadds, Add1ArgType | 
UnsignedAlts),
+  NEONMAP1(vrnd_v, arm_neon_vrintz, Add1ArgType),
+  NEONMAP1(vrnda_v, arm_neon_vrinta, Add1ArgType),
+  NEONMAP1(vrndaq_v, 

Re: [PATCH] Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Manuel Klimek
LG. Whooo, nice :)

http://reviews.llvm.org/D5197



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


[libclc] r217243 - add isfinite builtin

2014-09-05 Thread Jan Vesely
Author: jvesely
Date: Fri Sep  5 08:59:06 2014
New Revision: 217243

URL: http://llvm.org/viewvc/llvm-project?rev=217243view=rev
Log:
add isfinite builtin

v2: simplify and remove isinf leftovers
remove trailing newline

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Aaron Watry awa...@gmail.com

Added:
libclc/trunk/generic/include/clc/relational/isfinite.h
libclc/trunk/generic/lib/relational/isfinite.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217243r1=217242r2=217243view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  5 08:59:06 2014
@@ -114,6 +114,7 @@
 #include clc/relational/any.h
 #include clc/relational/bitselect.h
 #include clc/relational/isequal.h
+#include clc/relational/isfinite.h
 #include clc/relational/isgreater.h
 #include clc/relational/isgreaterequal.h
 #include clc/relational/isinf.h

Added: libclc/trunk/generic/include/clc/relational/isfinite.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isfinite.h?rev=217243view=auto
==
--- libclc/trunk/generic/include/clc/relational/isfinite.h (added)
+++ libclc/trunk/generic/include/clc/relational/isfinite.h Fri Sep  5 08:59:06 
2014
@@ -0,0 +1,9 @@
+#undef isfinite
+
+#define __CLC_FUNCTION isfinite
+#define __CLC_BODY clc/relational/unary_decl.inc
+
+#include clc/relational/floatn.inc
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217243r1=217242r2=217243view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  5 08:59:06 2014
@@ -49,6 +49,7 @@ math/sincos_helpers.cl
 relational/all.cl
 relational/any.cl
 relational/isequal.cl
+relational/isfinite.cl
 relational/isgreater.cl
 relational/isgreaterequal.cl
 relational/isinf.cl

Added: libclc/trunk/generic/lib/relational/isfinite.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isfinite.cl?rev=217243view=auto
==
--- libclc/trunk/generic/lib/relational/isfinite.cl (added)
+++ libclc/trunk/generic/lib/relational/isfinite.cl Fri Sep  5 08:59:06 2014
@@ -0,0 +1,18 @@
+#include clc/clc.h
+#include relational.h
+
+_CLC_DEFINE_RELATIONAL_UNARY(int, isfinite, __builtin_isfinite, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isfinite(double) returns an int, but the vector 
versions
+// return long.
+_CLC_DEF _CLC_OVERLOAD int isfinite(double x) {
+  return __builtin_isfinite(x);
+}
+
+_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isfinite, double)
+
+#endif


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


[libclc] r217244 - add isnormal builtin

2014-09-05 Thread Jan Vesely
Author: jvesely
Date: Fri Sep  5 08:59:09 2014
New Revision: 217244

URL: http://llvm.org/viewvc/llvm-project?rev=217244view=rev
Log:
add isnormal builtin

v2: simplify and remove isnan leftovers
remove trailing newline

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Aaron Watry awa...@gmail.com

Added:
libclc/trunk/generic/include/clc/relational/isnormal.h
libclc/trunk/generic/lib/relational/isnormal.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217244r1=217243r2=217244view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  5 08:59:09 2014
@@ -121,6 +121,7 @@
 #include clc/relational/isless.h
 #include clc/relational/islessequal.h
 #include clc/relational/isnan.h
+#include clc/relational/isnormal.h
 #include clc/relational/isnotequal.h
 #include clc/relational/select.h
 #include clc/relational/signbit.h

Added: libclc/trunk/generic/include/clc/relational/isnormal.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isnormal.h?rev=217244view=auto
==
--- libclc/trunk/generic/include/clc/relational/isnormal.h (added)
+++ libclc/trunk/generic/include/clc/relational/isnormal.h Fri Sep  5 08:59:09 
2014
@@ -0,0 +1,9 @@
+#undef isnormal
+
+#define __CLC_FUNCTION isnormal
+#define __CLC_BODY clc/relational/unary_decl.inc
+
+#include clc/relational/floatn.inc
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217244r1=217243r2=217244view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  5 08:59:09 2014
@@ -56,6 +56,7 @@ relational/isinf.cl
 relational/isless.cl
 relational/islessequal.cl
 relational/isnan.cl
+relational/isnormal.cl
 relational/isnotequal.cl
 relational/signbit.cl
 shared/clamp.cl

Added: libclc/trunk/generic/lib/relational/isnormal.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isnormal.cl?rev=217244view=auto
==
--- libclc/trunk/generic/lib/relational/isnormal.cl (added)
+++ libclc/trunk/generic/lib/relational/isnormal.cl Fri Sep  5 08:59:09 2014
@@ -0,0 +1,18 @@
+#include clc/clc.h
+#include relational.h
+
+_CLC_DEFINE_RELATIONAL_UNARY(int, isnormal, __builtin_isnormal, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isnormal(double) returns an int, but the vector 
versions
+// return long.
+_CLC_DEF _CLC_OVERLOAD int isnormal(double x) {
+  return __builtin_isnormal(x);
+}
+
+_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isnormal, double)
+
+#endif


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


[libclc] r217246 - add isunordered builtin

2014-09-05 Thread Jan Vesely
Author: jvesely
Date: Fri Sep  5 08:59:13 2014
New Revision: 217246

URL: http://llvm.org/viewvc/llvm-project?rev=217246view=rev
Log:
add isunordered builtin

v2: remove trailing newline

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Aaron Watry awa...@gmail.com

Added:
libclc/trunk/generic/include/clc/relational/isunordered.h
libclc/trunk/generic/lib/relational/isunordered.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217246r1=217245r2=217246view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  5 08:59:13 2014
@@ -124,6 +124,7 @@
 #include clc/relational/isnan.h
 #include clc/relational/isnormal.h
 #include clc/relational/isnotequal.h
+#include clc/relational/isunordered.h
 #include clc/relational/select.h
 #include clc/relational/signbit.h
 

Added: libclc/trunk/generic/include/clc/relational/isunordered.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isunordered.h?rev=217246view=auto
==
--- libclc/trunk/generic/include/clc/relational/isunordered.h (added)
+++ libclc/trunk/generic/include/clc/relational/isunordered.h Fri Sep  5 
08:59:13 2014
@@ -0,0 +1,9 @@
+#undef isunordered
+
+#define __CLC_FUNCTION isunordered
+#define __CLC_BODY clc/relational/binary_decl.inc
+
+#include clc/relational/floatn.inc
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217246r1=217245r2=217246view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  5 08:59:13 2014
@@ -59,6 +59,7 @@ relational/islessgreater.cl
 relational/isnan.cl
 relational/isnormal.cl
 relational/isnotequal.cl
+relational/isunordered.cl
 relational/signbit.cl
 shared/clamp.cl
 shared/max.cl

Added: libclc/trunk/generic/lib/relational/isunordered.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isunordered.cl?rev=217246view=auto
==
--- libclc/trunk/generic/lib/relational/isunordered.cl (added)
+++ libclc/trunk/generic/lib/relational/isunordered.cl Fri Sep  5 08:59:13 2014
@@ -0,0 +1,22 @@
+#include clc/clc.h
+#include relational.h
+
+//Note: It would be nice to use __builtin_isunordered with vector inputs, but 
it seems to only take scalar values as
+//  input, which will produce incorrect output for vector input types.
+
+_CLC_DEFINE_RELATIONAL_BINARY(int, isunordered, __builtin_isunordered, float, 
float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isunordered(double, double) returns an int, but the 
vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int isunordered(double x, double y){
+   return __builtin_isunordered(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isunordered, double, double)
+
+#endif


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


[libclc] r217245 - add islessgreater builtin

2014-09-05 Thread Jan Vesely
Author: jvesely
Date: Fri Sep  5 08:59:11 2014
New Revision: 217245

URL: http://llvm.org/viewvc/llvm-project?rev=217245view=rev
Log:
add islessgreater builtin

v2: remove trailing newline

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Aaron Watry awa...@gmail.com

Added:
libclc/trunk/generic/include/clc/relational/islessgreater.h
libclc/trunk/generic/lib/relational/islessgreater.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217245r1=217244r2=217245view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  5 08:59:11 2014
@@ -120,6 +120,7 @@
 #include clc/relational/isinf.h
 #include clc/relational/isless.h
 #include clc/relational/islessequal.h
+#include clc/relational/islessgreater.h
 #include clc/relational/isnan.h
 #include clc/relational/isnormal.h
 #include clc/relational/isnotequal.h

Added: libclc/trunk/generic/include/clc/relational/islessgreater.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/islessgreater.h?rev=217245view=auto
==
--- libclc/trunk/generic/include/clc/relational/islessgreater.h (added)
+++ libclc/trunk/generic/include/clc/relational/islessgreater.h Fri Sep  5 
08:59:11 2014
@@ -0,0 +1,7 @@
+#define __CLC_FUNCTION islessgreater
+#define __CLC_BODY clc/relational/binary_decl.inc
+
+#include clc/relational/floatn.inc
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217245r1=217244r2=217245view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  5 08:59:11 2014
@@ -55,6 +55,7 @@ relational/isgreaterequal.cl
 relational/isinf.cl
 relational/isless.cl
 relational/islessequal.cl
+relational/islessgreater.cl
 relational/isnan.cl
 relational/isnormal.cl
 relational/isnotequal.cl

Added: libclc/trunk/generic/lib/relational/islessgreater.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/islessgreater.cl?rev=217245view=auto
==
--- libclc/trunk/generic/lib/relational/islessgreater.cl (added)
+++ libclc/trunk/generic/lib/relational/islessgreater.cl Fri Sep  5 08:59:11 
2014
@@ -0,0 +1,22 @@
+#include clc/clc.h
+#include relational.h
+
+//Note: It would be nice to use __builtin_islessgreater with vector inputs, 
but it seems to only take scalar values as
+//  input, which will produce incorrect output for vector input types.
+
+_CLC_DEFINE_RELATIONAL_BINARY(int, islessgreater, __builtin_islessgreater, 
float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of islessgreater(double, double) returns an int, but the 
vector versions
+// return long.
+
+_CLC_DEF _CLC_OVERLOAD int islessgreater(double x, double y){
+   return __builtin_islessgreater(x, y);
+}
+
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, islessgreater, double, double)
+
+#endif


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


[libclc] r217247 - add isordered builtin

2014-09-05 Thread Jan Vesely
Author: jvesely
Date: Fri Sep  5 08:59:15 2014
New Revision: 217247

URL: http://llvm.org/viewvc/llvm-project?rev=217247view=rev
Log:
add isordered builtin

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Aaron Watry awa...@gmail.com

Added:
libclc/trunk/generic/include/clc/relational/isordered.h
libclc/trunk/generic/lib/relational/isordered.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217247r1=217246r2=217247view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  5 08:59:15 2014
@@ -124,6 +124,7 @@
 #include clc/relational/isnan.h
 #include clc/relational/isnormal.h
 #include clc/relational/isnotequal.h
+#include clc/relational/isordered.h
 #include clc/relational/isunordered.h
 #include clc/relational/select.h
 #include clc/relational/signbit.h

Added: libclc/trunk/generic/include/clc/relational/isordered.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isordered.h?rev=217247view=auto
==
--- libclc/trunk/generic/include/clc/relational/isordered.h (added)
+++ libclc/trunk/generic/include/clc/relational/isordered.h Fri Sep  5 08:59:15 
2014
@@ -0,0 +1,9 @@
+#undef isordered
+
+#define __CLC_FUNCTION isordered
+#define __CLC_BODY clc/relational/binary_decl.inc
+
+#include clc/relational/floatn.inc
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217247r1=217246r2=217247view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  5 08:59:15 2014
@@ -59,6 +59,7 @@ relational/islessgreater.cl
 relational/isnan.cl
 relational/isnormal.cl
 relational/isnotequal.cl
+relational/isordered.cl
 relational/isunordered.cl
 relational/signbit.cl
 shared/clamp.cl

Added: libclc/trunk/generic/lib/relational/isordered.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isordered.cl?rev=217247view=auto
==
--- libclc/trunk/generic/lib/relational/isordered.cl (added)
+++ libclc/trunk/generic/lib/relational/isordered.cl Fri Sep  5 08:59:15 2014
@@ -0,0 +1,23 @@
+#include clc/clc.h
+#include relational.h
+
+#define _CLC_DEFINE_ISORDERED(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
+_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
+  return isequal(x, x)  isequal(y, y); \
+} \
+
+_CLC_DEFINE_ISORDERED(int, isordered, float, float)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(int, isordered, float, float)
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isordered(double, double) returns an int, but the 
vector versions
+// return long.
+
+_CLC_DEFINE_ISORDERED(int, isordered, double, double)
+_CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(long, isordered, double, double)
+
+#endif
+
+#undef _CLC_DEFINE_ISORDERED


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


Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and directed rounding to integral

2014-09-05 Thread James Molloy
Hi Graham,

Committed as r217242.

Cheers,

James


On 5 September 2014 14:49, Graham Hunter graham.hun...@arm.com wrote:

 (Without the disclaimer this time -- oops)

 Hi James,

 Thanks for reviewing. (Tim as well)

 Updated patch attached, have retested and confirmed it all still passes.

   Do you need help committing?

 Yes please.

 -Graham

 From:  James Molloy ja...@jamesmolloy.co.uk
 Date:  Friday, 5 September 2014 13:35
 To:  Admin graham.hun...@arm.com
 Cc:  llvm cfe cfe-commits@cs.uiuc.edu
 Subject:  Re: [PATCH] AArch32 v8 NEON intrinsics for numeric max/min and
 directed rounding to integral


 Hi Graham,
 Thanks for working on this. The implementation looks fine to me, but in
 your testcase:

 +float32x2_t test_vrndx_f32(float32x2_t a) {
 +  // CHECK-LABEL: test_vrndx_f32
 +  // CHECK-LABEL: call 2 x float @llvm.arm.neon.vrintx.v2f32(2 x
 float %a)
 +  return vrndx_f32(a);
 +}


 Only the first should be a CHECK-LABEL. The other should be a CHECK.

 CHECK-LABELs are only hints to FileCheck, used to help isolate individual
 testcases and prevent accidental crosstalk (matching one CHECK: line in
 another function accidentally).

 With those changed, LGTM.

 Do you need help committing?

 Cheers,

 James



 On 5 September 2014 12:12, Graham Hunter graham.hun...@arm.com wrote:

 Hi,

 This patch adds support for the 32bit numeric max/min and directed
 round-to-integral NEON intrinsics that were added as part of v8, along
 with unit tests.

 -Graham

 ___
 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


[PATCH] Add ACLE predefines: maxmin, rounding and h/w integer division

2014-09-05 Thread Assad Hashmi
Hi,

This patch adds the following predefined macros:
__ARM_FEATURE_DIRECTED_ROUNDING
__ARM_FEATURE_NUMERIC_MAXMIN
__ARM_FEATURE_IDIV

Note that these are related to Graham Hunter¹s patch, (AArch32 v8 NEON
intrinsics for numeric max/min and directed rounding to integral), and were
unit tested together.

-Assad

diff --git include/clang/Basic/arm_neon.td include/clang/Basic/arm_neon.td
index 0247bb5..ce3b609 100644
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -944,13 +944,6 @@ def VCVT_F64 : SInstvcvt_f64, Fd,  lUlQlQUl;
 def VCVT_HIGH_F64_F32 : SOpInstvcvt_high_f64, wj, f, OP_VCVT_EX_HI_F64;
 def VCVTX_F32_F64 : SInstvcvtx_f32, fj,  d;
 def VCVTX_HIGH_F32_F64 : SOpInstvcvtx_high_f32, qfj, d, OP_VCVTX_HI;
-def FRINTN : SInstvrndn, dd, fdQfQd;
-def FRINTA : SInstvrnda, dd, fdQfQd;
-def FRINTP : SInstvrndp, dd, fdQfQd;
-def FRINTM : SInstvrndm, dd, fdQfQd;
-def FRINTX : SInstvrndx, dd, fdQfQd;
-def FRINTZ : SInstvrnd, dd, fdQfQd;
-def FRINTI : SInstvrndi, dd, fdQfQd;
 def VCVT_S64 : SInstvcvt_s64, xd,  dQd;
 def VCVT_U64 : SInstvcvt_u64, ud,  dQd;
 def FRECPE  : SInstvrecpe, dd, dQd;
@@ -983,11 +976,6 @@ def MAX : SInstvmax, ddd, dQd;
 def MIN : SInstvmin, ddd, dQd;
 
 

-// MaxNum/MinNum Floating Point
-def FMAXNM : SInstvmaxnm, ddd, fdQfQd;
-def FMINNM : SInstvminnm, ddd, fdQfQd;
-
-
 // Pairwise Max/Min
 def MAXP : SInstvpmax, ddd, QcQsQiQUcQUsQUiQfQd;
 def MINP : SInstvpmin, ddd, QcQsQiQUcQUsQUiQfQd;
@@ -1223,6 +1211,41 @@ def FCVTAU_S64 : SInstvcvta_u64, ud, dQd;
 }
 
 

+// Round to Integral
+
+let ArchGuard = __ARM_ARCH = 8  defined(__ARM_FEATURE_DIRECTED_ROUNDING) 
in {
+def FRINTN_S32 : SInstvrndn, dd, fQf;
+def FRINTA_S32 : SInstvrnda, dd, fQf;
+def FRINTP_S32 : SInstvrndp, dd, fQf;
+def FRINTM_S32 : SInstvrndm, dd, fQf;
+def FRINTX_S32 : SInstvrndx, dd, fQf;
+def FRINTZ_S32 : SInstvrnd, dd, fQf;
+}
+
+let ArchGuard = __ARM_ARCH = 8  defined(__aarch64__)  
defined(__ARM_FEATURE_DIRECTED_ROUNDING) in {
+def FRINTN_S64 : SInstvrndn, dd, dQd;
+def FRINTA_S64 : SInstvrnda, dd, dQd;
+def FRINTP_S64 : SInstvrndp, dd, dQd;
+def FRINTM_S64 : SInstvrndm, dd, dQd;
+def FRINTX_S64 : SInstvrndx, dd, dQd;
+def FRINTZ_S64 : SInstvrnd, dd, dQd;
+def FRINTI_S64 : SInstvrndi, dd, fdQfQd;
+}
+
+
+// MaxNum/MinNum Floating Point
+
+let ArchGuard = __ARM_ARCH = 8  defined(__ARM_FEATURE_NUMERIC_MAXMIN) in {
+def FMAXNM_S32 : SInstvmaxnm, ddd, fQf;
+def FMINNM_S32 : SInstvminnm, ddd, fQf;
+}
+
+let ArchGuard = __ARM_ARCH = 8  defined(__aarch64__)  
defined(__ARM_FEATURE_NUMERIC_MAXMIN) in {
+def FMAXNM_S64 : SInstvmaxnm, ddd, dQd;
+def FMINNM_S64 : SInstvminnm, ddd, dQd;
+}
+
+
 // Permutation
 def VTRN1 : SOpInstvtrn1, ddd,
 csiUcUsUifPcPsQcQsQiQlQUcQUsQUiQUlQfQdQPcQPsQPl, 
OP_TRN1;
diff --git lib/Basic/Targets.cpp lib/Basic/Targets.cpp
index 4998ca3..60f194c 100644
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3983,6 +3983,10 @@ public:
 
 // __ARM_ARCH is defined as an integer value indicating the current ARM ISA
 Builder.defineMacro(__ARM_ARCH, CPUArch.substr(0, 1));
+if (CPUArch[0] = '8') {
+  Builder.defineMacro(__ARM_FEATURE_NUMERIC_MAXMIN);
+  Builder.defineMacro(__ARM_FEATURE_DIRECTED_ROUNDING);
+}
 
 // __ARM_ARCH_ISA_ARM is defined to 1 if the core supports the ARM ISA.  It
 // is not defined for the M-profile.
@@ -4477,7 +4481,10 @@ public:
 Builder.defineMacro(__ARM_FEATURE_UNALIGNED);
 Builder.defineMacro(__ARM_FEATURE_CLZ);
 Builder.defineMacro(__ARM_FEATURE_FMA);
-Builder.defineMacro(__ARM_FEATURE_DIV);
+Builder.defineMacro(__ARM_FEATURE_IDIV); // As specified in ACLE
+Builder.defineMacro(__ARM_FEATURE_DIV);  // For backwards compatibility
+Builder.defineMacro(__ARM_FEATURE_NUMERIC_MAXMIN);
+Builder.defineMacro(__ARM_FEATURE_DIRECTED_ROUNDING);
 
 Builder.defineMacro(__ARM_ALIGN_MAX_STACK_PWR, 4);
 
diff --git lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGBuiltin.cpp
index b74038e..7decbbd 100644
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2009,8 +2009,12 @@ static NeonIntrinsicInfo ARMSIMDIntrinsicMap [] = {
   NEONMAP1(vld4q_lane_v, arm_neon_vld4lane, 0),
   NEONMAP1(vld4q_v, arm_neon_vld4, 0),
   NEONMAP2(vmax_v, arm_neon_vmaxu, arm_neon_vmaxs, Add1ArgType | UnsignedAlts),
+  NEONMAP1(vmaxnm_v, arm_neon_vmaxnm, Add1ArgType),
+  NEONMAP1(vmaxnmq_v, arm_neon_vmaxnm, Add1ArgType),
   NEONMAP2(vmaxq_v, arm_neon_vmaxu, arm_neon_vmaxs, Add1ArgType | 
UnsignedAlts),
   NEONMAP2(vmin_v, arm_neon_vminu, arm_neon_vmins, Add1ArgType | UnsignedAlts),
+  NEONMAP1(vminnm_v, 

[PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jon Roelofs
Hi danalbert, EricWF,

http://reviews.llvm.org/D5214

Files:
  lit.cfg
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -351,6 +351,12 @@
 self.config.available_features.add(
 'with_system_lib=%s' % sanitized_triple)
 
+if 'libcpp-has-no-threads' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+
+if 'no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+
 def configure_compile_flags(self):
 # Configure extra compiler flags.
 self.compile_flags += ['-I' + self.src_root + '/include',
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r217258 - [analyzer] Don't crash if malloc() has an unexpected function prototype.

2014-09-05 Thread Jordan Rose
Author: jrose
Date: Fri Sep  5 11:33:51 2014
New Revision: 217258

URL: http://llvm.org/viewvc/llvm-project?rev=217258view=rev
Log:
[analyzer] Don't crash if malloc() has an unexpected function prototype.

Patch by Daniel Fahlgren!

Added:
cfe/trunk/test/Analysis/malloc-protoype.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=217258r1=217257r2=217258view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Sep  5 11:33:51 
2014
@@ -901,6 +901,10 @@ ProgramStateRef MallocChecker::MallocMem
ProgramStateRef State,
AllocationFamily Family) {
 
+  // We expect the malloc functions to return a pointer.
+  if (!Loc::isLocType(CE-getType()))
+return nullptr;
+
   // Bind the return value to the symbolic value from the heap region.
   // TODO: We could rewrite post visit to eval call; 'malloc' does not have
   // side effects other than what we model here.
@@ -911,10 +915,6 @@ ProgramStateRef MallocChecker::MallocMem
   .castAsDefinedSVal();
   State = State-BindExpr(CE, C.getLocationContext(), RetVal);
 
-  // We expect the malloc functions to return a pointer.
-  if (!RetVal.getAsLoc())
-return nullptr;
-
   // Fill the region with the initialization value.
   State = State-bindDefault(RetVal, Init);
 

Added: cfe/trunk/test/Analysis/malloc-protoype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-protoype.c?rev=217258view=auto
==
--- cfe/trunk/test/Analysis/malloc-protoype.c (added)
+++ cfe/trunk/test/Analysis/malloc-protoype.c Fri Sep  5 11:33:51 2014
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -w -analyze -analyzer-checker=core,unix.Malloc -verify %s
+// expected-no-diagnostics
+
+// Test that strange prototypes doesn't crash the analyzer
+
+void malloc(int i);
+void valloc(int i);
+
+void test1()
+{
+  malloc(1);
+}
+
+void test2()
+{
+  valloc(1);
+}


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


Re: [PATCH] Fix analyzer crash when defining strange prototype of malloc

2014-09-05 Thread Jordan Rose

On Sep 4, 2014, at 5:28 , Daniel Fahlgren dan...@fahlgren.se wrote:

 Hi Jordan,
 
 On Wed, 2014-09-03 at 19:18 -0700, Jordan Rose wrote:
 This seems like a reasonable approach. It's not wonderful, but it's
 more a sanity check than anything else, right?
 
 Yes this is only a sanity check. If someone redefines malloc to
 something strange there isn't much we can do.
 
 Feel free to remove the check from a few lines down. Please add a test
 case as well.
 
 Attached is a new patch with two test cases.

Thanks, committed in r217258.
Jordan
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Dan Albert
How are those features getting set?

http://reviews.llvm.org/D5214



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


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jon Roelofs
I had been setting them in the lit.site.cfg, but it will work out better in 
zorg for them to come in from the command line too...

The updated patch lets you specify --param=additional_features=foo,bar,baz

http://reviews.llvm.org/D5214

Files:
  lit.cfg
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -291,6 +291,10 @@
 inferred use_clang_verify as: %r % self.use_clang_verify)
 
 def configure_features(self):
+additional_features = self.get_lit_conf('additional_features').split(,)
+for f in additional_features:
+self.config.available_features.add(f)
+
 # Figure out which of the required locales we support
 locales = {
 'Darwin': {
@@ -351,6 +355,12 @@
 self.config.available_features.add(
 'with_system_lib=%s' % sanitized_triple)
 
+if 'libcpp-has-no-threads' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+
+if 'no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+
 def configure_compile_flags(self):
 # Configure extra compiler flags.
 self.compile_flags += ['-I' + self.src_root + '/include',
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r217259 - -frewrite-includes: Normalize line endings to match the main source file

2014-09-05 Thread Reid Kleckner
Author: rnk
Date: Fri Sep  5 11:49:50 2014
New Revision: 217259

URL: http://llvm.org/viewvc/llvm-project?rev=217259view=rev
Log:
-frewrite-includes: Normalize line endings to match the main source file

It is very common to include headers with DOS-style line endings, such
as windows.h, from source files with Unix-style line endings.
Previously, we would end up with mixed line endings and #endifs that
appeared to be on the same line:

  #if 0 /* expanded by -frewrite-includes */
  #include windows.h^M#endif /* expanded by -frewrite-includes */

Clang treats either of \r or \n as a line ending character, so this is
purely a cosmetic issue.

This has no automated test because most Unix tools on Windows will
implictly convert CRLF to LF when reading files, making it very hard to
detect line ending mismatches. FileCheck doesn't understand {{\r}}
either.

Fixes PR20552.

Modified:
cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp

Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=217259r1=217258r2=217259view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Fri Sep  5 11:49:50 
2014
@@ -40,6 +40,7 @@ class InclusionRewriter : public PPCallb
   Preprocessor PP; /// Used to find inclusion directives.
   SourceManager SM; /// Used to read and manage source files.
   raw_ostream OS; /// The destination stream for rewritten contents.
+  StringRef MainEOL; /// The line ending marker to use.
   const llvm::MemoryBuffer *PredefinesBuffer; /// The preprocessor predefines.
   bool ShowLineMarkers; /// Show #line markers.
   bool UseLineDirective; /// Use of line directives or line markers.
@@ -54,6 +55,7 @@ public:
   void setPredefinesBuffer(const llvm::MemoryBuffer *Buf) {
 PredefinesBuffer = Buf;
   }
+  void detectMainFileEOL();
 private:
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
@@ -67,8 +69,8 @@ private:
   const Module *Imported) override;
   void WriteLineInfo(const char *Filename, int Line,
  SrcMgr::CharacteristicKind FileType,
- StringRef EOL, StringRef Extra = StringRef());
-  void WriteImplicitModuleImport(const Module *Mod, StringRef EOL);
+ StringRef Extra = StringRef());
+  void WriteImplicitModuleImport(const Module *Mod);
   void OutputContentUpTo(const MemoryBuffer FromFile,
  unsigned WriteFrom, unsigned WriteTo,
  StringRef EOL, int lines,
@@ -88,9 +90,9 @@ private:
 /// Initializes an InclusionRewriter with a \p PP source and \p OS destination.
 InclusionRewriter::InclusionRewriter(Preprocessor PP, raw_ostream OS,
  bool ShowLineMarkers)
-  : PP(PP), SM(PP.getSourceManager()), OS(OS), PredefinesBuffer(nullptr),
-ShowLineMarkers(ShowLineMarkers),
-LastInsertedFileChange(FileChanges.end()) {
+: PP(PP), SM(PP.getSourceManager()), OS(OS), MainEOL(\n),
+  PredefinesBuffer(nullptr), ShowLineMarkers(ShowLineMarkers),
+  LastInsertedFileChange(FileChanges.end()) {
   // If we're in microsoft mode, use normal #line instead of line markers.
   UseLineDirective = PP.getLangOpts().MicrosoftExt;
 }
@@ -101,7 +103,7 @@ InclusionRewriter::InclusionRewriter(Pre
 /// any \p Extra context specifiers in GNU line directives.
 void InclusionRewriter::WriteLineInfo(const char *Filename, int Line,
   SrcMgr::CharacteristicKind FileType,
-  StringRef EOL, StringRef Extra) {
+  StringRef Extra) {
   if (!ShowLineMarkers)
 return;
   if (UseLineDirective) {
@@ -125,13 +127,12 @@ void InclusionRewriter::WriteLineInfo(co
   // should be treated as being wrapped in an implicit extern C block.
   OS   3 4;
   }
-  OS  EOL;
+  OS  MainEOL;
 }
 
-void InclusionRewriter::WriteImplicitModuleImport(const Module *Mod,
-  StringRef EOL) {
+void InclusionRewriter::WriteImplicitModuleImport(const Module *Mod) {
   OS  @import   Mod-getFullModuleName()  ;
-   /* clang -frewrite-includes: implicit import */  EOL;
+   /* clang -frewrite-includes: implicit import */  MainEOL;
 }
 
 /// FileChanged - Whenever the preprocessor enters or exits a #include file
@@ -197,23 +198,33 @@ InclusionRewriter::FindFileChangeLocatio
 /// Detect the likely line ending style of \p FromFile by examining the first
 /// newline found within it.
 static StringRef DetectEOL(const MemoryBuffer FromFile) {
-  // detect what line endings the file uses, so that added content does not mix
-  // the style
+  // Detect what line endings the file uses, so 

Re: [PATCH] Division by zero

2014-09-05 Thread Anna Zaks

 On Sep 5, 2014, at 5:24 AM, Anders Rönnholm anders.ronnh...@evidente.se 
 wrote:
 
 Hi,
 
 I feel that to change this checker and the null dereference check would take 
 a large amount of time compared to what is gained, time which could be used 
 more efficiently on other checkers.
 The null dereference check is already completed as path sensitive and works 
 well.

We are talking about converting only the check after division/dereference 
(not regular div by zero or dereference checks) because these checks require 
all paths reasoning (See the [cfe-dev] [RFC] Creating base class for 'Test 
after X' checkers thread). The main win is speed (flow sensitive analyzes are 
algorithmically much simpler than the path sensitive ones), which also opens a 
possibility of converting this into a compiler warning.

I agree that it would not be a very easy task, but this is the right way to 
approach the problem.

 I don't know when we can deliver this as CFG-based (definitely not this 
 year),  wouldn't it be better to have it like this now?
 
 For a possible remake of this checker to a CFG-based one in the future, we 
 would need more help from you on how to make them CFG-based. What parts of 
 LiveVariables and DeadStoresChecker are related to our check? I guess just 
 parts of the LiveVariables framework is needed.

DeadStoresChecker is an example of other flow sensitive checks. You would need 
to create a similar one for div by zero / dereference. 

 
 So, Anna brought up that the check as implemented is very nearly 
 path-independent, i.e. it only depends on flow-sensitive properties of the 
 CFG. The path-sensitivity is buying us very little; it catches this case:
 
 int y = x;
 int div = z / y;
 if (x) { ...}
 
 But also warns here, which doesn't necessarily make sense:
 
 int foo(int x, int y, int z) {
   int div = z / y;
   if (x) return div;
   return 0;
 }
 
 foo(a, a, b); // only coincidentally the same symbol
 
 What would you think about turning this (and/or the null dereference check) 
 into a CFG-based check instead? We lose the first example (and cases where 
 inlining would help), but fix the second, and very possibly speed up 
 analysis. CFG analysis is also more capable of proving that something 
 happens on all paths rather than just some, since that's just propagating 
 information along the graph.
 
 I agree, this can in theory be a false positive but we believe it is an 
 unlikely one. Other existing checkers in the Clang static analyser have the 
 same problem. I don't have any proposal, but maybe a generic solution for 
 such FP would be good. In the long run I think it would be nice to have full 
 flow analysis in this checker so we can find deeper bugs that are not limited 
 to a single basic block.
 

Again, the main issue is the algorithmic performance win, not false positives.

 //Anders

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


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Dan Albert

Comment at: lit.cfg:296
@@ +295,3 @@
+for f in additional_features:
+self.config.available_features.add(f)
+

Probably f.strip() to be safe. I don't know what lit would do with 
--param=additional_features=' foo,   bar'

http://reviews.llvm.org/D5214



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


[PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Jon Roelofs
Hi danalbert, EricWF,

http://reviews.llvm.org/D5215

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/LibcxxAndAbiBuilder.py
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -667,8 +667,9 @@
  'slavenames': ['gribozavr4'],
  'builddir': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
  'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
- env={'CC': 'clang', 'CXX': 'clang++',
-  'CXXFLAGS' : '-D_LIBCPP_HAS_NO_THREADS -DLIBCXXABI_SINGLE_THREADED=1'}),
+ env={'CC': 'clang', 'CXX': 'clang++'},
+ additional_features=set(['libcpp-has-no-threads',
+  'no-monotonic-clock'])),
  'category': 'libcxx'},
 
 {'name': 'libcxx-libcxxabi-x86_64-linux-ubuntu',
Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -42,7 +42,7 @@
 return f
 
 
-def getLibcxxAndAbiBuilder(f=None, env={}):
+def getLibcxxAndAbiBuilder(f=None, env={}, additional_features=set()):
 if f is None:
 f = buildbot.process.factory.BuildFactory()
 
@@ -59,6 +59,17 @@
 
 f = getLibcxxWholeTree(f, src_root)
 
+if 'libcpp-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_THREADS'
+env['CXXFLAGS'] += ' -DLIBCXXABI_SINGLE_THREADED=1'
+
+if 'no-monotonic-clock' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'
+
+if additional_features:
+litTestArgs = --param=additional_features= +
+  ,.join(additional_features)
+
 # Nuke/remake build directory and run CMake
 f.addStep(buildbot.steps.shell.ShellCommand(
 name='rm.builddir', command=['rm', '-rf', build_path],
@@ -83,13 +94,14 @@
   haltOnFailure=True, workdir=build_path))
 
 # Test libc++abi
+lit_flags = properties.WithProperties(LIT_ARGS=%s % litTestArgs)]
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxxabi', command=['make', 'check-libcxxabi'],
+name='test.libcxxabi', command=['make', lit_flags, 'check-libcxxabi'],
 workdir=build_path))
 
 # Test libc++
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxx', command=['make', 'check-libcxx'],
+name='test.libcxx', command=['make', lit_flags, 'check-libcxx'],
 workdir=build_path))
 
 return f
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jon Roelofs
Looks like they do end up with weird whitespace in that case... So strip them 
on the way in.

http://reviews.llvm.org/D5214

Files:
  lit.cfg
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -291,6 +291,10 @@
 inferred use_clang_verify as: %r % self.use_clang_verify)
 
 def configure_features(self):
+additional_features = self.get_lit_conf('additional_features').split(,)
+for f in additional_features:
+self.config.available_features.add(f.strip())
+
 # Figure out which of the required locales we support
 locales = {
 'Darwin': {
@@ -351,6 +355,12 @@
 self.config.available_features.add(
 'with_system_lib=%s' % sanitized_triple)
 
+if 'libcpp-has-no-threads' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+
+if 'no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+
 def configure_compile_flags(self):
 # Configure extra compiler flags.
 self.compile_flags += ['-I' + self.src_root + '/include',
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Dan Albert

Comment at: lit.cfg:361
@@ +360,3 @@
+
+if 'no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']

One nitpick: libcpp-has-no-monotonic-clock to match the other one?

http://reviews.llvm.org/D5214



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


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jon Roelofs
re-name the features for consistency

http://reviews.llvm.org/D5214

Files:
  lit.cfg
  utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
  utilities/time/time.clock/time.clock.steady/now.pass.cpp
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -291,6 +291,10 @@
 inferred use_clang_verify as: %r % self.use_clang_verify)
 
 def configure_features(self):
+additional_features = self.get_lit_conf('additional_features').split(,)
+for f in additional_features:
+self.config.available_features.add(f.strip())
+
 # Figure out which of the required locales we support
 locales = {
 'Darwin': {
@@ -351,6 +355,12 @@
 self.config.available_features.add(
 'with_system_lib=%s' % sanitized_triple)
 
+if 'libcpp-has-no-threads' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+
+if 'libcpp-has-no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+
 def configure_compile_flags(self):
 # Configure extra compiler flags.
 self.compile_flags += ['-I' + self.src_root + '/include',
Index: utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
===
--- utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
+++ utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
@@ -11,7 +11,7 @@
 // darwin11 and darwin12:
 // XFAIL: with_system_lib=x86_64-apple-darwin11
 // XFAIL: with_system_lib=x86_64-apple-darwin12
-// UNSUPPORTED: no-monotonic-clock
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
 
 // chrono
 
Index: utilities/time/time.clock/time.clock.steady/now.pass.cpp
===
--- utilities/time/time.clock/time.clock.steady/now.pass.cpp
+++ utilities/time/time.clock/time.clock.steady/now.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: no-monotonic-clock
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
 
 // chrono
 
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Dan Albert

Comment at: zorg/buildbot/builders/LibcxxAndAbiBuilder.py:70
@@ +69,3 @@
+if additional_features:
+litTestArgs = --param=additional_features= +
+  ,.join(additional_features)

else this is undefined and then used below.

http://reviews.llvm.org/D5215



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


[libcxx] r217261 - Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jonathan Roelofs
Author: jroelofs
Date: Fri Sep  5 12:21:57 2014
New Revision: 217261

URL: http://llvm.org/viewvc/llvm-project?rev=217261view=rev
Log:
Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on 
available_features

http://reviews.llvm.org/D5214

Modified:
libcxx/trunk/test/lit.cfg

libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp

Modified: libcxx/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=217261r1=217260r2=217261view=diff
==
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Fri Sep  5 12:21:57 2014
@@ -291,6 +291,10 @@ class Configuration(object):
 inferred use_clang_verify as: %r % self.use_clang_verify)
 
 def configure_features(self):
+additional_features = 
self.get_lit_conf('additional_features').split(,)
+for f in additional_features:
+self.config.available_features.add(f.strip())
+
 # Figure out which of the required locales we support
 locales = {
 'Darwin': {
@@ -351,6 +355,12 @@ class Configuration(object):
 self.config.available_features.add(
 'with_system_lib=%s' % sanitized_triple)
 
+if 'libcpp-has-no-threads' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
+
+if 'libcpp-has-no-monotonic-clock' in self.config.available_features:
+self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
+
 def configure_compile_flags(self):
 # Configure extra compiler flags.
 self.compile_flags += ['-I' + self.src_root + '/include',

Modified: 
libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp?rev=217261r1=217260r2=217261view=diff
==
--- 
libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
 (original)
+++ 
libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
 Fri Sep  5 12:21:57 2014
@@ -11,7 +11,7 @@
 // darwin11 and darwin12:
 // XFAIL: with_system_lib=x86_64-apple-darwin11
 // XFAIL: with_system_lib=x86_64-apple-darwin12
-// UNSUPPORTED: no-monotonic-clock
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
 
 // chrono
 

Modified: 
libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp?rev=217261r1=217260r2=217261view=diff
==
--- libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp 
(original)
+++ libcxx/trunk/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp 
Fri Sep  5 12:21:57 2014
@@ -7,7 +7,7 @@
 //
 
//===--===//
 //
-// UNSUPPORTED: no-monotonic-clock
+// UNSUPPORTED: libcpp-has-no-monotonic-clock
 
 // chrono
 


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


Re: [PATCH] Pragma Loop constant expression support

2014-09-05 Thread Tyler Nowicki
Hi Richard,

Thanks for the review. Sorry for the delayed response. I made the changes
you suggested except for the following.

+  Token EoF;
 The 'o' in EOF is traditionally capitalized.


Unfortunately EOF is defined by stdio.h and at least in VS the conflict
triggers a compilation error. Also in PragmaMSPragma::HandlePragma EoF is
used.

Please review the attached patch.

Thanks,

Tyler


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


Re: [PATCH] [libcxx] Set -D_LIBCPP_HAS_NO_THREADS and -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK based on available_features

2014-09-05 Thread Jon Roelofs
r217261

http://reviews.llvm.org/D5214



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


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Jon Roelofs
Init litTestArgs always. Split out libcxxabi-has-no-threads.

http://reviews.llvm.org/D5215

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/LibcxxAndAbiBuilder.py
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -667,8 +667,10 @@
  'slavenames': ['gribozavr4'],
  'builddir': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
  'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
- env={'CC': 'clang', 'CXX': 'clang++',
-  'CXXFLAGS' : '-D_LIBCPP_HAS_NO_THREADS -DLIBCXXABI_SINGLE_THREADED=1'}),
+ env={'CC': 'clang', 'CXX': 'clang++'},
+ additional_features=set(['libcxxabi-has-no-threads',
+  'libcpp-has-no-threads'
+  'libcpp-has-no-monotonic-clock'])),
  'category': 'libcxx'},
 
 {'name': 'libcxx-libcxxabi-x86_64-linux-ubuntu',
Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -42,7 +42,7 @@
 return f
 
 
-def getLibcxxAndAbiBuilder(f=None, env={}):
+def getLibcxxAndAbiBuilder(f=None, env={}, additional_features=set()):
 if f is None:
 f = buildbot.process.factory.BuildFactory()
 
@@ -59,6 +59,20 @@
 
 f = getLibcxxWholeTree(f, src_root)
 
+if 'libcxxabi-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -DLIBCXXABI_SINGLE_THREADED=1'
+
+if 'libcpp-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_THREADS'
+
+if 'libcpp-has-no-monotonic-clock' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'
+
+litTestArgs = ''
+if additional_features:
+litTestArgs = '--param=additional_features=' +
+  ','.join(additional_features)
+
 # Nuke/remake build directory and run CMake
 f.addStep(buildbot.steps.shell.ShellCommand(
 name='rm.builddir', command=['rm', '-rf', build_path],
@@ -83,13 +97,14 @@
   haltOnFailure=True, workdir=build_path))
 
 # Test libc++abi
+lit_flags = properties.WithProperties(LIT_ARGS=%s % litTestArgs)]
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxxabi', command=['make', 'check-libcxxabi'],
+name='test.libcxxabi', command=['make', lit_flags, 'check-libcxxabi'],
 workdir=build_path))
 
 # Test libc++
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxx', command=['make', 'check-libcxx'],
+name='test.libcxx', command=['make', lit_flags, 'check-libcxx'],
 workdir=build_path))
 
 return f
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Dan Albert
Other than the quick syntax fixes, LGTM.


Comment at: zorg/buildbot/builders/LibcxxAndAbiBuilder.py:73
@@ +72,3 @@
+if additional_features:
+litTestArgs = '--param=additional_features=' +
+  ','.join(additional_features)

You need to surround the right hand side with () if you split it between two 
lines.


Comment at: zorg/buildbot/builders/LibcxxAndAbiBuilder.py:100
@@ -85,2 +99,3 @@
 # Test libc++abi
+lit_flags = properties.WithProperties(LIT_ARGS=%s % litTestArgs)]
 f.addStep(buildbot.steps.shell.ShellCommand(

Stray ] at EOL.

http://reviews.llvm.org/D5215



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


[PATCH] [libcxxabi] s/LIBCXXABI_SINGLE_THREADED/LIBCXXABI_HAS_NO_THREADS/ for consistency with libcxx

2014-09-05 Thread Jon Roelofs
Hi danalbert,

Also remove the audotedection part so that if you're crazy enough to want a 
single threaded abi library, you'll say so explicitly in the build.

http://reviews.llvm.org/D5216

Files:
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  test/test_exception_storage.cpp
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -16,11 +16,9 @@
 
 #include unistd.h
 
-#if !defined(LIBCXXABI_SINGLE_THREADED)  \
-defined(_POSIX_THREADS)  _POSIX_THREADS  0
-#  define LIBCXXABI_SINGLE_THREADED 0
-#else
-#  define LIBCXXABI_SINGLE_THREADED 1
+// Set this in the CXXFLAGS when you need it
+#if !defined(LIBCXXABI_HAS_NO_THREADS)
+#  define LIBCXXABI_HAS_NO_THREADS 0
 #endif
 
 // Set this in the CXXFLAGS when you need it, because otherwise we'd have to
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -17,7 +17,7 @@
 #include exception// for std::terminate
 #include cstdlib  // for malloc, free
 #include cstring  // for memset
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #  include pthread.h  // for fallback_malloc.ipp's mutexes
 #endif
 #include cxa_exception.hpp
Index: src/cxa_exception_storage.cpp
===
--- src/cxa_exception_storage.cpp
+++ src/cxa_exception_storage.cpp
@@ -15,7 +15,7 @@
 
 #include config.h
 
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 
 namespace __cxxabiv1 {
 extern C {
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -10,7 +10,7 @@
 #include abort_message.h
 #include config.h
 
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #  include pthread.h
 #endif
 #include stdint.h
@@ -62,7 +62,7 @@
 
 #endif
 
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 pthread_mutex_t guard_mut = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t  guard_cv  = PTHREAD_COND_INITIALIZER;
 #endif
@@ -166,7 +166,7 @@
 extern C
 {
 
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 int __cxa_guard_acquire(guard_type* guard_object)
 {
 return !is_initialized(guard_object);
@@ -183,7 +183,7 @@
 *guard_object = 0;
 }
 
-#else // !LIBCXXABI_SINGLE_THREADED
+#else // !LIBCXXABI_HAS_NO_THREADS
 
 int __cxa_guard_acquire(guard_type* guard_object)
 {
@@ -250,7 +250,7 @@
 abort_message(__cxa_guard_abort failed to broadcast condition variable);
 }
 
-#endif // !LIBCXXABI_SINGLE_THREADED
+#endif // !LIBCXXABI_HAS_NO_THREADS
 
 }  // extern C
 
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -26,7 +26,7 @@
 namespace {
 
 // When POSIX threads are not available, make the mutex operations a nop
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 static void * heap_mutex = 0;
 #else
 static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -34,7 +34,7 @@
 
 class mutexor {
 public:
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 mutexor ( void * ) {}
 ~mutexor () {}
 #else
@@ -44,7 +44,7 @@
 private:
 mutexor ( const mutexor rhs );
 mutexor  operator = ( const mutexor rhs );
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 pthread_mutex_t *mtx_;
 #endif
 };
Index: test/test_exception_storage.cpp
===
--- test/test_exception_storage.cpp
+++ test/test_exception_storage.cpp
@@ -12,7 +12,7 @@
 #include cstdlib
 #include algorithm
 #include iostream
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #  include pthread.h
 #endif
 #include unistd.h
@@ -38,7 +38,7 @@
 return parm;
 }
 
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
 size_t  thread_globals [ NUMTHREADS ] = { 0 };
 pthread_t   threads[ NUMTHREADS ];
@@ -54,7 +54,7 @@
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 size_t thread_globals;
 retVal = thread_code(thread_globals) != 0;
 #else
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxxabi] s/LIBCXXABI_SINGLE_THREADED/LIBCXXABI_HAS_NO_THREADS/ for consistency with libcxx

2014-09-05 Thread Dan Albert
LGTM.

http://reviews.llvm.org/D5216



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


[libcxxabi] r217262 - s/LIBCXXABI_SINGLE_THREADED/LIBCXXABI_HAS_NO_THREADS/ for consistency with libcxx

2014-09-05 Thread Jonathan Roelofs
Author: jroelofs
Date: Fri Sep  5 12:46:40 2014
New Revision: 217262

URL: http://llvm.org/viewvc/llvm-project?rev=217262view=rev
Log:
s/LIBCXXABI_SINGLE_THREADED/LIBCXXABI_HAS_NO_THREADS/ for consistency with 
libcxx

Also remove the audotedection part so that if you're crazy enough to want a
single-threaded abi library, you'll say so explicitly in the build.

Modified:
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/fallback_malloc.ipp
libcxxabi/trunk/test/test_exception_storage.cpp

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=217262r1=217261r2=217262view=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Fri Sep  5 12:46:40 2014
@@ -16,11 +16,9 @@
 
 #include unistd.h
 
-#if !defined(LIBCXXABI_SINGLE_THREADED)  \
-defined(_POSIX_THREADS)  _POSIX_THREADS  0
-#  define LIBCXXABI_SINGLE_THREADED 0
-#else
-#  define LIBCXXABI_SINGLE_THREADED 1
+// Set this in the CXXFLAGS when you need it
+#if !defined(LIBCXXABI_HAS_NO_THREADS)
+#  define LIBCXXABI_HAS_NO_THREADS 0
 #endif
 
 // Set this in the CXXFLAGS when you need it, because otherwise we'd have to

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=217262r1=217261r2=217262view=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Fri Sep  5 12:46:40 2014
@@ -17,7 +17,7 @@
 #include exception// for std::terminate
 #include cstdlib  // for malloc, free
 #include cstring  // for memset
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #  include pthread.h  // for fallback_malloc.ipp's mutexes
 #endif
 #include cxa_exception.hpp

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=217262r1=217261r2=217262view=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Fri Sep  5 12:46:40 2014
@@ -15,7 +15,7 @@
 
 #include config.h
 
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 
 namespace __cxxabiv1 {
 extern C {

Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=217262r1=217261r2=217262view=diff
==
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Fri Sep  5 12:46:40 2014
@@ -10,7 +10,7 @@
 #include abort_message.h
 #include config.h
 
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 #  include pthread.h
 #endif
 #include stdint.h
@@ -62,7 +62,7 @@ void set_initialized(guard_type* guard_o
 
 #endif
 
-#if !LIBCXXABI_SINGLE_THREADED
+#if !LIBCXXABI_HAS_NO_THREADS
 pthread_mutex_t guard_mut = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t  guard_cv  = PTHREAD_COND_INITIALIZER;
 #endif
@@ -166,7 +166,7 @@ set_lock(uint32_t x, lock_type y)
 extern C
 {
 
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 int __cxa_guard_acquire(guard_type* guard_object)
 {
 return !is_initialized(guard_object);
@@ -183,7 +183,7 @@ void __cxa_guard_abort(guard_type* guard
 *guard_object = 0;
 }
 
-#else // !LIBCXXABI_SINGLE_THREADED
+#else // !LIBCXXABI_HAS_NO_THREADS
 
 int __cxa_guard_acquire(guard_type* guard_object)
 {
@@ -250,7 +250,7 @@ void __cxa_guard_abort(guard_type* guard
 abort_message(__cxa_guard_abort failed to broadcast condition 
variable);
 }
 
-#endif // !LIBCXXABI_SINGLE_THREADED
+#endif // !LIBCXXABI_HAS_NO_THREADS
 
 }  // extern C
 

Modified: libcxxabi/trunk/src/fallback_malloc.ipp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/fallback_malloc.ipp?rev=217262r1=217261r2=217262view=diff
==
--- libcxxabi/trunk/src/fallback_malloc.ipp (original)
+++ libcxxabi/trunk/src/fallback_malloc.ipp Fri Sep  5 12:46:40 2014
@@ -26,7 +26,7 @@
 namespace {
 
 // When POSIX threads are not available, make the mutex operations a nop
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 static void * heap_mutex = 0;
 #else
 static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -34,7 +34,7 @@ static pthread_mutex_t heap_mutex = PTHR
 
 class mutexor {
 public:
-#if LIBCXXABI_SINGLE_THREADED
+#if LIBCXXABI_HAS_NO_THREADS
 mutexor ( void * ) {}
 ~mutexor () {}
 #else
@@ -44,7 +44,7 @@ public:
 private:
 mutexor ( const mutexor 

Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Jon Roelofs
http://reviews.llvm.org/D5215

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/LibcxxAndAbiBuilder.py
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -667,8 +667,10 @@
  'slavenames': ['gribozavr4'],
  'builddir': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
  'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
- env={'CC': 'clang', 'CXX': 'clang++',
-  'CXXFLAGS' : '-D_LIBCPP_HAS_NO_THREADS -DLIBCXXABI_SINGLE_THREADED=1'}),
+ env={'CC': 'clang', 'CXX': 'clang++'},
+ additional_features=set(['libcxxabi-has-no-threads',
+  'libcpp-has-no-threads'
+  'libcpp-has-no-monotonic-clock'])),
  'category': 'libcxx'},
 
 {'name': 'libcxx-libcxxabi-x86_64-linux-ubuntu',
Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -42,7 +42,7 @@
 return f
 
 
-def getLibcxxAndAbiBuilder(f=None, env={}):
+def getLibcxxAndAbiBuilder(f=None, env={}, additional_features=set()):
 if f is None:
 f = buildbot.process.factory.BuildFactory()
 
@@ -59,6 +59,20 @@
 
 f = getLibcxxWholeTree(f, src_root)
 
+if 'libcxxabi-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -DLIBCXXABI_HAS_NO_THREADS=1'
+
+if 'libcpp-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_THREADS'
+
+if 'libcpp-has-no-monotonic-clock' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'
+
+litTestArgs = ''
+if additional_features:
+litTestArgs = ('--param=additional_features=' +
+   ','.join(additional_features))
+
 # Nuke/remake build directory and run CMake
 f.addStep(buildbot.steps.shell.ShellCommand(
 name='rm.builddir', command=['rm', '-rf', build_path],
@@ -83,13 +97,14 @@
   haltOnFailure=True, workdir=build_path))
 
 # Test libc++abi
+lit_flags = properties.WithProperties(LIT_ARGS=%s % litTestArgs)
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxxabi', command=['make', 'check-libcxxabi'],
+name='test.libcxxabi', command=['make', lit_flags, 'check-libcxxabi'],
 workdir=build_path))
 
 # Test libc++
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxx', command=['make', 'check-libcxx'],
+name='test.libcxx', command=['make', lit_flags, 'check-libcxx'],
 workdir=build_path))
 
 return f
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Dan Albert

Comment at: buildbot/osuosl/master/config/builders.py:672
@@ +671,3 @@
+ additional_features=set(['libcxxabi-has-no-threads',
+  'libcpp-has-no-threads'
+  'libcpp-has-no-monotonic-clock'])),

Missed a comma (sorry I'm not catching all of these in one pass... I'm not the 
best Python interpreter).

http://reviews.llvm.org/D5215



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


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Jon Roelofs
Fix additional_features list's missing comma.

http://reviews.llvm.org/D5215

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/LibcxxAndAbiBuilder.py
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -667,8 +667,10 @@
  'slavenames': ['gribozavr4'],
  'builddir': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
  'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
- env={'CC': 'clang', 'CXX': 'clang++',
-  'CXXFLAGS' : '-D_LIBCPP_HAS_NO_THREADS -DLIBCXXABI_SINGLE_THREADED=1'}),
+ env={'CC': 'clang', 'CXX': 'clang++'},
+ additional_features=set(['libcxxabi-has-no-threads',
+  'libcpp-has-no-threads',
+  'libcpp-has-no-monotonic-clock'])),
  'category': 'libcxx'},
 
 {'name': 'libcxx-libcxxabi-x86_64-linux-ubuntu',
Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -42,7 +42,7 @@
 return f
 
 
-def getLibcxxAndAbiBuilder(f=None, env={}):
+def getLibcxxAndAbiBuilder(f=None, env={}, additional_features=set()):
 if f is None:
 f = buildbot.process.factory.BuildFactory()
 
@@ -59,6 +59,20 @@
 
 f = getLibcxxWholeTree(f, src_root)
 
+if 'libcxxabi-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -DLIBCXXABI_HAS_NO_THREADS=1'
+
+if 'libcpp-has-no-threads' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_THREADS'
+
+if 'libcpp-has-no-monotonic-clock' in additional_features:
+env['CXXFLAGS'] += ' -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'
+
+litTestArgs = ''
+if additional_features:
+litTestArgs = ('--param=additional_features=' +
+   ','.join(additional_features))
+
 # Nuke/remake build directory and run CMake
 f.addStep(buildbot.steps.shell.ShellCommand(
 name='rm.builddir', command=['rm', '-rf', build_path],
@@ -83,13 +97,14 @@
   haltOnFailure=True, workdir=build_path))
 
 # Test libc++abi
+lit_flags = properties.WithProperties(LIT_ARGS=%s % litTestArgs)
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxxabi', command=['make', 'check-libcxxabi'],
+name='test.libcxxabi', command=['make', lit_flags, 'check-libcxxabi'],
 workdir=build_path))
 
 # Test libc++
 f.addStep(buildbot.steps.shell.ShellCommand(
-name='test.libcxx', command=['make', 'check-libcxx'],
+name='test.libcxx', command=['make', lit_flags, 'check-libcxx'],
 workdir=build_path))
 
 return f
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Dan Albert
LGTM.

http://reviews.llvm.org/D5215



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


Re: Make -fstandalone-debug default on mingw

2014-09-05 Thread David Blaikie
On Mon, Sep 1, 2014 at 2:28 PM, Yaron Keren yaron.ke...@gmail.com wrote:

 There is no debug variant of libstdc++, just release DLL, import lib for
 this DLL and a static lib. You can see all the files (even without actually
 running Windows) in the install 7z file:


 http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.1/threads-posix/dwarf/

 Anyhow, for your example,

 mingw (gcc 4.9.1)
 

 0x0072:   DW_TAG_structure_type [2] *
 DW_AT_name [DW_FORM_string] (foo)
 DW_AT_declaration [DW_FORM_flag_present] (true)
 DW_AT_sibling [DW_FORM_ref4] (cu + 0x008b = {0x008b})

 0x007b: DW_TAG_subprogram [3] *
   DW_AT_external [DW_FORM_flag_present] (true)
   DW_AT_name [DW_FORM_string] (foo)
   DW_AT_artificial [DW_FORM_flag_present] (true)
   DW_AT_declaration [DW_FORM_flag_present] (true)
   DW_AT_object_pointer [DW_FORM_ref4] (cu + 0x0084 =
 {0x0084})

 0x0084:   DW_TAG_formal_parameter [4]
 DW_AT_type [DW_FORM_ref4] (cu + 0x008b =
 {0x008b})
 DW_AT_artificial [DW_FORM_flag_present] (true)

 0x0089:   NULL

 0x008a: NULL


 clang trunk
 --

 0x0037:   DW_TAG_structure_type [3] *
 DW_AT_name [DW_FORM_strp] ( .debug_str[0x0048] =
 foo)
 DW_AT_declaration [DW_FORM_flag_present] (true)

 0x003c: DW_TAG_subprogram [4] *
   DW_AT_name [DW_FORM_strp] ( .debug_str[0x0048] =
 foo)
   DW_AT_declaration [DW_FORM_flag_present] (true)
   DW_AT_artificial [DW_FORM_flag_present] (true)
   DW_AT_external [DW_FORM_flag_present] (true)
   DW_AT_accessibility [DW_FORM_data1] (0x01)

 0x0042:   DW_TAG_formal_parameter [5]
  DW_AT_type [DW_FORM_ref4] (cu + 0x005b =
 {0x005b})
 DW_AT_artificial [DW_FORM_flag_present] (true)

 0x0047:   NULL

 0x0048: NULL

 clang -fstandalone-debug
 --

 0x0037:   DW_TAG_structure_type [3] *
 DW_AT_containing_type [DW_FORM_ref4] (cu + 0x0037 =
 {0x0037})
 DW_AT_name [DW_FORM_strp] ( .debug_str[0x007a] =
 foo)
 DW_AT_byte_size [DW_FORM_data1] (0x04)
 DW_AT_decl_file [DW_FORM_data1] (0x01)
 DW_AT_decl_line [DW_FORM_data1] (0x01)

 0x0043: DW_TAG_member [4]
   DW_AT_name [DW_FORM_strp] ( .debug_str[0x0048] =
 _vptr$foo)
   DW_AT_type [DW_FORM_ref4] (cu + 0x0075 = {0x0075})
   DW_AT_data_member_location [DW_FORM_data1] (0x00)
   DW_AT_accessibility [DW_FORM_data1] (0x01)
   DW_AT_artificial [DW_FORM_flag_present] (true)

 0x004e: DW_TAG_subprogram [5] *
   DW_AT_MIPS_linkage_name [DW_FORM_strp] (
 .debug_str[0x0066] = _ZN3foo4funcEv)
   DW_AT_name [DW_FORM_strp] ( .debug_str[0x0075] =
 func)
   DW_AT_decl_file [DW_FORM_data1] (0x01)
   DW_AT_decl_line [DW_FORM_data1] (0x01)
   DW_AT_virtuality [DW_FORM_data1] (0x01)
   DW_AT_vtable_elem_location [DW_FORM_exprloc] (0x2 10
 00 )
   DW_AT_declaration [DW_FORM_flag_present] (true)
   DW_AT_external [DW_FORM_flag_present] (true)
   DW_AT_accessibility [DW_FORM_data1] (0x01)
   DW_AT_containing_type [DW_FORM_ref4] (cu + 0x0037 =
 {0x0037})

 0x0062:   DW_TAG_formal_parameter [6]
 DW_AT_type [DW_FORM_ref4] (cu + 0x008f =
 {0x008f})
 DW_AT_artificial [DW_FORM_flag_present] (true)

 0x0067:   NULL

 0x0068: DW_TAG_subprogram [7] *
   DW_AT_name [DW_FORM_strp] ( .debug_str[0x007a] =
 foo)
   DW_AT_declaration [DW_FORM_flag_present] (true)
   DW_AT_artificial [DW_FORM_flag_present] (true)
   DW_AT_external [DW_FORM_flag_present] (true)
   DW_AT_accessibility [DW_FORM_data1] (0x01)

 0x006e:   DW_TAG_formal_parameter [6]
 DW_AT_type [DW_FORM_ref4] (cu + 0x008f =
 {0x008f})
 DW_AT_artificial [DW_FORM_flag_present] (true)

 0x0073:   NULL

 0x0074: NULL


 That's consistent.

 What's odd is for std::string gcc produces a definition while clang
 produce a declaration only unless -fstandalone-debug. That what causes the
 debug pretty printer problem.


Yep - that's because Clang has another similar, bit different, optimization
that's founded on the same principle (the idea that you will compile your
whole program/libraries with debug info), using explicit 

Re: [PATCH] [zorg] Clean up libcxx-libcxxabi-singlethreaded-x86_64-linux-debian so that it passes the feature flags to lit

2014-09-05 Thread Jon Roelofs
r217265


Comment at: zorg/buildbot/builders/LibcxxAndAbiBuilder.py:70
@@ +69,3 @@
+if additional_features:
+litTestArgs = --param=additional_features= +
+  ,.join(additional_features)

danalbert wrote:
 else this is undefined and then used below.
Goood point! Untested code is untested...

http://reviews.llvm.org/D5215



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


Re: [PATCH] Fix PR20495: correct inference of the CUDA target for implicit members

2014-09-05 Thread Eli Bendersky
Addresses Richard's review comments

http://reviews.llvm.org/D5199

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/implicit-member-target-collision-cxx11.cu
  test/SemaCUDA/implicit-member-target-collision.cu
  test/SemaCUDA/implicit-member-target.cu
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2997,6 +2997,16 @@
 constructor (inherited)}0 not viable: call to 
 %select{__device__|__global__|__host__|__host__ __device__}1 function from
  %select{__device__|__global__|__host__|__host__ __device__}2 function;
+def err_implicit_member_target_infer_collision : Error
+implicit %select{
+default constructor|
+copy constructor|
+move constructor|
+copy assignment operator|
+move assignment operator|
+destructor}0 inferred target collision: call to both 
+%select{__device__|__global__|__host__|__host__ __device__}1 and 
+%select{__device__|__global__|__host__|__host__ __device__}2 members;
 
 def note_ambiguous_type_conversion: Note
 because of ambiguity in conversion %diff{of $ to $|between types}0,1;
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8148,10 +8148,24 @@
   bool CheckCUDATarget(CUDAFunctionTarget CallerTarget,
CUDAFunctionTarget CalleeTarget);
 
-  bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee) {
-return CheckCUDATarget(IdentifyCUDATarget(Caller),
-   IdentifyCUDATarget(Callee));
-  }
+  bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee);
+
+  /// Given a implicit special member, infer its CUDA target from the
+  /// calls it needs to make to underlying base/field special members.
+  /// \param ClassDecl the class for which the member is being created.
+  /// \param CSM the kind of special member.
+  /// \param MemberDecl the special member itself.
+  /// \param ConstRHS true if this is a copy operation with a const object on
+  ///its RHS.
+  /// \param Diagnose true if this call should emit diagnostics.
+  /// \return true if there was an error inferring.
+  /// The result of this call is implicit CUDA target attribute(s) attached to
+  /// the member declaration.
+  bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
+   CXXSpecialMember CSM,
+   CXXMethodDecl *MemberDecl,
+   bool ConstRHS,
+   bool Diagnose);
 
   /// \name Code completion
   //@{
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -15,6 +15,8 @@
 #include clang/AST/ASTContext.h
 #include clang/AST/Decl.h
 #include clang/Sema/SemaDiagnostic.h
+#include llvm/ADT/Optional.h
+#include llvm/ADT/SmallVector.h
 using namespace clang;
 
 ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation oc,
@@ -36,11 +38,6 @@
 
 /// IdentifyCUDATarget - Determine the CUDA compilation target for this function
 Sema::CUDAFunctionTarget Sema::IdentifyCUDATarget(const FunctionDecl *D) {
-  // Implicitly declared functions (e.g. copy constructors) are
-  // __host__ __device__
-  if (D-isImplicit())
-return CFT_HostDevice;
-
   if (D-hasAttrCUDAGlobalAttr())
 return CFT_Global;
 
@@ -53,6 +50,12 @@
   return CFT_Host;
 }
 
+bool Sema::CheckCUDATarget(const FunctionDecl *Caller,
+   const FunctionDecl *Callee) {
+  return CheckCUDATarget(IdentifyCUDATarget(Caller),
+ IdentifyCUDATarget(Callee));
+}
+
 bool Sema::CheckCUDATarget(CUDAFunctionTarget CallerTarget,
CUDAFunctionTarget CalleeTarget) {
   // CUDA B.1.1 The __device__ qualifier declares a function that is...
@@ -74,3 +77,159 @@
   return false;
 }
 
+/// When an implicitly-declared special member has to invoke more than one
+/// base/field special member, conflicts may occur in the targets of these
+/// members. For example, if one base's member __host__ and another's is
+/// __device__, it's a conflict.
+/// This function figures out if the given targets \param Target1 and
+/// \param Target2 conflict, and if they do not it fills in
+/// \param ResolvedTarget with a target that resolves for both calls.
+/// \return true if there's a conflict, false otherwise.
+static bool
+resolveCalleeCUDATargetConflict(Sema::CUDAFunctionTarget Target1,
+Sema::CUDAFunctionTarget Target2,
+   

Re: [PATCH] Fix PR20495: correct inference of the CUDA target for implicit members

2014-09-05 Thread Eli Bendersky
Thanks for the review Richard. I believe I've addressed your comments. PTAL


Comment at: lib/Sema/SemaCUDA.cpp:110-111
@@ +109,4 @@
+bool ConstRHS) {
+  CUDAFunctionTarget InferredTarget;
+  bool HasInferredTarget = false;
+

rsmith wrote:
 `OptionalCUDAFunctionTarget` InferredTarget;
Done.


Comment at: lib/Sema/SemaCUDA.cpp:119
@@ +118,3 @@
+  // Infer the target of this member base on the ones it should call.
+  for (const auto B : ClassDecl-bases()) {
+const RecordType *BaseType = B.getType()-getAsRecordType();

rsmith wrote:
 For a non-abstract class, you should visit virtual bases as well as direct 
 bases. (For an abstract class, you should skip direct and indirect virtual 
 bases.)
Done.


Comment at: lib/Sema/SemaCUDA.cpp:128-132
@@ +127,7 @@
+LookupSpecialMember(BaseClassDecl, CSM,
+/* ConstArg */ ConstRHS,
+/* VolatileArg */ false,
+/* RValueThis */ false,
+/* ConstThis */ false,
+/* VolatileThis */ false);
+

rsmith wrote:
 rsmith wrote:
  These are not necessarily correct; the user might have explicitly defaulted 
  a const/volatile/whatever special member function.
 Hmm, I see you're not actually doing this for any defaulted function, just 
 for an implicit one. In that case, this looks fine, but please rename the 
 function to talk about implicit special members not defaulted ones.
Renaming done.


Comment at: lib/Sema/SemaCUDA.cpp:146-148
@@ +145,5 @@
+  if (ResolutionError) {
+Diag(ClassDecl-getLocation(),
+ diag::err_implicit_member_target_infer_collision)
+ (unsigned)CSM  InferredTarget  BaseMethodTarget;
+return;

rsmith wrote:
 eliben wrote:
  rsmith wrote:
   Declaring implicit special members is done lazily, so emitting 
   diagnostics from here will result in erratic behavior. It would be better 
   to defer the diagnostic until the special member is defined in C++98, and 
   to mark the member as deleted in this case in C++11.
  If I just mark the member as deleted in C++11, is there away to still emit 
  the descriptive diagnostic? Just deleting the member doesn't provide the 
  user with any hint of what the underlying problem is.
 Yes, see `Sema::NoteDeletedFunction`.
Thanks. I ended up implanting this into ShouldDeleteSpecialMember, with 
diagnostics; this is called from NoteDeletedFunction, and it also takes care of 
actually deleting the member in C++11 mode. Let me know if this makes sense.


Comment at: lib/Sema/SemaOverload.cpp:5637
@@ -5636,3 +5636,3 @@
 if (const FunctionDecl *Caller = dyn_castFunctionDecl(CurContext))
-  if (CheckCUDATarget(Caller, Function)) {
+  if (!Caller-isImplicit()  CheckCUDATarget(Caller, Function)) {
 Candidate.Viable = false;

rsmith wrote:
 eliben wrote:
  rsmith wrote:
   Hmm, why do you need this change?
  Consider what happens when the target inference method runs. It looks up 
  the ctors of base classes, which gets to this point. Now, at this point we 
  don't yet know what the caller's (the implicit method being defined) target 
  is, so we can not reason whether there's a target mismatch. 
  
  AFAIU this added test solves the problem, since we really cannot reject 
  candidates based on target-ness when declaring an implicit member. The 
  implicit member's target-ness will be determined by the inference method, 
  and the collision test (the one with the Diag you commented on) should take 
  care of mismatches.
  
  Does this make sense?
 Thanks, that makes sense. This at least deserves an explanatory comment.
Comment added, let me know if you'd want to see more details in it.

http://reviews.llvm.org/D5199



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


Re: [PATCH] [libc++] Allow libc++ to be built on systems without POSIX threads

2014-09-05 Thread Jon Roelofs
Oh, and I also removed the autodetect part of include/__config

http://reviews.llvm.org/D3969



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


[libcxx] r217268 - Bugfix: allow additional_features to be empty

2014-09-05 Thread Jonathan Roelofs
Author: jroelofs
Date: Fri Sep  5 14:03:46 2014
New Revision: 217268

URL: http://llvm.org/viewvc/llvm-project?rev=217268view=rev
Log:
Bugfix: allow additional_features to be empty

Modified:
libcxx/trunk/test/lit.cfg

Modified: libcxx/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=217268r1=217267r2=217268view=diff
==
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Fri Sep  5 14:03:46 2014
@@ -291,9 +291,10 @@ class Configuration(object):
 inferred use_clang_verify as: %r % self.use_clang_verify)
 
 def configure_features(self):
-additional_features = 
self.get_lit_conf('additional_features').split(,)
-for f in additional_features:
-self.config.available_features.add(f.strip())
+additional_features = self.get_lit_conf('additional_features')
+if additional_features:
+for f in additional_features.split(','):
+self.config.available_features.add(f.strip())
 
 # Figure out which of the required locales we support
 locales = {


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


[PATCH] Add -fuse-line-directive flag to control usage of #line with -E

2014-09-05 Thread Reid Kleckner
Hi rsmith,

Currently -fms-extensions controls this behavior, which doesn't make
much sense. It means we can't identify what is and isn't a system header
when compiling our own preprocessed output, because #line doesn't
represent this information.

If someone is feeding Clang's preprocessed output to another compiler,
they can use this flag.

Fixes PR20553.

http://reviews.llvm.org/D5217

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/PreprocessorOutputOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  lib/Frontend/Rewrite/InclusionRewriter.cpp
  test/Frontend/rewrite-includes-line-markers.c
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -569,6 +569,10 @@
   Flags[CC1Option];
 def fno_rewrite_includes : Flag[-], fno-rewrite-includes, Groupf_Group;
 
+def fuse_line_directive : Flag[-], fuse-line-directive, Groupf_Group,
+  Flags[CC1Option];
+def fno_use_line_directive : Flag[-], fno-use-line-directive, Groupf_Group;
+
 def ffreestanding : Flag[-], ffreestanding, Groupf_Group, Flags[CC1Option],
   HelpTextAssert that the compilation takes place in a freestanding environment;
 def fgnu_keywords : Flag[-], fgnu-keywords, Groupf_Group, Flags[CC1Option],
Index: include/clang/Frontend/PreprocessorOutputOptions.h
===
--- include/clang/Frontend/PreprocessorOutputOptions.h
+++ include/clang/Frontend/PreprocessorOutputOptions.h
@@ -19,6 +19,7 @@
   unsigned ShowCPP : 1;/// Print normal preprocessed output.
   unsigned ShowComments : 1;   /// Show comments.
   unsigned ShowLineMarkers : 1;/// Show \#line markers.
+  unsigned UseLineDirective : 1;   /// Use \#line instead of GCC-style \# N.
   unsigned ShowMacroComments : 1;  /// Show comments, even in macros.
   unsigned ShowMacros : 1; /// Print macro definitions.
   unsigned RewriteIncludes : 1;/// Preprocess include directives only.
@@ -28,6 +29,7 @@
 ShowCPP = 0;
 ShowComments = 0;
 ShowLineMarkers = 1;
+UseLineDirective = 0;
 ShowMacroComments = 0;
 ShowMacros = 0;
 RewriteIncludes = 0;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1766,6 +1766,7 @@
   Opts.ShowMacroComments = Args.hasArg(OPT_CC);
   Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
   Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes);
+  Opts.UseLineDirective = Args.hasArg(OPT_fuse_line_directive);
 }
 
 static void ParseTargetArgs(TargetOptions Opts, ArgList Args) {
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -97,21 +97,18 @@
   bool UseLineDirective;
   bool IsFirstFileEntered;
 public:
-  PrintPPOutputPPCallbacks(Preprocessor pp, raw_ostream os,
-   bool lineMarkers, bool defines)
- : PP(pp), SM(PP.getSourceManager()),
-   ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers),
-   DumpDefines(defines) {
+  PrintPPOutputPPCallbacks(Preprocessor pp, raw_ostream os, bool lineMarkers,
+   bool defines, bool UseLineDirective)
+  : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
+DisableLineMarkers(lineMarkers), DumpDefines(defines),
+UseLineDirective(UseLineDirective) {
 CurLine = 0;
 CurFilename += uninit;
 EmittedTokensOnThisLine = false;
 EmittedDirectiveOnThisLine = false;
 FileType = SrcMgr::C_User;
 Initialized = false;
 IsFirstFileEntered = false;
-
-// If we're in microsoft mode, use normal #line instead of line markers.
-UseLineDirective = PP.getLangOpts().MicrosoftExt;
   }
 
   void setEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
@@ -716,9 +713,8 @@
   // to -C or -CC.
   PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments);
 
-  PrintPPOutputPPCallbacks *Callbacks =
-  new PrintPPOutputPPCallbacks(PP, *OS, !Opts.ShowLineMarkers,
-   Opts.ShowMacros);
+  PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(
+  PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, Opts.UseLineDirective);
   PP.AddPragmaHandler(new UnknownPragmaHandler(#pragma, Callbacks));
   PP.AddPragmaHandler(GCC, new UnknownPragmaHandler(#pragma GCC,Callbacks));
   PP.AddPragmaHandler(clang,
Index: lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -50,7 +50,8 @@
   /// various \c PPCallbacks callbacks.
   

Re: [PATCH] [libc++] Allow libc++ to be built on systems without POSIX threads

2014-09-05 Thread Jon Roelofs
r217271

http://reviews.llvm.org/D3969



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


r217272 - Require an x86 target for ms-inline-asm-return.cpp instead of XFAIL

2014-09-05 Thread Reid Kleckner
Author: rnk
Date: Fri Sep  5 15:06:06 2014
New Revision: 217272

URL: http://llvm.org/viewvc/llvm-project?rev=217272view=rev
Log:
Require an x86 target for ms-inline-asm-return.cpp instead of XFAIL

Modified:
cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Modified: cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp?rev=217272r1=217271r2=217272view=diff
==
--- cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp Fri Sep  5 15:06:06 2014
@@ -1,5 +1,5 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - 
-fasm-blocks | FileCheck %s
-// XFAIL: arm
 
 // Check that we take EAX or EAX:EDX and return it from these functions for 
MSVC
 // compatibility.


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


Re: r217187 - MS inline asm: Allow __asm blocks to set a return value

2014-09-05 Thread Reid Kleckner
It requires the x86 target to be compiled in. I added that requirement
in r217272.


On Fri, Sep 5, 2014 at 3:09 AM, Renato Golin renato.go...@linaro.org
wrote:

 On 5 September 2014 11:05, Timur Iskhodzhanov timur...@google.com wrote:
  Looks like r217192 wasn't enough?

 Nope, still failing...

 http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a15

 --renato
 ___
 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


r217274 - Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Samuel Benzaquen
Author: sbenza
Date: Fri Sep  5 15:15:31 2014
New Revision: 217274

URL: http://llvm.org/viewvc/llvm-project?rev=217274view=rev
Log:
Separate the matchers by type and statically dispatch to the right list.

Summary:
Separate the matchers by type and statically dispatch to the right list.
For any node type that we support, it reduces the number of matchers we
run it through.
For node types we do not support, it makes match() a noop.
This change improves our clang-tidy related benchmark by ~30%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h?rev=217274r1=217273r2=217274view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h Fri Sep  5 15:15:31 
2014
@@ -173,11 +173,23 @@ public:
   /// Each call to FindAll(...) will call the closure once.
   void registerTestCallbackAfterParsing(ParsingDoneTestCallback *ParsingDone);
 
-private:
-  /// \brief For each \c DynTypedMatcher a \c MatchCallback that will be called
+  /// \brief For each \c Matcher a \c MatchCallback that will be called
   /// when it matches.
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback * 
-MatcherCallbackPairs;
+  struct MatchersByType {
+std::vectorstd::pairDeclarationMatcher, MatchCallback * Decl;
+std::vectorstd::pairTypeMatcher, MatchCallback * Type;
+std::vectorstd::pairStatementMatcher, MatchCallback * Stmt;
+std::vectorstd::pairNestedNameSpecifierMatcher, MatchCallback *
+NestedNameSpecifier;
+std::vectorstd::pairNestedNameSpecifierLocMatcher, MatchCallback *
+NestedNameSpecifierLoc;
+std::vectorstd::pairTypeLocMatcher, MatchCallback * TypeLoc;
+/// \brief All the callbacks in one container to simplify iteration.
+std::vectorMatchCallback * AllCallbacks;
+  };
+
+private:
+  MatchersByType Matchers;
 
   /// \brief Called when parsing is done.
   ParsingDoneTestCallback *ParsingDone;

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=217274r1=217273r2=217274view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Fri Sep  5 15:15:31 2014
@@ -292,29 +292,17 @@ private:
 class MatchASTVisitor : public RecursiveASTVisitorMatchASTVisitor,
 public ASTMatchFinder {
 public:
-  MatchASTVisitor(
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback *  *
-  MatcherCallbackPairs)
-  : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(nullptr) 
{}
+ MatchASTVisitor(const MatchFinder::MatchersByType *Matchers)
+ : Matchers(Matchers), ActiveASTContext(nullptr) {}
 
   void onStartOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onStartOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onStartOfTranslationUnit();
   }
 
   void onEndOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onEndOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onEndOfTranslationUnit();
   }
 
   void set_active_ast_context(ASTContext *NewActiveASTContext) {
@@ -447,22 +435,27 @@ public:
 
   // Matches all registered matchers on the given node and calls the
   // result callback for every node that matches.
-  void match(const ast_type_traits::DynTypedNode Node) {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  BoundNodesTreeBuilder Builder;
-  if (I-first.matches(Node, this, Builder)) {
-MatchVisitor Visitor(ActiveASTContext, I-second);
-Builder.visitMatches(Visitor);
-  }
+  void match(const ast_type_traits::DynTypedNode Node) {
+// FIXME: Improve this with a switch or a visitor pattern.
+if (auto *N = Node.getDecl()) {
+  match(*N);
+} else if (auto *N = 

Re: [PATCH] Separate the matchers by type and statically dispatch to the right list.

2014-09-05 Thread Samuel Benzaquen
Closed by commit rL217274 (authored by @sbenza).

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D5197

Files:
  cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
  cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -173,11 +173,23 @@
   /// Each call to FindAll(...) will call the closure once.
   void registerTestCallbackAfterParsing(ParsingDoneTestCallback *ParsingDone);
 
-private:
-  /// \brief For each \c DynTypedMatcher a \c MatchCallback that will be called
+  /// \brief For each \c Matcher a \c MatchCallback that will be called
   /// when it matches.
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback * 
-MatcherCallbackPairs;
+  struct MatchersByType {
+std::vectorstd::pairDeclarationMatcher, MatchCallback * Decl;
+std::vectorstd::pairTypeMatcher, MatchCallback * Type;
+std::vectorstd::pairStatementMatcher, MatchCallback * Stmt;
+std::vectorstd::pairNestedNameSpecifierMatcher, MatchCallback *
+NestedNameSpecifier;
+std::vectorstd::pairNestedNameSpecifierLocMatcher, MatchCallback *
+NestedNameSpecifierLoc;
+std::vectorstd::pairTypeLocMatcher, MatchCallback * TypeLoc;
+/// \brief All the callbacks in one container to simplify iteration.
+std::vectorMatchCallback * AllCallbacks;
+  };
+
+private:
+  MatchersByType Matchers;
 
   /// \brief Called when parsing is done.
   ParsingDoneTestCallback *ParsingDone;
Index: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -292,29 +292,17 @@
 class MatchASTVisitor : public RecursiveASTVisitorMatchASTVisitor,
 public ASTMatchFinder {
 public:
-  MatchASTVisitor(
-  std::vectorstd::pairinternal::DynTypedMatcher, MatchCallback *  *
-  MatcherCallbackPairs)
-  : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(nullptr) {}
+ MatchASTVisitor(const MatchFinder::MatchersByType *Matchers)
+ : Matchers(Matchers), ActiveASTContext(nullptr) {}
 
   void onStartOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onStartOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onStartOfTranslationUnit();
   }
 
   void onEndOfTranslationUnit() {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  I-second-onEndOfTranslationUnit();
-}
+for (MatchCallback *MC : Matchers-AllCallbacks)
+  MC-onEndOfTranslationUnit();
   }
 
   void set_active_ast_context(ASTContext *NewActiveASTContext) {
@@ -447,22 +435,27 @@
 
   // Matches all registered matchers on the given node and calls the
   // result callback for every node that matches.
-  void match(const ast_type_traits::DynTypedNode Node) {
-for (std::vectorstd::pairinternal::DynTypedMatcher,
-   MatchCallback * ::const_iterator
- I = MatcherCallbackPairs-begin(),
- E = MatcherCallbackPairs-end();
- I != E; ++I) {
-  BoundNodesTreeBuilder Builder;
-  if (I-first.matches(Node, this, Builder)) {
-MatchVisitor Visitor(ActiveASTContext, I-second);
-Builder.visitMatches(Visitor);
-  }
+  void match(const ast_type_traits::DynTypedNode Node) {
+// FIXME: Improve this with a switch or a visitor pattern.
+if (auto *N = Node.getDecl()) {
+  match(*N);
+} else if (auto *N = Node.getStmt()) {
+  match(*N);
+} else if (auto *N = Node.getType()) {
+  match(*N);
+} else if (auto *N = Node.getQualType()) {
+  match(*N);
+} else if (auto *N = Node.getNestedNameSpecifier()) {
+  match(*N);
+} else if (auto *N = Node.getNestedNameSpecifierLoc()) {
+  match(*N);
+} else if (auto *N = Node.getTypeLoc()) {
+  match(*N);
 }
   }
 
   template typename T void match(const T Node) {
-match(ast_type_traits::DynTypedNode::create(Node));
+matchDispatch(Node);
   }
 
   // Implements ASTMatchFinder::getASTContext.
@@ -475,6 +468,40 @@
   bool shouldUseDataRecursionFor(clang::Stmt *S) const { return false; }
 
 private:
+  /// \brief Runs all the \p Matchers on \p Node.
+  ///
+  /// Used by \c matchDispatch() below.
+  template typename T, typename MC
+  void matchImpl(const T Node, const MC Matchers) {
+for (const 

Re: [PATCH] Support the assume_aligned function attribute

2014-09-05 Thread hfin...@anl.gov

Comment at: lib/CodeGen/CGExpr.cpp:3379-3382
@@ -3378,2 +3378,6 @@
 
-  return EmitCall(FnInfo, Callee, ReturnValue, Args, TargetDecl);
+  RValue Ret = EmitCall(FnInfo, Callee, ReturnValue, Args, TargetDecl);
+
+  if (Ret.isScalar()  TargetDecl) {
+if (const auto *AA = TargetDecl-getAttrAssumeAlignedAttr()) {
+  llvm::Value *OffsetValue = nullptr;

rsmith wrote:
 Is this really the right place for this code, rather than in the called 
 `EmitCall` function? Various places call the lower-level overload directly.
When I first looked, I thought that there were no other relevant callers, but 
maybe EmitCallAndReturnForThunk and EmitForwardingCallToLambda would need this 
handling too?

Because of the way that the lower-level EmitCall is structured, I'd need to 
wrap it (it has too many early returns). What would I call it?


Comment at: lib/Sema/SemaDeclAttr.cpp:1130
@@ -1129,2 +1129,3 @@
+bool Sema::isValidPointerAttrType(QualType T) {
   T = T.getNonReferenceType();
 

rsmith wrote:
 Is this really appropriate for your attribute? (It makes almost no sense for 
 `__attribute__((nonnull))` either, but I couldn't find anyone at Apple to 
 tell me what the relevant radar says, so I have no idea why we have this 
 feature.)
Nice :-) -- Honestly, I don't have a strong opinion regarding whether or not we 
strip references, but I like the idea of consistency between the two 
attributes. The set of returned pointers about which I can assert something 
about the alignment should be the same as that about which I can assert a 
nonnull property.

That having been said, it looks like the CodeGen for returns_nonnull that adds 
the nonnull IR attribute (and the associated UBSan code) does not handle 
references-to-pointers correctly. I'll fix that as a follow-up too.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:203-205
@@ +202,5 @@
+const AssumeAlignedAttr *AssumeAligned = 
dyn_castAssumeAlignedAttr(TmplAttr);
+if (AssumeAligned  (AssumeAligned-getAlignment()-isValueDependent() ||
+  (AssumeAligned-getOffset() 
+   AssumeAligned-getOffset()-isValueDependent( {
+  instantiateDependentAssumeAlignedAttr(*this, TemplateArgs, 
AssumeAligned, New);

rsmith wrote:
 You shouldn't have these 'is dependent' checks here; the other code above and 
 below is wrong to include them. Testcase:
 
   templatetypename T __attribute__((assume_aligned(sizeof(int(T()) T 
 *f();
   void *p = fvoid();
 
 This should result in a hard error, because `int(void())` is invalid, but I 
 think you'll accept it, because `sizeof(int(T()))` is not value-dependent, so 
 you never actually perform the substitution.
Interestingly, the current code does generate an error:
  invalid application of 'sizeof' to a function type

Removing the type-dependent checks does not seem to change any of the current 
behavior.

http://reviews.llvm.org/D4601



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


Re: [PATCH] Implement nonnull-attribute sanitizer

2014-09-05 Thread Alexey Samsonov
(ping)

http://reviews.llvm.org/D5082



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


r217275 - Move the initialization of VAListTagName after InitializeSema()

2014-09-05 Thread Ben Langmuir
Author: benlangmuir
Date: Fri Sep  5 15:24:27 2014
New Revision: 217275

URL: http://llvm.org/viewvc/llvm-project?rev=217275view=rev
Log:
Move the initialization of VAListTagName after InitializeSema()

This innocuous statement to get the identifier info for __va_list_tag
was causing an assertion failure:
  NextIsPrevious()  decl became non-canonical unexpectedly
if the __va_list_tag identifier was found in a PCH in some
circumstances, because it was looked up before the ASTReader had a Sema
object to use to find existing decls to merge with.

We could possibly move getting the identifier info even later, or make
it lazy if we wanted to, but this seemed like the minimal change.

Now why a PCH would have this identifier in the first place is a bit
mysterious. This seems to be related to the global module index in some
way, because when the test case is built without the global module index
it will not emit an identifier for __va_list_tag into the PCH, but with
the global module index it does.

Added:
cfe/trunk/test/Modules/Inputs/va_list/
cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
cfe/trunk/test/Modules/va_list.m
Modified:
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=217275r1=217274r2=217275view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri Sep  5 15:24:27 2014
@@ -69,8 +69,6 @@ PrintingPolicy Sema::getPrintingPolicy(c
 void Sema::ActOnTranslationUnitScope(Scope *S) {
   TUScope = S;
   PushDeclContext(S, Context.getTranslationUnitDecl());
-
-  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
 }
 
 Sema::Sema(Preprocessor pp, ASTContext ctxt, ASTConsumer consumer,
@@ -155,6 +153,10 @@ void Sema::Initialize() {
   = dyn_cast_or_nullExternalSemaSource(Context.getExternalSource()))
 ExternalSema-InitializeSema(*this);
 
+  // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
+  // will not be able to merge any duplicate __va_list_tag decls correctly.
+  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
+
   // Initialize predefined 128-bit integer types, if needed.
   if (Context.getTargetInfo().hasInt128Type()) {
 // If either of the 128-bit integer types are unavailable to name lookup,

Added: cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/module.modulemap?rev=217275view=auto
==
--- cfe/trunk/test/Modules/Inputs/va_list/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/va_list/module.modulemap Fri Sep  5 15:24:27 
2014
@@ -0,0 +1,5 @@
+module stdarg [system] {
+  header stdarg.h // note: supplied by the compiler
+}
+module va_list_a { header va_list_a.h }
+module va_list_b { header va_list_b.h }

Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h?rev=217275view=auto
==
--- cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h (added)
+++ cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h Fri Sep  5 15:24:27 2014
@@ -0,0 +1,2 @@
+@import stdarg;
+int  vprintf(const char * __restrict, va_list);

Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h?rev=217275view=auto
==
--- cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h (added)
+++ cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h Fri Sep  5 15:24:27 2014
@@ -0,0 +1,2 @@
+@import va_list_a;
+void NSLogv(id, va_list);

Added: cfe/trunk/test/Modules/va_list.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/va_list.m?rev=217275view=auto
==
--- cfe/trunk/test/Modules/va_list.m (added)
+++ cfe/trunk/test/Modules/va_list.m Fri Sep  5 15:24:27 2014
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules 
-fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
+// RUN: -x objective-c-header %s -o %t.pch -emit-pch
+
+// Include the pch, as a sanity check.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules 
-fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch 
%t.pch \
+// RUN: -x objective-c %s -fsyntax-only
+
+// Repeat the previous emit-pch, but not we will have a global module index.
+// For some reason, this results in an identifier 

[libcxx] r217276 - Address some post-commit review comments on r217261

2014-09-05 Thread Jonathan Roelofs
Author: jroelofs
Date: Fri Sep  5 15:28:44 2014
New Revision: 217276

URL: http://llvm.org/viewvc/llvm-project?rev=217276view=rev
Log:
Address some post-commit review comments on r217261

Modified:
libcxx/trunk/include/future
libcxx/trunk/include/ios
libcxx/trunk/src/ios.cpp
libcxx/trunk/src/memory.cpp

Modified: libcxx/trunk/include/future
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=217276r1=217275r2=217276view=diff
==
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Fri Sep  5 15:28:44 2014
@@ -374,7 +374,7 @@ template class R, class Alloc struct u
 #pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_HAS_NO_THREADS
+#ifdef _LIBCPP_HAS_NO_THREADS
 #error future is not supported on this single threaded system
 #else // !_LIBCPP_HAS_NO_THREADS
 

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=217276r1=217275r2=217276view=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Fri Sep  5 15:28:44 2014
@@ -216,7 +216,7 @@ storage-class-specifier const error_cate
 #include __locale
 #include system_error
 
-#if __has_feature(cxx_atomic)  !_LIBCPP_HAS_NO_THREADS
+#if __has_feature(cxx_atomic)  !defined(_LIBCPP_HAS_NO_THREADS)
 #include atomic // for __xindex_
 #endif
 
@@ -367,7 +367,7 @@ private:
 int*__index_;
 size_t  __event_size_;
 size_t  __event_cap_;
-#if __has_feature(cxx_atomic)  !_LIBCPP_HAS_NO_THREADS
+#if __has_feature(cxx_atomic)  !defined(_LIBCPP_HAS_NO_THREADS)
 static atomicint __xindex_;
 #else
 static int  __xindex_;

Modified: libcxx/trunk/src/ios.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/ios.cpp?rev=217276r1=217275r2=217276view=diff
==
--- libcxx/trunk/src/ios.cpp (original)
+++ libcxx/trunk/src/ios.cpp Fri Sep  5 15:28:44 2014
@@ -148,7 +148,7 @@ ios_base::getloc() const
 }
 
 // xalloc
-#if __has_feature(cxx_atomic)  !_LIBCPP_HAS_NO_THREADS
+#if __has_feature(cxx_atomic)  !defined(_LIBCPP_HAS_NO_THREADS)
 atomicint ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
 #else
 int ios_base::__xindex_ = 0;

Modified: libcxx/trunk/src/memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=217276r1=217275r2=217276view=diff
==
--- libcxx/trunk/src/memory.cpp (original)
+++ libcxx/trunk/src/memory.cpp Fri Sep  5 15:28:44 2014
@@ -121,7 +121,7 @@ __shared_weak_count::__get_deleter(const
 
 #endif  // _LIBCPP_NO_RTTI
 
-#if __has_feature(cxx_atomic)  !_LIBCPP_HAS_NO_THREADS
+#if __has_feature(cxx_atomic)  !defined(_LIBCPP_HAS_NO_THREADS)
 
 static const std::size_t __sp_mut_count = 16;
 static pthread_mutex_t mut_back_imp[__sp_mut_count] =


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


Re: r217187 - MS inline asm: Allow __asm blocks to set a return value

2014-09-05 Thread Renato Golin
On 5 September 2014 21:16, Reid Kleckner r...@google.com wrote:
 It requires the x86 target to be compiled in. I added that requirement in
 r217272.

Thanks Reid!

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


Re: [PATCH] Support the assume_aligned function attribute

2014-09-05 Thread Richard Smith

Comment at: lib/CodeGen/CGExpr.cpp:3379-3382
@@ -3378,2 +3378,6 @@
 
-  return EmitCall(FnInfo, Callee, ReturnValue, Args, TargetDecl);
+  RValue Ret = EmitCall(FnInfo, Callee, ReturnValue, Args, TargetDecl);
+
+  if (Ret.isScalar()  TargetDecl) {
+if (const auto *AA = TargetDecl-getAttrAssumeAlignedAttr()) {
+  llvm::Value *OffsetValue = nullptr;

hfinkel wrote:
 rsmith wrote:
  Is this really the right place for this code, rather than in the called 
  `EmitCall` function? Various places call the lower-level overload directly.
 When I first looked, I thought that there were no other relevant callers, but 
 maybe EmitCallAndReturnForThunk and EmitForwardingCallToLambda would need 
 this handling too?
 
 Because of the way that the lower-level EmitCall is structured, I'd need to 
 wrap it (it has too many early returns). What would I call it?
`EmitCXXMemberOrOperatorCall`, `EmitCXXMemberPointerCallExpr`, and 
`EmitNewDeleteCall` should also get this handling.

Maybe factor out the `switch` that produces the returned `RValue` from the call?


Comment at: lib/Sema/SemaDeclAttr.cpp:1130
@@ -1129,2 +1129,3 @@
+bool Sema::isValidPointerAttrType(QualType T) {
   T = T.getNonReferenceType();
 

hfinkel wrote:
 rsmith wrote:
  Is this really appropriate for your attribute? (It makes almost no sense 
  for `__attribute__((nonnull))` either, but I couldn't find anyone at Apple 
  to tell me what the relevant radar says, so I have no idea why we have this 
  feature.)
 Nice :-) -- Honestly, I don't have a strong opinion regarding whether or not 
 we strip references, but I like the idea of consistency between the two 
 attributes. The set of returned pointers about which I can assert something 
 about the alignment should be the same as that about which I can assert a 
 nonnull property.
 
 That having been said, it looks like the CodeGen for returns_nonnull that 
 adds the nonnull IR attribute (and the associated UBSan code) does not handle 
 references-to-pointers correctly. I'll fix that as a follow-up too.
It seems really weird for either of these to look through references to the 
referenced pointer. And it's ambiguous: does the attribute apply to the 
reference or to the pointer that the reference refers to? (For the nonnull 
attribute, GCC and Clang make different choices here, at least in the cases 
where you can persuade GCC not to reject the attribute!)


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:203-205
@@ +202,5 @@
+const AssumeAlignedAttr *AssumeAligned = 
dyn_castAssumeAlignedAttr(TmplAttr);
+if (AssumeAligned  (AssumeAligned-getAlignment()-isValueDependent() ||
+  (AssumeAligned-getOffset() 
+   AssumeAligned-getOffset()-isValueDependent( {
+  instantiateDependentAssumeAlignedAttr(*this, TemplateArgs, 
AssumeAligned, New);

hfinkel wrote:
 rsmith wrote:
  You shouldn't have these 'is dependent' checks here; the other code above 
  and below is wrong to include them. Testcase:
  
templatetypename T __attribute__((assume_aligned(sizeof(int(T()) T 
  *f();
void *p = fvoid();
  
  This should result in a hard error, because `int(void())` is invalid, but I 
  think you'll accept it, because `sizeof(int(T()))` is not value-dependent, 
  so you never actually perform the substitution.
 Interestingly, the current code does generate an error:
   invalid application of 'sizeof' to a function type
 
 Removing the type-dependent checks does not seem to change any of the current 
 behavior.
Ha, sorry, bitten by a parse ambiguity. Six closing parens wasn't enough; let's 
go up to seven:

templatetypename T __attribute__((assume_aligned(sizeof((int(T())) T 
*f();
void *p = fvoid();

http://reviews.llvm.org/D4601



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


Re: [PATCH] Implement nonnull-attribute sanitizer

2014-09-05 Thread Richard Smith
One diagnostic quality comment, otherwise this looks fine.


Comment at: projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:365
@@ +364,3 @@
+  if (!Data-DeclLoc.isInvalid())
+Diag(Data-DeclLoc, DL_Note, function declared here);
+}

It would seem better to point to the attribute rather than just to the function.

http://reviews.llvm.org/D5082



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


Re: [PATCH v4 2/8] Add the initial TypoExpr AST node for delayed typo correction.

2014-09-05 Thread David Blaikie
Looks mostly reasonable.

The changes to include/clang/Sema/SemaInternal.h seem unrelated to this
patch, though - perhaps they're meant for some other patch? The
TypoDiagnosticGenerator too, is an isolated/unrelated change.

It might be worth adding a test case for statement printing
(StmtPrinter.cpp) with typos - if you can cause the TypoExpr to still be
there when you do an AST Dump? (perhaps on invalid code? Or do you always
transform the TypoExpr into /something/ else, even if you can't suggest a
specific function to call?)

I'm assuming all the other changes are just necessary bits  Pieces to
adding a new expr type? (eg: if I removed some of them, things would
break/fail to compile/etc)



On Tue, Aug 26, 2014 at 11:04 AM, Kaelyn Takata ri...@google.com wrote:

 +dblaikie


 On Thu, Jul 31, 2014 at 1:20 PM, Kaelyn Takata ri...@google.com wrote:

 ---
  include/clang/AST/DataRecursiveASTVisitor.h |  1 +
  include/clang/AST/Expr.h| 18 ++
  include/clang/AST/RecursiveASTVisitor.h |  1 +
  include/clang/Basic/StmtNodes.td|  1 +
  include/clang/Sema/SemaInternal.h   |  3 +++
  include/clang/Sema/TypoCorrection.h |  5 +
  lib/AST/Expr.cpp|  1 +
  lib/AST/ExprClassification.cpp  |  3 ++-
  lib/AST/ExprConstant.cpp|  1 +
  lib/AST/ItaniumMangle.cpp   |  1 +
  lib/AST/StmtPrinter.cpp |  5 +
  lib/AST/StmtProfile.cpp |  4 
  lib/Sema/SemaExceptionSpec.cpp  |  1 +
  lib/Sema/TreeTransform.h|  6 ++
  lib/Serialization/ASTReaderStmt.cpp |  4 
  lib/Serialization/ASTWriterStmt.cpp |  6 ++
  lib/StaticAnalyzer/Core/ExprEngine.cpp  |  1 +
  tools/libclang/CXCursor.cpp |  1 +
  18 files changed, 62 insertions(+), 1 deletion(-)



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


Re: [PATCH] Fix PR20495: correct inference of the CUDA target for implicit members

2014-09-05 Thread Richard Smith
This should have more test coverage: at least cover each different kind of 
special member function, const/non-const arguments, explicitly-defaulted 
functions, and cases where a special member of a derived class is deleted 
because the base class's special member would call functions with a `__host__` 
/ `__device__` mismatch.


Comment at: lib/Sema/SemaCUDA.cpp:123-133
@@ +122,13 @@
+  llvm::SmallVectorconst CXXBaseSpecifier *, 16 Bases;
+  for (const auto B : ClassDecl-bases()) {
+if (!ClassDecl-isAbstract() || !B.isVirtual()) {
+  Bases.push_back(B);
+}
+  }
+
+  if (!ClassDecl-isAbstract()) {
+for (const auto VB : ClassDecl-vbases()) {
+  Bases.push_back(VB);
+}
+  }
+

For a non-abstract class, you'll collect direct vbases twice here (once from 
the bases list and once from the vbases list). The easiest thing to do would be 
to change the condition in the first loop to just

  if (!B.isVirtual())


Comment at: lib/Sema/SemaCUDA.cpp:164
@@ +163,3 @@
+  Diag(ClassDecl-getLocation(),
+   diag::err_implicit_member_target_infer_collision)
+   (unsigned)CSM  InferredTarget.getValue()

This should be a note, rather than an error.


Comment at: lib/Sema/SemaDeclCXX.cpp:5568-5574
@@ +5567,9 @@
+// failed.
+bool Const = false;
+if ((CSM == CXXCopyConstructor 
+ RD-implicitCopyConstructorHasConstParam()) ||
+(CSM == CXXCopyAssignment 
+ RD-implicitCopyAssignmentHasConstParam())) {
+  Const = true;
+}
+return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, Const,

This is `SMI.ConstArg`.


Comment at: lib/Sema/SemaOverload.cpp:5638
@@ +5637,3 @@
+  // Skip the check for callers that are implicit members, because in this
+  // case we still don't know what the member's target is; the target is
+  // inferred for the member automatically, based on the bases and fields 
of

s/we still don't know/we may not yet know/

http://reviews.llvm.org/D5199



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


Re: [PATCH] Implement nonnull-attribute sanitizer

2014-09-05 Thread Alexey Samsonov
Provide source location of nonnull attribute declaration,
instead of function declaration.

http://reviews.llvm.org/D5082

Files:
  projects/compiler-rt/lib/ubsan/ubsan_handlers.cc
  projects/compiler-rt/lib/ubsan/ubsan_handlers.h
  projects/compiler-rt/test/ubsan/TestCases/Misc/nonnull-arg.cpp
  tools/clang/include/clang/Basic/Sanitizers.def
  tools/clang/lib/CodeGen/CGCall.cpp
  tools/clang/lib/CodeGen/CGClass.cpp
  tools/clang/lib/CodeGen/CGExpr.cpp
  tools/clang/lib/CodeGen/CGExprCXX.cpp
  tools/clang/lib/CodeGen/CodeGenFunction.h
  tools/clang/test/CodeGen/catch-undef-behavior.c
  tools/clang/test/Driver/fsanitize.c
Index: tools/clang/lib/CodeGen/CodeGenFunction.h
===
--- tools/clang/lib/CodeGen/CodeGenFunction.h
+++ tools/clang/lib/CodeGen/CodeGenFunction.h
@@ -2621,6 +2621,7 @@
   void EmitCallArgs(CallArgList Args, const T *CallArgTypeInfo,
 CallExpr::const_arg_iterator ArgBeg,
 CallExpr::const_arg_iterator ArgEnd,
+const FunctionDecl *CalleeDecl = nullptr,
 unsigned ParamsToSkip = 0, bool ForceColumnInfo = false) {
 SmallVectorQualType, 16 ArgTypes;
 CallExpr::const_arg_iterator Arg = ArgBeg;
@@ -2669,13 +2670,15 @@
 for (; Arg != ArgEnd; ++Arg)
   ArgTypes.push_back(Arg-getType());
 
-EmitCallArgs(Args, ArgTypes, ArgBeg, ArgEnd, ForceColumnInfo);
+EmitCallArgs(Args, ArgTypes, ArgBeg, ArgEnd, CalleeDecl, ParamsToSkip,
+ ForceColumnInfo);
   }
 
   void EmitCallArgs(CallArgList Args, ArrayRefQualType ArgTypes,
 CallExpr::const_arg_iterator ArgBeg,
 CallExpr::const_arg_iterator ArgEnd,
-bool ForceColumnInfo = false);
+const FunctionDecl *CalleeDecl = nullptr,
+unsigned ParamsToSkip = 0, bool ForceColumnInfo = false);
 
 private:
   const TargetCodeGenInfo getTargetHooks() const {
Index: tools/clang/lib/CodeGen/CGExpr.cpp
===
--- tools/clang/lib/CodeGen/CGExpr.cpp
+++ tools/clang/lib/CodeGen/CGExpr.cpp
@@ -3320,7 +3320,8 @@
 
   CallArgList Args;
   EmitCallArgs(Args, dyn_castFunctionProtoType(FnType), E-arg_begin(),
-   E-arg_end(), /*ParamsToSkip*/ 0, ForceColumnInfo);
+   E-arg_end(), E-getDirectCallee(), /*ParamsToSkip*/ 0,
+   ForceColumnInfo);
 
   const CGFunctionInfo FnInfo =
 CGM.getTypes().arrangeFreeFunctionCall(Args, FnType);
Index: tools/clang/lib/CodeGen/CGExprCXX.cpp
===
--- tools/clang/lib/CodeGen/CGExprCXX.cpp
+++ tools/clang/lib/CodeGen/CGExprCXX.cpp
@@ -55,20 +55,18 @@
 
   const FunctionProtoType *FPT = MD-getType()-castAsFunctionProtoType();
   RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size());
-  
+
   // And the rest of the call args.
-  CallExpr::const_arg_iterator ArgBeg, ArgEnd;
-  if (CE == nullptr) {
-ArgBeg = ArgEnd = nullptr;
-  } else if (auto OCE = dyn_castCXXOperatorCallExpr(CE)) {
+  if (CE) {
 // Special case: skip first argument of CXXOperatorCall (it is this).
-ArgBeg = OCE-arg_begin() + 1;
-ArgEnd = OCE-arg_end();
+unsigned ArgsToSkip = isaCXXOperatorCallExpr(CE) ? 1 : 0;
+EmitCallArgs(Args, FPT, CE-arg_begin() + ArgsToSkip, CE-arg_end(),
+ CE-getDirectCallee());
   } else {
-ArgBeg = CE-arg_begin();
-ArgEnd = CE-arg_end();
+assert(
+FPT-getNumParams() == 0 
+No CallExpr specified for function with non-zero number of arguments);
   }
-  EmitCallArgs(Args, FPT, ArgBeg, ArgEnd);
 
   return EmitCall(CGM.getTypes().arrangeCXXMethodCall(Args, FPT, required),
   Callee, ReturnValue, Args, MD);
@@ -284,7 +282,7 @@
   RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, 1);
   
   // And the rest of the call args
-  EmitCallArgs(Args, FPT, E-arg_begin(), E-arg_end());
+  EmitCallArgs(Args, FPT, E-arg_begin(), E-arg_end(), E-getDirectCallee());
   return EmitCall(CGM.getTypes().arrangeCXXMethodCall(Args, FPT, required),
   Callee, ReturnValue, Args);
 }
@@ -1238,7 +1236,8 @@
   // We start at 1 here because the first argument (the allocation size)
   // has already been emitted.
   EmitCallArgs(allocatorArgs, allocatorType, E-placement_arg_begin(),
-   E-placement_arg_end(), /*ParamsToSkip*/ 1);
+   E-placement_arg_end(), /* CalleeDecl */ nullptr,
+   /*ParamsToSkip*/ 1);
 
   // Emit the allocation call.  If the allocator is a global placement
   // operator, just inline it directly.
Index: tools/clang/lib/CodeGen/CGClass.cpp
===
--- tools/clang/lib/CodeGen/CGClass.cpp
+++ tools/clang/lib/CodeGen/CGClass.cpp
@@ -1674,7 +1674,7 @@
 
   // Add the rest of the user-supplied arguments.
   const 

Re: [patch] Implementing -Wunused-local-typedefs

2014-09-05 Thread Richard Smith
Thanks, this is looking really good.

+  if (Diags.isIgnored(diag::warn_unused_local_typedef, SourceLocation()))
+return;

It would seem better to consider the diagnostic state at the point where
the typedef is declared. (Maybe check this when adding typedefs to the set
rather than when diagnosing?)

+// Warnigns emitted in ActOnEndOfTranslationUnit() should be emitted
for

Typo 'Warnigns'.

+  // Except for labels, we only care about unused decls that are local to
+  // functions.
+  bool WithinFunction = D-getDeclContext()-isFunctionOrMethod();
+  if (const auto *R = dyn_castCXXRecordDecl(D-getDeclContext()))
+WithinFunction =
+WithinFunction || (R-isLocalClass()  !R-isDependentType());

Why are dependent local classes skipped here? I'd like at least a comment
to explain this so future readers aren't surprised :)

+  for (auto *TmpD : D-decls()) {
+if (const auto* T = dyn_castTypedefNameDecl(TmpD))
+  DiagnoseUnusedDecl(T);
+else if(const auto *R = dyn_castRecordDecl(TmpD))

'*' on the right, please.

+  if (auto* TD = dyn_castTypedefNameDecl(D)) {
+// typedefs can be referenced later on, so the diagnostics are emitted
+// at end-of-translation-unit.

Likewise.

+void Sema::DiagnoseUnusedNestedTypedefs(const RecordDecl *D) {
+  if (D-getTypeForDecl()-isDependentType())
+return;
+
+  for (auto *TmpD : D-decls()) {
+if (const auto* T = dyn_castTypedefNameDecl(TmpD))
+  DiagnoseUnusedDecl(T);
+else if(const auto *R = dyn_castRecordDecl(TmpD))
+  DiagnoseUnusedNestedTypedefs(R);
+  }
+}
[...]
-if (!S-hasUnrecoverableErrorOccurred())
+if (!S-hasUnrecoverableErrorOccurred()) {
   DiagnoseUnusedDecl(D);
+  if (const auto *RD = dyn_castRecordDecl(D))
+DiagnoseUnusedNestedTypedefs(RD);
+}

Would it make sense for DiagnoseUnusedDecl to do the recursive walk over
child decls itself?

+/// In a function like
+/// auto f() {
+///   struct S { typedef int a; };
+///   return S;
+/// }

Should be 'return S();' or similar here.

+/// others. Pretend that all local typedefs are always references, to not
warn

Typo 'references'.

+class LocalTypedefNameReferencer
+: public RecursiveASTVisitorLocalTypedefNameReferencer {
+public:
+  LocalTypedefNameReferencer(Sema S) : S(S) {}
+  bool VisitRecordType(const RecordType *RT);
+private:
+  Sema S;
+};

I think you'll also need to handle MemberPointerType here; the `Class` in
`T Class::*` is just modeled as a CXXRecordDecl, not a RecordType.

+  if (T-getAccess() != AS_private)

You should also check if the class has any friends; if so, they might use
the member.

+  }
   else if (TypeDecl *TD = dyn_castTypeDecl(FoundDecl))

No newline between } and else.

+  // Build a record containing all of the UnusedLocalTypedefNameCandidates.
+  RecordData UnusedLocalTypedefNameCandidates;
+  for (const TypedefNameDecl *TD :
SemaRef.UnusedLocalTypedefNameCandidates)
+AddDeclRef(TD, UnusedLocalTypedefNameCandidates);

Maybe wrap this in a `if (!isModule)`

+  // FIXME: typedef that's only used in a constexpr

Do you mean in a constant expression? constexpr is an adjective, not a
noun.


On Thu, Sep 4, 2014 at 11:22 AM, Nico Weber tha...@chromium.org wrote:

 Ping :-)


 On Sat, Aug 30, 2014 at 3:27 PM, Nico Weber tha...@chromium.org wrote:

 The next chapter in the saga, with these new features:
 * Test for serialization to a gch file
 * Code change to emit this when building a module, not when the module is
 used
 * Test for modules

 Good enough to land?


 On Sat, Aug 9, 2014 at 5:46 PM, Nico Weber tha...@chromium.org wrote:

 On Wed, Aug 6, 2014 at 7:05 PM, Richard Smith rich...@metafoo.co.uk
 wrote:

 +  /// \brief Set containing all declared private fields that are not
 used.
typedef llvm::SmallSetVectorconst NamedDecl*, 16 NamedDeclSetType;
 -
 -  /// \brief Set containing all declared private fields that are not
 used.
NamedDeclSetType UnusedPrivateFields;

 Doesn't this make Doxygen attach the documentation to the wrong thing?


 Fixed.


 +  /// \brief Set containing all typedefs that are likely unused.
 +  llvm::SmallSetVectorconst TypedefNameDecl *, 4
 +  UnusedLocalTypedefNameCandidates;

 You don't seem to have any serialization/deserialization code for this;
 I don't think this is doing quite the right thing in all the AST-file
 cases. Preambles and PCH should behave exactly like we'd actually included
 the file, so in those cases you'd need to serialize/deserialize. For
 modules, you probably want to issue the diagnostic while building the
 module (you currently won't, because the emission code is after the end of
 the module).


 Added serialization code. For modules, the diagnostics are emitted when
 the module is used, not when it's build (this seems to match the other
 unused warnings).

 Are there good example for how to test the serialization bits? -verify
 doesn't work well with .ast files as far as I can tell. (I guess I could
 have a similar test that 

Re: [PATCH] Implement nonnull-attribute sanitizer

2014-09-05 Thread Alexey Samsonov

Comment at: projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:365
@@ +364,3 @@
+  if (!Data-DeclLoc.isInvalid())
+Diag(Data-DeclLoc, DL_Note, function declared here);
+}

rsmith wrote:
 It would seem better to point to the attribute rather than just to the 
 function.
Done.

Side note: do you it makes sense to provide source location of returns_nonnull 
attribute as well? (I'd say it could make sense, as attribute is attached to 
function declaration, which might be in a completely different where definition 
is).

http://reviews.llvm.org/D5082



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


Re: [PATCH] Fix IRGen for referencing a static local before emitting its decl

2014-09-05 Thread Reid Kleckner
This is turning out to be really, really difficult.


Comment at: lib/CodeGen/CGDecl.cpp:174
@@ -173,4 +173,3 @@
 
-llvm::Constant *
-CodeGenFunction::CreateStaticVarDecl(const VarDecl D,
- llvm::GlobalValue::LinkageTypes Linkage) {
+llvm::Constant *CodeGenFunction::getOrCreateStaticVarDecl(
+const VarDecl D, llvm::GlobalValue::LinkageTypes Linkage) {

rsmith wrote:
 Does it still make sense for this to be on `CodeGenFunction` since it can now 
 be called while emitting the wrong function? It seems to risk using local 
 state of the `CodeGenFunction` object, which would be bad.
It seems there's two uses of local state:
- CGF affects name mangling for static locals in non-C++ languages, but in 
those languages, the name is presumably not significant
- CGF matters to CGExprConstant, in particular for taking the address of a label


Comment at: lib/CodeGen/CGDecl.cpp:191
@@ -184,3 +190,3 @@
   else
 Name = GetStaticDeclName(*this, D);
 

rsmith wrote:
 Case in point: this will presumably produce the wrong mangled name if the 
 static local's emission is triggered by a function other than the containing 
 one.
No, in C++ mode it just mangles the VarDecl, which has all the info needed.


Comment at: lib/CodeGen/CGDecl.cpp:199
@@ -192,3 +198,3 @@
  Ty.isConstant(getContext()), Linkage,
  CGM.EmitNullConstant(D.getType()), Name, nullptr,
  llvm::GlobalVariable::NotThreadLocal,

rsmith wrote:
 This doesn't look right. If the static local has a constant initializer, you 
 need to emit it here, not as part of emitting the surrounding function. Given:
 
   static auto f() {
 static int n = 1;
 struct S { int operator()() { return n; } };
 return S();
   }
 
   int main() { return decltype(f())()(); }
 
 ... `main` should return 1, and I think with this patch it returns 0.
OK. This can be done, but it has considerable complexity because the 
initializer can reference itself circularly, apparently.

http://reviews.llvm.org/D4787



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


Re: [patch] Implementing -Wunused-local-typedefs

2014-09-05 Thread Nico Weber
On Fri, Sep 5, 2014 at 2:44 PM, Richard Smith rich...@metafoo.co.uk wrote:

 Thanks, this is looking really good.

 +  if (Diags.isIgnored(diag::warn_unused_local_typedef, SourceLocation()))
 +return;

 It would seem better to consider the diagnostic state at the point where
 the typedef is declared. (Maybe check this when adding typedefs to the set
 rather than when diagnosing?)


Great catch. -Wunused-private-fields probably gets this wrong too. I added
a test for this (see the very bottom of warn-unused-local-typedef.cpp, and
the pragma diagnostic push/pop). The test sadly showed that adding when
adding the typedefs is wrong too: For template instantiations, the
instantiation is done at end-of-file, but a pragma diag at end of file
shouldn't disable warnings in templates that physically are further up. So
I just removed this check.


 +// Warnigns emitted in ActOnEndOfTranslationUnit() should be emitted
 for

 Typo 'Warnigns'.


Doen.


 +  // Except for labels, we only care about unused decls that are local to
 +  // functions.
 +  bool WithinFunction = D-getDeclContext()-isFunctionOrMethod();
 +  if (const auto *R = dyn_castCXXRecordDecl(D-getDeclContext()))
 +WithinFunction =
 +WithinFunction || (R-isLocalClass()  !R-isDependentType());

 Why are dependent local classes skipped here? I'd like at least a comment
 to explain this so future readers aren't surprised :)


I added a short comment. This is covered by my tests, so removing it does
make something fail.
(SemaTemplateInstantiateDecl.cpp's Sema::BuildVariableInstantiation() calls
this method for instantiated fields, so the warnings are deferred until
after instantiation.)



 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))

 '*' on the right, please.



Done.



 +  if (auto* TD = dyn_castTypedefNameDecl(D)) {
 +// typedefs can be referenced later on, so the diagnostics are emitted
 +// at end-of-translation-unit.

 Likewise.



Done.



 +void Sema::DiagnoseUnusedNestedTypedefs(const RecordDecl *D) {
 +  if (D-getTypeForDecl()-isDependentType())
 +return;
 +
 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))
 +  DiagnoseUnusedNestedTypedefs(R);
 +  }
 +}
 [...]
 -if (!S-hasUnrecoverableErrorOccurred())
 +if (!S-hasUnrecoverableErrorOccurred()) {
DiagnoseUnusedDecl(D);
 +  if (const auto *RD = dyn_castRecordDecl(D))
 +DiagnoseUnusedNestedTypedefs(RD);
 +}

 Would it make sense for DiagnoseUnusedDecl to do the recursive walk over
 child decls itself?


Doesn't matter too much either way I guess? Left it as is for now.



 +/// In a function like
 +/// auto f() {
 +///   struct S { typedef int a; };
 +///   return S;
 +/// }

 Should be 'return S();' or similar here.


Done.


 +/// others. Pretend that all local typedefs are always references, to not
 warn

 Typo 'references'.


Done.


 +class LocalTypedefNameReferencer
 +: public RecursiveASTVisitorLocalTypedefNameReferencer {
 +public:
 +  LocalTypedefNameReferencer(Sema S) : S(S) {}
 +  bool VisitRecordType(const RecordType *RT);
 +private:
 +  Sema S;
 +};

 I think you'll also need to handle MemberPointerType here; the `Class` in
 `T Class::*` is just modeled as a CXXRecordDecl, not a RecordType.


I added the (slightly contrived :-) ) test you showed me, it seems to pass
as-is.


 +  if (T-getAccess() != AS_private)

 You should also check if the class has any friends; if so, they might use
 the member.


Good point. Done, added a test for this.


 +  }
else if (TypeDecl *TD = dyn_castTypeDecl(FoundDecl))

 No newline between } and else.


Done.


 +  // Build a record containing all of the
 UnusedLocalTypedefNameCandidates.
 +  RecordData UnusedLocalTypedefNameCandidates;
 +  for (const TypedefNameDecl *TD :
 SemaRef.UnusedLocalTypedefNameCandidates)
 +AddDeclRef(TD, UnusedLocalTypedefNameCandidates);

 Maybe wrap this in a `if (!isModule)`


UnusedLocalTypedefNameCandidates should've been clear()ed for modules at
this point I think, so should be fine as is.


 +  // FIXME: typedef that's only used in a constexpr

 Do you mean in a constant expression? constexpr is an adjective, not a
 noun.


Done (by fixing the FIXME).

Thanks for the thorough review!
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td (revision 217285)
+++ include/clang/Basic/DiagnosticGroups.td (working copy)
@@ -402,6 +402,7 @@
 def UnusedConstVariable : DiagGroupunused-const-variable;
 def UnusedVariable : DiagGroupunused-variable,
[UnusedConstVariable];
+def UnusedLocalTypedef : DiagGroupunused-local-typedef;
 def UnusedPropertyIvar : 

r217290 - Fix r217275 to work without the need for standard headers being included

2014-09-05 Thread David Blaikie
Author: dblaikie
Date: Fri Sep  5 18:36:59 2014
New Revision: 217290

URL: http://llvm.org/viewvc/llvm-project?rev=217290view=rev
Log:
Fix r217275 to work without the need for standard headers being included

It seems (I guess) in ObjC that va_list is provided without the need for
inclusions. I verified that with this change the test still crashes in
the absence of the fix committed in r217275.

Modified:
cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h

Modified: cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/module.modulemap?rev=217290r1=217289r2=217290view=diff
==
--- cfe/trunk/test/Modules/Inputs/va_list/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/va_list/module.modulemap Fri Sep  5 18:36:59 
2014
@@ -1,5 +1,2 @@
-module stdarg [system] {
-  header stdarg.h // note: supplied by the compiler
-}
 module va_list_a { header va_list_a.h }
 module va_list_b { header va_list_b.h }

Modified: cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h?rev=217290r1=217289r2=217290view=diff
==
--- cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h (original)
+++ cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h Fri Sep  5 18:36:59 2014
@@ -1,2 +1 @@
-@import stdarg;
 int  vprintf(const char * __restrict, va_list);


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


Re: r217275 - Move the initialization of VAListTagName after InitializeSema()

2014-09-05 Thread David Blaikie
On Fri, Sep 5, 2014 at 1:24 PM, Ben Langmuir blangm...@apple.com wrote:

 Author: benlangmuir
 Date: Fri Sep  5 15:24:27 2014
 New Revision: 217275

 URL: http://llvm.org/viewvc/llvm-project?rev=217275view=rev
 Log:
 Move the initialization of VAListTagName after InitializeSema()

 This innocuous statement to get the identifier info for __va_list_tag
 was causing an assertion failure:
   NextIsPrevious()  decl became non-canonical unexpectedly
 if the __va_list_tag identifier was found in a PCH in some
 circumstances, because it was looked up before the ASTReader had a Sema
 object to use to find existing decls to merge with.

 We could possibly move getting the identifier info even later, or make
 it lazy if we wanted to, but this seemed like the minimal change.

 Now why a PCH would have this identifier in the first place is a bit
 mysterious. This seems to be related to the global module index in some
 way, because when the test case is built without the global module index
 it will not emit an identifier for __va_list_tag into the PCH, but with
 the global module index it does.

 Added:
 cfe/trunk/test/Modules/Inputs/va_list/
 cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
 cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
 cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
 cfe/trunk/test/Modules/va_list.m
 Modified:
 cfe/trunk/lib/Sema/Sema.cpp

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

 ==
 --- cfe/trunk/lib/Sema/Sema.cpp (original)
 +++ cfe/trunk/lib/Sema/Sema.cpp Fri Sep  5 15:24:27 2014
 @@ -69,8 +69,6 @@ PrintingPolicy Sema::getPrintingPolicy(c
  void Sema::ActOnTranslationUnitScope(Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
 -
 -  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
  }

  Sema::Sema(Preprocessor pp, ASTContext ctxt, ASTConsumer consumer,
 @@ -155,6 +153,10 @@ void Sema::Initialize() {
= dyn_cast_or_nullExternalSemaSource(Context.getExternalSource()))
  ExternalSema-InitializeSema(*this);

 +  // This needs to happen after ExternalSemaSource::InitializeSema(this)
 or we
 +  // will not be able to merge any duplicate __va_list_tag decls
 correctly.
 +  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
 +
// Initialize predefined 128-bit integer types, if needed.
if (Context.getTargetInfo().hasInt128Type()) {
  // If either of the 128-bit integer types are unavailable to name
 lookup,

 Added: cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/module.modulemap?rev=217275view=auto

 ==
 --- cfe/trunk/test/Modules/Inputs/va_list/module.modulemap (added)
 +++ cfe/trunk/test/Modules/Inputs/va_list/module.modulemap Fri Sep  5
 15:24:27 2014
 @@ -0,0 +1,5 @@
 +module stdarg [system] {
 +  header stdarg.h // note: supplied by the compiler


I've simplified this test in 217290 so it doesn't depend on the presence of
system (or compiler) headers. It looks like it didn't need it (I guess objc
provides va_list by default?). Let me know if there's more to it than that,
but I did verify that the test still (with my changes) fails without your
patch.


 +}
 +module va_list_a { header va_list_a.h }
 +module va_list_b { header va_list_b.h }

 Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h?rev=217275view=auto

 ==
 --- cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h (added)
 +++ cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h Fri Sep  5 15:24:27
 2014
 @@ -0,0 +1,2 @@
 +@import stdarg;
 +int  vprintf(const char * __restrict, va_list);

 Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h?rev=217275view=auto

 ==
 --- cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h (added)
 +++ cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h Fri Sep  5 15:24:27
 2014
 @@ -0,0 +1,2 @@
 +@import va_list_a;
 +void NSLogv(id, va_list);

 Added: cfe/trunk/test/Modules/va_list.m
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/va_list.m?rev=217275view=auto

 ==
 --- cfe/trunk/test/Modules/va_list.m (added)
 +++ cfe/trunk/test/Modules/va_list.m Fri Sep  5 15:24:27 2014
 @@ -0,0 +1,27 @@
 +// RUN: rm -rf %t
 +// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules
 -fmodules-cache-path=%t \
 +// RUN: -fmodules-ignore-macro=PREFIX 

Re: r217275 - Move the initialization of VAListTagName after InitializeSema()

2014-09-05 Thread Ben Langmuir

 On Sep 5, 2014, at 4:48 PM, David Blaikie dblai...@gmail.com wrote:
 
 
 
 
 On Fri, Sep 5, 2014 at 1:24 PM, Ben Langmuir blangm...@apple.com 
 mailto:blangm...@apple.com wrote:
 Author: benlangmuir
 Date: Fri Sep  5 15:24:27 2014
 New Revision: 217275
 
 URL: http://llvm.org/viewvc/llvm-project?rev=217275view=rev 
 http://llvm.org/viewvc/llvm-project?rev=217275view=rev
 Log:
 Move the initialization of VAListTagName after InitializeSema()
 
 This innocuous statement to get the identifier info for __va_list_tag
 was causing an assertion failure:
   NextIsPrevious()  decl became non-canonical unexpectedly
 if the __va_list_tag identifier was found in a PCH in some
 circumstances, because it was looked up before the ASTReader had a Sema
 object to use to find existing decls to merge with.
 
 We could possibly move getting the identifier info even later, or make
 it lazy if we wanted to, but this seemed like the minimal change.
 
 Now why a PCH would have this identifier in the first place is a bit
 mysterious. This seems to be related to the global module index in some
 way, because when the test case is built without the global module index
 it will not emit an identifier for __va_list_tag into the PCH, but with
 the global module index it does.
 
 Added:
 cfe/trunk/test/Modules/Inputs/va_list/
 cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
 cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
 cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
 cfe/trunk/test/Modules/va_list.m
 Modified:
 cfe/trunk/lib/Sema/Sema.cpp
 
 Modified: cfe/trunk/lib/Sema/Sema.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=217275r1=217274r2=217275view=diff
  
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=217275r1=217274r2=217275view=diff
 ==
 --- cfe/trunk/lib/Sema/Sema.cpp (original)
 +++ cfe/trunk/lib/Sema/Sema.cpp Fri Sep  5 15:24:27 2014
 @@ -69,8 +69,6 @@ PrintingPolicy Sema::getPrintingPolicy(c
  void Sema::ActOnTranslationUnitScope(Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
 -
 -  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
  }
 
  Sema::Sema(Preprocessor pp, ASTContext ctxt, ASTConsumer consumer,
 @@ -155,6 +153,10 @@ void Sema::Initialize() {
= dyn_cast_or_nullExternalSemaSource(Context.getExternalSource()))
  ExternalSema-InitializeSema(*this);
 
 +  // This needs to happen after ExternalSemaSource::InitializeSema(this) or 
 we
 +  // will not be able to merge any duplicate __va_list_tag decls correctly.
 +  VAListTagName = PP.getIdentifierInfo(__va_list_tag);
 +
// Initialize predefined 128-bit integer types, if needed.
if (Context.getTargetInfo().hasInt128Type()) {
  // If either of the 128-bit integer types are unavailable to name lookup,
 
 Added: cfe/trunk/test/Modules/Inputs/va_list/module.modulemap
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/module.modulemap?rev=217275view=auto
  
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/module.modulemap?rev=217275view=auto
 ==
 --- cfe/trunk/test/Modules/Inputs/va_list/module.modulemap (added)
 +++ cfe/trunk/test/Modules/Inputs/va_list/module.modulemap Fri Sep  5 
 15:24:27 2014
 @@ -0,0 +1,5 @@
 +module stdarg [system] {
 +  header stdarg.h // note: supplied by the compiler
 
 I've simplified this test in 217290 so it doesn't depend on the presence of 
 system (or compiler) headers. It looks like it didn't need it (I guess objc 
 provides va_list by default?). Let me know if there's more to it than that, 
 but I did verify that the test still (with my changes) fails without your 
 patch.

Weird - I thought I tried that and it didn’t work.  Thanks for the 
simplification!

Ben

  
 +}
 +module va_list_a { header va_list_a.h }
 +module va_list_b { header va_list_b.h }
 
 Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h?rev=217275view=auto
  
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h?rev=217275view=auto
 ==
 --- cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h (added)
 +++ cfe/trunk/test/Modules/Inputs/va_list/va_list_a.h Fri Sep  5 15:24:27 2014
 @@ -0,0 +1,2 @@
 +@import stdarg;
 +int  vprintf(const char * __restrict, va_list);
 
 Added: cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h?rev=217275view=auto
  
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/va_list/va_list_b.h?rev=217275view=auto
 

r217293 - Reword switch/goto diagnostics protected scope diagnostics. Making up a term

2014-09-05 Thread Richard Smith
Author: rsmith
Date: Fri Sep  5 19:24:58 2014
New Revision: 217293

URL: http://llvm.org/viewvc/llvm-project?rev=217293view=rev
Log:
Reword switch/goto diagnostics protected scope diagnostics. Making up a term
protected scope is very unhelpful here and actively confuses users. Instead,
simply state the nature of the problem in the diagnostic: we cannot jump from
here to there. The notes explain nicely why not.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/ARCMT/checking.m
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/drs/dr2xx.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
cfe/trunk/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
cfe/trunk/test/Sema/block-misc.c
cfe/trunk/test/Sema/scope-check.c
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
cfe/trunk/test/SemaCXX/exceptions.cpp
cfe/trunk/test/SemaCXX/goto.cpp
cfe/trunk/test/SemaCXX/scope-check.cpp
cfe/trunk/test/SemaCXX/statements.cpp
cfe/trunk/test/SemaObjC/arc-jump-block.m
cfe/trunk/test/SemaObjC/arc.m
cfe/trunk/test/SemaObjC/autoreleasepool.m
cfe/trunk/test/SemaObjC/scope-check.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=217293r1=217292r2=217293view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep  5 19:24:58 
2014
@@ -4110,25 +4110,28 @@ def err_undeclared_label_use : Errorus
 def warn_unused_label : Warningunused label %0,
   InGroupUnusedLabel, DefaultIgnore;
 
-def err_goto_into_protected_scope : Errorgoto into protected scope;
-def ext_goto_into_protected_scope : ExtWarngoto into protected scope,
+def err_goto_into_protected_scope : Error
+  cannot jump from this goto statement to its label;
+def ext_goto_into_protected_scope : ExtWarn
+  jump from this goto statement to its label is a Microsoft extension,
   InGroupMicrosoft;
 def warn_cxx98_compat_goto_into_protected_scope : Warning
-  goto would jump into protected scope in C++98,
+  jump from this goto statement to its label is incompatible with C++98,
   InGroupCXX98Compat, DefaultIgnore;
 def err_switch_into_protected_scope : Error
-  switch case is in protected scope;
+  cannot jump from switch statement to this case label;
 def warn_cxx98_compat_switch_into_protected_scope : Warning
-  switch case would be in a protected scope in C++98,
+  jump from switch statement to this case label is incompatible with C++98,
   InGroupCXX98Compat, DefaultIgnore;
 def err_indirect_goto_without_addrlabel : Error
   indirect goto in function with no address-of-label expressions;
 def err_indirect_goto_in_protected_scope : Error
-  indirect goto might cross protected scopes;
+  cannot jump from this indirect goto statement to one of its possible 
targets;
 def warn_cxx98_compat_indirect_goto_in_protected_scope : Warning
-  indirect goto might cross protected scopes in C++98,
-  InGroupCXX98Compat, DefaultIgnore;
-def note_indirect_goto_target : Notepossible target of indirect goto;
+  jump from this indirect goto statement to one of its possible targets 
+  is incompatible with C++98, InGroupCXX98Compat, DefaultIgnore;
+def note_indirect_goto_target : Note
+  possible target of indirect goto statement;
 def note_protected_by_variable_init : Note
   jump bypasses variable initialization;
 def note_protected_by_variable_nontriv_destructor : Note

Modified: cfe/trunk/test/ARCMT/checking.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=217293r1=217292r2=217293view=diff
==
--- cfe/trunk/test/ARCMT/checking.m (original)
+++ cfe/trunk/test/ARCMT/checking.m Fri Sep  5 19:24:58 2014
@@ -182,7 +182,7 @@ void test6(unsigned cond) {
 ;
 id x; // expected-note {{jump bypasses initialization of retaining 
variable}}
 
-  case 1: // expected-error {{switch case is in protected scope}}
+  case 1: // expected-error {{cannot jump}}
 x = 0;
 break;
   }

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp?rev=217293r1=217292r2=217293view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp Fri Sep  5 
19:24:58 2014
@@ -44,7 +44,7 @@ namespace VariableLengthArrays {
 
   void f() {
 int n = 42;
-goto foo; // expected-error {{goto into protected scope}}
+

Re: [patch] Implementing -Wunused-local-typedefs

2014-09-05 Thread Richard Smith
On Fri, Sep 5, 2014 at 4:44 PM, Nico Weber tha...@chromium.org wrote:

 On Fri, Sep 5, 2014 at 2:44 PM, Richard Smith rich...@metafoo.co.uk
 wrote:

 Thanks, this is looking really good.

 +  if (Diags.isIgnored(diag::warn_unused_local_typedef, SourceLocation()))
 +return;

 It would seem better to consider the diagnostic state at the point where
 the typedef is declared. (Maybe check this when adding typedefs to the set
 rather than when diagnosing?)


 Great catch. -Wunused-private-fields probably gets this wrong too. I added
 a test for this (see the very bottom of warn-unused-local-typedef.cpp, and
 the pragma diagnostic push/pop). The test sadly showed that adding when
 adding the typedefs is wrong too: For template instantiations, the
 instantiation is done at end-of-file, but a pragma diag at end of file
 shouldn't disable warnings in templates that physically are further up. So
 I just removed this check.


 +// Warnigns emitted in ActOnEndOfTranslationUnit() should be emitted
 for

 Typo 'Warnigns'.


 Doen.


 +  // Except for labels, we only care about unused decls that are local to
 +  // functions.
 +  bool WithinFunction = D-getDeclContext()-isFunctionOrMethod();
 +  if (const auto *R = dyn_castCXXRecordDecl(D-getDeclContext()))
 +WithinFunction =
 +WithinFunction || (R-isLocalClass()  !R-isDependentType());

 Why are dependent local classes skipped here? I'd like at least a comment
 to explain this so future readers aren't surprised :)


 I added a short comment. This is covered by my tests, so removing it does
 make something fail.
 (SemaTemplateInstantiateDecl.cpp's Sema::BuildVariableInstantiation() calls
 this method for instantiated fields, so the warnings are deferred until
 after instantiation.)



 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))

 '*' on the right, please.



   Done.



 +  if (auto* TD = dyn_castTypedefNameDecl(D)) {
 +// typedefs can be referenced later on, so the diagnostics are
 emitted
 +// at end-of-translation-unit.

 Likewise.



   Done.



 +void Sema::DiagnoseUnusedNestedTypedefs(const RecordDecl *D) {
 +  if (D-getTypeForDecl()-isDependentType())
 +return;
 +
 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))
 +  DiagnoseUnusedNestedTypedefs(R);
 +  }
 +}
 [...]
 -if (!S-hasUnrecoverableErrorOccurred())
 +if (!S-hasUnrecoverableErrorOccurred()) {
DiagnoseUnusedDecl(D);
 +  if (const auto *RD = dyn_castRecordDecl(D))
 +DiagnoseUnusedNestedTypedefs(RD);
 +}

 Would it make sense for DiagnoseUnusedDecl to do the recursive walk over
 child decls itself?


 Doesn't matter too much either way I guess? Left it as is for now.



 +/// In a function like
 +/// auto f() {
 +///   struct S { typedef int a; };
 +///   return S;
 +/// }

 Should be 'return S();' or similar here.


 Done.


 +/// others. Pretend that all local typedefs are always references, to
 not warn

 Typo 'references'.


 Done.


 +class LocalTypedefNameReferencer
 +: public RecursiveASTVisitorLocalTypedefNameReferencer {
 +public:
 +  LocalTypedefNameReferencer(Sema S) : S(S) {}
 +  bool VisitRecordType(const RecordType *RT);
 +private:
 +  Sema S;
 +};

 I think you'll also need to handle MemberPointerType here; the `Class` in
 `T Class::*` is just modeled as a CXXRecordDecl, not a RecordType.


 I added the (slightly contrived :-) ) test you showed me, it seems to pass
 as-is.


Does it still not warn if you remove the g() function and its use?

+  if (T-getAccess() != AS_private)

 You should also check if the class has any friends; if so, they might use
 the member.


 Good point. Done, added a test for this.


 +  }
else if (TypeDecl *TD = dyn_castTypeDecl(FoundDecl))

 No newline between } and else.


 Done.


 +  // Build a record containing all of the
 UnusedLocalTypedefNameCandidates.
 +  RecordData UnusedLocalTypedefNameCandidates;
 +  for (const TypedefNameDecl *TD :
 SemaRef.UnusedLocalTypedefNameCandidates)
 +AddDeclRef(TD, UnusedLocalTypedefNameCandidates);

 Maybe wrap this in a `if (!isModule)`


 UnusedLocalTypedefNameCandidates should've been clear()ed for modules at
 this point I think, so should be fine as is.


 +  // FIXME: typedef that's only used in a constexpr

 Do you mean in a constant expression? constexpr is an adjective, not a
 noun.


 Done (by fixing the FIXME).

 Thanks for the thorough review!

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


r217298 - Add -Wunused-local-typedef, a warning that finds unused local typedefs.

2014-09-05 Thread Nico Weber
Author: nico
Date: Fri Sep  5 20:25:55 2014
New Revision: 217298

URL: http://llvm.org/viewvc/llvm-project?rev=217298view=rev
Log:
Add -Wunused-local-typedef, a warning that finds unused local typedefs.

The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

template class T
void template_fun(T t) {
  typename T::Foo s3foo;  // YYY
  (void)s3foo;
}
void template_fun_user() {
  struct Local {
typedef int Foo;  // XXX
  } p;
  template_fun(p);
}

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

auto f() {
  struct S { typedef int a; };
  return S();
}

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

Added:
cfe/trunk/test/Modules/Inputs/warn-unused-local-typedef.h
cfe/trunk/test/Modules/warn-unused-local-typedef.cpp
cfe/trunk/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
cfe/trunk/test/SemaCXX/warn-unused-local-typedef.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ExternalSemaSource.h
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Misc/ast-dump-color.cpp
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=217298r1=217297r2=217298view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Sep  5 20:25:55 2014
@@ -402,6 +402,7 @@ def UnusedValue : DiagGroupunused-valu
 def UnusedConstVariable : DiagGroupunused-const-variable;
 def UnusedVariable : DiagGroupunused-variable,
[UnusedConstVariable];
+def UnusedLocalTypedef : DiagGroupunused-local-typedef;
 def UnusedPropertyIvar :  DiagGroupunused-property-ivar;
 def UsedButMarkedUnused : DiagGroupused-but-marked-unused;
 def UserDefinedLiterals : DiagGroupuser-defined-literals;
@@ -526,7 +527,7 @@ def Unused : DiagGroupunused,
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
-UnusedPrivateField,
+UnusedPrivateField, UnusedLocalTypedef,
 UnusedValue, UnusedVariable, UnusedPropertyIvar],
 DiagCategoryUnused Entity Issue;
 
@@ -622,6 +623,8 @@ def : DiagGroupint-conversions,
 [IntConversion]; // -Wint-conversions = -Wint-conversion
 

Re: [patch] Implementing -Wunused-local-typedefs

2014-09-05 Thread Nico Weber
On Fri, Sep 5, 2014 at 6:01 PM, Richard Smith rich...@metafoo.co.uk wrote:

 On Fri, Sep 5, 2014 at 4:44 PM, Nico Weber tha...@chromium.org wrote:

 On Fri, Sep 5, 2014 at 2:44 PM, Richard Smith rich...@metafoo.co.uk
 wrote:

 Thanks, this is looking really good.

 +  if (Diags.isIgnored(diag::warn_unused_local_typedef,
 SourceLocation()))
 +return;

 It would seem better to consider the diagnostic state at the point where
 the typedef is declared. (Maybe check this when adding typedefs to the set
 rather than when diagnosing?)


 Great catch. -Wunused-private-fields probably gets this wrong too. I
 added a test for this (see the very bottom of
 warn-unused-local-typedef.cpp, and the pragma diagnostic push/pop). The
 test sadly showed that adding when adding the typedefs is wrong too: For
 template instantiations, the instantiation is done at end-of-file, but a
 pragma diag at end of file shouldn't disable warnings in templates that
 physically are further up. So I just removed this check.


 +// Warnigns emitted in ActOnEndOfTranslationUnit() should be
 emitted for

 Typo 'Warnigns'.


 Doen.


 +  // Except for labels, we only care about unused decls that are local
 to
 +  // functions.
 +  bool WithinFunction = D-getDeclContext()-isFunctionOrMethod();
 +  if (const auto *R = dyn_castCXXRecordDecl(D-getDeclContext()))
 +WithinFunction =
 +WithinFunction || (R-isLocalClass()  !R-isDependentType());

 Why are dependent local classes skipped here? I'd like at least a
 comment to explain this so future readers aren't surprised :)


 I added a short comment. This is covered by my tests, so removing it does
 make something fail.
 (SemaTemplateInstantiateDecl.cpp's Sema::BuildVariableInstantiation() calls
 this method for instantiated fields, so the warnings are deferred until
 after instantiation.)



 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))

 '*' on the right, please.



   Done.



 +  if (auto* TD = dyn_castTypedefNameDecl(D)) {
 +// typedefs can be referenced later on, so the diagnostics are
 emitted
 +// at end-of-translation-unit.

 Likewise.



   Done.



 +void Sema::DiagnoseUnusedNestedTypedefs(const RecordDecl *D) {
 +  if (D-getTypeForDecl()-isDependentType())
 +return;
 +
 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))
 +  DiagnoseUnusedNestedTypedefs(R);
 +  }
 +}
 [...]
 -if (!S-hasUnrecoverableErrorOccurred())
 +if (!S-hasUnrecoverableErrorOccurred()) {
DiagnoseUnusedDecl(D);
 +  if (const auto *RD = dyn_castRecordDecl(D))
 +DiagnoseUnusedNestedTypedefs(RD);
 +}

 Would it make sense for DiagnoseUnusedDecl to do the recursive walk over
 child decls itself?


 Doesn't matter too much either way I guess? Left it as is for now.



 +/// In a function like
 +/// auto f() {
 +///   struct S { typedef int a; };
 +///   return S;
 +/// }

 Should be 'return S();' or similar here.


 Done.


 +/// others. Pretend that all local typedefs are always references, to
 not warn

 Typo 'references'.


 Done.


 +class LocalTypedefNameReferencer
 +: public RecursiveASTVisitorLocalTypedefNameReferencer {
 +public:
 +  LocalTypedefNameReferencer(Sema S) : S(S) {}
 +  bool VisitRecordType(const RecordType *RT);
 +private:
 +  Sema S;
 +};

 I think you'll also need to handle MemberPointerType here; the `Class`
 in `T Class::*` is just modeled as a CXXRecordDecl, not a RecordType.


 I added the (slightly contrived :-) ) test you showed me, it seems to
 pass as-is.


 Does it still not warn if you remove the g() function and its use?


Yes, as discussed on IRC, RecursiveASTVisitor gets this right for me.

As also discussed on IRC, landed in r217298. Thanks for the great review,
and for realizing that this warning is trickier to get right than I (and
the person who implemented it in gcc ;-) ) thought – I learned quite a bit
about clang while working on this :-)
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r217241 - Mark ms-inline-asm as xfail on ARM

2014-09-05 Thread Saleem Abdulrasool
On Fri, Sep 5, 2014 at 6:29 AM, Renato Golin renato.go...@linaro.org
wrote:

 http://llvm.org/viewvc/llvm-project?rev=217241view=rev


Why is this test expected to fail?  The target triple is specified, so it
should work (its a cross-compile).

-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r217302 - Add error, recovery and fixit for ~A::A() {...}.

2014-09-05 Thread Richard Smith
Author: rsmith
Date: Fri Sep  5 21:06:12 2014
New Revision: 217302

URL: http://llvm.org/viewvc/llvm-project?rev=217302view=rev
Log:
Add error, recovery and fixit for ~A::A() {...}.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=217302r1=217301r2=217302view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep  5 21:06:12 
2014
@@ -492,6 +492,8 @@ def err_constructor_bad_name : Error
   missing return type for function %0; did you mean the constructor name 
%1?;
 def err_destructor_tilde_identifier : Error
   expected a class name after '~' to name a destructor;
+def err_destructor_tilde_scope : Error
+  '~' in destructor name should be after nested name specifier;
 def err_destructor_template_id : Error
   destructor name %0 does not refer to a template;
 def err_default_arg_unparsed : Error

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=217302r1=217301r2=217302view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Sep  5 21:06:12 2014
@@ -2452,10 +2452,29 @@ bool Parser::ParseUnqualifiedId(CXXScope
   return true;
 }
 
+// If the user wrote ~T::T, correct it to T::~T.
+if (!TemplateSpecified  NextToken().is(tok::coloncolon)) {
+  if (SS.isSet()) {
+AnnotateScopeToken(SS, /*NewAnnotation*/true);
+SS.clear();
+  }
+  if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
+return true;
+  if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon)) {
+Diag(TildeLoc, diag::err_destructor_tilde_scope);
+return true;
+  }
+
+  // Recover as if the tilde had been written before the identifier.
+  Diag(TildeLoc, diag::err_destructor_tilde_scope)
+ FixItHint::CreateRemoval(TildeLoc)
+ FixItHint::CreateInsertion(Tok.getLocation(), ~);
+}
+
 // Parse the class-name (or template-name in a simple-template-id).
 IdentifierInfo *ClassName = Tok.getIdentifierInfo();
 SourceLocation ClassNameLoc = ConsumeToken();
-
+
 if (TemplateSpecified || Tok.is(tok::less)) {
   Result.setDestructorName(TildeLoc, ParsedType(), ClassNameLoc);
   return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
@@ -2463,7 +2482,7 @@ bool Parser::ParseUnqualifiedId(CXXScope
   EnteringContext, ObjectType,
   Result, TemplateSpecified);
 }
-
+
 // Note that this is a destructor name.
 ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName, 
   ClassNameLoc, getCurScope(),

Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=217302r1=217301r2=217302view=diff
==
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Fri Sep  5 21:06:12 2014
@@ -308,6 +308,13 @@ namespace dtor_fixit {
 ~bar() { }  // expected-error {{expected the class name after '~' to name 
a destructor}}
 // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:6-[[@LINE-1]]:9}:foo
   };
+
+  class bar {
+~bar();
+  };
+  ~bar::bar() {} // expected-error {{'~' in destructor name should be after 
nested name specifier}}
+  // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:4}:
+  // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:~
 }
 
 namespace PR5066 {

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=217302r1=217301r2=217302view=diff
==
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Fri Sep  5 21:06:12 2014
@@ -139,6 +139,20 @@ namespace CtorErrors {
   };
 }
 
+namespace DtorErrors {
+  struct A { ~A(); } a;
+  ~A::A() {} // expected-error {{'~' in destructor name should be after nested 
name specifier}} expected-note {{previous}}
+  A::~A() {} // expected-error {{redefinition}}
+
+  struct B { ~B(); } *b;
+  DtorErrors::~B::B() {} // expected-error {{'~' in destructor name should be 
after nested name specifier}}
+
+  void f() {
+a.~A::A(); // expected-error {{'~' in destructor name should be after 
nested name specifier}}
+b-~DtorErrors::~B::B(); 

Re: [patch] Implementing -Wunused-local-typedefs

2014-09-05 Thread Richard Smith
On Fri, Sep 5, 2014 at 6:37 PM, Nico Weber tha...@chromium.org wrote:

 On Fri, Sep 5, 2014 at 6:01 PM, Richard Smith rich...@metafoo.co.uk
 wrote:

 On Fri, Sep 5, 2014 at 4:44 PM, Nico Weber tha...@chromium.org wrote:

 On Fri, Sep 5, 2014 at 2:44 PM, Richard Smith rich...@metafoo.co.uk
 wrote:

 Thanks, this is looking really good.

 +  if (Diags.isIgnored(diag::warn_unused_local_typedef,
 SourceLocation()))
 +return;

 It would seem better to consider the diagnostic state at the point
 where the typedef is declared. (Maybe check this when adding typedefs to
 the set rather than when diagnosing?)


 Great catch. -Wunused-private-fields probably gets this wrong too. I
 added a test for this (see the very bottom of
 warn-unused-local-typedef.cpp, and the pragma diagnostic push/pop). The
 test sadly showed that adding when adding the typedefs is wrong too: For
 template instantiations, the instantiation is done at end-of-file, but a
 pragma diag at end of file shouldn't disable warnings in templates that
 physically are further up. So I just removed this check.


 +// Warnigns emitted in ActOnEndOfTranslationUnit() should be
 emitted for

 Typo 'Warnigns'.


 Doen.


 +  // Except for labels, we only care about unused decls that are local
 to
 +  // functions.
 +  bool WithinFunction = D-getDeclContext()-isFunctionOrMethod();
 +  if (const auto *R = dyn_castCXXRecordDecl(D-getDeclContext()))
 +WithinFunction =
 +WithinFunction || (R-isLocalClass()  !R-isDependentType());

 Why are dependent local classes skipped here? I'd like at least a
 comment to explain this so future readers aren't surprised :)


 I added a short comment. This is covered by my tests, so removing it
 does make something fail.
 (SemaTemplateInstantiateDecl.cpp's Sema::BuildVariableInstantiation() calls
 this method for instantiated fields, so the warnings are deferred until
 after instantiation.)



 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))

 '*' on the right, please.



 Done.



 +  if (auto* TD = dyn_castTypedefNameDecl(D)) {
 +// typedefs can be referenced later on, so the diagnostics are
 emitted
 +// at end-of-translation-unit.

 Likewise.



 Done.



 +void Sema::DiagnoseUnusedNestedTypedefs(const RecordDecl *D) {
 +  if (D-getTypeForDecl()-isDependentType())
 +return;
 +
 +  for (auto *TmpD : D-decls()) {
 +if (const auto* T = dyn_castTypedefNameDecl(TmpD))
 +  DiagnoseUnusedDecl(T);
 +else if(const auto *R = dyn_castRecordDecl(TmpD))
 +  DiagnoseUnusedNestedTypedefs(R);
 +  }
 +}
 [...]
 -if (!S-hasUnrecoverableErrorOccurred())
 +if (!S-hasUnrecoverableErrorOccurred()) {
DiagnoseUnusedDecl(D);
 +  if (const auto *RD = dyn_castRecordDecl(D))
 +DiagnoseUnusedNestedTypedefs(RD);
 +}

 Would it make sense for DiagnoseUnusedDecl to do the recursive walk
 over child decls itself?


 Doesn't matter too much either way I guess? Left it as is for now.



 +/// In a function like
 +/// auto f() {
 +///   struct S { typedef int a; };
 +///   return S;
 +/// }

 Should be 'return S();' or similar here.


 Done.


 +/// others. Pretend that all local typedefs are always references, to
 not warn

 Typo 'references'.


 Done.


 +class LocalTypedefNameReferencer
 +: public RecursiveASTVisitorLocalTypedefNameReferencer {
 +public:
 +  LocalTypedefNameReferencer(Sema S) : S(S) {}
 +  bool VisitRecordType(const RecordType *RT);
 +private:
 +  Sema S;
 +};

 I think you'll also need to handle MemberPointerType here; the `Class`
 in `T Class::*` is just modeled as a CXXRecordDecl, not a RecordType.


 I added the (slightly contrived :-) ) test you showed me, it seems to
 pass as-is.


 Does it still not warn if you remove the g() function and its use?


 Yes, as discussed on IRC, RecursiveASTVisitor gets this right for me.

 As also discussed on IRC, landed in r217298.


(For posterity: LGTM)


 Thanks for the great review, and for realizing that this warning is
 trickier to get right than I (and the person who implemented it in gcc ;-)
 ) thought – I learned quite a bit about clang while working on this :-)

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


Re: r217302 - Add error, recovery and fixit for ~A::A() {...}.

2014-09-05 Thread Richard Smith
Looks like this is PR13183.

On Fri, Sep 5, 2014 at 7:06 PM, Richard Smith richard-l...@metafoo.co.uk
wrote:

 Author: rsmith
 Date: Fri Sep  5 21:06:12 2014
 New Revision: 217302

 URL: http://llvm.org/viewvc/llvm-project?rev=217302view=rev
 Log:
 Add error, recovery and fixit for ~A::A() {...}.

 Modified:
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/lib/Parse/ParseExprCXX.cpp
 cfe/trunk/test/FixIt/fixit.cpp
 cfe/trunk/test/Parser/cxx-class.cpp

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

 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep  5
 21:06:12 2014
 @@ -492,6 +492,8 @@ def err_constructor_bad_name : Error
missing return type for function %0; did you mean the constructor name
 %1?;
  def err_destructor_tilde_identifier : Error
expected a class name after '~' to name a destructor;
 +def err_destructor_tilde_scope : Error
 +  '~' in destructor name should be after nested name specifier;
  def err_destructor_template_id : Error
destructor name %0 does not refer to a template;
  def err_default_arg_unparsed : Error

 Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=217302r1=217301r2=217302view=diff

 ==
 --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
 +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Sep  5 21:06:12 2014
 @@ -2452,10 +2452,29 @@ bool Parser::ParseUnqualifiedId(CXXScope
return true;
  }

 +// If the user wrote ~T::T, correct it to T::~T.
 +if (!TemplateSpecified  NextToken().is(tok::coloncolon)) {
 +  if (SS.isSet()) {
 +AnnotateScopeToken(SS, /*NewAnnotation*/true);
 +SS.clear();
 +  }
 +  if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
 +return true;
 +  if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon)) {
 +Diag(TildeLoc, diag::err_destructor_tilde_scope);
 +return true;
 +  }
 +
 +  // Recover as if the tilde had been written before the identifier.
 +  Diag(TildeLoc, diag::err_destructor_tilde_scope)
 + FixItHint::CreateRemoval(TildeLoc)
 + FixItHint::CreateInsertion(Tok.getLocation(), ~);
 +}
 +
  // Parse the class-name (or template-name in a simple-template-id).
  IdentifierInfo *ClassName = Tok.getIdentifierInfo();
  SourceLocation ClassNameLoc = ConsumeToken();
 -
 +
  if (TemplateSpecified || Tok.is(tok::less)) {
Result.setDestructorName(TildeLoc, ParsedType(), ClassNameLoc);
return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
 @@ -2463,7 +2482,7 @@ bool Parser::ParseUnqualifiedId(CXXScope
EnteringContext, ObjectType,
Result, TemplateSpecified);
  }
 -
 +
  // Note that this is a destructor name.
  ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName,
ClassNameLoc, getCurScope(),

 Modified: cfe/trunk/test/FixIt/fixit.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=217302r1=217301r2=217302view=diff

 ==
 --- cfe/trunk/test/FixIt/fixit.cpp (original)
 +++ cfe/trunk/test/FixIt/fixit.cpp Fri Sep  5 21:06:12 2014
 @@ -308,6 +308,13 @@ namespace dtor_fixit {
  ~bar() { }  // expected-error {{expected the class name after '~' to
 name a destructor}}
  // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:6-[[@LINE-1]]:9}:foo
};
 +
 +  class bar {
 +~bar();
 +  };
 +  ~bar::bar() {} // expected-error {{'~' in destructor name should be
 after nested name specifier}}
 +  // CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:4}:
 +  // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:~
  }

  namespace PR5066 {

 Modified: cfe/trunk/test/Parser/cxx-class.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=217302r1=217301r2=217302view=diff

 ==
 --- cfe/trunk/test/Parser/cxx-class.cpp (original)
 +++ cfe/trunk/test/Parser/cxx-class.cpp Fri Sep  5 21:06:12 2014
 @@ -139,6 +139,20 @@ namespace CtorErrors {
};
  }

 +namespace DtorErrors {
 +  struct A { ~A(); } a;
 +  ~A::A() {} // expected-error {{'~' in destructor name should be after
 nested name specifier}} expected-note {{previous}}
 +  A::~A() {} // expected-error {{redefinition}}
 +
 +  struct B { ~B(); } *b;
 +  DtorErrors::~B::B() {} // expected-error {{'~'