r262765 - Add null check to diagnostic path for lambda captures.

2016-03-04 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar  4 22:04:57 2016
New Revision: 262765

URL: http://llvm.org/viewvc/llvm-project?rev=262765=rev
Log:
Add null check to diagnostic path for lambda captures.

Previously, the failed capture of a variable in nested lambdas may crash when
the lambda pointer is null.  Only give the note if a location can be retreived
from the lambda pointer.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=262765=262764=262765=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Mar  4 22:04:57 2016
@@ -13509,8 +13509,9 @@ bool Sema::tryCaptureVariable(
 Diag(ExprLoc, diag::err_lambda_impcap) << Var->getDeclName();
 Diag(Var->getLocation(), diag::note_previous_decl) 
   << Var->getDeclName();
-Diag(cast(CSI)->Lambda->getLocStart(),
- diag::note_lambda_decl);
+if (cast(CSI)->Lambda)
+  Diag(cast(CSI)->Lambda->getLocStart(),
+   diag::note_lambda_decl);
 // FIXME: If we error out because an outer lambda can not implicitly
 // capture a variable that an inner lambda explicitly captures, we
 // should have the inner lambda do the explicit capture - because

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=262765=262764=262765=diff
==
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Fri Mar  4 22:04:57 2016
@@ -487,3 +487,15 @@ void foo() {
   };
 }
 }
+
+namespace nested_lambda {
+template 
+class S {};
+
+void foo() {
+  const int num = 18;  // expected-note {{'num' declared here}}
+  auto outer = []() {
+auto inner = [](S ) {};  // expected-error {{variable 'num' cannot 
be implicitly captured in a lambda with no capture-default specified}}
+  };
+}
+}


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


Re: [PATCH] D14905: [constexpr-lambda] Support parsing of constexpr specifier (and its inference) on lambda expressions

2016-03-04 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/DiagnosticParseKinds.td:772
@@ +771,3 @@
+def warn_cxx14_compat_constexpr_on_lambda : Warning<
+  "constexpr on lambda expressions are incompatible with C++14">,
+  InGroup, DefaultIgnore;

are -> is


Comment at: include/clang/Basic/DiagnosticParseKinds.td:773
@@ +772,3 @@
+  "constexpr on lambda expressions are incompatible with C++14">,
+  InGroup, DefaultIgnore;
+def err_constexpr_on_lambda : Error<

Should be CXXPre1zCompat, it's also incompatible with C++11.


Comment at: include/clang/Basic/DiagnosticParseKinds.td:775
@@ +774,3 @@
+def err_constexpr_on_lambda : Error<
+  "constexpr on lambda expressions is permitted only in C++1z">;
+

Any reason not to allow this as an extension in earlier standards?


Comment at: lib/Parse/ParseExprCXX.cpp:1049
@@ +1048,3 @@
+  SourceLocation , DeclSpec ) {
+  if (P.TryConsumeToken(tok::kw_mutable, MutableLoc)) {
+if (P.TryConsumeToken(tok::kw_constexpr, ConstexprLoc))

This doesn't look like it'll handle duplicates very well. We should consume and 
diagnose them, and recover as if they weren't there.


Comment at: lib/Parse/ParseExprCXX.cpp:1061
@@ +1060,3 @@
+
+  if (ConstexprLoc.isValid()) {
+if (!P.getLangOpts().CPlusPlus1z) {

Move this into the caller. It's inconsistent (and doesn't match the function 
name) to handle this but not 'mutable' here.


Comment at: lib/Sema/SemaLambda.cpp:1599
@@ +1598,3 @@
+  !Class->getDeclContext()->isDependentContext()) {
+TentativeAnalysisScope DiagnosticScopeGuard(*this);
+CallOperator->setConstexpr(

Ah, I now see why you were asking about this... :)

I would prefer a Diagnose flag here, but we can make that change later.


Comment at: test/Parser/cxx1z-constexpr-lambdas.cpp:5
@@ +4,3 @@
+auto L0 = [] constexpr { }; //expected-error{{requires '()'}} 
expected-error{{expected body}}
+#ifdef CPP1Z
+

Maybe test __cplusplus > 201402L rather than passing a separate macro?


Comment at: test/SemaCXX/cxx1z-constexpr-lambdas.cpp:4
@@ +3,3 @@
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions 
%s -DMS_EXTENSIONS
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks 
-fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS 
-DDELAYED_TEMPLATE_PARSING
+

You're not using these -D flags for anything; remove them.


http://reviews.llvm.org/D14905



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


Re: [PATCH] D14905: [constexpr-lambda] Support parsing of constexpr specifier (and its inference) on lambda expressions

2016-03-04 Thread Faisal Vali via cfe-commits
faisalv added a comment.

*ping*


http://reviews.llvm.org/D14905



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


r262764 - Test commit: Fix run-on sentence in comment

2016-03-04 Thread Mike Spertus via cfe-commits
Author: mps
Date: Fri Mar  4 19:56:07 2016
New Revision: 262764

URL: http://llvm.org/viewvc/llvm-project?rev=262764=rev
Log:
Test commit: Fix run-on sentence in comment


Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=262764=262763=262764=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Mar  4 19:56:07 2016
@@ -1416,8 +1416,8 @@ void Parser::handleDeclspecAlignBeforeCl
   while (AL) {
 AttributeList *Next = AL->getNext();
 
-// We only consider attributes using the appropriate '__declspec' spelling,
-// this behavior doesn't extend to any other spellings.
+// We only consider attributes using the appropriate '__declspec' spelling.
+// This behavior doesn't extend to any other spellings.
 if (AL->getKind() == AttributeList::AT_Aligned &&
 AL->isDeclspecAttribute()) {
   // Stitch the attribute into the tag's attribute list.


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


Re: [PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

2016-03-04 Thread Ryan Yee via cfe-commits
ryee88 added a subscriber: dblaikie.
ryee88 added a comment.

Anyone care to take a look?


http://reviews.llvm.org/D16965



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


Re: [PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

2016-03-04 Thread Ryan Yee via cfe-commits
ryee88 updated this revision to Diff 49866.

http://reviews.llvm.org/D16965

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Parser/cxx-class.cpp

Index: test/Parser/cxx-class.cpp
===
--- test/Parser/cxx-class.cpp
+++ test/Parser/cxx-class.cpp
@@ -98,17 +98,36 @@
 // expected-error{{unknown type name 'UnknownType'}}
 }
 
-namespace nns_decl {
-  struct A {
-struct B;
+namespace NestedNameSpecifiers {
+  struct OuterStruct {
+struct InnerStruct;
   };
-  namespace N {
-union C;
+  namespace UnionOuterNamespace {
+union UnionInner;
   }
-  struct A::B; // expected-error {{forward declaration of struct cannot have a 
nested name specifier}}
-  union N::C; // expected-error {{forward declaration of union cannot have a 
nested name specifier}}
+   class OuterClass{
+   class InnerClass;
+   };
+
+  struct OuterStruct::InnerStruct; // expected-error {{forward declaration of 
struct cannot have a nested name specifier}}
+  struct ::NestedNameSpecifiers::OuterStruct::InnerStruct; // expected-error 
{{forward declaration of struct cannot have a nested name specifier}}
+
+  union UnionOuterNamespace::UnionInner; // expected-error {{forward 
declaration of union cannot have a nested name specifier}}
+  union ::NestedNameSpecifiers::UnionOuterNamespace::UnionInner; // 
expected-error {{forward declaration of union cannot have a nested name 
specifier}}
+
+  class OuterClass::InnerClass; // expected-error {{forward declaration of 
class cannot have a nested name specifier}}
+  class ::NestedNameSpecifiers::OuterClass::InnerClass; // expected-error 
{{forward declaration of class cannot have a nested name specifier}}
 }
 
+// Testing the global "nested" name qualifier
+class GlobalSpecifierOuterClass {class InnerClass;};
+class ::GlobalSpecifierOuterClass; // expected-error {{forward declaration of 
qualified class not allowed}} expected-warning {{extra qualification on member 
'GlobalSpecifierOuterClass'}}
+class GlobalSpecifierOuterClass;
+// specializations of qualified type introduction?
+class GlobalSpecifierOuterClass::InnerClass; // expected-error {{forward 
declaration of class cannot have a nested name specifier}}
+class ::GlobalSpecifierOuterClass::InnerClass; // expected-error {{forward 
declaration of class cannot have a nested name specifier}}
+
+
 // PR13775: Don't assert here.
 namespace PR13775 {
   class bar
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3799,6 +3799,17 @@
   if (Tag && SS.isNotEmpty() && !Tag->isCompleteDefinition() &&
   !IsExplicitInstantiation && !IsExplicitSpecialization &&
   !isa(Tag)) {
+
+// Per C++ standard [n3485] 3.4.4 Elaborated type specifiers, section 3:
+// "Cannot introduce an qualified".
+// A clang::NestedNameSpecifier can represent many kinds of specifiers.
+// A global-specifier with no nested-name-specifier requires a different
+// diagnostic from a nested-name specifier.
+unsigned diagId = ( SS.getScopeRep()->getKind() == 
NestedNameSpecifier::Global &&
+  !SS.getScopeRep()->getPrefix() )
+  ? diag::err_standalone_class_specifier
+  : diagId = diag::err_standalone_class_nested_name_specifier;
+
 // Per C++ [dcl.type.elab]p1, a class declaration cannot have a
 // nested-name-specifier unless it is an explicit instantiation
 // or an explicit specialization.
@@ -3807,8 +3818,9 @@
 // obvious intent of DR1819.
 //
 // Per C++ [dcl.enum]p1, an opaque-enum-declaration can't either.
-Diag(SS.getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
-<< GetDiagnosticTypeSpecifierID(DS.getTypeSpecType()) << SS.getRange();
+Diag(SS.getBeginLoc(), diagId)
+  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType()) << SS.getRange();
+
 return nullptr;
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5266,6 +5266,9 @@
 def err_standalone_class_nested_name_specifier : Error<
   "forward declaration of %select{class|struct|interface|union|enum}0 cannot "
   "have a nested name specifier">;
+def err_standalone_class_specifier : Error<
+  "forward declaration of qualified 
%select{class|struct|interface|union|enum}0 "
+   "not allowed">;
 def err_typecheck_sclass_func : Error<"illegal storage class on function">;
 def err_static_block_func : Error<
   "function declared in block scope cannot have 'static' storage class">;


Index: test/Parser/cxx-class.cpp
===
--- test/Parser/cxx-class.cpp
+++ test/Parser/cxx-class.cpp
@@ -98,17 +98,36 @@
 // expected-error{{unknown type name 'UnknownType'}}
 }
 

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#368330, @zaks.anna wrote:

>


?


http://reviews.llvm.org/D17688



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


Re: r262741 - [OPENMP] Codegen for distribute directive

2016-03-04 Thread Carlo Bertolli via cfe-commits

Thanks - already reverted and I found the problem. Will push a new version
soon.

-- Carlo



From:   Nico Weber 
To: Carlo Bertolli/Watson/IBM@IBMUS
Cc: cfe-commits 
Date:   03/04/2016 06:09 PM
Subject:Re: r262741 - [OPENMP] Codegen for distribute directive



Looks like the new tests don't pass on Windows:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10365


On Mar 4, 2016 12:29 PM, "Carlo Bertolli via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
  Author: cbertol
  Date: Fri Mar  4 14:24:58 2016
  New Revision: 262741

  URL: http://llvm.org/viewvc/llvm-project?rev=262741=rev
  Log:
  [OPENMP] Codegen for distribute directive

  This patch provide basic implementation of codegen for teams directive,
  excluding all clauses except dist_schedule. It also fixes parts of AST
  reader/writer to enable correct pre-compiled header handling.

  http://reviews.llvm.org/D17170


  Added:
      cfe/trunk/test/OpenMP/distribute_codegen.cpp
  Modified:
      cfe/trunk/include/clang/AST/StmtOpenMP.h
      cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
      cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
      cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
      cfe/trunk/lib/CodeGen/CodeGenFunction.h
      cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
      cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

  Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
  URL:
  
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=262741=262740=262741=diff

  ==

  --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
  +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Mar  4 14:24:58 2016
  @@ -595,49 +595,56 @@ public:
     }
     Expr *getIsLastIterVariable() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), IsLastIterVariableOffset)));
     }
     Expr *getLowerBoundVariable() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), LowerBoundVariableOffset)));
     }
     Expr *getUpperBoundVariable() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), UpperBoundVariableOffset)));
     }
     Expr *getStrideVariable() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), StrideVariableOffset)));
     }
     Expr *getEnsureUpperBound() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), EnsureUpperBoundOffset)));
     }
     Expr *getNextLowerBound() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
       return const_cast(reinterpret_cast(
           *std::next(child_begin(), NextLowerBoundOffset)));
     }
     Expr *getNextUpperBound() const {
       assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
  -            isOpenMPTaskLoopDirective(getDirectiveKind())) &&
  +            isOpenMPTaskLoopDirective(getDirectiveKind()) ||
  +            isOpenMPDistributeDirective(getDirectiveKind())) &&
              "expected worksharing loop directive");
     

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.




http://reviews.llvm.org/D17688



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


r262753 - Update diagnostics now that hexadecimal literals look likely to be part of C++17.

2016-03-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Mar  4 16:32:06 2016
New Revision: 262753

URL: http://llvm.org/viewvc/llvm-project?rev=262753=rev
Log:
Update diagnostics now that hexadecimal literals look likely to be part of 
C++17.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp
cfe/trunk/test/Lexer/hexfloat.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=262753=262752=262753=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Mar  4 16:32:06 2016
@@ -175,10 +175,17 @@ def err_multichar_utf_character_literal
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
 def ext_imaginary_constant : Extension<
   "imaginary constants are a GNU extension">, InGroup;
-def err_hexconstant_requires: Error<
-  "hexadecimal floating constants require %select{an exponent|a 
significand}0">;
-def ext_hexconstant_invalid : Extension<
+def err_hex_constant_requires : Error<
+  "hexadecimal floating %select{constant|literal}0 requires "
+  "%select{an exponent|a significand}1">;
+def ext_hex_constant_invalid : Extension<
   "hexadecimal floating constants are a C99 feature">, InGroup;
+def ext_hex_literal_invalid : Extension<
+  "hexadecimal floating literals are a C++1z feature">, InGroup;
+def warn_cxx1z_hex_literal : Warning<
+  "hexidecimal floating literals are incompatible with "
+  "C++ standards before C++1z">,
+  InGroup, DefaultIgnore;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=262753=262752=262753=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Fri Mar  4 16:32:06 2016
@@ -125,11 +125,11 @@ LANGSTANDARD(gnucxx14, "gnu++14",
 LANGSTANDARD(cxx1z, "c++1z",
  "Working draft for ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
- Digraphs)
+ Digraphs | HexFloat)
 LANGSTANDARD(gnucxx1z, "gnu++1z",
  "Working draft for ISO C++ 2017 with GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
- Digraphs | GNUMode)
+ Digraphs | HexFloat | GNUMode)
 
 // OpenCL
 LANGSTANDARD(opencl, "cl",

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=262753=262752=262753=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri Mar  4 16:32:06 2016
@@ -1607,14 +1607,15 @@ bool Lexer::LexNumericConstant(Token 
 
   // If we have a hex FP constant, continue.
   if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p')) {
-// Outside C99, we accept hexadecimal floating point numbers as a
+// Outside C99 and C++17, we accept hexadecimal floating point numbers as a
 // not-quite-conforming extension. Only do so if this looks like it's
 // actually meant to be a hexfloat, and not if it has a ud-suffix.
 bool IsHexFloat = true;
 if (!LangOpts.C99) {
   if (!isHexaLiteral(BufferPtr, LangOpts))
 IsHexFloat = false;
-  else if (std::find(BufferPtr, CurPtr, '_') != CurPtr)
+  else if (!getLangOpts().CPlusPlus1z &&
+   std::find(BufferPtr, CurPtr, '_') != CurPtr)
 IsHexFloat = false;
 }
 if (IsHexFloat)

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=262753=262752=262753=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Fri Mar  4 16:32:06 2016
@@ -797,7 +797,8 @@ void NumericLiteralParser::ParseNumberSt
 
 if (!HasSignificandDigits) {
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
-diag::err_hexconstant_requires) << 1;
+  diag::err_hex_constant_requires)
+  << PP.getLangOpts().CPlusPlus << 1;
   hadError = true;
   return;
 }
@@ -821,10 +822,15 @@ void NumericLiteralParser::ParseNumberSt
   s = first_non_digit;
 
   if (!PP.getLangOpts().HexFloats)
-PP.Diag(TokLoc, 

Re: [PATCH] D16949: Fix for: Bug 5941 - improve diagnostic for * vs & confusion

2016-03-04 Thread David Blaikie via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262752: PR5941 - improve diagnostic for * vs & confusion 
when choosing overload… (authored by dblaikie).

Changed prior to commit:
  http://reviews.llvm.org/D16949?vs=49577=49856#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16949

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/overload-call.cpp

Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -9131,10 +9131,13 @@
   if (const PointerType *PTy = TempFromTy->getAs())
 TempFromTy = PTy->getPointeeType();
   if (TempFromTy->isIncompleteType()) {
+// Emit the generic diagnostic and, optionally, add the hints to it.
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
   << (unsigned) FnKind << FnDesc
   << (FromExpr ? FromExpr->getSourceRange() : SourceRange())
-  << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
+  << FromTy << ToTy << (unsigned) isObjectArgument << I+1
+  << (unsigned) (Cand->Fix.Kind);
+  
 MaybeEmitInheritedConstructorNote(S, Fn);
 return;
   }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3219,7 +3219,12 @@
 "function (the implicit move assignment operator)|"
 "constructor (inherited)}0%1 "
 "not viable: cannot convert argument of incomplete type "
-"%diff{$ to $|to parameter type}2,3">;
+"%diff{$ to $|to parameter type}2,3 for "
+"%select{%ordinal5 argument|object argument}4"
+"%select{|; dereference the argument with *|"
+"; take the address of the argument with &|"
+"; remove *|"
+"; remove &}6">;
 def note_ovl_candidate_bad_list_argument : Note<"candidate "
 "%select{function|function|constructor|"
 "function |function |constructor |"
Index: cfe/trunk/test/SemaCXX/overload-call.cpp
===
--- cfe/trunk/test/SemaCXX/overload-call.cpp
+++ cfe/trunk/test/SemaCXX/overload-call.cpp
@@ -375,16 +375,24 @@
 }
 
 // PR 6117
-namespace test3 {
-  struct Base {};
+namespace IncompleteConversion {
+  struct Complete {};
   struct Incomplete;
 
-  void foo(Base *); // expected-note 2 {{cannot convert argument of incomplete 
type}}
-  void foo(Base &); // expected-note 2 {{cannot convert argument of incomplete 
type}}
-
-  void test(Incomplete *P) {
-foo(P); // expected-error {{no matching function for call to 'foo'}}
-foo(*P); // expected-error {{no matching function for call to 'foo'}}
+  void completeFunction(Complete *); // expected-note 2 {{cannot convert 
argument of incomplete type}}
+  void completeFunction(Complete &); // expected-note 2 {{cannot convert 
argument of incomplete type}}
+  
+  void testTypeConversion(Incomplete *P) {
+completeFunction(P); // expected-error {{no matching function for call to 
'completeFunction'}}
+completeFunction(*P); // expected-error {{no matching function for call to 
'completeFunction'}}
+  }
+  
+  void incompletePointerFunction(Incomplete *); // expected-note {{candidate 
function not viable: cannot convert argument of incomplete type 
'IncompleteConversion::Incomplete' to 'IncompleteConversion::Incomplete *' for 
1st argument; take the address of the argument with &}}
+  void incompleteReferenceFunction(Incomplete &); // expected-note {{candidate 
function not viable: cannot convert argument of incomplete type 
'IncompleteConversion::Incomplete *' to 'IncompleteConversion::Incomplete &' 
for 1st argument; dereference the argument with *}}
+  
+  void testPointerReferenceConversion(Incomplete , Incomplete 
*pointer) {
+incompletePointerFunction(reference); // expected-error {{no matching 
function for call to 'incompletePointerFunction'}}
+incompleteReferenceFunction(pointer); // expected-error {{no matching 
function for call to 'incompleteReferenceFunction'}}
   }
 }
 


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -9131,10 +9131,13 @@
   if (const PointerType *PTy = TempFromTy->getAs())
 TempFromTy = PTy->getPointeeType();
   if (TempFromTy->isIncompleteType()) {
+// Emit the generic diagnostic and, optionally, add the hints to it.
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
   << (unsigned) FnKind << FnDesc
   << (FromExpr ? FromExpr->getSourceRange() : SourceRange())
-  << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
+  << FromTy << ToTy << (unsigned) isObjectArgument << 

r262752 - PR5941 - improve diagnostic for * vs & confusion when choosing overload candidate with a parameter of incomplete (ref or pointer) type

2016-03-04 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Mar  4 16:29:11 2016
New Revision: 262752

URL: http://llvm.org/viewvc/llvm-project?rev=262752=rev
Log:
PR5941 - improve diagnostic for * vs & confusion when choosing overload 
candidate with a parameter of incomplete (ref or pointer) type

Reviewers: dblaikie

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=262752=262751=262752=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Mar  4 16:29:11 
2016
@@ -3219,7 +3219,12 @@ def note_ovl_candidate_bad_conv_incomple
 "function (the implicit move assignment operator)|"
 "constructor (inherited)}0%1 "
 "not viable: cannot convert argument of incomplete type "
-"%diff{$ to $|to parameter type}2,3">;
+"%diff{$ to $|to parameter type}2,3 for "
+"%select{%ordinal5 argument|object argument}4"
+"%select{|; dereference the argument with *|"
+"; take the address of the argument with &|"
+"; remove *|"
+"; remove &}6">;
 def note_ovl_candidate_bad_list_argument : Note<"candidate "
 "%select{function|function|constructor|"
 "function |function |constructor |"

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=262752=262751=262752=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Mar  4 16:29:11 2016
@@ -9131,10 +9131,13 @@ static void DiagnoseBadConversion(Sema &
   if (const PointerType *PTy = TempFromTy->getAs())
 TempFromTy = PTy->getPointeeType();
   if (TempFromTy->isIncompleteType()) {
+// Emit the generic diagnostic and, optionally, add the hints to it.
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
   << (unsigned) FnKind << FnDesc
   << (FromExpr ? FromExpr->getSourceRange() : SourceRange())
-  << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
+  << FromTy << ToTy << (unsigned) isObjectArgument << I+1
+  << (unsigned) (Cand->Fix.Kind);
+  
 MaybeEmitInheritedConstructorNote(S, Fn);
 return;
   }

Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=262752=262751=262752=diff
==
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Fri Mar  4 16:29:11 2016
@@ -375,16 +375,24 @@ namespace test2 {
 }
 
 // PR 6117
-namespace test3 {
-  struct Base {};
+namespace IncompleteConversion {
+  struct Complete {};
   struct Incomplete;
 
-  void foo(Base *); // expected-note 2 {{cannot convert argument of incomplete 
type}}
-  void foo(Base &); // expected-note 2 {{cannot convert argument of incomplete 
type}}
-
-  void test(Incomplete *P) {
-foo(P); // expected-error {{no matching function for call to 'foo'}}
-foo(*P); // expected-error {{no matching function for call to 'foo'}}
+  void completeFunction(Complete *); // expected-note 2 {{cannot convert 
argument of incomplete type}}
+  void completeFunction(Complete &); // expected-note 2 {{cannot convert 
argument of incomplete type}}
+  
+  void testTypeConversion(Incomplete *P) {
+completeFunction(P); // expected-error {{no matching function for call to 
'completeFunction'}}
+completeFunction(*P); // expected-error {{no matching function for call to 
'completeFunction'}}
+  }
+  
+  void incompletePointerFunction(Incomplete *); // expected-note {{candidate 
function not viable: cannot convert argument of incomplete type 
'IncompleteConversion::Incomplete' to 'IncompleteConversion::Incomplete *' for 
1st argument; take the address of the argument with &}}
+  void incompleteReferenceFunction(Incomplete &); // expected-note {{candidate 
function not viable: cannot convert argument of incomplete type 
'IncompleteConversion::Incomplete *' to 'IncompleteConversion::Incomplete &' 
for 1st argument; dereference the argument with *}}
+  
+  void testPointerReferenceConversion(Incomplete , Incomplete 
*pointer) {
+incompletePointerFunction(reference); // expected-error {{no matching 
function for call to 'incompletePointerFunction'}}
+incompleteReferenceFunction(pointer); // expected-error {{no matching 
function for call to 'incompleteReferenceFunction'}}
   }
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

RE: r262688 - [X86] Pass __m64 types via SSE registers for GCC compatibility

2016-03-04 Thread Robinson, Paul via cfe-commits
> Ah, great! I always love it when people document their ABIs.
> 
> Is your ABI document public? If so, could you add it to
> docs/CompilerWriterInfo.rst?

I don't think I was aware of that page...  AFAIK ours is not available
on-line, but I can raise the question internally.
--paulr

> 
> On Fri, Mar 4, 2016 at 11:54 AM, Robinson, Paul
>  wrote:
> >> It'd be nice to have a comment here that mentions that the clang
> >> behavior which is being preserved for Darwin, FreeBSD, and PS4 is a
> >> *bug* which is being intentionally left unfixed. The previous clang
> >> behavior directly contradicts the x86_64 ABI document, which I believe
> >> all of these platforms claim to follow. :)
> >
> > Well, PS4 uses x86_64 ABI as a base document, but we have a handful of
> > variances.  We had already documented this one to our licensees.  So,
> > from our perspective, it's not a bug, it's a feature. :-)  Describing
> > it as a bug (at least for PS4) would be technically incorrect.
> > --paulr
> >
> >>
> >> On Fri, Mar 4, 2016 at 2:03 AM, Robinson, Paul via cfe-commits
> >>  wrote:
> >> >> To: cfe-commits@lists.llvm.org
> >> >> Subject: r262688 - [X86] Pass __m64 types via SSE registers for GCC
> >> >> compatibility
> >> >>
> >> >> Author: majnemer
> >> >> Date: Thu Mar  3 23:26:16 2016
> >> >> New Revision: 262688
> >> >>
> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=262688=rev
> >> >> Log:
> >> >> [X86] Pass __m64 types via SSE registers for GCC compatibility
> >> >>
> >> >> For compatibility with GCC, classify __m64 as SSE.
> >> >> However, clang is a platform compiler for certain targets; retain
> our
> >> >> old behavior on those targets: classify __m64 as integer.
> >> >
> >> > Thank you very much for that!
> >> > --paulr
> >> >
> >> >>
> >> >> This fixes PR26832.
> >> >>
> >> >> Modified:
> >> >> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >> >> cfe/trunk/test/CodeGen/3dnow-builtins.c
> >> >> cfe/trunk/test/CodeGen/x86_64-arguments.c
> >> >>
> >> >> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >> >> URL: http://llvm.org/viewvc/llvm-
> >> >>
> >>
> project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=262688=262687=26268
> >> >> 8=diff
> >> >>
> >>
> ==
> >> >> 
> >> >> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> >> >> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar  3 23:26:16 2016
> >> >> @@ -1857,6 +1857,17 @@ class X86_64ABIInfo : public ABIInfo {
> >> >>  return !getTarget().getTriple().isOSDarwin();
> >> >>}
> >> >>
> >> >> +  /// GCC classifies <1 x long long> as SSE but compatibility with
> >> older
> >> >> clang
> >> >> +  // compilers require us to classify it as INTEGER.
> >> >> +  bool classifyIntegerMMXAsSSE() const {
> >> >> +const llvm::Triple  = getTarget().getTriple();
> >> >> +if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
> >> >> +  return false;
> >> >> +if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10)
> >> >> +  return false;
> >> >> +return true;
> >> >> +  }
> >> >> +
> >> >>X86AVXABILevel AVXLevel;
> >> >>// Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit
> pointers
> >> on
> >> >>// 64-bit hardware.
> >> >> @@ -2298,15 +2309,20 @@ void X86_64ABIInfo::classify(QualType Ty
> >> >>if (EB_Lo != EB_Hi)
> >> >>  Hi = Lo;
> >> >>  } else if (Size == 64) {
> >> >> +  QualType ElementType = VT->getElementType();
> >> >> +
> >> >>// gcc passes <1 x double> in memory. :(
> >> >> -  if (VT->getElementType()-
> >> >> >isSpecificBuiltinType(BuiltinType::Double))
> >> >> +  if (ElementType->isSpecificBuiltinType(BuiltinType::Double))
> >> >>  return;
> >> >>
> >> >> -  // gcc passes <1 x long long> as INTEGER.
> >> >> -  if (VT->getElementType()-
> >> >> >isSpecificBuiltinType(BuiltinType::LongLong) ||
> >> >> -  VT->getElementType()-
> >> >> >isSpecificBuiltinType(BuiltinType::ULongLong) ||
> >> >> -  VT->getElementType()-
> >> >isSpecificBuiltinType(BuiltinType::Long)
> >> >> ||
> >> >> -  VT->getElementType()-
> >> >> >isSpecificBuiltinType(BuiltinType::ULong))
> >> >> +  // gcc passes <1 x long long> as SSE but clang used to
> >> >> unconditionally
> >> >> +  // pass them as integer.  For platforms where clang is the de
> >> facto
> >> >> +  // platform compiler, we must continue to use integer.
> >> >> +  if (!classifyIntegerMMXAsSSE() &&
> >> >> +  (ElementType-
> >isSpecificBuiltinType(BuiltinType::LongLong)
> >> ||
> >> >> +   ElementType-
> >isSpecificBuiltinType(BuiltinType::ULongLong)
> >> ||
> >> >> +   ElementType->isSpecificBuiltinType(BuiltinType::Long) ||
> >> >> +   ElementType->isSpecificBuiltinType(BuiltinType::ULong)))
> >> >>  Current = Integer;
> >> >>else
> >> >>  Current = SSE;
> >> >>
> 

Re: r262741 - [OPENMP] Codegen for distribute directive

2016-03-04 Thread Nico Weber via cfe-commits
Looks like the new tests don't pass on Windows:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10365
On Mar 4, 2016 12:29 PM, "Carlo Bertolli via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: cbertol
> Date: Fri Mar  4 14:24:58 2016
> New Revision: 262741
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262741=rev
> Log:
> [OPENMP] Codegen for distribute directive
>
> This patch provide basic implementation of codegen for teams directive,
> excluding all clauses except dist_schedule. It also fixes parts of AST
> reader/writer to enable correct pre-compiled header handling.
>
> http://reviews.llvm.org/D17170
>
>
> Added:
> cfe/trunk/test/OpenMP/distribute_codegen.cpp
> Modified:
> cfe/trunk/include/clang/AST/StmtOpenMP.h
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>
> Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=262741=262740=262741=diff
>
> ==
> --- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
> +++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Mar  4 14:24:58 2016
> @@ -595,49 +595,56 @@ public:
>}
>Expr *getIsLastIterVariable() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), IsLastIterVariableOffset)));
>}
>Expr *getLowerBoundVariable() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), LowerBoundVariableOffset)));
>}
>Expr *getUpperBoundVariable() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), UpperBoundVariableOffset)));
>}
>Expr *getStrideVariable() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), StrideVariableOffset)));
>}
>Expr *getEnsureUpperBound() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), EnsureUpperBoundOffset)));
>}
>Expr *getNextLowerBound() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), NextLowerBoundOffset)));
>}
>Expr *getNextUpperBound() const {
>  assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
> -isOpenMPTaskLoopDirective(getDirectiveKind())) &&
> +isOpenMPTaskLoopDirective(getDirectiveKind()) ||
> +isOpenMPDistributeDirective(getDirectiveKind())) &&
> "expected worksharing loop directive");
>  return const_cast(reinterpret_cast(
>  *std::next(child_begin(), NextUpperBoundOffset)));
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=262741=262740=262741=diff
>
> 

r262749 - clang-cl: Enable PCH flags by default.

2016-03-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Mar  4 15:59:42 2016
New Revision: 262749

URL: http://llvm.org/viewvc/llvm-project?rev=262749=rev
Log:
clang-cl: Enable PCH flags by default.

Now that pragma comment and pragma detect_mismatch are implemented, this might
just work.

Some pragmas aren't serialized yet (from the top of my head: code_seg, bss_seg,
data_seg, const_seg, init_seg, section, vtordisp), but these are as far as I
know usually pushed and popped within the header and usually don't leak out.
If it turns out the current PCH support isn't good enough yet, we can turn it
off again.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
cfe/trunk/test/Driver/cl-pch-search.cpp
cfe/trunk/test/Driver/cl-pch.c
cfe/trunk/test/Driver/cl-pch.cpp

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=262749=262748=262749=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Mar  4 15:59:42 2016
@@ -20,9 +20,6 @@ def cl_compile_Group : OptionGroup<"">,
   Group;
 
-def cl_internal_Group : OptionGroup<"">,
-  Group;
-
 class CLFlag : Option<["/", "-"], name, KIND_FLAG>,
   Group, Flags<[CLOption, DriverOption]>;
 
@@ -32,9 +29,6 @@ class CLCompileFlag : Optio
 class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>,
   Group, Flags<[CLOption, DriverOption, HelpHidden]>;
 
-class CLInternalFlag : Option<["-"], name, KIND_FLAG>,
-  Group, Flags<[CLOption, DriverOption, HelpHidden]>;
-
 class CLJoined : Option<["/", "-"], name, KIND_JOINED>,
   Group, Flags<[CLOption, DriverOption]>;
 
@@ -270,11 +264,6 @@ def _SLASH_Y_ : CLFlag<"Y-">,
 def _SLASH_Fp : CLJoined<"Fp">,
   HelpText<"Set pch filename (with /Yc and /Yu)">, MetaVarName<"">;
 
-// Internal:
-// FIXME: Once /Yc support is stable enough, turn it on by default (when /Yc
-// is passed) and remove this flag.
-def _SLASH_internal_enable_pch : CLInternalFlag<"internal-enable-pch">;
-
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=262749=262748=262749=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Mar  4 15:59:42 2016
@@ -1503,14 +1503,6 @@ void Driver::BuildActions(Compilation 
 Args.eraseArg(options::OPT__SLASH_Yu);
 YcArg = YuArg = nullptr;
   }
-  // FIXME: For now, only enable pch support if an internal flag is passed too.
-  // Remove this once pch support has stabilitzed.
-  if (!Args.hasArg(options::OPT__SLASH_internal_enable_pch)) {
-Args.eraseArg(options::OPT__SLASH_Fp);
-Args.eraseArg(options::OPT__SLASH_Yc);
-Args.eraseArg(options::OPT__SLASH_Yu);
-YcArg = YuArg = nullptr;
-  }
 
   // Construct the actions to perform.
   ActionList LinkerInputs;

Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262749=262748=262749=diff
==
--- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Fri Mar  4 15:59:42 2016
@@ -6,7 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h 
/Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1

Modified: cfe/trunk/test/Driver/cl-pch-search.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-search.cpp?rev=262749=262748=262749=diff
==
--- cfe/trunk/test/Driver/cl-pch-search.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-search.cpp Fri Mar  4 15:59:42 2016
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c 
/Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- 
%S/Inputs/pchfile.cpp 

Modified: cfe/trunk/test/Driver/cl-pch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.c?rev=262749=262748=262749=diff
==
--- cfe/trunk/test/Driver/cl-pch.c (original)
+++ 

Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 15 inline comments as done.


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:348
@@ +347,2 @@
+  initializeEnvironment();
+}

This function will also handle global variables from the 'declare target' 
construct in the future.

void CGOpenMPRuntimeNVPTX::createOffloadEntry(llvm::Constant *ID,
  llvm::Constant *Addr,
  uint64_t Size) {
  auto *F = dyn_cast(Addr);
  // TODO: Add support for global variables on the device after declare target
  // support.
  if (!F)
return;


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:348
@@ +347,2 @@
+  initializeEnvironment();
+}

arpith-jacob wrote:
> This function will also handle global variables from the 'declare target' 
> construct in the future.
> 
> void CGOpenMPRuntimeNVPTX::createOffloadEntry(llvm::Constant *ID,
>   llvm::Constant *Addr,
>   uint64_t Size) {
>   auto *F = dyn_cast(Addr);
>   // TODO: Add support for global variables on the device after declare target
>   // support.
>   if (!F)
> return;
> What about exceptions? Do you plan to support them? If yes, add tests for 
> classes with constructors/destructors and exceptions

This backend does not support exceptions.  We plan to send a separate patch 
that will selectively deactivate exceptions in target regions generated for the 
GPU. 


http://reviews.llvm.org/D17877



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


Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 49851.
arpith-jacob added a comment.

Addressed feedback; see inline comments for details.


http://reviews.llvm.org/D17877

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_target_codegen.cpp

Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -0,0 +1,587 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
+// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
+  // CHECK-NEXT: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK-NEXT: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+
+  // CHECK: define {{.*}}void [[T1]]()
+  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-NEXT: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-NEXT: [[A:%.+]] = sub i32 [[WS]], 1
+  // CHECK-NEXT: [[B:%.+]] = sub i32 [[NTID]], 1
+  // CHECK-NEXT: [[C:%.+]] = xor i32 [[A]], -1
+  // CHECK-NEXT: [[MID:%.+]] = and i32 [[B]], [[C]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+  //
+  // CHECK: [[CHECK_WORKER]]
+  // CHECK-NEXT: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK-NEXT: call void [[T1]]_worker()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[MASTER]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+  // CHECK-NEXT: br label {{%?}}[[TERM:.+]]
+  //
+  // CHECK: [[TERM]]
+  // CHECK-NEXT: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+  #pragma omp target
+  {
+  }
+
+  // CHECK-NOT: define {{.*}}void [[T2:@__omp_offloading_.+foo.+]]_worker()
+  #pragma omp target if(0)
+  {
+  }
+
+  // CHECK: define {{.*}}void [[T3:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // 

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-04 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:228
@@ -226,3 +227,3 @@
 /// \pre Replacements must be for the same file.
-std::vector
-calculateChangedRangesInFile(const tooling::Replacements );
+std::vector calculateChangedRangesInFile(const Replacements );
+

This was pre-existing, but I'd remove the "InFile" suffix. It doesn't seem to 
add any information.


Comment at: include/clang/Tooling/Core/Replacement.h:230
@@ +229,3 @@
+
+typedef std::map
+FileToReplacementsMap;

I think the key type in a map is always const, so no need for "const".


Comment at: include/clang/Tooling/Core/Replacement.h:235
@@ -229,1 +234,3 @@
+/// related to the same file entry are put into the same vector.
+FileToReplacementsMap groupReplacementsByFile(const Replacements );
 

I also wonder whether this should really return a map. I find such maps in 
interfaces sometimes a bit difficult as they have some cost and the subsequent 
analyses might actually prefer a different container. How about instead just 
returning a vector? I mean the Replacements themselves already 
have the filename stored in them so the key in the map is redundant anyway.

Manuel, any thoughts?


http://reviews.llvm.org/D17852



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


Re: r262691 - [MIPS] initFeatureMap() to handle empty string argument

2016-03-04 Thread Eric Christopher via cfe-commits
I've followed up to the original thread, but I'm fairly certain this isn't
the right patch here.

-eric

On Fri, Mar 4, 2016 at 10:28 AM Eric Christopher  wrote:

> Test case?
>
> On Fri, Mar 4, 2016, 4:02 AM Bhushan D. Attarde via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: bhushan.attarde
>> Date: Fri Mar  4 00:56:29 2016
>> New Revision: 262691
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262691=rev
>> Log:
>> [MIPS] initFeatureMap() to handle empty string argument
>>
>> SUMMARY:
>> This patch sets CPU string to its default value when it is not
>> supplied by caller.
>>
>> Reviewers: vkalintiris, dsanders
>> Subscribers: mohit.bhakkad, sagar, jaydeep, cfe-commits
>> Differential Revision: http://reviews.llvm.org/D16139
>>
>> Modified:
>> cfe/trunk/lib/Basic/Targets.cpp
>>
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262691=262690=262691=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Mar  4 00:56:29 2016
>> @@ -6689,6 +6689,8 @@ public:
>>initFeatureMap(llvm::StringMap , DiagnosticsEngine
>> ,
>>   StringRef CPU,
>>   const std::vector ) const
>> override {
>> +if (CPU.empty())
>> +  CPU = getCPU();
>>  if (CPU == "octeon")
>>Features["mips64r2"] = Features["cnmips"] = true;
>>  else
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-03-04 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

This seems wrong. You should fix setCPU instead or set a default CPU.


Repository:
  rL LLVM

http://reviews.llvm.org/D16139



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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-04 Thread Alexander Riccio via cfe-commits
ariccio updated this revision to Diff 49845.
ariccio added a comment.

Alrighty. This final version of the patch causes no test failures (vs the 
unmodified build*).

*An unrelated test normally fails on my machine.


http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  llvm/tools/clang/test/Analysis/malloc.c

Index: llvm/tools/clang/test/Analysis/malloc.c
===
--- llvm/tools/clang/test/Analysis/malloc.c
+++ llvm/tools/clang/test/Analysis/malloc.c
@@ -4,6 +4,21 @@
 
 void clang_analyzer_eval(int);
 
+// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
+// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
+// the builtin type: "Using the typedef version can cause portability
+// problems", but we're ok here because we're not actually running anything.
+// Also of note is this cryptic warning: "The wchar_t type is not supported
+// when you compile C code".
+//
+// See the docs for more:
+// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
+#if !defined(_WCHAR_T_DEFINED)
+// "Microsoft implements wchar_t as a two-byte unsigned value"
+typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif // !defined(_WCHAR_T_DEFINED)
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
@@ -13,9 +28,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +76,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +235,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +263,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1141,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1512,14 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(char *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
+wchar_t *testWinWideLeakWithinReturn(wchar_t *str) {
+  return _wcsdup(_wcsdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-

r262744 - Revert r262741 - [OPENMP] Codegen for distribute directive

2016-03-04 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Mar  4 15:02:14 2016
New Revision: 262744

URL: http://llvm.org/viewvc/llvm-project?rev=262744=rev
Log:
Revert r262741 - [OPENMP] Codegen for distribute directive

Was causing a failure in one of the buildbot slaves.

Removed:
cfe/trunk/test/OpenMP/distribute_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=262744=262743=262744=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Mar  4 15:02:14 2016
@@ -595,56 +595,49 @@ public:
   }
   Expr *getIsLastIterVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), IsLastIterVariableOffset)));
   }
   Expr *getLowerBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), LowerBoundVariableOffset)));
   }
   Expr *getUpperBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), UpperBoundVariableOffset)));
   }
   Expr *getStrideVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), StrideVariableOffset)));
   }
   Expr *getEnsureUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), EnsureUpperBoundOffset)));
   }
   Expr *getNextLowerBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextLowerBoundOffset)));
   }
   Expr *getNextUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind()) ||
-isOpenMPDistributeDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextUpperBoundOffset)));

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=262744=262743=262744=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Mar  4 15:02:14 2016
@@ -425,9 +425,6 @@ enum OpenMPSchedType {
   OMP_ord_runtime = 69,
   OMP_ord_auto = 70,
   OMP_sch_default = OMP_sch_static,
-  /// \brief dist_schedule types
-  OMP_dist_sch_static_chunked = 91,
-  OMP_dist_sch_static = 92,
 };
 
 enum OpenMPRTLFunction {
@@ -2151,26 +2148,12 @@ static OpenMPSchedType getRuntimeSchedul
   llvm_unreachable("Unexpected runtime schedule");
 }
 
-/// \brief Map the OpenMP 

r262743 - Update cxx_status with likely new features from Jacksonville WG21 meeting.

2016-03-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Mar  4 15:01:14 2016
New Revision: 262743

URL: http://llvm.org/viewvc/llvm-project?rev=262743=rev
Log:
Update cxx_status with likely new features from Jacksonville WG21 meeting.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=262743=262742=262743=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Fri Mar  4 15:01:14 2016
@@ -571,10 +571,14 @@ as the draft C++1z standard evolves.
 
 
 
-  Fold expressions
+  Fold expressions
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4295.html;>N4295
   Clang 3.6
 
+   
+http://wg21.link/p0036r0;>P0036R0
+No
+  
 
   u8 character literals
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4267.html;>N4267
@@ -621,6 +625,52 @@ as the draft C++1z standard evolves.
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0136r1.html;>P0136R1
   No
 
+
+
+  [[fallthrough]] attribute
+  http://wg21.link/p0188r1;>P0188R1
+  No
+
+
+  [[nodiscard]] attribute
+  http://wg21.link/p0189r1;>P0189R1
+  No
+
+
+  [[maybe_unused]] attribute
+  http://wg21.link/p0212r1;>P0212R1
+  No
+
+
+  Aggregate initialization of classes with base classes
+  http://wg21.link/p0017r1;>P0017R1
+  No
+
+
+  constexpr lambda expressions
+  http://wg21.link/p0170r1;>P0170R1
+  No
+
+
+  Differing begin and end types in range-based 
for
+  http://wg21.link/p0184r0;>P0184R0
+  No
+
+
+  Lambda capture of *this
+  http://wg21.link/p0018r3;>P0018R3
+  No
+
+
+  Direct-list-initialization of enums
+  http://wg21.link/p0138r2;>P0138R2
+  No
+
+
+  Hexadecimal floating-point literals
+  http://wg21.link/p0245r1;>P0245R1
+  Yes
+
 
 
 
@@ -686,6 +736,11 @@ Clang version they became available:
   No
 
 
+  [TS] Modules
+  http://wg21.link/p0143r2;>P0143R2
+  No
+
+
   [TS] Transactional Memory
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4514.pdf;>N4514
   No


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


Re: [PATCH] D17874: Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-04 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262742: Switch krait to use -mcpu=cortex-a15 for assembler 
tool invocations. (authored by srhines).

Changed prior to commit:
  http://reviews.llvm.org/D17874?vs=49791=49844#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17874

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

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8706,12 +8706,12 @@
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262742 - Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-04 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Fri Mar  4 14:57:22 2016
New Revision: 262742

URL: http://llvm.org/viewvc/llvm-project?rev=262742=rev
Log:
Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

Summary:
Using -no-integrated-as causes -mcpu=krait to be transformed into
-march=armv7-a today. This precludes the assembler from using
instructions like sdiv, which are present for krait. Cortex-a15 is the
closest subset of functionality for krait, so we should switch the
assembler to use that instead.

Reviewers: cfe-commits, apazos, weimingz

Subscribers: aemerson

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

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=262742=262741=262742=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar  4 14:57:22 2016
@@ -8706,12 +8706,12 @@ void gnutools::Assembler::ConstructJob(C
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
 // FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -march=armv7-a  to avoid a lower
+// for now replace it with -mcpu=cortex-a15 to avoid a lower
 // march from being picked in the absence of a cpu flag.
 Arg *A;
 if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
 StringRef(A->getValue()).lower() == "krait")
-  CmdArgs.push_back("-march=armv7-a");
+  CmdArgs.push_back("-mcpu=cortex-a15");
 else
   Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);


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


r262741 - [OPENMP] Codegen for distribute directive

2016-03-04 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Fri Mar  4 14:24:58 2016
New Revision: 262741

URL: http://llvm.org/viewvc/llvm-project?rev=262741=rev
Log:
[OPENMP] Codegen for distribute directive

This patch provide basic implementation of codegen for teams directive, 
excluding all clauses except dist_schedule. It also fixes parts of AST 
reader/writer to enable correct pre-compiled header handling.

http://reviews.llvm.org/D17170


Added:
cfe/trunk/test/OpenMP/distribute_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=262741=262740=262741=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Mar  4 14:24:58 2016
@@ -595,49 +595,56 @@ public:
   }
   Expr *getIsLastIterVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), IsLastIterVariableOffset)));
   }
   Expr *getLowerBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), LowerBoundVariableOffset)));
   }
   Expr *getUpperBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), UpperBoundVariableOffset)));
   }
   Expr *getStrideVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), StrideVariableOffset)));
   }
   Expr *getEnsureUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), EnsureUpperBoundOffset)));
   }
   Expr *getNextLowerBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextLowerBoundOffset)));
   }
   Expr *getNextUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextUpperBoundOffset)));

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=262741=262740=262741=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Mar  4 14:24:58 2016
@@ -425,6 +425,9 @@ enum OpenMPSchedType {
   OMP_ord_runtime = 69,
   OMP_ord_auto = 70,
   OMP_sch_default = OMP_sch_static,
+  /// \brief dist_schedule types
+  OMP_dist_sch_static_chunked = 91,
+  OMP_dist_sch_static = 92,
 };
 
 enum 

Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-03-04 Thread Carlo Bertolli via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Committed revision 262741.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170



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


Re: [PATCH] D17874: Switch krait to use -mcpu=cortex-a15 for assembler tool invocations.

2016-03-04 Thread Weiming Zhao via cfe-commits
weimingz accepted this revision.
weimingz added a comment.
This revision is now accepted and ready to land.

Ana is OK with it.


http://reviews.llvm.org/D17874



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


Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-04 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.


Comment at: include/clang/Basic/Attr.td:1543
@@ +1542,3 @@
+  let Subjects = SubjectList<[Record]>;
+  let Documentation = [Undocumented];
+}

aaron.ballman wrote:
> No new undocumented attributes, please. Same below.
Yes, sorry, forgot to go back and add documentation for these attributes. Will 
do. (Reckon it's not worth documenting the feature itself until it actually 
does something.)


http://reviews.llvm.org/D17893



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


Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

I may have more comments when I catch up on email next week. Just a drive-by as 
I added myself as reviewer.



Comment at: include/clang/Basic/Attr.td:1543
@@ +1542,3 @@
+  let Subjects = SubjectList<[Record]>;
+  let Documentation = [Undocumented];
+}

No new undocumented attributes, please. Same below.


http://reviews.llvm.org/D17893



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


Re: r262688 - [X86] Pass __m64 types via SSE registers for GCC compatibility

2016-03-04 Thread James Y Knight via cfe-commits
Ah, great! I always love it when people document their ABIs.

Is your ABI document public? If so, could you add it to
docs/CompilerWriterInfo.rst?

On Fri, Mar 4, 2016 at 11:54 AM, Robinson, Paul
 wrote:
>> It'd be nice to have a comment here that mentions that the clang
>> behavior which is being preserved for Darwin, FreeBSD, and PS4 is a
>> *bug* which is being intentionally left unfixed. The previous clang
>> behavior directly contradicts the x86_64 ABI document, which I believe
>> all of these platforms claim to follow. :)
>
> Well, PS4 uses x86_64 ABI as a base document, but we have a handful of
> variances.  We had already documented this one to our licensees.  So,
> from our perspective, it's not a bug, it's a feature. :-)  Describing
> it as a bug (at least for PS4) would be technically incorrect.
> --paulr
>
>>
>> On Fri, Mar 4, 2016 at 2:03 AM, Robinson, Paul via cfe-commits
>>  wrote:
>> >> To: cfe-commits@lists.llvm.org
>> >> Subject: r262688 - [X86] Pass __m64 types via SSE registers for GCC
>> >> compatibility
>> >>
>> >> Author: majnemer
>> >> Date: Thu Mar  3 23:26:16 2016
>> >> New Revision: 262688
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=262688=rev
>> >> Log:
>> >> [X86] Pass __m64 types via SSE registers for GCC compatibility
>> >>
>> >> For compatibility with GCC, classify __m64 as SSE.
>> >> However, clang is a platform compiler for certain targets; retain our
>> >> old behavior on those targets: classify __m64 as integer.
>> >
>> > Thank you very much for that!
>> > --paulr
>> >
>> >>
>> >> This fixes PR26832.
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> >> cfe/trunk/test/CodeGen/3dnow-builtins.c
>> >> cfe/trunk/test/CodeGen/x86_64-arguments.c
>> >>
>> >> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> >> URL: http://llvm.org/viewvc/llvm-
>> >>
>> project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=262688=262687=26268
>> >> 8=diff
>> >>
>> ==
>> >> 
>> >> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>> >> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar  3 23:26:16 2016
>> >> @@ -1857,6 +1857,17 @@ class X86_64ABIInfo : public ABIInfo {
>> >>  return !getTarget().getTriple().isOSDarwin();
>> >>}
>> >>
>> >> +  /// GCC classifies <1 x long long> as SSE but compatibility with
>> older
>> >> clang
>> >> +  // compilers require us to classify it as INTEGER.
>> >> +  bool classifyIntegerMMXAsSSE() const {
>> >> +const llvm::Triple  = getTarget().getTriple();
>> >> +if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
>> >> +  return false;
>> >> +if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10)
>> >> +  return false;
>> >> +return true;
>> >> +  }
>> >> +
>> >>X86AVXABILevel AVXLevel;
>> >>// Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit pointers
>> on
>> >>// 64-bit hardware.
>> >> @@ -2298,15 +2309,20 @@ void X86_64ABIInfo::classify(QualType Ty
>> >>if (EB_Lo != EB_Hi)
>> >>  Hi = Lo;
>> >>  } else if (Size == 64) {
>> >> +  QualType ElementType = VT->getElementType();
>> >> +
>> >>// gcc passes <1 x double> in memory. :(
>> >> -  if (VT->getElementType()-
>> >> >isSpecificBuiltinType(BuiltinType::Double))
>> >> +  if (ElementType->isSpecificBuiltinType(BuiltinType::Double))
>> >>  return;
>> >>
>> >> -  // gcc passes <1 x long long> as INTEGER.
>> >> -  if (VT->getElementType()-
>> >> >isSpecificBuiltinType(BuiltinType::LongLong) ||
>> >> -  VT->getElementType()-
>> >> >isSpecificBuiltinType(BuiltinType::ULongLong) ||
>> >> -  VT->getElementType()-
>> >isSpecificBuiltinType(BuiltinType::Long)
>> >> ||
>> >> -  VT->getElementType()-
>> >> >isSpecificBuiltinType(BuiltinType::ULong))
>> >> +  // gcc passes <1 x long long> as SSE but clang used to
>> >> unconditionally
>> >> +  // pass them as integer.  For platforms where clang is the de
>> facto
>> >> +  // platform compiler, we must continue to use integer.
>> >> +  if (!classifyIntegerMMXAsSSE() &&
>> >> +  (ElementType->isSpecificBuiltinType(BuiltinType::LongLong)
>> ||
>> >> +   ElementType->isSpecificBuiltinType(BuiltinType::ULongLong)
>> ||
>> >> +   ElementType->isSpecificBuiltinType(BuiltinType::Long) ||
>> >> +   ElementType->isSpecificBuiltinType(BuiltinType::ULong)))
>> >>  Current = Integer;
>> >>else
>> >>  Current = SSE;
>> >>
>> >> Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
>> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-
>> >> builtins.c?rev=262688=262687=262688=diff
>> >>
>> ==
>> >> 
>> >> --- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
>> >> +++ 

Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-04 Thread Jonathan B Coe via cfe-commits
jbcoe added a comment.

I think there are some minor issues with the tests, easily fixed. I wonder if 
the matchers can catch things inside implementation-defined inline namespaces 
like `std::_v1_::experimental::library_fundamentals_v1::string_view`.



Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:57
@@ +56,3 @@
+ast_matchers::internal::Matcher isASequence() {
+  return hasAnyName("::std::deque", "::std::forward_list", "::std::list",
+"::std::vector");

Will this (and similar checkers) handle inline namespaces?


Comment at: test/clang-tidy/misc-dangling-handle.cpp:73
@@ +72,3 @@
+  StringRef(const char*);  // NOLINT
+  StringRef(const std::string&);  // NOLINT
+};

What does `NOLINT` do here?


Comment at: test/clang-tidy/misc-dangling-handle.cpp:85
@@ +84,3 @@
+  std::string_view view_2 = ReturnsAString();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: std::basic_string_view outlives
+

This (and other) check-messages line looks truncated.


http://reviews.llvm.org/D17811



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


r262737 - Make TargetInfo store an actual DataLayout instead of a string.

2016-03-04 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Fri Mar  4 13:00:41 2016
New Revision: 262737

URL: http://llvm.org/viewvc/llvm-project?rev=262737=rev
Log:
Make TargetInfo store an actual DataLayout instead of a string.

Use it to calculate UserLabelPrefix, instead of specifying it (often
incorrectly).

Note that the *actual* user label prefix has always come from the
DataLayout, and is handled within LLVM. The main thing clang's
TargetInfo::UserLabelPrefix did was to set the #define value. Having
these be different from each-other is just silly.

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/lib/AST/Mangle.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Index/CodegenNameGenerator.cpp
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/unittests/Basic/SourceManagerTest.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp
cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=262737=262736=262737=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Mar  4 13:00:41 2016
@@ -21,13 +21,14 @@
 #include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/VersionTuple.h"
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/APInt.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/IR/DataLayout.h"
 #include "llvm/Support/DataTypes.h"
 #include 
 #include 
@@ -74,8 +75,7 @@ protected:
   unsigned short MaxVectorAlign;
   unsigned short MaxTLSAlign;
   unsigned short SimdDefaultAlign;
-  const char *DataLayoutString;
-  const char *UserLabelPrefix;
+  std::unique_ptr DataLayout;
   const char *MCountName;
   const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
 *LongDoubleFormat;
@@ -95,6 +95,10 @@ protected:
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple );
 
+  void resetDataLayout(StringRef DL) {
+DataLayout.reset(new llvm::DataLayout(DL));
+  }
+
 public:
   /// \brief Construct a target for the given options.
   ///
@@ -426,14 +430,6 @@ public:
 return PointerWidth;
   }
 
-  /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro,
-  /// which is the prefix given to user symbols by default.
-  ///
-  /// On most platforms this is "_", but it is "" on some, and "." on others.
-  const char *getUserLabelPrefix() const {
-return UserLabelPrefix;
-  }
-
   /// \brief Returns the name of the mcount instrumentation function.
   const char *getMCountName() const {
 return MCountName;
@@ -721,9 +717,9 @@ public:
 return Triple;
   }
 
-  const char *getDataLayoutString() const {
-assert(DataLayoutString && "Uninitialized DataLayoutString!");
-return DataLayoutString;
+  const llvm::DataLayout () const {
+assert(DataLayout && "Uninitialized DataLayout!");
+return *DataLayout;
   }
 
   struct GCCRegAlias {

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=262737=262736=262737=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Fri Mar  4 13:00:41 2016
@@ -35,8 +35,8 @@ namespace clang {
 
   void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions 
,
  const TargetOptions , const LangOptions ,
- StringRef TDesc, llvm::Module *M, BackendAction 
Action,
- raw_pwrite_stream *OS);
+ const llvm::DataLayout , llvm::Module *M,
+ BackendAction Action, raw_pwrite_stream *OS);
 }
 
 #endif

Modified: cfe/trunk/lib/AST/Mangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=262737=262736=262737=diff
==
--- cfe/trunk/lib/AST/Mangle.cpp (original)
+++ cfe/trunk/lib/AST/Mangle.cpp Fri Mar  4 13:00:41 2016
@@ -126,9 +126,9 @@ void MangleContext::mangleName(const Nam
 // llvm mangler on ELF is a nop, so we can just avoid adding the \01
 // marker.  We also 

Re: [PATCH] D17183: Make TargetInfo store an actual DataLayout instead of a string.

2016-03-04 Thread James Y Knight via cfe-commits
This revision was automatically updated to reflect the committed changes.
jyknight marked an inline comment as done.
Closed by commit rL262737: Make TargetInfo store an actual DataLayout instead 
of a string. (authored by jyknight).

Changed prior to commit:
  http://reviews.llvm.org/D17183?vs=47763=49841#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17183

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/include/clang/CodeGen/BackendUtil.h
  cfe/trunk/lib/AST/Mangle.cpp
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
  cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/lib/Index/CodegenNameGenerator.cpp
  cfe/trunk/test/Preprocessor/init.c
  cfe/trunk/unittests/Basic/SourceManagerTest.cpp
  cfe/trunk/unittests/Lex/LexerTest.cpp
  cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Index: cfe/trunk/lib/AST/Mangle.cpp
===
--- cfe/trunk/lib/AST/Mangle.cpp
+++ cfe/trunk/lib/AST/Mangle.cpp
@@ -126,9 +126,9 @@
 // llvm mangler on ELF is a nop, so we can just avoid adding the \01
 // marker.  We also avoid adding the marker if this is an alias for an
 // LLVM intrinsic.
-StringRef UserLabelPrefix =
-getASTContext().getTargetInfo().getUserLabelPrefix();
-if (!UserLabelPrefix.empty() && !ALA->getLabel().startswith("llvm."))
+char GlobalPrefix =
+getASTContext().getTargetInfo().getDataLayout().getGlobalPrefix();
+if (GlobalPrefix && !ALA->getLabel().startswith("llvm."))
   Out << '\01'; // LLVM IR Marker for __asm("foo")
 
 Out << ALA->getLabel();
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -102,9 +102,7 @@
 
 public:
   CloudABITargetInfo(const llvm::Triple )
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder , const LangOptions ,
@@ -284,8 +282,6 @@
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple )
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +323,6 @@
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +362,7 @@
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple )
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +384,7 @@
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -422,7 +412,6 @@
   }
 public:
   LinuxTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->WIntType = TargetInfo::UnsignedInt;
 
 switch (Triple.getArch()) {
@@ -467,7 +456,6 @@
   }
 public:
   NetBSDTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +476,6 @@
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +523,6 @@
   }
 public:
   BitrigTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +540,7 @@
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,13 +560,12 @@
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
 this->Int64Type = TargetInfo::SignedLongLong;
 this->SizeType = TargetInfo::UnsignedInt;
-this->DataLayoutString = "E-m:e-p:32:32-i64:64-n32:64";
+this->resetDataLayout("E-m:e-p:32:32-i64:64-n32:64");
   }
 };
 
@@ -604,7 +587,6 @@
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 // On PS4, do not honor explicit bit field alignment,
 // as in "__attribute__((aligned(2))) int b : 1;".
@@ -647,7 +629,6 @@

Re: [PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob added a comment.

Thanks for the quick review!  The test cases are the same as the CUDA version 
so it should be fine.


http://reviews.llvm.org/D17890



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


Re: r262691 - [MIPS] initFeatureMap() to handle empty string argument

2016-03-04 Thread Eric Christopher via cfe-commits
Test case?

On Fri, Mar 4, 2016, 4:02 AM Bhushan D. Attarde via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bhushan.attarde
> Date: Fri Mar  4 00:56:29 2016
> New Revision: 262691
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262691=rev
> Log:
> [MIPS] initFeatureMap() to handle empty string argument
>
> SUMMARY:
> This patch sets CPU string to its default value when it is not
> supplied by caller.
>
> Reviewers: vkalintiris, dsanders
> Subscribers: mohit.bhakkad, sagar, jaydeep, cfe-commits
> Differential Revision: http://reviews.llvm.org/D16139
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262691=262690=262691=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Mar  4 00:56:29 2016
> @@ -6689,6 +6689,8 @@ public:
>initFeatureMap(llvm::StringMap , DiagnosticsEngine
> ,
>   StringRef CPU,
>   const std::vector ) const
> override {
> +if (CPU.empty())
> +  CPU = getCPU();
>  if (CPU == "octeon")
>Features["mips64r2"] = Features["cnmips"] = true;
>  else
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262729 - [analyzer] Add diagnostic in ObjCDeallocChecker for use of -dealloc instead of -release.

2016-03-04 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Mar  4 12:09:58 2016
New Revision: 262729

URL: http://llvm.org/viewvc/llvm-project?rev=262729=rev
Log:
[analyzer] Add diagnostic in ObjCDeallocChecker for use of -dealloc instead of 
-release.

In dealloc methods, the analyzer now warns when -dealloc is called directly on
a synthesized retain/copy ivar instead of -release. This is intended to find 
mistakes of
the form:

- (void)dealloc {
  [_ivar dealloc]; // Mistaken call to -dealloc instead of -release

  [super dealloc];
}

rdar://problem/16227989

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/DeallocMissingRelease.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=262729=262728=262729=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Fri Mar  4 
12:09:58 2016
@@ -103,6 +103,7 @@ class ObjCDeallocChecker
 
   std::unique_ptr MissingReleaseBugType;
   std::unique_ptr ExtraReleaseBugType;
+  std::unique_ptr MistakenDeallocBugType;
 
 public:
   ObjCDeallocChecker();
@@ -130,14 +131,20 @@ private:
   bool diagnoseExtraRelease(SymbolRef ReleasedValue, const ObjCMethodCall ,
 CheckerContext ) const;
 
-  SymbolRef getValueExplicitlyReleased(const ObjCMethodCall ,
-  CheckerContext ) const;
+  bool diagnoseMistakenDealloc(SymbolRef DeallocedValue,
+   const ObjCMethodCall ,
+   CheckerContext ) const;
+
   SymbolRef getValueReleasedByNillingOut(const ObjCMethodCall ,
  CheckerContext ) const;
 
   const ObjCIvarRegion *getIvarRegionForIvarSymbol(SymbolRef IvarSym) const;
   SymbolRef getInstanceSymbolFromIvarSymbol(SymbolRef IvarSym) const;
 
+  const ObjCPropertyImplDecl*
+  findPropertyOnDeallocatingInstance(SymbolRef IvarSym,
+ CheckerContext ) const;
+
   ReleaseRequirement
   getDeallocReleaseRequirement(const ObjCPropertyImplDecl *PropImpl) const;
 
@@ -336,7 +343,14 @@ void ObjCDeallocChecker::checkPreObjCMes
   if (!instanceDeallocIsOnStack(C, DeallocedInstance))
 return;
 
-  SymbolRef ReleasedValue = getValueExplicitlyReleased(M, C);
+  SymbolRef ReleasedValue = nullptr;
+
+  if (M.getSelector() == ReleaseSel) {
+ReleasedValue = M.getReceiverSVal().getAsSymbol();
+  } else if (M.getSelector() == DeallocSel && !M.isReceiverSelfOrSuper()) {
+if (diagnoseMistakenDealloc(M.getReceiverSVal().getAsSymbol(), M, C))
+  return;
+  }
 
   if (ReleasedValue) {
 // An instance variable symbol was released with -release:
@@ -597,40 +611,55 @@ void ObjCDeallocChecker::diagnoseMissing
   assert(!LCtx->inTopFrame() || State->get().isEmpty());
 }
 
+/// Given a symbol, determine whether the symbol refers to an ivar on
+/// the top-most deallocating instance. If so, find the property for that
+/// ivar, if one exists. Otherwise return null.
+const ObjCPropertyImplDecl *
+ObjCDeallocChecker::findPropertyOnDeallocatingInstance(
+SymbolRef IvarSym, CheckerContext ) const {
+  SVal DeallocedInstance;
+  if (!isInInstanceDealloc(C, DeallocedInstance))
+return nullptr;
+
+  // Try to get the region from which the ivar value was loaded.
+  auto *IvarRegion = getIvarRegionForIvarSymbol(IvarSym);
+  if (!IvarRegion)
+return nullptr;
+
+  // Don't try to find the property if the ivar was not loaded from the
+  // given instance.
+  if (DeallocedInstance.castAs().getRegion() !=
+  IvarRegion->getSuperRegion())
+return nullptr;
+
+  const LocationContext *LCtx = C.getLocationContext();
+  const ObjCIvarDecl *IvarDecl = IvarRegion->getDecl();
+
+  const ObjCImplDecl *Container = getContainingObjCImpl(LCtx);
+  const ObjCPropertyImplDecl *PropImpl =
+  Container->FindPropertyImplIvarDecl(IvarDecl->getIdentifier());
+  return PropImpl;
+}
+
 /// Emits a warning if the current context is -dealloc and ReleasedValue
 /// must not be directly released in a -dealloc. Returns true if a diagnostic
 /// was emitted.
 bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue,
   const ObjCMethodCall ,
   CheckerContext ) const {
-  SVal DeallocedInstance;
-  if (!isInInstanceDealloc(C, DeallocedInstance))
-return false;
-
   // Try to get the region from which the the released value was loaded.
   // Note that, unlike diagnosing for missing releases, here we don't track
   // values that must not be released in the state. This is because even if
   // these values escape, it is still an error under the rules of MRR to
   // release them in -dealloc.
-  auto *ReleasedIvar = 

Re: [PATCH] D17682: [X86] AMD Bobcat CPU (btver1) doesn't support XSAVE

2016-03-04 Thread Craig Topper via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D17682



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


RE: r262688 - [X86] Pass __m64 types via SSE registers for GCC compatibility

2016-03-04 Thread Robinson, Paul via cfe-commits
> It'd be nice to have a comment here that mentions that the clang
> behavior which is being preserved for Darwin, FreeBSD, and PS4 is a
> *bug* which is being intentionally left unfixed. The previous clang
> behavior directly contradicts the x86_64 ABI document, which I believe
> all of these platforms claim to follow. :)

Well, PS4 uses x86_64 ABI as a base document, but we have a handful of
variances.  We had already documented this one to our licensees.  So,
from our perspective, it's not a bug, it's a feature. :-)  Describing
it as a bug (at least for PS4) would be technically incorrect.
--paulr

> 
> On Fri, Mar 4, 2016 at 2:03 AM, Robinson, Paul via cfe-commits
>  wrote:
> >> To: cfe-commits@lists.llvm.org
> >> Subject: r262688 - [X86] Pass __m64 types via SSE registers for GCC
> >> compatibility
> >>
> >> Author: majnemer
> >> Date: Thu Mar  3 23:26:16 2016
> >> New Revision: 262688
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=262688=rev
> >> Log:
> >> [X86] Pass __m64 types via SSE registers for GCC compatibility
> >>
> >> For compatibility with GCC, classify __m64 as SSE.
> >> However, clang is a platform compiler for certain targets; retain our
> >> old behavior on those targets: classify __m64 as integer.
> >
> > Thank you very much for that!
> > --paulr
> >
> >>
> >> This fixes PR26832.
> >>
> >> Modified:
> >> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >> cfe/trunk/test/CodeGen/3dnow-builtins.c
> >> cfe/trunk/test/CodeGen/x86_64-arguments.c
> >>
> >> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> >> URL: http://llvm.org/viewvc/llvm-
> >>
> project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=262688=262687=26268
> >> 8=diff
> >>
> ==
> >> 
> >> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar  3 23:26:16 2016
> >> @@ -1857,6 +1857,17 @@ class X86_64ABIInfo : public ABIInfo {
> >>  return !getTarget().getTriple().isOSDarwin();
> >>}
> >>
> >> +  /// GCC classifies <1 x long long> as SSE but compatibility with
> older
> >> clang
> >> +  // compilers require us to classify it as INTEGER.
> >> +  bool classifyIntegerMMXAsSSE() const {
> >> +const llvm::Triple  = getTarget().getTriple();
> >> +if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
> >> +  return false;
> >> +if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10)
> >> +  return false;
> >> +return true;
> >> +  }
> >> +
> >>X86AVXABILevel AVXLevel;
> >>// Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit pointers
> on
> >>// 64-bit hardware.
> >> @@ -2298,15 +2309,20 @@ void X86_64ABIInfo::classify(QualType Ty
> >>if (EB_Lo != EB_Hi)
> >>  Hi = Lo;
> >>  } else if (Size == 64) {
> >> +  QualType ElementType = VT->getElementType();
> >> +
> >>// gcc passes <1 x double> in memory. :(
> >> -  if (VT->getElementType()-
> >> >isSpecificBuiltinType(BuiltinType::Double))
> >> +  if (ElementType->isSpecificBuiltinType(BuiltinType::Double))
> >>  return;
> >>
> >> -  // gcc passes <1 x long long> as INTEGER.
> >> -  if (VT->getElementType()-
> >> >isSpecificBuiltinType(BuiltinType::LongLong) ||
> >> -  VT->getElementType()-
> >> >isSpecificBuiltinType(BuiltinType::ULongLong) ||
> >> -  VT->getElementType()-
> >isSpecificBuiltinType(BuiltinType::Long)
> >> ||
> >> -  VT->getElementType()-
> >> >isSpecificBuiltinType(BuiltinType::ULong))
> >> +  // gcc passes <1 x long long> as SSE but clang used to
> >> unconditionally
> >> +  // pass them as integer.  For platforms where clang is the de
> facto
> >> +  // platform compiler, we must continue to use integer.
> >> +  if (!classifyIntegerMMXAsSSE() &&
> >> +  (ElementType->isSpecificBuiltinType(BuiltinType::LongLong)
> ||
> >> +   ElementType->isSpecificBuiltinType(BuiltinType::ULongLong)
> ||
> >> +   ElementType->isSpecificBuiltinType(BuiltinType::Long) ||
> >> +   ElementType->isSpecificBuiltinType(BuiltinType::ULong)))
> >>  Current = Integer;
> >>else
> >>  Current = SSE;
> >>
> >> Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-
> >> builtins.c?rev=262688=262687=262688=diff
> >>
> ==
> >> 
> >> --- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
> >> +++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Mar  3 23:26:16 2016
> >> @@ -1,4 +1,5 @@
> >> -// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature
> >> +3dnowa -emit-llvm -o - -Werror | FileCheck %s
> >> +// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature
> >> +3dnowa -emit-llvm -o - -Werror | FileCheck %s -check-prefix=GCC -
> check-
> >> prefix=CHECK
> >> +// RUN: 

[PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added a reviewer: jlebar.
arpith-jacob added subscribers: carlo.bertolli, sfantao, caomhin, cfe-commits.

Support for CUDA printf is exploited to support printf for an NVPTX OpenMP 
device.

To reflect the support of both programming models, the file CGCUDABuiltin.cpp 
has been changed to CGGPUBuiltin.cpp, and the call EmitCUDADevicePrintfCallExpr 
has been changed to EmitGPUDevicePrintfCallExpr.

http://reviews.llvm.org/D17890

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/nvptx_target_printf_codegen.c

Index: test/OpenMP/nvptx_target_printf_codegen.c
===
--- /dev/null
+++ test/OpenMP/nvptx_target_printf_codegen.c
@@ -0,0 +1,90 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+#include 
+
+// expected-no-diagnostics
+extern int printf(const char *, ...);
+extern int vprintf(const char *, va_list);
+
+// Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
+int CheckSimple() {
+// CHECK: define {{.*}}void [[T1:@__omp_offloading_.+CheckSimple.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T1]]()
+// Alloca in entry block.
+// CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T1]]_worker()
+
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+// printf in master-only basic block.
+// CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
+const char* fmt = "%d %lld %f";
+// CHECK: [[PTR0:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 0
+// CHECK: store i32 1, i32* [[PTR0]], align 4
+// CHECK: [[PTR1:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 1
+// CHECK: store i64 2, i64* [[PTR1]], align 8
+// CHECK: [[PTR2:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 2
+
+// CHECK: store double 3.0{{[^,]*}}, double* [[PTR2]], align 8
+// CHECK: [[BUF_CAST:%[0-9]+]] = bitcast [[SIMPLE_PRINTF_TY]]* [[BUF]] to i8*
+// CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF_CAST]])
+printf(fmt, 1, 2ll, 3.0);
+  }
+
+  return 0;
+}
+
+void CheckNoArgs() {
+// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+CheckNoArgs.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T2]]()
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T2]]_worker()
+
+// printf in master-only basic block.
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+
+// CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
+printf("hello, world!");
+  }
+}
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+int foo;
+void CheckAllocaIsInEntryBlock() {
+// CHECK: define {{.*}}void [[T3:@__omp_offloading_.+CheckAllocaIsInEntryBlock.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T3]](
+// Alloca in entry block.
+// CHECK: alloca %printf_args
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T3]]_worker()
+
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, 

Re: r262688 - [X86] Pass __m64 types via SSE registers for GCC compatibility

2016-03-04 Thread James Y Knight via cfe-commits
It'd be nice to have a comment here that mentions that the clang
behavior which is being preserved for Darwin, FreeBSD, and PS4 is a
*bug* which is being intentionally left unfixed. The previous clang
behavior directly contradicts the x86_64 ABI document, which I believe
all of these platforms claim to follow. :)

On Fri, Mar 4, 2016 at 2:03 AM, Robinson, Paul via cfe-commits
 wrote:
>> To: cfe-commits@lists.llvm.org
>> Subject: r262688 - [X86] Pass __m64 types via SSE registers for GCC
>> compatibility
>>
>> Author: majnemer
>> Date: Thu Mar  3 23:26:16 2016
>> New Revision: 262688
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262688=rev
>> Log:
>> [X86] Pass __m64 types via SSE registers for GCC compatibility
>>
>> For compatibility with GCC, classify __m64 as SSE.
>> However, clang is a platform compiler for certain targets; retain our
>> old behavior on those targets: classify __m64 as integer.
>
> Thank you very much for that!
> --paulr
>
>>
>> This fixes PR26832.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> cfe/trunk/test/CodeGen/3dnow-builtins.c
>> cfe/trunk/test/CodeGen/x86_64-arguments.c
>>
>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=262688=262687=26268
>> 8=diff
>> ==
>> 
>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar  3 23:26:16 2016
>> @@ -1857,6 +1857,17 @@ class X86_64ABIInfo : public ABIInfo {
>>  return !getTarget().getTriple().isOSDarwin();
>>}
>>
>> +  /// GCC classifies <1 x long long> as SSE but compatibility with older
>> clang
>> +  // compilers require us to classify it as INTEGER.
>> +  bool classifyIntegerMMXAsSSE() const {
>> +const llvm::Triple  = getTarget().getTriple();
>> +if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
>> +  return false;
>> +if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10)
>> +  return false;
>> +return true;
>> +  }
>> +
>>X86AVXABILevel AVXLevel;
>>// Some ABIs (e.g. X32 ABI and Native Client OS) use 32 bit pointers on
>>// 64-bit hardware.
>> @@ -2298,15 +2309,20 @@ void X86_64ABIInfo::classify(QualType Ty
>>if (EB_Lo != EB_Hi)
>>  Hi = Lo;
>>  } else if (Size == 64) {
>> +  QualType ElementType = VT->getElementType();
>> +
>>// gcc passes <1 x double> in memory. :(
>> -  if (VT->getElementType()-
>> >isSpecificBuiltinType(BuiltinType::Double))
>> +  if (ElementType->isSpecificBuiltinType(BuiltinType::Double))
>>  return;
>>
>> -  // gcc passes <1 x long long> as INTEGER.
>> -  if (VT->getElementType()-
>> >isSpecificBuiltinType(BuiltinType::LongLong) ||
>> -  VT->getElementType()-
>> >isSpecificBuiltinType(BuiltinType::ULongLong) ||
>> -  VT->getElementType()->isSpecificBuiltinType(BuiltinType::Long)
>> ||
>> -  VT->getElementType()-
>> >isSpecificBuiltinType(BuiltinType::ULong))
>> +  // gcc passes <1 x long long> as SSE but clang used to
>> unconditionally
>> +  // pass them as integer.  For platforms where clang is the de facto
>> +  // platform compiler, we must continue to use integer.
>> +  if (!classifyIntegerMMXAsSSE() &&
>> +  (ElementType->isSpecificBuiltinType(BuiltinType::LongLong) ||
>> +   ElementType->isSpecificBuiltinType(BuiltinType::ULongLong) ||
>> +   ElementType->isSpecificBuiltinType(BuiltinType::Long) ||
>> +   ElementType->isSpecificBuiltinType(BuiltinType::ULong)))
>>  Current = Integer;
>>else
>>  Current = SSE;
>>
>> Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-
>> builtins.c?rev=262688=262687=262688=diff
>> ==
>> 
>> --- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
>> +++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Mar  3 23:26:16 2016
>> @@ -1,4 +1,5 @@
>> -// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature
>> +3dnowa -emit-llvm -o - -Werror | FileCheck %s
>> +// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature
>> +3dnowa -emit-llvm -o - -Werror | FileCheck %s -check-prefix=GCC -check-
>> prefix=CHECK
>> +// RUN: %clang_cc1 %s -triple=x86_64-scei-ps4 -target-feature +3dnowa -
>> emit-llvm -o - -Werror | FileCheck %s -check-prefix=PS4 -check-
>> prefix=CHECK
>>
>>  // Don't include mm_malloc.h, it's system specific.
>>  #define __MM_MALLOC_H
>> @@ -6,151 +7,176 @@
>>  #include 
>>
>>  __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
>> -  // CHECK-LABEL: define i64 @test_m_pavgusb
>> +  // PS4-LABEL: define i64 @test_m_pavgusb
>> +  // GCC-LABEL: define double @test_m_pavgusb
>>// CHECK: @llvm.x86.3dnow.pavgusb
>>return 

Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-03-04 Thread Samuel Antao via cfe-commits
sfantao marked an inline comment as done.


Comment at: lib/Sema/SemaOpenMP.cpp:9127
@@ +9126,3 @@
+// whose base type is \a BaseQTy.
+static bool CheckArrayExpressionDoesNotReferToUnitySize(Sema ,
+   const Expr *E,

Sorry, my bad. It is fixed in the new diff.




http://reviews.llvm.org/D17547



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


Re: [PATCH] D17816: [PPC] FE support for generating VSX [negated] absolute value instructions

2016-03-04 Thread amehsan via cfe-commits
amehsan updated this revision to Diff 49822.
amehsan added a comment.

added -ferror-limit 0 to the command line for no-altivec test.
fixed indentation of RUN commands
confirmed that all tests pass in a release and minrelsize build types 
changed {{[0-9]*}} to {{.*}} (it was fine but no need to put a restrictions in 
the tests that we do not care about).


http://reviews.llvm.org/D17816

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -29,6 +29,14 @@
 // CHECK-LABEL: define void @test1
 // CHECK-LE-LABEL: define void @test1
 
+  res_vf = vec_abs(vf);
+// CHECK: call <4 x float> @llvm.fabs.v4f32(<4 x float> %{{[0-9]*}})
+// CHECK-LE: call <4 x float> @llvm.fabs.v4f32(<4 x float> %{{[0-9]*}})
+
+  dummy();
+// CHECK: call void @dummy()
+// CHECK-LE: call void @dummy()
+
   res_vd = vec_add(vd, vd);
 // CHECK: fadd <2 x double>
 // CHECK-LE: fadd <2 x double>
Index: test/CodeGen/builtins-ppc-p8vector.c
===
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -73,10 +73,10 @@
 // CHECK-PPC: error: call to 'vec_abs' is ambiguous
 
   res_vd = vec_abs(vda);
-// CHECK: store <2 x i64> , <2 x i64>*
-// CHECK: and <2 x i64>
-// CHECK-LE: store <2 x i64> , <2 x i64>*
-// CHECK-LE: and <2 x i64>
+// CHECK: call <2 x double> @llvm.fabs.v2f64(<2 x double> %{{.*}})
+// CHECK: store <2 x double> %{{.*}}, <2 x double>* @res_vd
+// CHECK-LE: call <2 x double> @llvm.fabs.v2f64(<2 x double> %{{.*}})
+// CHECK-LE: store <2 x double> %{{.*}}, <2 x double>* @res_vd
 // CHECK-PPC: error: call to 'vec_abs' is ambiguous
 
   /* vec_add */
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -1,7 +1,13 @@
 // REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -faltivec -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE
+// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+// RUN: %clang_cc1 -faltivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+// RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s -check-prefix=CHECK-LE
+// RUN: not %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:-ferror-limit 0 -o - 2>&1 \
+// RUN:| FileCheck %s -check-prefix=CHECK-NOALTIVEC
 
 vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 };
 vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16 };
@@ -27,6 +33,8 @@
 vector unsigned int res_vui;
 vector float res_vf;
 
+// CHECK-NOALTIVEC: error: unknown type name 'vector'
+
 signed char param_sc;
 unsigned char param_uc;
 short param_s;
@@ -66,8 +74,16 @@
 // CHECK-LE: @llvm.ppc.altivec.vmaxsw
 
   vf = vec_abs(vf);
-// CHECK: and <4 x i32>
-// CHECK-LE: and <4 x i32>
+// CHECK: bitcast <4 x float> %{{.*}} to <4 x i32>
+// CHECK: and <4 x i32> {{.*}}, 
+// CHECK: bitcast <4 x i32> %{{.*}} to <4 x float>
+// CHECK: store <4 x float> %{{.*}}, <4 x float>* @vf
+// CHECK-LE: bitcast <4 x float> %{{.*}} to <4 x i32>
+// CHECK-LE: and <4 x i32> {{.*}}, 
+// CHECK-LE: bitcast <4 x i32> %{{.*}} to <4 x float>
+// CHECK-LE: store <4 x float> %{{.*}}, <4 x float>* @vf
+// CHECK-NOALTIVEC: error: use of undeclared identifier 'vf'
+// CHECK-NOALTIVEC: vf = vec_abs(vf) 
 
   /* vec_abs */
   vsc = vec_abss(vsc);
Index: lib/Headers/altivec.h
===
--- lib/Headers/altivec.h
+++ lib/Headers/altivec.h
@@ -124,16 +124,18 @@
 #endif
 
 static vector float __ATTRS_o_ai vec_abs(vector float __a) {
+#ifdef __VSX__
+  return __builtin_vsx_xvabssp(__a);
+#else
   vector unsigned int __res =
   (vector unsigned int)__a & (vector unsigned int)(0x7FFF);
   return (vector float)__res;
+#endif
 }
 
 #if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 static vector double __ATTRS_o_ai vec_abs(vector double __a) {
-  vector unsigned long long __res = { 0x7FFF, 0x7FFF };
-  __res &= (vector unsigned int)__a;
-  return (vector double)__res;
+  return __builtin_vsx_xvabsdp(__a);
 }
 #endif
 
Index: lib/CodeGen/CGBuiltin.cpp

Re: [PATCH] D17816: [PPC] FE support for generating VSX [negated] absolute value instructions

2016-03-04 Thread amehsan via cfe-commits
amehsan marked 4 inline comments as done.
amehsan added a comment.

http://reviews.llvm.org/D17816



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-04 Thread Craig, Ben via cfe-commits

On 3/4/2016 6:23 AM, Joerg Sonnenberger via cfe-commits wrote:

On Thu, Mar 03, 2016 at 04:50:11PM -0800, Nico Weber via cfe-commits wrote:

On Thu, Mar 3, 2016 at 4:28 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:


On Thu, Mar 03, 2016 at 02:09:17PM -0800, Nico Weber via cfe-commits wrote:

On Thu, Mar 3, 2016 at 1:50 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:


On Thu, Mar 03, 2016 at 07:39:04PM +, Weiming Zhao via cfe-commits
wrote:

Change the option name to -ffile-macro-prefix-to-remove

This still sounds to me like a solution for a very restricted part of a
much more generic problem...


What do you mean?

Storing only the base name of file names is a strict subset of __FILE__
transformations. As mentioned in the linked GCC PR, other uses are
creating build location independent output for larger software projects
etc. For that, reducing to the base name is not an option as it removes
too much information.


But ffile-macro-prefix-to-remove has a general prefix arg, which you can
set to your build dir. This isn't just a "get me the basename" flag (?)

It doesn't help to make sure that path names are always using /usr/src
or src/ and build/ without requiring those to be part of the build
layout. Another instance not handled is symlink trees for controlling
access, where you still want to use the original path etc.

This isn't changing the defaults.  In addition, you could have a mix of 
files in the same binary, some with ffile-macro-prefix-to-remove set, 
and some without.  In cases where the user wants to be explicit about 
full name vs. base name in the source, this patch also provides 
__CLANG_FILE_BASENAME__.


There doesn't seem to be one approach to improve all of the existing use 
cases.  This patch provides two independent tools that can be used to 
improve many of the use cases.


--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


[libcxxabi] r262717 - Reducing stack usage of test

2016-03-04 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Fri Mar  4 08:25:13 2016
New Revision: 262717

URL: http://llvm.org/viewvc/llvm-project?rev=262717=rev
Log:
Reducing stack usage of test

This test has a lot of classes with large amounts of manually inserted padding 
in them, presumably to prevent various optimizations. The test then creates 
lots of these objects on the stack. On embedded targets, this was usually 
enough to overflow the stack.

I moved the objects to global / namespace scope. Since the tests are each in 
their own namespace, there should be no cross-test conflicts.

Modified:
libcxxabi/trunk/test/dynamic_cast14.pass.cpp

Modified: libcxxabi/trunk/test/dynamic_cast14.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/dynamic_cast14.pass.cpp?rev=262717=262716=262717=diff
==
--- libcxxabi/trunk/test/dynamic_cast14.pass.cpp (original)
+++ libcxxabi/trunk/test/dynamic_cast14.pass.cpp Fri Mar  4 08:25:13 2016
@@ -213,20 +213,20 @@ struct A13
 A13* getA13() {return this;}
 };
 
+A3 a3;
+A4 a4;
+A5 a5;
+A6 a6;
+A7 a7;
+A8 a8;
+A9 a9;
+A10 a10;
+A11 a11;
+A12 a12;
+A13 a13;
+
 void test()
 {
-A3 a3;
-A4 a4;
-A5 a5;
-A6 a6;
-A7 a7;
-A8 a8;
-A9 a9;
-A10 a10;
-A11 a11;
-A12 a12;
-A13 a13;
-
 assert(dynamic_cast(a3.getA1_3()) == a3.getA3());
 assert(dynamic_cast(a3.getA2()) == a3.getA3());
 
@@ -934,20 +934,20 @@ struct A13
 A13* getA13() {return this;}
 };
 
+A3 a3;
+A4 a4;
+A5 a5;
+A6 a6;
+A7 a7;
+A8 a8;
+A9 a9;
+A10 a10;
+A11 a11;
+A12 a12;
+A13 a13;
+
 void test()
 {
-A3 a3;
-A4 a4;
-A5 a5;
-A6 a6;
-A7 a7;
-A8 a8;
-A9 a9;
-A10 a10;
-A11 a11;
-A12 a12;
-A13 a13;
-
 assert(dynamic_cast(a3.getA1_3()) == 0);
 assert(dynamic_cast(a3.getA2()) == a3.getA3());
 
@@ -1655,20 +1655,20 @@ struct A13
 A13* getA13() {return this;}
 };
 
+A3 a3;
+A4 a4;
+A5 a5;
+A6 a6;
+A7 a7;
+A8 a8;
+A9 a9;
+A10 a10;
+A11 a11;
+A12 a12;
+A13 a13;
+
 void test()
 {
-A3 a3;
-A4 a4;
-A5 a5;
-A6 a6;
-A7 a7;
-A8 a8;
-A9 a9;
-A10 a10;
-A11 a11;
-A12 a12;
-A13 a13;
-
 assert(dynamic_cast(a3.getA1_3()) == a3.getA3());
 assert(dynamic_cast(a3.getA2()) == 0);
 


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


r262716 - Move class into anonymous namespace. NFC.

2016-03-04 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Mar  4 08:18:52 2016
New Revision: 262716

URL: http://llvm.org/viewvc/llvm-project?rev=262716=rev
Log:
Move class into anonymous namespace. NFC.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=262716=262715=262716=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Fri Mar  
4 08:18:52 2016
@@ -61,6 +61,7 @@ private:
 // SymbolRef for the receiver.
 REGISTER_SET_WITH_PROGRAMSTATE(CalledSuperDealloc, SymbolRef)
 
+namespace {
 class SuperDeallocBRVisitor final
 : public BugReporterVisitorImpl {
 
@@ -81,6 +82,7 @@ public:
 ID.Add(ReceiverSymbol);
   }
 };
+} // End anonymous namespace.
 
 void ObjCSuperDeallocChecker::checkPreObjCMessage(const ObjCMethodCall ,
   CheckerContext ) const {


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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-04 Thread Joerg Sonnenberger via cfe-commits
On Thu, Mar 03, 2016 at 04:50:11PM -0800, Nico Weber via cfe-commits wrote:
> On Thu, Mar 3, 2016 at 4:28 PM, Joerg Sonnenberger via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > On Thu, Mar 03, 2016 at 02:09:17PM -0800, Nico Weber via cfe-commits wrote:
> > > On Thu, Mar 3, 2016 at 1:50 PM, Joerg Sonnenberger via cfe-commits <
> > > cfe-commits@lists.llvm.org> wrote:
> > >
> > > > On Thu, Mar 03, 2016 at 07:39:04PM +, Weiming Zhao via cfe-commits
> > > > wrote:
> > > > > Change the option name to -ffile-macro-prefix-to-remove
> > > >
> > > > This still sounds to me like a solution for a very restricted part of a
> > > > much more generic problem...
> > > >
> > >
> > > What do you mean?
> >
> > Storing only the base name of file names is a strict subset of __FILE__
> > transformations. As mentioned in the linked GCC PR, other uses are
> > creating build location independent output for larger software projects
> > etc. For that, reducing to the base name is not an option as it removes
> > too much information.
> >
> 
> But ffile-macro-prefix-to-remove has a general prefix arg, which you can
> set to your build dir. This isn't just a "get me the basename" flag (?)

It doesn't help to make sure that path names are always using /usr/src
or src/ and build/ without requiring those to be part of the build
layout. Another instance not handled is symlink trees for controlling
access, where you still want to use the original path etc.

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


r262691 - [MIPS] initFeatureMap() to handle empty string argument

2016-03-04 Thread Bhushan D. Attarde via cfe-commits
Author: bhushan.attarde
Date: Fri Mar  4 00:56:29 2016
New Revision: 262691

URL: http://llvm.org/viewvc/llvm-project?rev=262691=rev
Log:
[MIPS] initFeatureMap() to handle empty string argument

SUMMARY:
This patch sets CPU string to its default value when it is not supplied by 
caller.

Reviewers: vkalintiris, dsanders
Subscribers: mohit.bhakkad, sagar, jaydeep, cfe-commits
Differential Revision: http://reviews.llvm.org/D16139

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262691=262690=262691=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Mar  4 00:56:29 2016
@@ -6689,6 +6689,8 @@ public:
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
  const std::vector ) const override {
+if (CPU.empty())
+  CPU = getCPU();
 if (CPU == "octeon")
   Features["mips64r2"] = Features["cnmips"] = true;
 else


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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49807.
ioeric added a comment.

- removed unused forward declarations.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,71 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =
+  "auto a = new MyType012345678901234567890123456789();\n"
+  "g(iii, nullptr,\n"
+  "  jjj, nullptr,\n"
+  "  kkk, nullptr,\n"
+  "  mmm);\n"
+  "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 38, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 40),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 43),
+  1, "nullptr"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ(Expected, Context.getRewrittenText(ID));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11215,7 +11215,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-04 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:237
@@ +236,3 @@
+/// related to the same file entry are put into the same vector.
+FileToReplacementsMap groupReplacementsByFile(const Replacements ,
+  FileManager );

djasper wrote:
> Hm... I am not sure here. I think I would implement this entirely without 
> FileManager or FileEntries, just based on the names of the file. I guess you 
> are worried about different paths leading to the same FileEntry?
You are right. Getting rid of `FileManger` would make more sense for users. And 
yes, I was worrying about different names leading to the same entry. Do we need 
to worry about this case? Or we can assume Replacements for the same file 
always have the same file path? 


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49806.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Moved formatAndApplyAllReplacements to Tooling/Refactoing; added an 
overloaded version of formatAndApplyAllReplacements that takes no Style; 
groupReplacementsByFile groups Replacements by filename instead of FileEntry.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,71 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =
+  "auto a = new MyType012345678901234567890123456789();\n"
+  "g(iii, nullptr,\n"
+  "  jjj, nullptr,\n"
+  "  kkk, nullptr,\n"
+  "  mmm);\n"
+  "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 38, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 40),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 43),
+  1, "nullptr"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ(Expected, Context.getRewrittenText(ID));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- 

r262700 - [SemaExprCXX] Avoid calling isInSystemHeader for invalid source locations

2016-03-04 Thread Pavel Labath via cfe-commits
Author: labath
Date: Fri Mar  4 04:00:08 2016
New Revision: 262700

URL: http://llvm.org/viewvc/llvm-project?rev=262700=rev
Log:
[SemaExprCXX] Avoid calling isInSystemHeader for invalid source locations

Summary:
While diagnosing a CXXNewExpr warning, we were calling isInSystemHeader(), 
which expect to be
called with a valid source location. This causes an assertion failure if the 
location is unknown.
A quick grep shows it's not without precedent to guard calls to the function 
with a
"Loc.isValid()".

This fixes a test failure in LLDB, which always creates object with invalid 
source locations as it
does not (always) have access to the source.

Reviewers: nlewycky

Subscribers: lldb-commits, cfe-commits

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

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

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=262700=262699=262700=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Mar  4 04:00:08 2016
@@ -1551,7 +1551,8 @@ Sema::BuildCXXNew(SourceRange Range, boo
   // new.
   if (PlacementArgs.empty() && OperatorNew &&
   (OperatorNew->isImplicit() ||
-   getSourceManager().isInSystemHeader(OperatorNew->getLocStart( {
+   (OperatorNew->getLocStart().isValid() &&
+getSourceManager().isInSystemHeader(OperatorNew->getLocStart() {
 if (unsigned Align = 
Context.getPreferredTypeAlign(AllocType.getTypePtr())){
   unsigned SuitableAlign = Context.getTargetInfo().getSuitableAlign();
   if (Align > SuitableAlign)


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


r262699 - [OPENMP 4.0] Codegen for 'declare reduction' construct.

2016-03-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Mar  4 03:22:22 2016
New Revision: 262699

URL: http://llvm.org/viewvc/llvm-project?rev=262699=rev
Log:
[OPENMP 4.0] Codegen for 'declare reduction' construct.

Emit function for 'combiner' part of 'declare reduction' construct and
'initialilzer' part, if any.

Added:
cfe/trunk/test/OpenMP/declare_reduction_codegen.c
cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/OpenMP/threadprivate_codegen.cpp

Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=262699=262698=262699=diff
==
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Fri Mar  4 03:22:22 2016
@@ -99,7 +99,7 @@ public:
 /// \endcode
 ///
 /// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an 
initializer.
-class OMPDeclareReductionDecl final : public NamedDecl, public DeclContext {
+class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext {
 private:
   friend class ASTDeclReader;
   /// \brief Combiner for declare reduction construct.
@@ -110,21 +110,18 @@ private:
   /// scope with the same name. Required for proper templates instantiation if
   /// the declare reduction construct is declared inside compound statement.
   LazyDeclPtr PrevDeclInScope;
-  /// \brief Type of declare reduction construct.
-  QualType Ty;
 
   virtual void anchor();
 
   OMPDeclareReductionDecl(Kind DK, DeclContext *DC, SourceLocation L,
   DeclarationName Name, QualType Ty,
   OMPDeclareReductionDecl *PrevDeclInScope)
-  : NamedDecl(DK, DC, L, Name), DeclContext(DK), Combiner(nullptr),
-Initializer(nullptr), PrevDeclInScope(PrevDeclInScope), Ty(Ty) {}
+  : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr),
+Initializer(nullptr), PrevDeclInScope(PrevDeclInScope) {}
 
   void setPrevDeclInScope(OMPDeclareReductionDecl *Prev) {
 PrevDeclInScope = Prev;
   }
-  void setType(QualType T) { Ty = T; }
 
 public:
   /// \brief Create declare reduction node.
@@ -153,8 +150,6 @@ public:
   OMPDeclareReductionDecl *getPrevDeclInScope();
   const OMPDeclareReductionDecl *getPrevDeclInScope() const;
 
-  QualType getType() const { return Ty; }
-
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == OMPDeclareReduction; }
   static DeclContext *castToDeclContext(const OMPDeclareReductionDecl *D) {

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=262699=262698=262699=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Fri Mar  4 03:22:22 2016
@@ -17,6 +17,7 @@
 
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclOpenMP.h"
 #include "clang/Basic/ABI.h"
 
 namespace clang {
@@ -43,6 +44,7 @@ public:
   GlobalDecl(const BlockDecl *D) { Init(D); }
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
+  GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
 
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
   : Value(D, Type) {}

Modified: cfe/trunk/include/clang/Basic/DeclNodes.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DeclNodes.td?rev=262699=262698=262699=diff
==
--- cfe/trunk/include/clang/Basic/DeclNodes.td (original)
+++ cfe/trunk/include/clang/Basic/DeclNodes.td Fri Mar  4 03:22:22 2016
@@ -37,6 +37,7 @@ def Named : Decl<1>;
 def EnumConstant : DDecl;
 def UnresolvedUsingValue : DDecl;
 def IndirectField : DDecl;
+def OMPDeclareReduction : DDecl, DeclContext;
 def Declarator : DDecl;
   def Field : DDecl;
 def ObjCIvar : DDecl;
@@ -75,7 +76,6 @@ def Named : Decl<1>;
   def ObjCImplementation : DDecl;
   def ObjCProperty : DDecl;
   def ObjCCompatibleAlias : DDecl;
-  def OMPDeclareReduction : DDecl, DeclContext;
 def LinkageSpec : Decl, 

Re: [PATCH] D17849: [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions.

2016-03-04 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262698: [clang-tidy] Make 'modernize-use-nullptr' check work 
on multiple nested… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17849?vs=49736=49802#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17849

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
@@ -327,6 +327,21 @@
   // CHECK-FIXES: const int *const_p6 = static_cast(t ? t : 
static_cast(nullptr));
 }
 
+void test_nested_implicit_cast_expr() {
+  int func0(void*, void*);
+  int func1(int, void*, void*);
+
+  (double)func1(0, 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr
+  // CHECK-FIXES: (double)func1(0, nullptr, nullptr);
+  (double)func1(func0(0, 0), 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr
+  // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr);
+}
 
 // FIXME: currently, the check doesn't work as it should with templates.
 template
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -252,7 +252,7 @@
 }
 replaceWithNullptr(Check, SM, StartLoc, EndLoc);
 
-return skipSubTree();
+return true;
   }
 
 private:


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
@@ -327,6 +327,21 @@
   // CHECK-FIXES: const int *const_p6 = static_cast(t ? t : static_cast(nullptr));
 }
 
+void test_nested_implicit_cast_expr() {
+  int func0(void*, void*);
+  int func1(int, void*, void*);
+
+  (double)func1(0, 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr
+  // CHECK-FIXES: (double)func1(0, nullptr, nullptr);
+  (double)func1(func0(0, 0), 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr
+  // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr);
+}
 
 // FIXME: currently, the check doesn't work as it should with templates.
 template
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -252,7 +252,7 @@
 }
 replaceWithNullptr(Check, SM, StartLoc, EndLoc);
 
-return skipSubTree();
+return true;
   }
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r262698 - [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions.

2016-03-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Mar  4 02:55:54 2016
New Revision: 262698

URL: http://llvm.org/viewvc/llvm-project?rev=262698=rev
Log:
[clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested 
implicit cast expressions.

Summary:
For some test cases like:

```
 int func(int, void*, void*);
(double)func(0, 0, 0);
```

The AST contains several `ImplicitCastExpr`s, so we should not only check on 
the first sub expression.

```
 `-CStyleCastExpr 0x7fe43a088938  'double' 
  `-ImplicitCastExpr 0x7fe43a088920  'double' 

`-CallExpr 0x7fe43a0888a0  'int'
  |-ImplicitCastExpr 0x7fe43a08  'int (*)(int, void *, void 
*)' 
  | `-DeclRefExpr 0x7fe43a0887d8  'int (int, void *, void *)' 
lvalue Function 0x7fe43a0886f0 'func1' 'int (int, void *, void *)'
  |-IntegerLiteral 0x7fe43a088800  'int' 0
  |-ImplicitCastExpr 0x7fe43a0888e0  'void *' 
  | `-IntegerLiteral 0x7fe43a088820  'int' 0
  `-ImplicitCastExpr 0x7fe43a0888f8  'void *' 
`-IntegerLiteral 0x7fe43a088840  'int' 0
```

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=262698=262697=262698=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Mar  4 
02:55:54 2016
@@ -252,7 +252,7 @@ public:
 }
 replaceWithNullptr(Check, SM, StartLoc, EndLoc);
 
-return skipSubTree();
+return true;
   }
 
 private:

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp?rev=262698=262697=262698=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp Fri 
Mar  4 02:55:54 2016
@@ -327,6 +327,21 @@ void test_const_pointers() {
   // CHECK-FIXES: const int *const_p6 = static_cast(t ? t : 
static_cast(nullptr));
 }
 
+void test_nested_implicit_cast_expr() {
+  int func0(void*, void*);
+  int func1(int, void*, void*);
+
+  (double)func1(0, 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr
+  // CHECK-FIXES: (double)func1(0, nullptr, nullptr);
+  (double)func1(func0(0, 0), 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr
+  // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr);
+}
 
 // FIXME: currently, the check doesn't work as it should with templates.
 template


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


r262697 - [Coverage] Fix the start/end locations of switch statements

2016-03-04 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Mar  4 02:07:15 2016
New Revision: 262697

URL: http://llvm.org/viewvc/llvm-project?rev=262697=rev
Log:
[Coverage] Fix the start/end locations of switch statements

While pushing switch statements onto the region stack we neglected to
specify their start/end locations. This results in a crash (PR26825) if
we end up in nested macro expansions without enough information to
handle the relevant file exits.

I added a test in switchmacro.c and fixed up a bunch of incorrect CHECK
lines that specify strange end locations for switches.

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/switch.c
cfe/trunk/test/CoverageMapping/switchmacro.c

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=262697=262696=262697=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Fri Mar  4 02:07:15 2016
@@ -776,7 +776,7 @@ struct CounterCoverageMappingBuilder
   BreakContinueStack.back().ContinueCount, BC.ContinueCount);
 
 Counter ExitCount = getRegionCounter(S);
-pushRegion(ExitCount);
+pushRegion(ExitCount, getStart(S), getEnd(S));
   }
 
   void VisitSwitchCase(const SwitchCase *S) {

Modified: cfe/trunk/test/CoverageMapping/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/switch.c?rev=262697=262696=262697=diff
==
--- cfe/trunk/test/CoverageMapping/switch.c (original)
+++ cfe/trunk/test/CoverageMapping/switch.c Fri Mar  4 02:07:15 2016
@@ -1,44 +1,44 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck 
%s
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:4 = #1
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
   }
-  int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
+  int x = 0;
 }
 
 void nop() {}
 
 // CHECK: bar
 void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
-  switch (i)
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:6 = #1
 ;   // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:6 = 0
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+16]]:2 = #1
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:4 = #2
   }
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #2
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0
 
-  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:2 = #3
+  switch (i)// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #4
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5
 nop();
 
-  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
+  switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:4 = #6
 nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
-  nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
+  nop();
 }
 
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
   int i = 0;
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+9]]:4 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
 i = 1;
 break;
@@ -48,7 +48,7 @@ int main() {// CHECK-NEXT: File
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;
   }
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:4 = #5
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
@@ -58,7 +58,7 @@ int main() {// CHECK-NEXT: File
 break;
   }
 
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:4 = #9
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = 
(#10 + #11)
 i = 11;
@@ -67,7 +67,7 @@ int