Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

I just wrote how I tested this in the bugzilla report page below:
https://llvm.org/bugs/show_bug.cgi?id=28660


https://reviews.llvm.org/D22666



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Well, in this case `SourceMgr` should be removed...

Please accept patches so fast; at least let the others take a look at it.


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

*please don't accept patches so fast


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

  if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
return setResult(RD, TypeBeginLoc, TypeEndLoc);

This isn't needed, too...


https://reviews.llvm.org/D22881



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


[PATCH] D22904: Fix two bugs for musl-libc on ARM

2016-07-28 Thread Lei Zhang via cfe-commits
zlei created this revision.
zlei added reviewers: cfe-commits, rafael.
Herald added subscribers: samparker, srhines, danalbert, tberghammer, rengolin, 
aemerson.

Bug #1: triples like `armv7-pc-linux-musl` uses wrong linker name 
`ld-musl-armv7.so.1`; the right name should be `ld-musl-arm.so.1`, disregarding 
the subarch field.

Bug #2: when compiler option `-mhard-float` is used, we should use the 
"hardfloat" linker, no matter whether the triple itself mentions "hardfloat".

https://reviews.llvm.org/D22904

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4262,21 +4262,29 @@
 
   const enum Distro Distro = DetectDistro(getDriver(), Arch);
 
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";
-  else if (Triple.isMusl()) {
+  } else if (Triple.isMusl()) {
 std::string ArchName;
+bool IsArm = false;
+
 switch (Arch) {
+case llvm::Triple::arm:
 case llvm::Triple::thumb:
   ArchName = "arm";
+  IsArm = true;
   break;
+case llvm::Triple::armeb:
 case llvm::Triple::thumbeb:
   ArchName = "armeb";
+  IsArm = true;
   break;
 default:
   ArchName = Triple.getArchName().str();
 }
-if (Triple.getEnvironment() == llvm::Triple::MuslEABIHF)
+if (IsArm &&
+(Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
+ tools::arm::getARMFloatABI(*this, Args) == 
tools::arm::FloatABI::Hard))
   ArchName += "hf";
 
 return "/lib/ld-musl-" + ArchName + ".so.1";


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4262,21 +4262,29 @@
 
   const enum Distro Distro = DetectDistro(getDriver(), Arch);
 
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
 return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
-  else if (Triple.isMusl()) {
+  } else if (Triple.isMusl()) {
 std::string ArchName;
+bool IsArm = false;
+
 switch (Arch) {
+case llvm::Triple::arm:
 case llvm::Triple::thumb:
   ArchName = "arm";
+  IsArm = true;
   break;
+case llvm::Triple::armeb:
 case llvm::Triple::thumbeb:
   ArchName = "armeb";
+  IsArm = true;
   break;
 default:
   ArchName = Triple.getArchName().str();
 }
-if (Triple.getEnvironment() == llvm::Triple::MuslEABIHF)
+if (IsArm &&
+(Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
+ tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard))
   ArchName += "hf";
 
 return "/lib/ld-musl-" + ArchName + ".so.1";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

inside setResult  Decl->getQualifiedNameAsString() is used
so RD should not be nullptr there.
we get there in the newly added test.


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D22881#498911, @alexshap wrote:

> inside setResult  Decl->getQualifiedNameAsString() is used
>  so RD should not be nullptr there.
>  we get there in the newly added test.


It is used, but then we should add this check to setResult, don't we? Otherwise 
it only works for TypeLocs.


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

i took a look at handleNestedNameSpecifierLoc:

const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
if (Decl) {
 setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
}

and added this check to VisitTypeLoc.

the other Visit* methods are:
VisitNamedDecl(const NamedDecl *Decl)
VisitDeclRefExpr(const DeclRefExpr *Expr)
VisitMemberExpr(const MemberExpr *Expr)


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D22881#498919, @alexshap wrote:

> i took a look at handleNestedNameSpecifierLoc:
>
>   const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
>   if (Decl) {
>setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
>   }
>


Yes, that's why if something happens twice in the codebase, it should be moved 
to the other place :)

> and added this check to VisitTypeLoc.

> 

> the other Visit* methods are:

>  VisitNamedDecl(const NamedDecl *Decl)

>  VisitDeclRefExpr(const DeclRefExpr *Expr)

>  VisitMemberExpr(const MemberExpr *Expr)


Yes, I am aware of that.


https://reviews.llvm.org/D22881



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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-07-28 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: test/Analysis/misc-ps-region-store.m:332
@@ -330,3 +331,3 @@
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.

ayartsev wrote:
> zaks.anna wrote:
> > Try substituting 'p' with null and you will se that n must be zero in that 
> > case because, otherwise, we would take the early return branch. Since p is 
> > not null, we should not warn here. 
> > 
> > This is a regression.
> If we reached the line "unsigned short *p = (unsigned short*) data;" then 
> ''data" is definitely null and "n" is definitely >0, otherwise we would take 
> the early return branch. Then we have "p" is definitely null and "q" is 
> either equal (if n == 1) or greater then "p". In case of n > 1 we definitely 
> have a null dereference. Please tell what I'm missing.
> "data" is definitely null and "n" is definitely >0

"data" is definitely non-null or "n" is definitely =0.

We return on 'not-or', which means we continue on plain 'or'.

I also agree that the easiest way to understand that is to substitute `data` 
with null and see what happens.


https://reviews.llvm.org/D22862



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


[PATCH] D22906: Refactor NamedDeclFindingASTVisitor

2016-07-28 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added reviewers: omtcyfz, klimek, compnerd.
alexshap added a subscriber: cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

Address the comments on the diff D22881.
Remove SourceMgr.
Check Decl inside setResult.
All the tests are green.



https://reviews.llvm.org/D22906

Files:
  clang-rename/USRFinder.cpp

Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -34,17 +34,15 @@
 public:
   // \brief Finds the NamedDecl at a point in the source.
   // \param Point the location in the source to search for the NamedDecl.
-  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const SourceLocation Point,
+  explicit NamedDeclFindingASTVisitor(const SourceLocation Point,
   const ASTContext *Context)
-  : Result(nullptr), SourceMgr(SourceMgr), Point(Point), Context(Context) 
{}
+  : Result(nullptr), Point(Point), Context(Context) {}
 
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
-  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name,
+  explicit NamedDeclFindingASTVisitor(const std::string &Name,
   const ASTContext *Context)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
+  : Result(nullptr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -74,12 +72,11 @@
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
+const SourceManager &SourceMgr = Context->getSourceManager();
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
 TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
-  return setResult(RD, TypeBeginLoc, TypeEndLoc);
-return true;
+return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc, 
TypeEndLoc);
   }
 
   // Other:
@@ -91,9 +88,7 @@
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
   const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
-  if (Decl) {
-setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
-  }
+  setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
 }
   }
@@ -103,6 +98,8 @@
   // \returns false on success.
   bool setResult(const NamedDecl *Decl, SourceLocation Start,
  SourceLocation End) {
+if (!Decl)
+  return true;
 if (Name.empty()) {
   // Offset is used to find the declaration.
   if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
@@ -130,13 +127,13 @@
   // \brief Determines if the Point is within Start and End.
   bool isPointWithin(const SourceLocation Start, const SourceLocation End) {
 // FIXME: Add tests for Point == End.
+const SourceManager &SourceMgr = Context->getSourceManager();
 return Point == Start || Point == End ||
(SourceMgr.isBeforeInTranslationUnit(Start, Point) &&
 SourceMgr.isBeforeInTranslationUnit(Point, End));
   }
 
   const NamedDecl *Result;
-  const SourceManager &SourceMgr;
   const SourceLocation Point; // The location to find the NamedDecl.
   const std::string Name;
   const ASTContext *Context;
@@ -148,7 +145,7 @@
   const auto &SourceMgr = Context.getSourceManager();
   const auto SearchFile = SourceMgr.getFilename(Point);
 
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Point, &Context);
+  NamedDeclFindingASTVisitor Visitor(Point, &Context);
 
   // We only want to search the decls that exist in the same file as the point.
   auto Decls = Context.getTranslationUnitDecl()->decls();
@@ -171,8 +168,7 @@
 
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
-  const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
+  NamedDeclFindingASTVisitor Visitor(Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();


Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -34,17 +34,15 @@
 public:
   // \brief Finds the NamedDecl at a point in the source.
   // \param Point the location in the source to search for the NamedDecl.
-  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const SourceLocation Point,
+  explicit NamedDeclFindingASTVisitor(const 

[clang-tools-extra] r276967 - [clang-rename] USRFinder.cpp cleanup

2016-07-28 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Jul 28 04:05:06 2016
New Revision: 276967

URL: http://llvm.org/viewvc/llvm-project?rev=276967&view=rev
Log:
[clang-rename] USRFinder.cpp cleanup

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=276967&r1=276966&r2=276967&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Thu Jul 28 04:05:06 2016
@@ -34,17 +34,15 @@ class NamedDeclFindingASTVisitor
 public:
   // \brief Finds the NamedDecl at a point in the source.
   // \param Point the location in the source to search for the NamedDecl.
-  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const SourceLocation Point,
-  const ASTContext *Context)
-  : Result(nullptr), SourceMgr(SourceMgr), Point(Point), Context(Context) 
{}
+  explicit NamedDeclFindingASTVisitor(const SourceLocation Point,
+  const ASTContext &Context)
+  : Result(nullptr), Point(Point), Context(Context) {}
 
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
-  explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name,
-  const ASTContext *Context)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
+  explicit NamedDeclFindingASTVisitor(const std::string &Name,
+  const ASTContext &Context)
+  : Result(nullptr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -53,8 +51,10 @@ public:
   // checking if the point lies within the length of the name of the 
declaration
   // and the start location is sufficient.
   bool VisitNamedDecl(const NamedDecl *Decl) {
-return dyn_cast(Decl) ? true :
-setResult(Decl, Decl->getLocation(), Decl->getNameAsString().length());
+return dyn_cast(Decl)
+   ? true
+   : setResult(Decl, Decl->getLocation(),
+   Decl->getNameAsString().length());
   }
 
   // Expression visitors:
@@ -76,10 +76,9 @@ public:
   bool VisitTypeLoc(const TypeLoc Loc) {
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
-  return setResult(RD, TypeBeginLoc, TypeEndLoc);
-return true;
+TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
+ TypeEndLoc);
   }
 
   // Other:
@@ -91,9 +90,7 @@ public:
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
   const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
-  if (Decl) {
-setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
-  }
+  setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
 }
   }
@@ -103,6 +100,9 @@ private:
   // \returns false on success.
   bool setResult(const NamedDecl *Decl, SourceLocation Start,
  SourceLocation End) {
+if (!Decl) {
+  return true;
+}
 if (Name.empty()) {
   // Offset is used to find the declaration.
   if (!Start.isValid() || !Start.isFileID() || !End.isValid() ||
@@ -131,30 +131,28 @@ private:
   bool isPointWithin(const SourceLocation Start, const SourceLocation End) {
 // FIXME: Add tests for Point == End.
 return Point == Start || Point == End ||
-   (SourceMgr.isBeforeInTranslationUnit(Start, Point) &&
-SourceMgr.isBeforeInTranslationUnit(Point, End));
+   (Context.getSourceManager().isBeforeInTranslationUnit(Start,
+ Point) &&
+Context.getSourceManager().isBeforeInTranslationUnit(Point, End));
   }
 
   const NamedDecl *Result;
-  const SourceManager &SourceMgr;
   const SourceLocation Point; // The location to find the NamedDecl.
   const std::string Name;
-  const ASTContext *Context;
+  const ASTContext &Context;
 };
 } // namespace
 
 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
 const SourceLocation Point) {
-  const auto &SourceMgr = Context.getSourceManager();
-  const auto SearchFile = SourceMgr.getFilename(Point);
-
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Point, &Context);
+  const auto SearchFile = Context.getSourceManager().getFilename

Re: [PATCH] D22906: Refactor NamedDeclFindingASTVisitor

2016-07-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Fixed in https://reviews.llvm.org/rL276967


https://reviews.llvm.org/D22906



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


Re: [PATCH] D22906: Refactor NamedDeclFindingASTVisitor

2016-07-28 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thanks!


https://reviews.llvm.org/D22906



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-28 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

Thanks for the reviews everyone!

I'm currently still stuck on an issue I discovered when processing LLVM. I 
asked for help on the mailing list [0] but maybe someone here can help. 
Basically the issue is that sometimes pointers are passed to memcpy for which 
the types are not assignable. That's okay for memcpy because it takes its 
arguments as void pointers, but of course this causes std::copy to complain.

I want my pass to warn the user about this issue but skip the substitution, but 
I don't know how to check for this case...

[0] http://lists.llvm.org/pipermail/cfe-dev/2016-July/050105.html


https://reviews.llvm.org/D22725



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-28 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Hi, friendly ping.

@rsmith any further comment on this?

Thank you very much.


https://reviews.llvm.org/D20561



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


[clang-tools-extra] r276971 - [clang-rename] remove redundant *_cast<> traversal

2016-07-28 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Jul 28 05:31:16 2016
New Revision: 276971

URL: http://llvm.org/viewvc/llvm-project?rev=276971&view=rev
Log:
[clang-rename] remove redundant *_cast<> traversal

Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=276971&r1=276970&r2=276971&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Thu Jul 28 05:31:16 
2016
@@ -95,22 +95,6 @@ public:
 return true;
   }
 
-  bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {
-return handleCXXNamedCastExpr(Expr);
-  }
-
-  bool VisitCXXDynamicCastExpr(clang::CXXDynamicCastExpr *Expr) {
-return handleCXXNamedCastExpr(Expr);
-  }
-
-  bool VisitCXXReinterpretCastExpr(clang::CXXReinterpretCastExpr *Expr) {
-return handleCXXNamedCastExpr(Expr);
-  }
-
-  bool VisitCXXConstCastExpr(clang::CXXConstCastExpr *Expr) {
-return handleCXXNamedCastExpr(Expr);
-  }
-
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
@@ -139,24 +123,6 @@ public:
 }
   }
 
-  bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {
-clang::QualType Type = Expr->getType();
-// See if this a cast of a pointer.
-const RecordDecl *Decl = Type->getPointeeCXXRecordDecl();
-if (!Decl) {
-  // See if this is a cast of a reference.
-  Decl = Type->getAsCXXRecordDecl();
-}
-
-if (Decl && getUSRForDecl(Decl) == USR) {
-  SourceLocation Location =
-  Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
-  checkAndAddLocation(Location);
-}
-
-return true;
-  }
-
 private:
   void checkAndAddLocation(SourceLocation Loc) {
 const auto BeginLoc = Loc;


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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-07-28 Thread Anton Yartsev via cfe-commits
ayartsev added inline comments.


Comment at: test/Analysis/misc-ps-region-store.m:332
@@ -330,3 +331,3 @@
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.

zaks.anna wrote:
> Try substituting 'p' with null and you will se that n must be zero in that 
> case because, otherwise, we would take the early return branch. Since p is 
> not null, we should not warn here. 
> 
> This is a regression.
If we reached the line "unsigned short *p = (unsigned short*) data;" then 
''data" is definitely null and "n" is definitely >0, otherwise we would take 
the early return branch. Then we have "p" is definitely null and "q" is either 
equal (if n == 1) or greater then "p". In case of n > 1 we definitely have a 
null dereference. Please tell what I'm missing.


https://reviews.llvm.org/D22862



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


D22910 Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-07-28 Thread Andi Bogdan Postelnicu via cfe-commits
I’m trying to get reviews for this patch that modifies Expr::HasSideEffects in 
order to have better support for CXXOperatorCallExpr and i don’t know from who 
i can ask review.

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


Re: [PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-07-28 Thread Anton Yartsev via cfe-commits
ayartsev added inline comments.


Comment at: test/Analysis/PR12421.c:11
@@ +10,2 @@
+
+// CHECK: warning: Path diagnostic report is not generated. HTMLDiagnostics 
does not support diagnostics that cross file boundaries.

zaks.anna wrote:
> ayartsev wrote:
> > zaks.anna wrote:
> > > We should use the name of the diagnostic consumer here - that will only 
> > > be legible for the developers working on the attic analyzer core. 
> > Done. As for me the name of the diagnostic consumer also makes the warning 
> > more clear and helpful for an ordinary user. From the consumer name he can 
> > see what report format is talked about and maybe change the scan-build 
> > (which setups the '-analyzer-output' frontend option internally) options. 
> > Do you still want to remove the consumer name from the warning?
> "HTMLDiagnostics" is not a name a user would be familiar with. You should use 
> only familiar terms in diagnostics.
Ok.


Comment at: test/Analysis/PR12421.h:1
@@ +1,2 @@
+static void f() {
+  int *p = 0;

zaks.anna wrote:
> zaks.anna wrote:
> > Please. do not use the PR as a file name. Use the purpose of the test 
> > instead,
> this does not seem to be done.
Did you see an updated diff? Or I'm probably missing something. Maybe you mean 
something like this: check-diag-cross-file-boundaries-no-report.* ?


https://reviews.llvm.org/D22494



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


Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-28 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:509
@@ +508,3 @@
+  //}
+  //  }
+  //}

dcoughlin wrote:
> I disagree about compactness being valuable here. I think it is more 
> important to intrinsically document the spec. These will be written once and 
> read frequently. When they are written, they will copied from a previous 
> example -- probably by someone who is not familiar with the code or the spec 
> format.
> 
> Another possibility (not sure if it is the right one here) is to use macro 
> tricks to define a simple DSL like Kulpreet did in the 
> LocalizationChecker.cpp.
> These will be written once and read frequently.

If only it was so :))

Hmm. What do you think of the following format? Macros mostly expand to empty 
or (argument), but it should be more readable than the `/*`...`*/` noise.


```
SPEC {
  FOR_FUNCTION("isalnum"),
  SPEC_DATA {
ARGUMENT_TYPES { IntTy },
RETURN_TYPE(IntTy),
INVALIDATION_APPROACH(EvalCallAsPure),
BRANCHES {
  BRANCH { // Boils down to isupper() or islower() or isdigit()
RANGE {
  ARG_NO(0), RANGE_KIND(WithinRange),
  SET { SEG('0', '9') U SEG('A', 'Z') U SEG('a', 'z') }
},
RANGE {
  RET_VAL, RANGE_KIND(OutOfRange),
  SET { SEG(0, 0) }
}
  },
  BRANCH { // The locale-specific branch.
RANGE {
  ARG_NO(0), RANGE_KIND(WithinRange),
  SET { SEG(128, 255) }
}
  },
  BRANCH { // Other.
RANGE {
  ARG_NO(0), RANGE_KIND(OutOfRange),
  SET { SEG('0', '9') U SEG('A', 'Z')
  U SEG('a', 'z') U SEG(128, 255)}
},
RANGE {
  RET_VAL, RANGE_KIND(WithinRange),
  SET { SEG(0, 0) }
}
  }
}
  }
},
```


https://reviews.llvm.org/D20811



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


[PATCH] D22913: Mention of proper support for "__unaligned" type qualifier in 3.9 clang release notes

2016-07-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added a reviewer: hans.
andreybokhanko added a subscriber: cfe-commits.

This add mention of proper support for "__unaligned" type qualifier in 3.9 
clang release notes.

https://reviews.llvm.org/D22913

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Thank you for the patch!

One thing this patch is missing is a test case that exercises this code path. 
For instance, there are diagnostics triggered for expressions with side effects 
when used as part of an unevaluated expression like sizeof, noexcept, etc. You 
should include a test case that demonstrates some behavioral change in the 
compiler that this patch addresses.

> The AST node that will get generated for the assignment is of type 
> CXXOperatorCallExpr so calling HasSideEffects on that expression would have 
> resulted in a false return since CXXOperatorCallExpr was not considered to 
> have a possible side effect when it's underlying operator type is assignment.


I think the underlying issue here is that `HasSideEffects()` accepts an 
argument as to whether possible side effects should count as definite side 
effects, and for the unevaluated context diagnostics, we do not want to include 
possible side effects, only definite ones. For instance, consider this very 
common code pattern where the function definition is not available to the TU:

  struct S {
S& operator=(int);
  };

There's no way to know whether side effects will or won't happen for an 
assignment operator on an object of the above type because the definition does 
not exist. Assuming that side effects *definitely* happen, as your patch does, 
can then trigger false positives. So the second question is: how many 
false-positives will it generate? I think it may be reasonable to assume that 
`operator=()` has side effects, but you should run some large C++ projects 
(like LLVM itself) through Clang to see how many new diagnostics this change 
triggers and how many of those diagnostics are true positives vs false 
positives. That will tell us for sure whether this is adding value or not.


Repository:
  rL LLVM

https://reviews.llvm.org/D22910



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


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-28 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65909.
teemperor added a comment.

- Actually removed the duplicate test now.


https://reviews.llvm.org/D22514

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/test-asm.cpp
  test/Analysis/copypaste/test-attributes.cpp
  test/Analysis/copypaste/test-call.cpp
  test/Analysis/copypaste/test-catch.cpp
  test/Analysis/copypaste/test-delete.cpp
  test/Analysis/copypaste/test-dependent-exist.cpp
  test/Analysis/copypaste/test-expr-types.cpp
  test/Analysis/copypaste/test-fold.cpp
  test/Analysis/copypaste/test-function-try-block.cpp
  test/Analysis/copypaste/test-generic.c
  test/Analysis/copypaste/test-labels.cpp
  test/Analysis/copypaste/test-lambda.cpp

Index: test/Analysis/copypaste/test-lambda.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-lambda.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+void foo1(int a, long b) {
+  auto l = [a, b](){};
+}
+
+void foo2(int a, long b) {
+  auto l = [&a, b](){};
+}
+
+void foo3(int a, long b) {
+  auto l = [a](){};
+}
+
+void foo4(int a, long b) {
+  auto l = [=](){};
+}
+
+void foo5(int a, long b) {
+  auto l = [&](){};
+}
+
Index: test/Analysis/copypaste/test-labels.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&end;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &&foo;
+goto foo;
+  }
+  end:
+  return false;
+}
Index: test/Analysis/copypaste/test-generic.c
===
--- /dev/null
+++ test/Analysis/copypaste/test-generic.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global;
+
+int foo1() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, float: 2, default: 3);
+  return 1;
+}
+
+// Different associated type (int instead of float)
+int foo2() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, int: 2, default: 4);
+  return 1;
+}
+
+// Different number of associated types.
+int foo3() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, default: 4);
+  return 1;
+}
Index: test/Analysis/copypaste/test-function-try-block.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-fold.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-fold.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global = 0;
+
+template
+int foo1(Args&&... args) {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return (args + ...);
+  return 1;
+}
+
+// Different opeator in fold expression.
+template
+int foo2(Args&&... args) {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return (args - ...);
+  return 1;
+}
+
+// Parameter pack on a different side
+template
+int foo3(Args&&... args) {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return -1;
+  return (... + args);
+return 1;
+}
Index: test/Analysis/copypaste/test-expr-types.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-expr-types.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -std=c++

Re: [PATCH] D21070: Pass the ABI in the triple when appropriate (currently for MIPS) for 'clang -cc1' and 'clang -cc1as'

2016-07-28 Thread Daniel Sanders via cfe-commits
dsanders updated this revision to Diff 65918.
dsanders added a comment.

Refresh and ping


https://reviews.llvm.org/D21070

Files:
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  tools/driver/cc1as_main.cpp

Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -69,6 +69,10 @@
   /// The name of the target triple to assemble for.
   std::string Triple;
 
+  /// The name of the ABI to assembler for or the empty string for the default
+  /// ABI.
+  std::string ABI;
+
   /// If given, the name of the target CPU to determine which instructions
   /// are legal.
   std::string CPU;
@@ -134,6 +138,7 @@
 public:
   AssemblerInvocation() {
 Triple = "";
+ABI = "";
 NoInitialTextSection = 0;
 InputFile = "-";
 OutputPath = "-";
@@ -185,13 +190,24 @@
 
   // Target Options
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  Opts.ABI = Args.getLastArgValue(OPT_target_abi);
   Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
   Opts.Features = Args.getAllArgValues(OPT_target_feature);
 
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
 
+  // Modify the Triple and ABI according to the Triple and ABI.
+  llvm::Triple ABITriple;
+  StringRef ABIName;
+  std::tie(ABITriple, ABIName) =
+  llvm::Triple(Opts.Triple).getABIVariant(Opts.ABI);
+  if (ABITriple.getArch() == llvm::Triple::UnknownArch)
+Diags.Report(diag::err_target_unknown_abi) << Opts.ABI;
+  Opts.Triple = ABITriple.str();
+  Opts.ABI = ABIName;
+
   // Language Options
   Opts.IncludePaths = Args.getAllArgValues(OPT_I);
   Opts.NoInitialTextSection = Args.hasArg(OPT_n);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2309,6 +2309,16 @@
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+
+  // Modify the Triple and ABI according to the Triple and ABI.
+  llvm::Triple ABITriple;
+  StringRef ABIName;
+  std::tie(ABITriple, ABIName) =
+  llvm::Triple(Opts.Triple).getABIVariant(Opts.ABI);
+  if (ABITriple.getArch() == llvm::Triple::UnknownArch)
+Diags.Report(diag::err_target_unknown_abi) << Opts.ABI;
+  Opts.Triple = ABITriple.str();
+  Opts.ABI = ABIName;
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1249,7 +1249,7 @@
   // MIPS32r6 is the default for mips(el)?-img-linux-gnu and MIPS64r6 is the
   // default for mips64(el)?-img-linux-gnu.
   if (Triple.getVendor() == llvm::Triple::ImaginationTechnologies &&
-  Triple.getEnvironment() == llvm::Triple::GNU) {
+  Triple.isGNUEnvironment()) {
 DefMips32CPU = "mips32r6";
 DefMips64CPU = "mips64r6";
   }
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2409,7 +2409,7 @@
 
   if (TargetTriple.getVendor() == llvm::Triple::ImaginationTechnologies &&
   TargetTriple.getOS() == llvm::Triple::Linux &&
-  TargetTriple.getEnvironment() == llvm::Triple::GNU)
+  TargetTriple.isGNUEnvironment())
 return findMipsImgMultilibs(Flags, NonExistent, Result);
 
   if (findMipsCsMultilibs(Flags, NonExistent, Result))
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7161,10 +7161,22 @@
 BigEndian = getTriple().getArch() == llvm::Triple::mips ||
 getTriple().getArch() == llvm::Triple::mips64;
 
-setABI((getTriple().getArch() == llvm::Triple::mips ||
-getTriple().getArch() == llvm::Triple::mipsel)
-   ? "o32"
-   : "n64");
+if (getTriple().getEnvironment() == llvm::Triple::ABI32 ||
+getTriple().getEnvironment() == llvm::Triple::GNUABI32 ||
+getTriple().getEnvironment() == llvm::Triple::AndroidABI32)
+  setABI("o32");
+else if (getTriple().getEnvironment() == llvm::Triple::ABIN32 ||
+getTriple().getEnvironment() == llvm::Triple::GNUABIN32)
+  setABI("n32");
+else if (getTriple().getEnvironment() == llvm::Triple::ABI64 ||
+ getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
+ getTriple().getEnvironment() == llvm::Triple::AndroidABI64)
+  setABI("n64");
+else
+  setABI((getTriple().getArch() == llvm::Triple::mips ||
+  getTriple().getArch() == llvm::Triple::mipsel)
+ ? "o32"
+ : "

[clang-tools-extra] r276973 - Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"

2016-07-28 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Jul 28 07:48:17 2016
New Revision: 276973

URL: http://llvm.org/viewvc/llvm-project?rev=276973&view=rev
Log:
Reapply r276856 "Adjust Registry interface to not require plugins to export a 
registry"

This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=276973&r1=276972&r2=276973&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Jul 28 07:48:17 2016
@@ -47,7 +47,7 @@ using namespace clang::driver;
 using namespace clang::tooling;
 using namespace llvm;
 
-template class llvm::Registry;
+LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
 
 namespace clang {
 namespace tidy {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h?rev=276973&r1=276972&r2=276973&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h Thu Jul 28 
07:48:17 2016
@@ -13,8 +13,6 @@
 #include "ClangTidyModule.h"
 #include "llvm/Support/Registry.h"
 
-extern template class llvm::Registry;
-
 namespace clang {
 namespace tidy {
 


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


r276973 - Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"

2016-07-28 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Jul 28 07:48:17 2016
New Revision: 276973

URL: http://llvm.org/viewvc/llvm-project?rev=276973&view=rev
Log:
Reapply r276856 "Adjust Registry interface to not require plugins to export a 
registry"

This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

Modified:
cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt?rev=276973&r1=276972&r2=276973&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt (original)
+++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt Thu Jul 28 07:48:17 2016
@@ -1,4 +1,4 @@
-add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
+add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(AnnotateFunctions PRIVATE

Modified: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt?rev=276973&r1=276972&r2=276973&view=diff
==
--- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt (original)
+++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt Thu Jul 28 07:48:17 
2016
@@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols di
   endif()
 endif()
 
-add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(PrintFunctionNames PRIVATE

Modified: cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h?rev=276973&r1=276972&r2=276973&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h Thu Jul 28 
07:48:17 2016
@@ -13,9 +13,6 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/Support/Registry.h"
 
-// Instantiated in FrontendAction.cpp.
-extern template class llvm::Registry;
-
 namespace clang {
 
 /// The frontend plugin registry.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=276973&r1=276972&r2=276973&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jul 28 07:48:17 2016
@@ -1972,6 +1972,4 @@ typedef llvm::Registry Pr
 
 }  // end namespace clang
 
-extern template class llvm::Registry;
-
 #endif

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=276973&r1=276972&r2=276973&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jul 28 07:48:17 2016
@@ -33,7 +33,7 @@
 #include 
 using namespace clang;
 
-template class llvm::Registry;
+LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
 
 names

Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-07-28 Thread Krzysztof Parzyszek via cfe-commits
kparzysz updated this revision to Diff 65919.
kparzysz marked 2 inline comments as done.
kparzysz added a comment.

Removed the cleanup part.


Repository:
  rL LLVM

https://reviews.llvm.org/D22766

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/Driver/hexagon-long-calls.c

Index: test/Driver/hexagon-long-calls.c
===
--- /dev/null
+++ test/Driver/hexagon-long-calls.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target hexagon -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target hexagon -### -mlong-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LONG-CALLS
+
+// RUN: %clang -target hexagon -### -mlong-calls -mno-long-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-LONG-CALLS
+
+// CHECK-DEFAULT-NOT: "-target-feature" "+long-calls"
+
+// CHECK-LONG-CALLS: "-target-feature" "+long-calls"
+
+// CHECK-NO-LONG-CALLS-NOT: "-target-feature" "+long-calls"
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2536,7 +2536,7 @@
 
 static void getHexagonTargetFeatures(const ArgList &Args,
  std::vector &Features) {
-  bool HasHVX = false, HasHVXD = false;
+  bool HasHVX = false, HasHVXD = false, UseLongCalls = false;
 
   // FIXME: This should be able to use handleTargetFeaturesGroup except it is
   // doing dependent option handling here rather than in initFeatureMap or a
@@ -2551,13 +2551,18 @@
   HasHVXD = HasHVX = true;
 else if (Opt.matches(options::OPT_mno_hexagon_hvx_double))
   HasHVXD = false;
+else if (Opt.matches(options::OPT_mlong_calls))
+  UseLongCalls = true;
+else if (Opt.matches(options::OPT_mno_long_calls))
+  UseLongCalls = false;
 else
   continue;
 A->claim();
   }
 
   Features.push_back(HasHVX  ? "+hvx" : "-hvx");
   Features.push_back(HasHVXD ? "+hvx-double" : "-hvx-double");
+  Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
 }
 
 static void getWebAssemblyTargetFeatures(const ArgList &Args,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6079,6 +6079,7 @@
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
   std::string CPU;
   bool HasHVX, HasHVXDouble;
+  bool UseLongCalls;
 
 public:
   HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
@@ -6103,6 +6104,7 @@
 UseBitFieldTypeAlignment = true;
 ZeroLengthBitfieldBoundary = 32;
 HasHVX = HasHVXDouble = false;
+UseLongCalls = false;
   }
 
   ArrayRef getTargetBuiltins() const override {
@@ -6137,6 +6139,7 @@
   .Case("hexagon", true)
   .Case("hvx", HasHVX)
   .Case("hvx-double", HasHVXDouble)
+  .Case("long-calls", UseLongCalls)
   .Default(false);
   }
 
@@ -6226,6 +6229,9 @@
   HasHVX = HasHVXDouble = true;
 else if (F == "-hvx-double")
   HasHVXDouble = false;
+
+if (F == "+long-calls")
+  UseLongCalls = true;
   }
   return true;
 }
@@ -6236,11 +6242,11 @@
   // Default for v60: -hvx, -hvx-double.
   Features["hvx"] = false;
   Features["hvx-double"] = false;
+  Features["long-calls"] = false;
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
-
 const char *const HexagonTargetInfo::GCCRegNames[] = {
   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1370,6 +1370,8 @@
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, Group;
+def mlong_calls : Flag<["-"], "mlong-calls">, Group,
+  HelpText<"ARM: Generate an indirect jump to enable jumps further than 64M, Hexagon: Generate constant-extended branches.">;
 def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;
 def mappletvos_version_min_EQ : Joined<["-"], "mappletvos-version-min=">, Alias;
 def mtvos_simulator_version_min_EQ : Joined<["-"], "mtvos-simulator-version-min=">, Alias;
@@ -1514,8 +1516,6 @@
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,
   HelpText<"Disallow use of CRC instructions (ARM only)">;
-def mlong_calls : Flag<["-"], "mlong-calls">, Group,
-  HelpText<"Generate an indirect jump to enable jumps further than 64M">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/

Re: [PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.h:36-37
@@ -32,1 +35,4 @@
+private:
+  std::vector ContainersWithPushBack;
+  std::vector SmartPointers;
 };

What about `llvm::make_range()`?


https://reviews.llvm.org/D22208



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


Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-special-member-functions

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:62
@@ +61,3 @@
+std::string
+SpecialMemberFunctionsCheck::join(llvm::ArrayRef 
SMFS,
+ llvm::StringRef AndOr) {

I think this join function can maybe be replaced by a call to llvm::join() from 
StringExtras.h?


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:64
@@ +63,3 @@
+ llvm::StringRef AndOr) {
+  assert(!SMFS.empty());
+  std::string Buffer;

It's good to put an && along with some explanatory text for debugging if this 
assertion ever triggers.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:73
@@ +72,3 @@
+  }
+  if (LastIndex != 0) {
+Stream << AndOr << toString(SMFS[LastIndex]);

Elide braces per usual style conventions.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:94
@@ +93,3 @@
+
+  for (const auto& KV : Matchers)
+if (Result.Nodes.getNodeAs(KV.first))

The & should bind to KV rather than auto (clang-format should handle this for 
you).


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h:42-44
@@ +41,5 @@
+
+  using ClassDefId = std::pair;
+
+  using ClassDefiningSpecialMembersMap = llvm::DenseMap>;
+

Do these need to be public?


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h:62-63
@@ +61,4 @@
+/// Specialisation of DenseMapInfo to allow ClassDefId objects in DenseMaps
+/// FIXME: Move this to the corresponding cpp file as is done for
+/// clang-tidy/readability/IdentifierNamingCheck.cpp. 
+template <>

Any reason why not to do this as part of this patch?


https://reviews.llvm.org/D22513



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


Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-07-28 Thread Andi via cfe-commits
Abpostelnicu added a comment.

In https://reviews.llvm.org/D22910#499082, @aaron.ballman wrote:

> Thank you for the patch!
>
> One thing this patch is missing is a test case that exercises this code path. 
> For instance, there are diagnostics triggered for expressions with side 
> effects when used as part of an unevaluated expression like sizeof, noexcept, 
> etc. You should include a test case that demonstrates some behavioral change 
> in the compiler that this patch addresses.
>
> > The AST node that will get generated for the assignment is of type 
> > CXXOperatorCallExpr so calling HasSideEffects on that expression would have 
> > resulted in a false return since CXXOperatorCallExpr was not considered to 
> > have a possible side effect when it's underlying operator type is 
> > assignment.
>
>
> I think the underlying issue here is that `HasSideEffects()` accepts an 
> argument as to whether possible side effects should count as definite side 
> effects, and for the unevaluated context diagnostics, we do not want to 
> include possible side effects, only definite ones. For instance, consider 
> this very common code pattern where the function definition is not available 
> to the TU:
>
>   struct S {
> S& operator=(int);
>   };
>
>
> There's no way to know whether side effects will or won't happen for an 
> assignment operator on an object of the above type because the definition 
> does not exist. Assuming that side effects *definitely* happen, as your patch 
> does, can then trigger false positives. So the second question is: how many 
> false-positives will it generate? I think it may be reasonable to assume that 
> `operator=()` has side effects, but you should run some large C++ projects 
> (like LLVM itself) through Clang to see how many new diagnostics this change 
> triggers and how many of those diagnostics are true positives vs false 
> positives. That will tell us for sure whether this is adding value or not.


You are right, using this patch i've built the firefox codebase, witch is 
rather a very large product, and there is no issues triggered. I will also add 
some test cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D22910



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-28 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 65928.
yaxunl added a comment.

Use 'opencl.sampler_t' as opque type name for sampler in LLVM IR.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,31 +1,85 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}
+
+constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}
+
+constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
 
 void foo(sampler_t);
 
 constant struct sampler_s {
   sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
 } sampler_str = {0};
 
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
+  const sampler_t const_smp3 = const_smp;
+  const sampler_t const_smp4 = f();
+  const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}}
+  const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
+
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
+  foo(glb_smp4);
+  foo(glb_smp5);
+  foo(glb_smp6);
+  foo(glb_smp7);
+  foo(glb_smp8);
+  foo(glb_smp9);
+  foo(smp);
+  foo(sampler_str.smp);
   foo(const_smp);
+  foo(const_smp2);
+  foo(const_smp3);
+  foo(const_smp4);
+  foo(const_smp5);
+  foo(const_smp6);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
+  foo(sa[0]);
+  foo(bad());
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expr

Re: [PATCH] D22668: TrailingObjects::FixedSizeStorage constexpr fixes

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I don't suppose there's a way to test these changes, is there?



Comment at: include/llvm/Support/MathExtras.h:682
@@ +681,3 @@
+
+// alignTo for contexts where a constant expression is required.
+// FIXME: remove when LLVM_CONSTEXPR becomes really constexpr

Switch to use doxygen-style comments?


Comment at: include/llvm/Support/TrailingObjects.h:149
@@ -148,1 +148,3 @@
 
+  struct RequiresRealignment {
+static const bool value =

Does this need to be public?


https://reviews.llvm.org/D22668



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


r276977 - [OpenMP] Codegen for use_device_ptr clause.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 09:23:26 2016
New Revision: 276977

URL: http://llvm.org/viewvc/llvm-project?rev=276977&view=rev
Log:
[OpenMP] Codegen for use_device_ptr clause.

Summary: This patch adds support for the use_device_ptr clause. It includes 
changes in SEMA that could not be tested without codegen, namely, the use of 
the first private logic and mappable expressions support.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Added:
cfe/trunk/test/OpenMP/target_data_use_device_ptr_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
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/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=276977&r1=276976&r2=276977&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Jul 28 09:23:26 2016
@@ -4228,50 +4228,153 @@ public:
 /// 'use_device_ptr' with the variables 'a' and 'b'.
 ///
 class OMPUseDevicePtrClause final
-: public OMPVarListClause,
-  private llvm::TrailingObjects {
+: public OMPMappableExprListClause,
+  private llvm::TrailingObjects<
+  OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned,
+  OMPClauseMappableExprCommon::MappableComponent> {
   friend TrailingObjects;
   friend OMPVarListClause;
+  friend OMPMappableExprListClause;
   friend class OMPClauseReader;
-  /// Build clause with number of variables \a N.
+
+  /// Define the sizes of each trailing object array except the last one. This
+  /// is required for TrailingObjects to work properly.
+  size_t numTrailingObjects(OverloadToken) const {
+return 3 * varlist_size();
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return getUniqueDeclarationsNum();
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return getUniqueDeclarationsNum() + getTotalComponentListNum();
+  }
+
+  /// Build clause with number of variables \a NumVars.
   ///
   /// \param StartLoc Starting location of the clause.
-  /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  /// \param N Number of the variables in the clause.
-  ///
-  OMPUseDevicePtrClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-SourceLocation EndLoc, unsigned N)
-  : OMPVarListClause(OMPC_use_device_ptr, StartLoc,
-LParenLoc, EndLoc, N) {}
+  /// \param NumVars Number of expressions listed in this clause.
+  /// \param NumUniqueDeclarations Number of unique base declarations in this
+  /// clause.
+  /// \param NumComponentLists Number of component lists in this clause.
+  /// \param NumComponents Total number of expression components in the clause.
+  ///
+  explicit OMPUseDevicePtrClause(SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc, unsigned NumVars,
+ unsigned NumUniqueDeclarations,
+ unsigned NumComponentLists,
+ unsigned NumComponents)
+  : OMPMappableExprListClause(OMPC_use_device_ptr, StartLoc, LParenLoc,
+  EndLoc, NumVars, NumUniqueDeclarations,
+  NumComponentLists, NumComponents) {}
 
-  /// \brief Build an empty clause.
-  ///
-  /// \param N Number of variables.
+  /// Build an empty clause.
   ///
-  explicit OMPUseDevicePtrClause(unsigned N)
-  : OMPVarListClause(
-OMPC_use_device_ptr, SourceLocation(), SourceLocation(),
-SourceLocation(), N) {}
+  /// \param NumVars Number of expressions listed in this clause.
+  /// \param NumUniqueDeclarations Number of unique base declarations in this
+  /// clause.
+  /// \param NumComponentLists Number of component lists in this clause.
+  /// \param NumComponents Total number of expression components in the clause.
+  ///
+  explicit OMPUseDevicePtrClause(unsigned NumVars,
+ unsigned NumUniqueDeclarations,
+ unsigned NumComponentLists,
+ unsigned NumComponents)
+  : OMPMappableExprListClause(OMPC_use_device_ptr, SourceLocation(),
+  SourceLocation(), SourceLocation(), NumVars,
+  NumUniqueDeclarations, N

r276978 - [OpenMP] Code generation for the is_device_ptr clause

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 09:25:09 2016
New Revision: 276978

URL: http://llvm.org/viewvc/llvm-project?rev=276978&view=rev
Log:
[OpenMP] Code generation for the is_device_ptr clause

Summary: This patch adds support for the is_device_ptr clause. It expands SEMA 
to use the mappable expression logic that can only be tested with code 
generation in place and check conflicts with other data sharing related clauses 
using the mappable expressions infrastructure.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Added:
cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/target_is_device_ptr_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=276978&r1=276977&r2=276978&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Jul 28 09:25:09 2016
@@ -4396,50 +4396,94 @@ public:
 /// 'is_device_ptr' with the variables 'a' and 'b'.
 ///
 class OMPIsDevicePtrClause final
-: public OMPVarListClause,
-  private llvm::TrailingObjects {
+: public OMPMappableExprListClause,
+  private llvm::TrailingObjects<
+  OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned,
+  OMPClauseMappableExprCommon::MappableComponent> {
   friend TrailingObjects;
   friend OMPVarListClause;
+  friend OMPMappableExprListClause;
   friend class OMPClauseReader;
-  /// Build clause with number of variables \a N.
+
+  /// Define the sizes of each trailing object array except the last one. This
+  /// is required for TrailingObjects to work properly.
+  size_t numTrailingObjects(OverloadToken) const {
+return varlist_size();
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return getUniqueDeclarationsNum();
+  }
+  size_t numTrailingObjects(OverloadToken) const {
+return getUniqueDeclarationsNum() + getTotalComponentListNum();
+  }
+  /// Build clause with number of variables \a NumVars.
   ///
   /// \param StartLoc Starting location of the clause.
-  /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  /// \param N Number of the variables in the clause.
-  ///
-  OMPIsDevicePtrClause(SourceLocation StartLoc, SourceLocation LParenLoc,
-   SourceLocation EndLoc, unsigned N)
-  : OMPVarListClause(OMPC_is_device_ptr, StartLoc,
-   LParenLoc, EndLoc, N) {}
+  /// \param NumVars Number of expressions listed in this clause.
+  /// \param NumUniqueDeclarations Number of unique base declarations in this
+  /// clause.
+  /// \param NumComponentLists Number of component lists in this clause.
+  /// \param NumComponents Total number of expression components in the clause.
+  ///
+  explicit OMPIsDevicePtrClause(SourceLocation StartLoc,
+SourceLocation LParenLoc, SourceLocation 
EndLoc,
+unsigned NumVars,
+unsigned NumUniqueDeclarations,
+unsigned NumComponentLists,
+unsigned NumComponents)
+  : OMPMappableExprListClause(OMPC_is_device_ptr, StartLoc, LParenLoc,
+  EndLoc, NumVars, NumUniqueDeclarations,
+  NumComponentLists, NumComponents) {}
 
   /// Build an empty clause.
   ///
-  /// \param N Number of variables.
-  ///
-  explicit OMPIsDevicePtrClause(unsigned N)
-  : OMPVarListClause(
-OMPC_is_device_ptr, SourceLocation(), SourceLocation(),
-SourceLocation(), N) {}
+  /// \param NumVars Number of expressions listed in this clause.
+  /// \param NumUniqueDeclarations Number of unique base declarations in this
+  /// clause.
+  /// \param NumComponentLists Number of component lists in this clause.
+  /// \param NumComponents Total number of expression components in the clause.
+  ///
+  explicit OMPIsDevicePtrClause(unsigned NumVars,
+unsigned NumUniqueDeclarations,
+unsigned NumComponentLists,
+unsigned NumComponents)
+  : OMPMappableExprListClause(OMPC_is_device_ptr, SourceLocation(),
+  SourceLocation(), SourceLocation(), NumVars,
+  NumUniqueDeclarations, NumCompo

r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 09:29:18 2016
New Revision: 276979

URL: http://llvm.org/viewvc/llvm-project?rev=276979&view=rev
Log:
[OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

Summary:
This patch prevents OpenMP flags from being forwarded to CUDA device commands. 
That was causing the CUDA frontend to attempt to emit OpenMP code which is not 
supported.

This fixes the bug reported in https://llvm.org/bugs/show_bug.cgi?id=28723.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra, ABataev

Subscribers: caomhin, cfe-commits

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

Added:
cfe/trunk/test/Driver/offloading-interoperability.c
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=276979&r1=276978&r2=276979&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 28 09:29:18 2016
@@ -5008,9 +5008,13 @@ void Clang::ConstructJob(Compilation &C,
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
-  // Forward flags for OpenMP
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action.
+  //
+  // TODO: Allow OpenMP offload actions when they become available.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
-   options::OPT_fno_openmp, false)) {
+   options::OPT_fno_openmp, false) &&
+  JA.isDeviceOffloading(Action::OFK_None)) {
 switch (getOpenMPRuntime(getToolChain(), Args)) {
 case OMPRT_OMP:
 case OMPRT_IOMP5:

Added: cfe/trunk/test/Driver/offloading-interoperability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/offloading-interoperability.c?rev=276979&view=auto
==
--- cfe/trunk/test/Driver/offloading-interoperability.c (added)
+++ cfe/trunk/test/Driver/offloading-interoperability.c Thu Jul 28 09:29:18 2016
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 
--cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" 
"--eh-frame-hdr" "-m" "elf64lppc"


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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: klimek.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:44-54
@@ +43,13 @@
+if (OriginalText == "::std::move") {
+  Diag << FixItHint::CreateReplacement(CallRange, "::std::" + ForwardName);
+  // If the original text was simply "move", we conservatively still put a
+  // "std::" in front of the "forward". Rationale: Even if the code
+  // apparently had a "using std::move;", that doesn't tell us whether it
+  // also had a "using std::forward;".
+} else if (OriginalText == "std::move" || OriginalText == "move") {
+  Diag << FixItHint::CreateReplacement(CallRange, "std::" + ForwardName);
+}
+  }
+}
+
+// Returns whether the UnresolvedLookupExpr (potentially) refers to 
std::move().

I kind of thought that was going to be the case, but wanted to double-check. I 
agree with the notion, but disagree with the approach -- as @etienneb mentions, 
this code is not resilient enough to actually do the right thing. I don't think 
we should be going back to the original source text, but should instead be 
using the information the AST already tracks. This will perform better and do 
the right thing in all cases.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:93
@@ +92,3 @@
+   hasArgument(0, ignoringParenImpCasts(declRefExpr(
+  to(ForwardingReferenceParmMatcher)
+  .bind("call-move"),

I wonder if there's a reason for this behavior, or if it's simple a matter of 
not being needed previously and so it was never implemented. @sbenza or @klimek 
may know. I think we should be fixing the RecursiveASTVisitor, unless there is 
a valid reason not to (which there may be), though that would be a separate 
patch (and can happen after we land this one).


https://reviews.llvm.org/D0



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


Re: [PATCH] D22824: MathExtras.h: add LLVM_CONSTEXPR where simple

2016-07-28 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/llvm/Support/MathExtras.h:672
@@ -669,2 +671,3 @@
 inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew = 0) {
+  assert(Align != 0u);
   Skew %= Align;

Usually preferred to put in && "rationale goes here" for asserts (here and 
elsewhere).

Were these changes expected, as they don't seem to relate to constexpr?


https://reviews.llvm.org/D22824



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


r276981 - [OpenMP] Do not use default argument in lambda from mappable expressions handlers.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 09:47:35 2016
New Revision: 276981

URL: http://llvm.org/viewvc/llvm-project?rev=276981&view=rev
Log:
[OpenMP] Do not use default argument in lambda from mappable expressions 
handlers.

Windows bots were complaining about that.


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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276981&r1=276980&r2=276981&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jul 28 09:47:35 2016
@@ -5479,7 +5479,7 @@ public:
 const ValueDecl *D,
 OMPClauseMappableExprCommon::MappableExprComponentListRef L,
 OpenMPMapClauseKind MapType, OpenMPMapClauseKind MapModifier,
-MapInfo::ReturnPointerKind ReturnDevicePointer = MapInfo::RPK_None) {
+MapInfo::ReturnPointerKind ReturnDevicePointer) {
   const ValueDecl *VD =
   D ? cast(D->getCanonicalDecl()) : nullptr;
   Info[VD].push_back({L, MapType, MapModifier, ReturnDevicePointer});
@@ -5487,13 +5487,16 @@ public:
 
 for (auto *C : Directive.getClausesOfKind())
   for (auto L : C->component_lists())
-InfoGen(L.first, L.second, C->getMapType(), C->getMapTypeModifier());
+InfoGen(L.first, L.second, C->getMapType(), C->getMapTypeModifier(),
+MapInfo::RPK_None);
 for (auto *C : Directive.getClausesOfKind())
   for (auto L : C->component_lists())
-InfoGen(L.first, L.second, OMPC_MAP_to, OMPC_MAP_unknown);
+InfoGen(L.first, L.second, OMPC_MAP_to, OMPC_MAP_unknown,
+MapInfo::RPK_None);
 for (auto *C : Directive.getClausesOfKind())
   for (auto L : C->component_lists())
-InfoGen(L.first, L.second, OMPC_MAP_from, OMPC_MAP_unknown);
+InfoGen(L.first, L.second, OMPC_MAP_from, OMPC_MAP_unknown,
+MapInfo::RPK_None);
 
 // Look at the use_device_ptr clause information and mark the existing map
 // entries as such. If there is no map information for an entry in the


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


r276983 - [OpenMP] Fix link command pattern in offloading interoperability test.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 09:56:19 2016
New Revision: 276983

URL: http://llvm.org/viewvc/llvm-project?rev=276983&view=rev
Log:
[OpenMP] Fix link command pattern in offloading interoperability test.

It was causing a few bots to fail.


Modified:
cfe/trunk/test/Driver/offloading-interoperability.c

Modified: cfe/trunk/test/Driver/offloading-interoperability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/offloading-interoperability.c?rev=276983&r1=276982&r2=276983&view=diff
==
--- cfe/trunk/test/Driver/offloading-interoperability.c (original)
+++ cfe/trunk/test/Driver/offloading-interoperability.c Thu Jul 28 09:56:19 2016
@@ -14,4 +14,4 @@
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le--linux-gnu"
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
-// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" 
"--eh-frame-hdr" "-m" "elf64lppc"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" {{.*}}"-m" "elf64lppc"


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


Re: r276350 - [CodeGen] Fix a crash when constant folding switch statement

2016-07-28 Thread Hans Wennborg via cfe-commits
I see, thanks.

I've taken a second look at the patch and it seems straight-forward to
me, so I've merged it in r276985.

Cheers,
Hans

On Wed, Jul 27, 2016 at 5:16 PM, David Majnemer
 wrote:
> I hear that he is on vacation.
>
>
> On Wednesday, July 27, 2016, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Richard: ping?
>>
>> On Fri, Jul 22, 2016 at 7:00 AM, Hans Wennborg  wrote:
>> > Richard: should we merge this to 3.9?
>> >
>> > On Thu, Jul 21, 2016 at 6:31 PM, Erik Pilkington via cfe-commits
>> >  wrote:
>> >> Author: epilk
>> >> Date: Thu Jul 21 17:31:40 2016
>> >> New Revision: 276350
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=276350&view=rev
>> >> Log:
>> >> [CodeGen] Fix a crash when constant folding switch statement
>> >>
>> >> Differential revision: https://reviews.llvm.org/D22542
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/CodeGen/CGStmt.cpp
>> >> cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>> >>
>> >> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276350&r1=276349&r2=276350&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
>> >> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 17:31:40 2016
>> >> @@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const
>> >>  }
>> >>
>> >>  void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
>> >> +  // If there is no enclosing switch instance that we're aware of,
>> >> then this
>> >> +  // default statement can be elided. This situation only happens when
>> >> we've
>> >> +  // constant-folded the switch.
>> >> +  if (!SwitchInsn) {
>> >> +EmitStmt(S.getSubStmt());
>> >> +return;
>> >> +  }
>> >> +
>> >>llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
>> >>assert(DefaultBlock->empty() &&
>> >>   "EmitDefaultStmt: Default block already defined?");
>> >>
>> >> Modified: cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276350&r1=276349&r2=276350&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp (original)
>> >> +++ cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 21
>> >> 17:31:40 2016
>> >> @@ -18,4 +18,13 @@ int main(void) {
>> >>   return test(5);
>> >>  }
>> >>
>> >> +void other_test() {
>> >> +  switch(0) {
>> >> +  case 0:
>> >> +do {
>> >> +default:;
>> >> +} while(0);
>> >> +  }
>> >> +}
>> >> +
>> >>  // CHECK: call i32 (i8*, ...) @_Z6printfPKcz
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22904: Fix two bugs for musl-libc on ARM

2016-07-28 Thread Renato Golin via cfe-commits
rengolin added a comment.

Hi Lei,

Thanks for the fix. A few comments. Also, please, add some tests.

cheers,
--renato



Comment at: lib/Driver/ToolChains.cpp:4266
@@ -4266,1 +4265,3 @@
+  if (Triple.isAndroid()) {
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";
+  } else if (Triple.isMusl()) {

This is an early return, no need for brackets not the "else" below. Ex:

if (Android)
  return ...

if (musl) {
  ...
  return ...
}


https://reviews.llvm.org/D22904



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


r276988 - [OpenMP] Change name of variable in mappble expression.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 10:31:29 2016
New Revision: 276988

URL: http://llvm.org/viewvc/llvm-project?rev=276988&view=rev
Log:
[OpenMP] Change name of variable in mappble expression.

This attempts to fix a failure in Windows bots pottentially related with a 
reserved keyword.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276988&r1=276987&r2=276988&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jul 28 10:31:29 2016
@@ -5014,7 +5014,7 @@ public:
 
 private:
   /// \brief Directive from where the map clauses were extracted.
-  const OMPExecutableDirective &Directive;
+  const OMPExecutableDirective &CurDir;
 
   /// \brief Function the directive is being generated for.
   CodeGenFunction &CGF;
@@ -5419,7 +5419,7 @@ private:
 
 public:
   MappableExprsHandler(const OMPExecutableDirective &Dir, CodeGenFunction &CGF)
-  : Directive(Dir), CGF(CGF) {
+  : CurDir(Dir), CGF(CGF) {
 // Extract firstprivate clause information.
 for (const auto *C : Dir.getClausesOfKind())
   for (const auto *D : C->varlists())
@@ -5485,15 +5485,15 @@ public:
   Info[VD].push_back({L, MapType, MapModifier, ReturnDevicePointer});
 };
 
-for (auto *C : Directive.getClausesOfKind())
+for (auto *C : CurDir.getClausesOfKind())
   for (auto L : C->component_lists())
 InfoGen(L.first, L.second, C->getMapType(), C->getMapTypeModifier(),
 MapInfo::RPK_None);
-for (auto *C : Directive.getClausesOfKind())
+for (auto *C : CurDir.getClausesOfKind())
   for (auto L : C->component_lists())
 InfoGen(L.first, L.second, OMPC_MAP_to, OMPC_MAP_unknown,
 MapInfo::RPK_None);
-for (auto *C : Directive.getClausesOfKind())
+for (auto *C : CurDir.getClausesOfKind())
   for (auto L : C->component_lists())
 InfoGen(L.first, L.second, OMPC_MAP_from, OMPC_MAP_unknown,
 MapInfo::RPK_None);
@@ -5502,7 +5502,7 @@ public:
 // entries as such. If there is no map information for an entry in the
 // use_device_ptr list, we create one with map type 'alloc' and zero size
 // section. It is the user fault if that was not mapped before.
-for (auto *C : Directive.getClausesOfKind())
+for (auto *C : CurDir.getClausesOfKind())
   for (auto L : C->component_lists()) {
 assert(!L.second.empty() && "Not expecting empty list of components!");
 const ValueDecl *VD = L.second.back().getAssociatedDeclaration();
@@ -5632,7 +5632,7 @@ public:
   return;
 }
 
-for (auto *C : Directive.getClausesOfKind())
+for (auto *C : CurDir.getClausesOfKind())
   for (auto L : C->decl_component_lists(VD)) {
 assert(L.first == VD &&
"We got information for the wrong declaration??");


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


RE: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-28 Thread Keane, Erich via cfe-commits
I’ve put this review up on the Phabricator site so that it is easier to look 
at, see here: https://reviews.llvm.org/D22919

Thanks!
-Erich

From: David Majnemer [mailto:david.majne...@gmail.com]
Sent: Monday, July 25, 2016 1:18 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for 
__final specifier

You've added a comment describing the new enum value.  Please make sure the 
comment starts with a cap letter and ends with a period.

On Mon, Jul 25, 2016 at 4:09 PM, Keane, Erich 
mailto:erich.ke...@intel.com>> wrote:
Thanks for the quick review!  I’ve updated the patch with the name changes in 
the attached diff file.

From: David Majnemer 
[mailto:david.majne...@gmail.com]
Sent: Monday, July 25, 2016 12:40 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>
Cc: cfe-commits@lists.llvm.org
Subject: Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for 
__final specifier

I'd rename VS_Alt_Final to VS_GNU_Final.

On Mon, Jul 25, 2016 at 2:24 PM, Keane, Erich via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Hi all, my first potential-contribution, so I apologize if I’m submitting this 
improperly, I’m unfamiliar with the ‘type’ keys that you use in the topic, so 
hopefully I have this right.

As reported in bug 28473, GCC supports ‘final’ functionality in pre-C++11 code 
using the __final keyword.  Clang currently supports the ‘final’ keyword in 
accordance with the C++11 specification, however it ALSO supports it in 
pre-C++11 mode, with a warning.

This patch adds the ‘__final’ keyword for compatibility with GCC in GCC 
Keywords mode (so it is enabled with existing flags), and issues a warning on 
its usage (suggesting switching to the C++11 keyword).  This patch also adds a 
regression test for the functionality described.  I believe this patch has 
minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions.  Patch is 
created in reference to revisions 276665

Thanks,
Erich

___
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] D22913: Mention of proper support for "__unaligned" type qualifier in 3.9 clang release notes

2016-07-28 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276994: Mention of proper support for "__unaligned" type 
qualifier in 3.9 clang… (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D22913?vs=65914&id=65943#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22913

Files:
  cfe/branches/release_39/docs/ReleaseNotes.rst

Index: cfe/branches/release_39/docs/ReleaseNotes.rst
===
--- cfe/branches/release_39/docs/ReleaseNotes.rst
+++ cfe/branches/release_39/docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---


Index: cfe/branches/release_39/docs/ReleaseNotes.rst
===
--- cfe/branches/release_39/docs/ReleaseNotes.rst
+++ cfe/branches/release_39/docs/ReleaseNotes.rst
@@ -92,6 +92,9 @@
 
 TLS is enabled for Cygwin defaults to -femulated-tls.
 
+Proper support, including correct mangling and overloading, added for
+MS-specific "__unaligned" type qualifier.
+
 
 C Language Changes in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21459: Implement http://wg21.link/P0254R1: "Integrating std::string_view and std::string"

2016-07-28 Thread Kim Gräsman via cfe-commits
kimgr added a comment.

This is probably not the right place for this discussion, but I thought I'd 
offer one more note.



Comment at: include/string_view:216
@@ +215,3 @@
+   basic_string_view(const _CharT* __s)
+   : __data(__s), __size(_Traits::length(__s)) {}
+

mclow.lists wrote:
> kimgr wrote:
> > mclow.lists wrote:
> > > mclow.lists wrote:
> > > > kimgr wrote:
> > > > > mclow.lists wrote:
> > > > > > kimgr wrote:
> > > > > > > I'm working from the paper at 
> > > > > > > https://isocpp.org/files/papers/N3762.html, and I find it a 
> > > > > > > little sketchy on the policy for nullptrs.
> > > > > > > 
> > > > > > > Since the ctor above accepts nullptr as long as the length is 
> > > > > > > zero, would it make sense to do that here too? That is, only call 
> > > > > > > _Traits::length for non-nullptr __s args?
> > > > > > Reading from N4600: Requires: `[str, str + traits::length(str))` is 
> > > > > > a valid range.
> > > > > > 
> > > > > > So, no - passing `nullptr` here is undefined.
> > > > > > 
> > > > > OK, that feels more principled to me, anyway.
> > > > > 
> > > > > But the `(const char*, size_t)` constructor has the same requirement 
> > > > > and it *does* accept `nullptr`, provided the length is zero. I saw 
> > > > > you had to get rid of the assertion, but I feel like the constructor 
> > > > > should probably not silently accept `nullptr` for zero-sized strings. 
> > > > > Or do you know if that's intentional? Many StringRef/StringPiece 
> > > > > implementations seem to have the same behavior.
> > > > It is absolutely intentional. `[nullptr, nullptr+0)` is a perfectly 
> > > > fine half-open range. It contains no characters.  
> > > > 
> > > > However, the ctor that takes just a pointer has to calculate the length 
> > > > .. by dereferencing the pointer.
> > > > 
> > > > I had to get rid of the assertion because one of the bots (gcc 4.9) has 
> > > > a bug about constexpr ctors in c++11 mode.  Even though the assertion 
> > > > was `#ifdef`ed on C++ > 11, the compiler complained about it.  I'll be 
> > > > putting the assertion back as soon as I can figure out how to keep gcc 
> > > > from complaining.
> > > This was discussed (at length) in LEWG during the design of `string_view`.
> > Ah, got it, thanks! It opens up for cases where `data()` for an empty 
> > `string_view` can sometimes return `""` and sometimes `nullptr`, but I 
> > guess that problem extends beyond `string_view`'s responsibilities.
> > 
> > Thanks for the thorough explanation.
> I think you're laboring under a misapprehension here.
> 
> An empty `string_view` points to *no characters*, not an empty 
> null-terminated string.
> 
> Treating the pointer that you get back from `string_view::data` as a 
> null-terminated string will lead to all sorts of problems.  This is 
> explicitly called out in [string.view.access]/19:
> 
> > Note: Unlike basic_string::data() and string literals, data() may return a 
> > pointer to a buffer that is not null-terminated. Therefore it is typically 
> > a mistake to pass data() to a routine that takes just a const charT* and 
> > expects a null-terminated string.
> 
> 
Thanks, I think I'm free of that particular misapprehension :-)

The case I had in mind was:

void f(const string_view& s) {
  char buf[50] = {0};
  assert(s.size() < 50);
  memcpy(buf, s.data(), s.size());
}

There's no assumption of null-termination here, but as I understand it, 
`memcpy` has undefined behavior if source is `nullptr`, irrespective of whether 
`num` is zero or not.

So these would be valid:

f(string_view("", 0));
f(string_view(""));

but this wouldn't:

f(string_view(nullptr, 0));

which I find slightly asymmetric.

But again, maybe this is not `string_view`'s fault, but `memcpy`'s, in which 
case `nullptr` kludges could be moved to wherever `memcpy` is used instead of 
wherever `string_view::string_view` is used.


https://reviews.llvm.org/D21459



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


[PATCH] D22920: [codeview] Emit information about vftables

2016-07-28 Thread Reid Kleckner via cfe-commits
rnk created this revision.
rnk added reviewers: amccarth, aprantl, dblaikie, dexonsmith.
rnk added a subscriber: cfe-commits.
rnk added a dependency: D22884: [codeview] Emit vftable records.

MSVC emits codeview records describing all the methods contained in a
vftable. This is observable in windbg with 'dt -v'.

Depends on D22884

https://reviews.llvm.org/D22920

Files:
  include/clang/AST/VTableBuilder.h
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-ms-abi.cpp
  test/CodeGenCXX/debug-info-ms-vftables.cpp

Index: test/CodeGenCXX/debug-info-ms-vftables.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-ms-vftables.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
+
+namespace diamond {
+struct A { virtual void f(); };
+struct B : virtual A { virtual void g(); };
+struct C : virtual A { virtual void h(); };
+struct D : B, C { virtual void j(); };
+D d;
+}
+
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D",
+// CHECK-SAME:elements: ![[elements:[0-9]+]],
+// CHECK-SAME:identifier: ".?AUD@diamond@@")
+
+// CHECK: ![[elements]] = !{!{{[0-9]+}}, !{{[0-9]+}}, ![[vt_D_B:[0-9]+]], ![[vt_D_A:[0-9]+]], ![[vt_D_C:[0-9]+]], !{{[0-9]+}}}
+
+// CHECK: ![[vt_D_B]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7D@diamond@@6BB@1@@",
+// CHECK: ![[vt_D_A]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7D@diamond@@6BA@1@@",
+// CHECK: ![[vt_D_C]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7D@diamond@@6BC@1@@",
+
+// This test tries to exercise all four of the possible MS ABI manglings for
+// C++ virtual methods:
+// - normal methods
+// - virtual dtors
+// - virtual dtor thunks
+// - virtual method thunks
+namespace thunks {
+struct A {
+  virtual ~A();
+  virtual void f();
+};
+struct B {
+  virtual ~B();
+  virtual void f();
+};
+struct C : A, B {
+  virtual ~C();
+  virtual void f();
+};
+C c;
+}
+
+// CHECK: ![[C_thunks:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C",
+// CHECK-SAME:elements: ![[elements:[0-9]+]],
+// CHECK-SAME:identifier: ".?AUC@thunks@@")
+
+// CHECK: ![[elements]] = !{!{{[0-9]+}}, !{{[0-9]+}}, ![[vt_C_A:[0-9]+]], ![[vt_C_B:[0-9]+]], !{{[0-9]+}}, !{{[0-9]+}}}
+
+// CHECK: ![[vt_C_A]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7C@thunks@@6BA@1@@",
+// CHECK-SAME:   extraData: ![[vt_C_A_methods:[0-9]+]])
+
+// CHECK: ![[vt_C_A_methods]] = !{!"??_GC@thunks@@UAEPAXI@Z", !"?f@C@thunks@@UAEXXZ"}
+
+// CHECK: ![[vt_C_B]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7C@thunks@@6BB@1@@",
+// CHECK-SAME:   extraData: ![[vt_C_B_methods:[0-9]+]])
+
+// CHECK: ![[vt_C_B_methods]] = !{!"??_EC@thunks@@W3AEPAXI@Z", !"?f@C@thunks@@W3AEXXZ"}
Index: test/CodeGenCXX/debug-info-ms-abi.cpp
===
--- test/CodeGenCXX/debug-info-ms-abi.cpp
+++ test/CodeGenCXX/debug-info-ms-abi.cpp
@@ -15,7 +15,11 @@
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 // CHECK-SAME: identifier: ".?AUFoo@@"
 
-// CHECK: ![[elements]] = !{![[vptr:[0-9]+]], ![[Nested:[0-9]+]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]]}
+// CHECK: ![[elements]] = !{![[vftable:[0-9]+]], ![[vptr:[0-9]+]], ![[Nested:[0-9]+]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]]}
+
+// CHECK: ![[vftable]] = !DIDerivedType(tag: DW_TAG_LLVM_msvftable, name: "??_7Foo@@6B@", scope: ![[Foo]], baseType: null, extraData: ![[methodlist:[0-9]+]])
+
+// CHECK: ![[methodlist]] = !{!"?f@Foo@@UAEXXZ", !"?g@Foo@@UAEXXZ", !"?h@Foo@@UAEXXZ"}
 
 // CHECK: ![[Nested]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
 // CHECK-SAME: identifier: ".?AUNested@Foo@@"
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -22,6 +22,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/ValueHandle.h"
@@ -40,6 +41,7 @@
 class ObjCIvarDecl;
 class UsingDecl;
 class VarDecl;
+struct VPtrInfo;
 
 namespace CodeGen {
 class CodeGenModule;
@@ -128,6 +130,7 @@
   NamespaceAliasCache;
   llvm::DenseMap>
   StaticDataMemberCache;
+  llvm::DenseMap MSVFTableCache;
 
   /// Helper functions for getOrCreateType.
   /// @{
@@ -263,7 +266,13 @@
   /// If the C++ class has vtable info then insert appropriate debug
   /// info entry in EltTys vector.
   void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile *F,
- SmallVectorImpl &EltTys);
+ SmallVectorImpl &EltTys,
+ llvm::DIType *RecordTy);
+
+  /// Get the DW_TAG_LLVM_msvftab

r276995 - [CUDA] Rename cuda_phases.cu test to cuda-phases.cu to be consistent with the other tests.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 11:12:30 2016
New Revision: 276995

URL: http://llvm.org/viewvc/llvm-project?rev=276995&view=rev
Log:
[CUDA] Rename cuda_phases.cu test to cuda-phases.cu to be consistent with the 
other tests.

Added:
cfe/trunk/test/Driver/cuda-phases.cu

Added: cfe/trunk/test/Driver/cuda-phases.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-phases.cu?rev=276995&view=auto
==
--- cfe/trunk/test/Driver/cuda-phases.cu (added)
+++ cfe/trunk/test/Driver/cuda-phases.cu Thu Jul 28 11:12:30 2016
@@ -0,0 +1,206 @@
+// Tests the phases generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: 0: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// BIN: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
+// BIN: 2: compiler, {1}, ir, (host-cuda)
+// BIN: 3: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// BIN: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
+// BIN: 5: compiler, {4}, ir, (device-cuda, sm_30)
+// BIN: 6: backend, {5}, assembler, (device-cuda, sm_30)
+// BIN: 7: assembler, {6}, object, (device-cuda, sm_30)
+// BIN: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
+// BIN: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
+// BIN: 10: linker, {8, 9}, cuda-fatbin, (device-cuda)
+// BIN: 11: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {10}, ir
+// BIN: 12: backend, {11}, assembler, (host-cuda)
+// BIN: 13: assembler, {12}, object, (host-cuda)
+// BIN: 14: linker, {13}, image, (host-cuda)
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: 0: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// ASM: 1: preprocessor, {0}, cuda-cpp-output, (device-cuda, sm_30)
+// ASM: 2: compiler, {1}, ir, (device-cuda, sm_30)
+// ASM: 3: backend, {2}, assembler, (device-cuda, sm_30)
+// ASM: 4: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {3}, assembler
+// ASM: 5: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// ASM: 6: preprocessor, {5}, cuda-cpp-output, (host-cuda)
+// ASM: 7: compiler, {6}, ir, (host-cuda)
+// ASM: 8: backend, {7}, assembler, (host-cuda)
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: 0: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// BIN2: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
+// BIN2: 2: compiler, {1}, ir, (host-cuda)
+// BIN2: 3: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// BIN2: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
+// BIN2: 5: compiler, {4}, ir, (device-cuda, sm_30)
+// BIN2: 6: backend, {5}, assembler, (device-cuda, sm_30)
+// BIN2: 7: assembler, {6}, object, (device-cuda, sm_30)
+// BIN2: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
+// BIN2: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
+// BIN2: 10: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_35)
+// BIN2: 11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_35)
+// BIN2: 12: compiler, {11}, ir, (device-cuda, sm_35)
+// BIN2: 13: backend, {12}, assembler, (device-cuda, sm_35)
+// BIN2: 14: assembler, {13}, object, (device-cuda, sm_35)
+// BIN2: 15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {14}, object
+// BIN2: 16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {13}, assembler
+// BIN2: 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
+// BIN2: 18: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, 
"device-cuda (nvptx64-nvidia-cuda)" {17}, ir
+// BIN2: 19: backend, {18}, assembler, (host-cuda)
+// BIN2: 20: assembler, {19}, object, (host-cuda)
+// BIN2: 21: linker, {20}, image, (host-cuda)
+
+//
+// Test two gpu architecturess up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: 0: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// ASM2: 1: preprocessor, {0}, cuda-cpp-output, (device-cuda, sm_30)
+// ASM2: 2: compiler, {1}, ir, (device-cuda, sm_30)
+// ASM2: 3: backend, {2}

Re: [PATCH] D22919: GCC Compatibility: Support for __final specifier

2016-07-28 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM as-is, clang's behavior would be congruent with GCC's.



Comment at: lib/Parse/ParseDeclCXX.cpp:3024-3026
@@ -3013,2 +3023,5 @@
   Diag(FinalLoc, diag::ext_ms_sealed_keyword);
+else if (Specifier == VirtSpecifiers::VS_GNU_Final) {
+  Diag(FinalLoc, diag::ext_warn_gnu_final);
+}
 

Please remove these braces.


Repository:
  rL LLVM

https://reviews.llvm.org/D22919



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


r276996 - [CUDA] Remove duplicated test that should have been removed in r276995.

2016-07-28 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jul 28 11:18:31 2016
New Revision: 276996

URL: http://llvm.org/viewvc/llvm-project?rev=276996&view=rev
Log:
[CUDA] Remove duplicated test that should have been removed in r276995.

Removed:
cfe/trunk/test/Driver/cuda_phases.cu

Removed: cfe/trunk/test/Driver/cuda_phases.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda_phases.cu?rev=276995&view=auto
==
--- cfe/trunk/test/Driver/cuda_phases.cu (original)
+++ cfe/trunk/test/Driver/cuda_phases.cu (removed)
@@ -1,206 +0,0 @@
-// Tests the phases generated for a CUDA offloading target for different
-// combinations of:
-// - Number of gpu architectures;
-// - Host/device-only compilation;
-// - User-requested final phase - binary or assembly.
-
-// REQUIRES: clang-driver
-// REQUIRES: powerpc-registered-target
-// REQUIRES: nvptx-registered-target
-
-//
-// Test single gpu architecture with complete compilation.
-//
-// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN %s
-// BIN: 0: input, "{{.*}}cuda_phases.cu", cuda, (host-cuda)
-// BIN: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
-// BIN: 2: compiler, {1}, ir, (host-cuda)
-// BIN: 3: input, "{{.*}}cuda_phases.cu", cuda, (device-cuda, sm_30)
-// BIN: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN: 5: compiler, {4}, ir, (device-cuda, sm_30)
-// BIN: 6: backend, {5}, assembler, (device-cuda, sm_30)
-// BIN: 7: assembler, {6}, object, (device-cuda, sm_30)
-// BIN: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
-// BIN: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
-// BIN: 10: linker, {8, 9}, cuda-fatbin, (device-cuda)
-// BIN: 11: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {10}, ir
-// BIN: 12: backend, {11}, assembler, (host-cuda)
-// BIN: 13: assembler, {12}, object, (host-cuda)
-// BIN: 14: linker, {13}, image, (host-cuda)
-
-//
-// Test single gpu architecture up to the assemble phase.
-//
-// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 %s -S 2>&1 \
-// RUN: | FileCheck -check-prefix=ASM %s
-// ASM: 0: input, "{{.*}}cuda_phases.cu", cuda, (device-cuda, sm_30)
-// ASM: 1: preprocessor, {0}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM: 2: compiler, {1}, ir, (device-cuda, sm_30)
-// ASM: 3: backend, {2}, assembler, (device-cuda, sm_30)
-// ASM: 4: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {3}, assembler
-// ASM: 5: input, "{{.*}}cuda_phases.cu", cuda, (host-cuda)
-// ASM: 6: preprocessor, {5}, cuda-cpp-output, (host-cuda)
-// ASM: 7: compiler, {6}, ir, (host-cuda)
-// ASM: 8: backend, {7}, assembler, (host-cuda)
-
-//
-// Test two gpu architectures with complete compilation.
-//
-// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN2 %s
-// BIN2: 0: input, "{{.*}}cuda_phases.cu", cuda, (host-cuda)
-// BIN2: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
-// BIN2: 2: compiler, {1}, ir, (host-cuda)
-// BIN2: 3: input, "{{.*}}cuda_phases.cu", cuda, (device-cuda, sm_30)
-// BIN2: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN2: 5: compiler, {4}, ir, (device-cuda, sm_30)
-// BIN2: 6: backend, {5}, assembler, (device-cuda, sm_30)
-// BIN2: 7: assembler, {6}, object, (device-cuda, sm_30)
-// BIN2: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
-// BIN2: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
-// BIN2: 10: input, "{{.*}}cuda_phases.cu", cuda, (device-cuda, sm_35)
-// BIN2: 11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_35)
-// BIN2: 12: compiler, {11}, ir, (device-cuda, sm_35)
-// BIN2: 13: backend, {12}, assembler, (device-cuda, sm_35)
-// BIN2: 14: assembler, {13}, object, (device-cuda, sm_35)
-// BIN2: 15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {14}, object
-// BIN2: 16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {13}, assembler
-// BIN2: 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
-// BIN2: 18: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, 
"device-cuda (nvptx64-nvidia-cuda)" {17}, ir
-// BIN2: 19: backend, {18}, assembler, (host-cuda)
-// BIN2: 20: assembler, {19}, object, (host-cuda)
-// BIN2: 21: linker, {20}, image, (host-cuda)
-
-//
-// Test two gpu architecturess up to the assemble phase.
-//
-// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
-// RUN: | FileCheck -check-prefix=ASM2 %s
-// ASM2: 0: input, "{{.*}}cuda_phases.cu", cuda, (device-cuda, sm_30)
-// ASM2: 1: preprocessor, {0}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM2: 2: compiler, {1}, ir, (device-cuda, sm_30)
-// ASM2: 3: backend, {2}, assembler, (device-cuda, s

Re: [PATCH] D22919: GCC Compatibility: Support for __final specifier

2016-07-28 Thread Erich Keane via cfe-commits
erichkeane removed rL LLVM as the repository for this revision.
erichkeane updated this revision to Diff 65951.

https://reviews.llvm.org/D22919

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/DeclSpec.cpp
  test/Parser/gcc-__final-compatibility.cpp

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2005,6 +2005,7 @@
 ///   virt-specifier:
 /// override
 /// final
+/// __final
 VirtSpecifiers::Specifier Parser::isCXX11VirtSpecifier(const Token &Tok) const {
   if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
 return VirtSpecifiers::VS_None;
@@ -2014,6 +2015,8 @@
   // Initialize the contextual keywords.
   if (!Ident_final) {
 Ident_final = &PP.getIdentifierTable().get("final");
+if (getLangOpts().GNUKeywords)
+  Ident_GNU_final = &PP.getIdentifierTable().get("__final");
 if (getLangOpts().MicrosoftExt)
   Ident_sealed = &PP.getIdentifierTable().get("sealed");
 Ident_override = &PP.getIdentifierTable().get("override");
@@ -2028,6 +2031,9 @@
   if (II == Ident_final)
 return VirtSpecifiers::VS_Final;
 
+  if (II == Ident_GNU_final)
+return VirtSpecifiers::VS_GNU_Final;
+
   return VirtSpecifiers::VS_None;
 }
 
@@ -2067,6 +2073,8 @@
 << VirtSpecifiers::getSpecifierName(Specifier);
 } else if (Specifier == VirtSpecifiers::VS_Sealed) {
   Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
+} else if (Specifier == VirtSpecifiers::VS_GNU_Final) {
+  Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
 } else {
   Diag(Tok.getLocation(),
getLangOpts().CPlusPlus11
@@ -2083,6 +2091,7 @@
 bool Parser::isCXX11FinalKeyword() const {
   VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier();
   return Specifier == VirtSpecifiers::VS_Final ||
+ Specifier == VirtSpecifiers::VS_GNU_Final || 
  Specifier == VirtSpecifiers::VS_Sealed;
 }
 
@@ -2996,6 +3005,7 @@
   if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) {
 VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(Tok);
 assert((Specifier == VirtSpecifiers::VS_Final ||
+Specifier == VirtSpecifiers::VS_GNU_Final || 
 Specifier == VirtSpecifiers::VS_Sealed) &&
"not a class definition");
 FinalLoc = ConsumeToken();
@@ -3011,6 +3021,8 @@
 << VirtSpecifiers::getSpecifierName(Specifier);
 else if (Specifier == VirtSpecifiers::VS_Sealed)
   Diag(FinalLoc, diag::ext_ms_sealed_keyword);
+else if (Specifier == VirtSpecifiers::VS_GNU_Final)
+  Diag(FinalLoc, diag::ext_warn_gnu_final);
 
 // Parse any C++11 attributes after 'final' keyword.
 // These attributes are not allowed to appear here,
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -1299,6 +1299,7 @@
   switch (VS) {
   default: llvm_unreachable("Unknown specifier!");
   case VS_Override: VS_overrideLoc = Loc; break;
+  case VS_GNU_Final:
   case VS_Sealed:
   case VS_Final:VS_finalLoc = Loc; break;
   }
@@ -1311,6 +1312,7 @@
   default: llvm_unreachable("Unknown specifier");
   case VS_Override: return "override";
   case VS_Final: return "final";
+  case VS_GNU_Final: return "__final";
   case VS_Sealed: return "sealed";
   }
 }
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -143,6 +143,7 @@
 
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
+  mutable IdentifierInfo *Ident_GNU_final;
   mutable IdentifierInfo *Ident_override;
 
   // C++ type trait keywords that can be reverted to identifiers and still be
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -2399,7 +2399,9 @@
 VS_None = 0,
 VS_Override = 1,
 VS_Final = 2,
-VS_Sealed = 4
+VS_Sealed = 4,
+// Represents the __final keyword, which is legal for gcc in pre-C++11 mode.
+VS_GNU_Final = 8
   };
 
   VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
@@ -2412,7 +2414,7 @@
   bool isOverrideSpecified() const { return Specifiers & VS_Override; }
   SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
 
-  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed); }
+  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed | VS_GNU_Final); }
   bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; }
   SourceLocation getFinalLoc() const { return VS_finalLoc; }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td

Re: [PATCH] D22919: GCC Compatibility: Support for __final specifier

2016-07-28 Thread Erich Keane via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added a comment.

Fixed the braces mentioned.


https://reviews.llvm.org/D22919



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


Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect

2016-07-28 Thread Zachary Turner via cfe-commits
Sorry for the delay, I had forgotten about this.  I will check it in today.

On Wed, Jul 27, 2016 at 5:57 PM comicfans44  wrote:

> comicfans44 added a comment.
>
> In https://reviews.llvm.org/D21946#473071, @zturner wrote:
>
> > In https://reviews.llvm.org/D21946#473070, @comicfans44 wrote:
> >
> > > I've not commited to cfe before, so I think I havn't commit access
> permission.
> >
> >
> > If you've committed anywhere in LLVM, you should have commit access to
> cfe.  Feel free to give it a try, as I won't be able to commit until
> Wednesday of next week at the earliest anyway due to the upcoming holiday.
>
>
> ping ?
>
>
> https://reviews.llvm.org/D21946
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22803: [clang-tidy] Fix an unused-using-decl false positive about template arguments infunction call expression.

2016-07-28 Thread Manuel Klimek via cfe-commits
klimek added a subscriber: klimek.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:83
@@ -80,3 +82,3 @@
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-if (const auto *Specialization =
-dyn_cast(Used))
+if (const auto *FD = dyn_cast(Used)) {
+  // There is no straightforward way to match template arguments in a

I thought the idea was to make an overload for hasTemplateArgument to work on 
FunctionDecl. Any specific reason not to make the matchers better?


https://reviews.llvm.org/D22803



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


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-28 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/Analysis/CloneDetection.cpp:91
@@ +90,3 @@
+  ASTContext &Context;
+  std::vector &CollectedData;
+

Maybe it's a good idea to introduce a typedef for `unsigned` here, because it'd 
be nice to be able to change it (eg., some day we may desire to switch to 
uint64_t).


Comment at: lib/Analysis/CloneDetection.cpp:119
@@ +118,3 @@
+// with zeroes.
+if (Str.size() % sizeof(unsigned))
+  CollectedData.push_back(0);

Maybe just allocate the right amount of bytes during resize? Some usual trick 
with rounding up, eg. `(x + y - 1) / y`.


Comment at: lib/Analysis/CloneDetection.cpp:134
@@ +133,3 @@
+  DEF_ADD_DATA(Stmt, { addData(S->getStmtClass()); })
+  DEF_ADD_DATA(Expr, { addData(S->getType()); })
+

I noticed something: with this patch, you no longer consider the kind of the 
statement for supported statement types (even for, say, `Expr`), because the 
visitor doesn't automatically fall back to parent classes when a method for the 
child class is defined. Is this intentional? Or you may want to visit some 
statements with parent methods manually.


Comment at: lib/Analysis/CloneDetection.cpp:148
@@ +147,3 @@
+  DEF_ADD_DATA(CallExpr,
+   { addData(S->getDirectCallee()->getQualifiedNameAsString()); })
+

I wonder how much we can save if we use a few pointers-based hashes instead of 
hashing long fully-qualified names, for stuff like function decls or types.

Uhm, by the way, in fact C++ overloaded functions have same qualified names, do 
we consider that? I guess sub-statement hashing would most likely take care of 
that.


Comment at: test/Analysis/copypaste/test-asm.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -analyze -std=c++11 
-analyzer-checker=alpha.clone.CloneChecker -verify %s
+

Do we really need to prefix all test file names with "`test-`"? It's kind of 
obvious :)


https://reviews.llvm.org/D22514



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-28 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks! Could you please address these small comments before committing!



Comment at: lib/Sema/SemaInit.cpp:6959
@@ +6958,3 @@
+// this has already been done when parsing the variable declaration.
+// Do not diagnose this since it has already been diagnosed when 
parsing
+// the initializer.

Can you remove this sentence as it duplicates the previous one.


Comment at: lib/Sema/SemaInit.cpp:6961
@@ +6960,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

I think you don't need this check any more because this code is inside the else 
part. Could you please double check before committing?


Comment at: test/CodeGenOpenCL/sampler.cl:3
@@ +2,3 @@
+//
+// This test covers 6 cases of sampler initialzation:
+//   1. function argument passing

5 cases


https://reviews.llvm.org/D21567



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


Re: [PATCH] D22913: Mention of proper support for "__unaligned" type qualifier in 3.9 clang release notes

2016-07-28 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


https://reviews.llvm.org/D22913



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


Re: r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-28 Thread Hans Wennborg via cfe-commits
Should we merge this to 3.9?

Cheers,
Hans

On Thu, Jul 28, 2016 at 7:29 AM, Samuel Antao via cfe-commits
 wrote:
> Author: sfantao
> Date: Thu Jul 28 09:29:18 2016
> New Revision: 276979
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276979&view=rev
> Log:
> [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.
>
> Summary:
> This patch prevents OpenMP flags from being forwarded to CUDA device 
> commands. That was causing the CUDA frontend to attempt to emit OpenMP code 
> which is not supported.
>
> This fixes the bug reported in https://llvm.org/bugs/show_bug.cgi?id=28723.
>
> Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra, ABataev
>
> Subscribers: caomhin, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D22895
>
> Added:
> cfe/trunk/test/Driver/offloading-interoperability.c
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-28 Thread Samuel F Antao via cfe-commits
Hi Hans,
 
I think it should. All the stuff that enables this fix seems to be in 3.9 already.
 
Thanks!
Samuel
 
 
- Original message -From: Hans Wennborg Sent by: hwennb...@google.comTo: Samuel F Antao/Watson/IBM@IBMUS, "Bataev, Alexey" Cc: cfe-commits Subject: Re: r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.Date: Thu, Jul 28, 2016 1:10 PM 
Should we merge this to 3.9?Cheers,HansOn Thu, Jul 28, 2016 at 7:29 AM, Samuel Antao via cfe-commits wrote:> Author: sfantao> Date: Thu Jul 28 09:29:18 2016> New Revision: 276979>> URL: http://llvm.org/viewvc/llvm-project?rev=276979&view=rev> Log:> [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.>> Summary:> This patch prevents OpenMP flags from being forwarded to CUDA device commands. That was causing the CUDA frontend to attempt to emit OpenMP code which is not supported.>> This fixes the bug reported in https://llvm.org/bugs/show_bug.cgi?id=28723.>> Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra, ABataev>> Subscribers: caomhin, cfe-commits>> Differential Revision: https://reviews.llvm.org/D22895>> Added:>     cfe/trunk/test/Driver/offloading-interoperability.c> Modified:>     cfe/trunk/lib/Driver/Tools.cpp 
 

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


Re: r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-28 Thread Hans Wennborg via cfe-commits
I've merged it in r277004.

Cheers,
Hans

On Thu, Jul 28, 2016 at 10:15 AM, Samuel F Antao  wrote:
> Hi Hans,
>
> I think it should. All the stuff that enables this fix seems to be in 3.9
> already.
>
> Thanks!
> Samuel
>
>
>
> - Original message -
> From: Hans Wennborg 
> Sent by: hwennb...@google.com
> To: Samuel F Antao/Watson/IBM@IBMUS, "Bataev, Alexey" 
> Cc: cfe-commits 
> Subject: Re: r276979 - [OpenMP][CUDA] Do not forward OpenMP flags for CUDA
> device actions.
> Date: Thu, Jul 28, 2016 1:10 PM
>
> Should we merge this to 3.9?
>
> Cheers,
> Hans
>
> On Thu, Jul 28, 2016 at 7:29 AM, Samuel Antao via cfe-commits
>  wrote:
>> Author: sfantao
>> Date: Thu Jul 28 09:29:18 2016
>> New Revision: 276979
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276979&view=rev
>> Log:
>> [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.
>>
>> Summary:
>> This patch prevents OpenMP flags from being forwarded to CUDA device
>> commands. That was causing the CUDA frontend to attempt to emit OpenMP code
>> which is not supported.
>>
>> This fixes the bug reported in
>> https://llvm.org/bugs/show_bug.cgi?id=28723.
>>
>> Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra, ABataev
>>
>> Subscribers: caomhin, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D22895
>>
>> Added:
>> cfe/trunk/test/Driver/offloading-interoperability.c
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r277005 - [Driver] Fix Windows SDK Detection

2016-07-28 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Jul 28 12:13:32 2016
New Revision: 277005

URL: http://llvm.org/viewvc/llvm-project?rev=277005&view=rev
Log:
[Driver] Fix Windows SDK Detection

This fixes a couple of bugs in Windows SDK Detection.

1. `readFullStringValue` returns a bool, but was being compared
   with ERROR_SUCCESS.
2. `RegQueryValueExW` might return the null terminator in the
   queried value which will result in incorrect values being
   returned from `getSystemRegistryString`.

Patch By: comicfan...@gmail.com
Reviewed By: zturner
Differential Revision: http://reviews.llvm.org/D21946

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

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=277005&r1=277004&r2=277005&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Thu Jul 28 12:13:32 2016
@@ -114,6 +114,9 @@ static bool readFullStringValue(HKEY hke
   if (result == ERROR_SUCCESS) {
 std::wstring WideValue(reinterpret_cast(buffer.data()),
valueSize / sizeof(wchar_t));
+if (valueSize && WideValue.back() == L'\0') {
+WideValue.pop_back();
+}
 // The destination buffer must be empty as an invariant of the conversion
 // function; but this function is sometimes called in a loop that passes in
 // the same buffer, however. Simply clear it out so we can overwrite it.
@@ -191,8 +194,7 @@ static bool getSystemRegistryString(cons
   lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0,
   KEY_READ | KEY_WOW64_32KEY, &hKey);
   if (lResult == ERROR_SUCCESS) {
-lResult = readFullStringValue(hKey, valueName, value);
-if (lResult == ERROR_SUCCESS) {
+if (readFullStringValue(hKey, valueName, value)) {
   bestValue = dvalue;
   if (phValue)
 *phValue = bestName;
@@ -209,8 +211,7 @@ static bool getSystemRegistryString(cons
 lResult =
 RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey);
 if (lResult == ERROR_SUCCESS) {
-  lResult = readFullStringValue(hKey, valueName, value);
-  if (lResult == ERROR_SUCCESS)
+  if (readFullStringValue(hKey, valueName, value))
 returnValue = true;
   if (phValue)
 phValue->clear();


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


Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect

2016-07-28 Thread Zachary Turner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277005: [Driver] Fix Windows SDK Detection (authored by 
zturner).

Changed prior to commit:
  https://reviews.llvm.org/D21946?vs=62570&id=65958#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21946

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

Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -114,6 +114,9 @@
   if (result == ERROR_SUCCESS) {
 std::wstring WideValue(reinterpret_cast(buffer.data()),
valueSize / sizeof(wchar_t));
+if (valueSize && WideValue.back() == L'\0') {
+WideValue.pop_back();
+}
 // The destination buffer must be empty as an invariant of the conversion
 // function; but this function is sometimes called in a loop that passes in
 // the same buffer, however. Simply clear it out so we can overwrite it.
@@ -191,8 +194,7 @@
   lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0,
   KEY_READ | KEY_WOW64_32KEY, &hKey);
   if (lResult == ERROR_SUCCESS) {
-lResult = readFullStringValue(hKey, valueName, value);
-if (lResult == ERROR_SUCCESS) {
+if (readFullStringValue(hKey, valueName, value)) {
   bestValue = dvalue;
   if (phValue)
 *phValue = bestName;
@@ -209,8 +211,7 @@
 lResult =
 RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey);
 if (lResult == ERROR_SUCCESS) {
-  lResult = readFullStringValue(hKey, valueName, value);
-  if (lResult == ERROR_SUCCESS)
+  if (readFullStringValue(hKey, valueName, value))
 returnValue = true;
   if (phValue)
 phValue->clear();


Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -114,6 +114,9 @@
   if (result == ERROR_SUCCESS) {
 std::wstring WideValue(reinterpret_cast(buffer.data()),
valueSize / sizeof(wchar_t));
+if (valueSize && WideValue.back() == L'\0') {
+WideValue.pop_back();
+}
 // The destination buffer must be empty as an invariant of the conversion
 // function; but this function is sometimes called in a loop that passes in
 // the same buffer, however. Simply clear it out so we can overwrite it.
@@ -191,8 +194,7 @@
   lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0,
   KEY_READ | KEY_WOW64_32KEY, &hKey);
   if (lResult == ERROR_SUCCESS) {
-lResult = readFullStringValue(hKey, valueName, value);
-if (lResult == ERROR_SUCCESS) {
+if (readFullStringValue(hKey, valueName, value)) {
   bestValue = dvalue;
   if (phValue)
 *phValue = bestName;
@@ -209,8 +211,7 @@
 lResult =
 RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey);
 if (lResult == ERROR_SUCCESS) {
-  lResult = readFullStringValue(hKey, valueName, value);
-  if (lResult == ERROR_SUCCESS)
+  if (readFullStringValue(hKey, valueName, value))
 returnValue = true;
   if (phValue)
 phValue->clear();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect

2016-07-28 Thread Zachary Turner via cfe-commits
Committed in r277005

On Thu, Jul 28, 2016 at 9:38 AM Zachary Turner  wrote:

> Sorry for the delay, I had forgotten about this.  I will check it in today.
>
> On Wed, Jul 27, 2016 at 5:57 PM comicfans44  wrote:
>
>> comicfans44 added a comment.
>>
>> In https://reviews.llvm.org/D21946#473071, @zturner wrote:
>>
>> > In https://reviews.llvm.org/D21946#473070, @comicfans44 wrote:
>> >
>> > > I've not commited to cfe before, so I think I havn't commit access
>> permission.
>> >
>> >
>> > If you've committed anywhere in LLVM, you should have commit access to
>> cfe.  Feel free to give it a try, as I won't be able to commit until
>> Wednesday of next week at the earliest anyway due to the upcoming holiday.
>>
>>
>> ping ?
>>
>>
>> https://reviews.llvm.org/D21946
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r277008 - Revert r276973 "Adjust Registry interface to not require plugins to export a registry"

2016-07-28 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Jul 28 12:17:22 2016
New Revision: 277008

URL: http://llvm.org/viewvc/llvm-project?rev=277008&view=rev
Log:
Revert r276973 "Adjust Registry interface to not require plugins to export a 
registry"

Buildbot failures when building with clang -Werror. Reverting while I try to
figure this out.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=277008&r1=277007&r2=277008&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Jul 28 12:17:22 2016
@@ -47,7 +47,7 @@ using namespace clang::driver;
 using namespace clang::tooling;
 using namespace llvm;
 
-LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
+template class llvm::Registry;
 
 namespace clang {
 namespace tidy {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h?rev=277008&r1=277007&r2=277008&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h Thu Jul 28 
12:17:22 2016
@@ -13,6 +13,8 @@
 #include "ClangTidyModule.h"
 #include "llvm/Support/Registry.h"
 
+extern template class llvm::Registry;
+
 namespace clang {
 namespace tidy {
 


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


r277008 - Revert r276973 "Adjust Registry interface to not require plugins to export a registry"

2016-07-28 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Jul 28 12:17:22 2016
New Revision: 277008

URL: http://llvm.org/viewvc/llvm-project?rev=277008&view=rev
Log:
Revert r276973 "Adjust Registry interface to not require plugins to export a 
registry"

Buildbot failures when building with clang -Werror. Reverting while I try to
figure this out.

Modified:
cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt (original)
+++ cfe/trunk/examples/AnnotateFunctions/CMakeLists.txt Thu Jul 28 12:17:22 2016
@@ -1,4 +1,4 @@
-add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL 
clang)
+add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(AnnotateFunctions PRIVATE

Modified: cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt (original)
+++ cfe/trunk/examples/PrintFunctionNames/CMakeLists.txt Thu Jul 28 12:17:22 
2016
@@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols di
   endif()
 endif()
 
-add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL 
clang)
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(PrintFunctionNames PRIVATE

Modified: cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendPluginRegistry.h Thu Jul 28 
12:17:22 2016
@@ -13,6 +13,9 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/Support/Registry.h"
 
+// Instantiated in FrontendAction.cpp.
+extern template class llvm::Registry;
+
 namespace clang {
 
 /// The frontend plugin registry.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jul 28 12:17:22 2016
@@ -1972,4 +1972,6 @@ typedef llvm::Registry Pr
 
 }  // end namespace clang
 
+extern template class llvm::Registry;
+
 #endif

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jul 28 12:17:22 2016
@@ -33,7 +33,7 @@
 #include 
 using namespace clang;
 
-LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
+template class llvm::Registry;
 
 namespace {
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Thu Jul 28 12:17:22 2016
@@ -54,7 +54,7 @@
 #include 
 using namespace clang;
 
-LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
+template class llvm::Registry;
 
 
//===--===//
 ExternalPreprocessorSource::~ExternalPreprocessorSource() { }

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=277008&r1=277007&r2=277008&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Thu Jul 28 12:17:22 2016
@@ -32,8 +32,6 @@
 using namespace clang;
 using namespace too

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-28 Thread Yaxun Liu via cfe-commits
yaxunl marked 2 inline comments as done.


Comment at: lib/Sema/SemaInit.cpp:6961
@@ +6960,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Anastasia wrote:
> I think you don't need this check any more because this code is inside the 
> else part. Could you please double check before committing?
I tried removing this line. There will be extra diagnostics emitted for test 
case:

constant sampler_t glb_smp6 = glb_smp;

We only expects error msg: `initializer element is not a compile-time 
constant`. However in addition to that, we also get `sampler_t initialization 
requires 32-bit integer, not '__constant sampler_t'`. This is because the break 
is removed. So I think better not removed the line.



https://reviews.llvm.org/D21567



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


r277009 - [analyzer] Fix misleading indentation in ObjCDeallocChecker. NFC.

2016-07-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Jul 28 12:18:33 2016
New Revision: 277009

URL: http://llvm.org/viewvc/llvm-project?rev=277009&view=rev
Log:
[analyzer] Fix misleading indentation in ObjCDeallocChecker. NFC.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=277009&r1=277008&r2=277009&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Jul 28 
12:18:33 2016
@@ -525,7 +525,7 @@ void ObjCDeallocChecker::diagnoseMissing
 if (SelfRegion != IvarRegion->getSuperRegion())
   continue;
 
-  const ObjCIvarDecl *IvarDecl = IvarRegion->getDecl();
+const ObjCIvarDecl *IvarDecl = IvarRegion->getDecl();
 // Prevent an inlined call to -dealloc in a super class from warning
 // about the values the subclass's -dealloc should release.
 if (IvarDecl->getContainingInterface() !=


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


Re: [PATCH] D22767: [OpenCL] Added CLK_ABGR definition for get_image_channel_order return value

2016-07-28 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D22767



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-28 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-28 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaInit.cpp:6961
@@ +6960,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

yaxunl wrote:
> Anastasia wrote:
> > I think you don't need this check any more because this code is inside the 
> > else part. Could you please double check before committing?
> I tried removing this line. There will be extra diagnostics emitted for test 
> case:
> 
> constant sampler_t glb_smp6 = glb_smp;
> 
> We only expects error msg: `initializer element is not a compile-time 
> constant`. However in addition to that, we also get `sampler_t initialization 
> requires 32-bit integer, not '__constant sampler_t'`. This is because the 
> break is removed. So I think better not removed the line.
> 
Sure! Thanks for checking it!


https://reviews.llvm.org/D21567



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


[PATCH] D22926: Static Analyzer - Localizability Checker: New Localizable APIs for macOS Sierra

2016-07-28 Thread Kulpreet Chilana via cfe-commits
kulpreet created this revision.
kulpreet added reviewers: zaks.anna, dcoughlin.
kulpreet added a subscriber: cfe-commits.

  - Added in new iOS and macOS APIs that require a localized string
  - Removed two APIs that incorrectly were marked as requiring a localized 
string






https://reviews.llvm.org/D22926

Files:
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -189,6 +189,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButton[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButton, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButton[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButton, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -271,6 +287,9 @@
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -336,9 +355,6 @@
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActionSheet, setTitle, 0)
 
-  NEW_RECEIVER(NSURLSessionTask)
-  ADD_UNARY_METHOD(NSURLSessionTask, setTaskDescription, 0)
-
   NEW_RECEIVER(UIAccessibilityCustomAction)
   IdentifierInfo *initWithNameUIAccessibilityCustomAction[] = {
   &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("target"),
@@ -363,6 +379,9 @@
 
   NEW_RECEIVER(NSTextField)
   ADD_UNARY_METHOD(NSTextField, setPlaceholderString, 0)
+  ADD_UNARY_METHOD(NSTextField, textFieldWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, wrappingLabelWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, labelWithString, 0)
 
   NEW_RECEIVER(NSAttributedString)
   ADD_UNARY_METHOD(NSAttributedString, initWithString, 0)
@@ -393,6 +412,11 @@
   ADD_UNARY_METHOD(NSAlert, setMessageText, 0)
   ADD_UNARY_METHOD(NSAlert, setInformativeText, 0)
   ADD_UNARY_METHOD(NSAlert, setHelpAnchor, 0)
+  IdentifierInfo *alertWithMessageTextNSAlert[] = {
+  &Ctx.Idents.get("alertWithMessageText"), 
&Ctx.Idents.get("defaultButton"),
+  &Ctx.Idents.get("alternateButton"), &Ctx.Idents.get("otherButton"),
+  &Ctx.Idents.get("informativeTextWithFormat")};
+  ADD_METHOD(NSAlert, alertWithMessageTextNSAlert, 5, 0)
 
   NEW_RECEIVER(UIMutableApplicationShortcutItem)
   ADD_UNARY_METHOD(UIMutableApplicationShortcutItem, setLocalizedTitle, 0)
@@ -523,9 +547,6 @@
   ADD_METHOD(NSUserNotificationAction,
  actionWithIdentifierNSUserNotificationAction, 2, 1)
 
-  NEW_RECEIVER(NSURLSession)
-  ADD_UNARY_METHOD(NSURLSession, setSessionDescription, 0)
-
   NEW_RECEIVER(UITextField)
   ADD_UNARY_METHOD(UITextField, setText, 0)
   ADD_UNARY_METHOD(UITextField, setPlaceholder, 0)


Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -189,6 +189,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButton[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButton, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButton[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWi

[PATCH] D22927: [OpenCL] Fix size of image type

2016-07-28 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
yaxunl added subscribers: cfe-commits, tstellarAMD.

The size of image type is reported incorrectly as size of a pointer to address 
space 0, which causes error when casting image type to pointers by 
__builtin_astype.

The fix is to get image address space from TargetInfo then report the size 
accordingly.

https://reviews.llvm.org/D22927

Files:
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/cast_image.cl

Index: test/CodeGenOpenCL/cast_image.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/cast_image.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa %s | FileCheck --check-prefix=AMDGCN %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck --check-prefix=SPIR %s
+
+#ifdef __AMDGCN__
+
+constant int* convert(image2d_t img) {
+  // AMDGCN: bitcast %opencl.image2d_ro_t addrspace(2)* %img to i32 addrspace(2)*
+  return __builtin_astype(img, constant int*);
+}
+
+#else
+
+global int* convert(image2d_t img) {
+  // SPIR: bitcast %opencl.image2d_ro_t addrspace(1)* %img to i32 addrspace(1)*
+  return __builtin_astype(img, global int*);
+}
+
+#endif
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -220,9 +220,6 @@
 
   /// Get LLVM calling convention for OpenCL kernel.
   virtual unsigned getOpenCLKernelCallingConv() const;
-
-  /// Get LLVM Image Address Space for OpenCL kernel.
-  virtual unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -401,10 +401,6 @@
   return llvm::CallingConv::C;
 }
 
-unsigned TargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
-  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
-}
-
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
@@ -6883,7 +6879,6 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
   unsigned getOpenCLKernelCallingConv() const override;
-  unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const override;
 };
 
 }
@@ -6920,10 +6915,6 @@
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
-unsigned AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
-  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);
-}
-
 //===--===//
 // SPARC v8 ABI Implementation.
 // Based on the SPARC Compliance Definition version 2.4.1.
Index: lib/CodeGen/CGOpenCLRuntime.cpp
===
--- lib/CodeGen/CGOpenCLRuntime.cpp
+++ lib/CodeGen/CGOpenCLRuntime.cpp
@@ -35,8 +35,8 @@
  "Not an OpenCL specific type!");
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
-  uint32_t ImgAddrSpc =
-CGM.getTargetCodeGenInfo().getOpenCLImageAddrSpace(CGM);
+  uint32_t ImgAddrSpc = CGM.getContext().getTargetAddressSpace(
+CGM.getTarget().getOpenCLImageAddrSpace());
   switch (cast(T)->getKind()) {
   default: 
 llvm_unreachable("Unexpected opencl builtin type!");
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2130,6 +2130,10 @@
 }
   }
 
+  LangAS::ID getOpenCLImageAddrSpace() const override {
+return LangAS::opencl_constant;
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
 switch (CC) {
   default:
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1745,14 +1745,18 @@
 case BuiltinType::OCLQueue:
 case BuiltinType::OCLNDRange:
 case BuiltinType::OCLReserveID:
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-case BuiltinType::Id:
-#include "clang/Basic/OpenCLImageTypes.def"
-
   // Currently these types are pointers to opaque types.
   Width = Target->getPointerWidth(0);
   Align = Target->getPointerAlign(0);
   break;
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+case BuiltinType::Id:
+#include "clang/Basic/OpenCLImageTypes.def"
+  {
+auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace());
+Width = Target->getPointerWidth(AS);
+Align = Target->getPoi

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread Hal Finkel via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

Comments about the comment, but otherwise, LGTM.



Comment at: lib/CodeGen/CodeGenFunction.cpp:789
@@ -796,1 +788,3 @@
 
+  // Since emitting mcount call here impacts optimization phase such as 
function
+  // inlining, we just mark an attribute to insert a mcount call in backend.

emitting mcount call -> emitting the mcount call

optimization phase -> optimizations


Comment at: lib/CodeGen/CodeGenFunction.cpp:790
@@ +789,3 @@
+  // Since emitting mcount call here impacts optimization phase such as 
function
+  // inlining, we just mark an attribute to insert a mcount call in backend.
+  // Attribute "counting-function" is set to mcount function name which is

mark -> add


Comment at: lib/CodeGen/CodeGenFunction.cpp:791
@@ +790,3 @@
+  // inlining, we just mark an attribute to insert a mcount call in backend.
+  // Attribute "counting-function" is set to mcount function name which is
+  // architecture dependent, and it is processed by CountingFunctionInserter.

Attribute -> The attribute


Comment at: lib/CodeGen/CodeGenFunction.cpp:792
@@ -797,1 +791,3 @@
+  // Attribute "counting-function" is set to mcount function name which is
+  // architecture dependent, and it is processed by CountingFunctionInserter.
   if (CGM.getCodeGenOpts().InstrumentForProfiling)

remove ", and is processed by CountingFunctionInserter". That's an 
implementation detail of the backend, which might change, and is irrelevant to 
the frontend.


https://reviews.llvm.org/D22666



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


Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-28 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 65966.
szepet marked 12 inline comments as done.
szepet added a comment.

updates based on comments, counter and search functions replaced by std 
functions


https://reviews.llvm.org/D22507

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/EnumMisuseCheck.cpp
  clang-tidy/misc/EnumMisuseCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-enum-misuse.rst
  test/clang-tidy/misc-enum-misuse-weak.cpp
  test/clang-tidy/misc-enum-misuse.cpp

Index: test/clang-tidy/misc-enum-misuse.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-enum-misuse.cpp
@@ -0,0 +1,81 @@
+// RUN: %check_clang_tidy %s misc-enum-misuse %t -- -config="{CheckOptions: [{key: misc-enum-misuse.IsStrict, value: 0}]}" --
+
+enum Empty {
+};
+
+enum A { A = 1,
+ B = 2,
+ C = 4,
+ D = 8,
+ E = 16,
+ F = 32,
+ G = 63
+};
+
+enum X { X = 8,
+ Y = 16,
+ Z = 4
+};
+
+enum { P = 2,
+   Q = 3,
+   R = 4,
+   S = 8,
+   T = 16
+};
+
+enum { H,
+   I,
+   J,
+   K,
+   L
+};
+
+enum Days { Monday,
+Tuesday,
+Wednesday,
+Thursday,
+Friday,
+Saturday,
+Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types [misc-enum-misuse]
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types 
+  unsigned p;
+  p = Q | P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: left hand side value is not power-of-2 unlike most other values in the enum type
+}
+
+int dont_trigger() {
+  if (A + G == E)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = T | Q;
+  return 0;
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: test/clang-tidy/misc-enum-misuse-weak.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-enum-misuse-weak.cpp
@@ -0,0 +1,88 @@
+// RUN: %check_clang_tidy %s misc-enum-misuse %t -- -config="{CheckOptions: [{key: misc-enum-misuse.IsStrict, value: 1}]}" --
+
+enum A { A = 1,
+ B = 2,
+ C = 4,
+ D = 8,
+ E = 16,
+ F = 32,
+ G = 63
+};
+
+enum X { X = 8,
+ Y = 16,
+ Z = 4
+};
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: enum type seems like a bitfield but possibly contains misspelled number(s) [misc-enum-misuse] 
+enum PP { P = 2,
+  Q = 3,
+  R = 4,
+  S = 8,
+  T = 16,
+  U = 31
+};
+
+enum { H,
+   I,
+   J,
+   K,
+   L
+};
+
+enum Days { Monday,
+Tuesday,
+Wednesday,
+Thursday,
+Friday,
+Saturday,
+Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types 
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types 
+  if (P + Q == R)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: right hand side value is not power-of-2 unlike most other values in the enum type 
+  else if ((Q | R) == T)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:13: warning: left hand side value is not power-of-2 unlike most other values in the enum type 
+  else
+int k = T | Q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: right hand side value is not power-of-2 unlike most other values in the enum type 
+  unsigned p = R;
+  PP pp = Q;
+  p |= pp;
+  // Line 60 triggers the LINE:18 warning
+  p = A | G;
+  //p = G | X;
+  return 0;
+}
+
+int dont_trigger() {
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+
+  unsigned bitflag;
+  enum A aa = B;
+  bitflag = aa | C;
+
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: docs/clang-tidy/checks/misc-enum-misuse.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-enum-misuse.rst
@@ -0,0 +1,66 @@
+.. title:: clang-tidy - misc-enum-misuse
+
+misc-enum-misuse
+
+
+The checker detects various cases when an enum is probably misused (as a bitfield).
+  1. When "add" or "bitwise 

Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-07-28 Thread Peter Szecsi via cfe-commits
szepet marked 2 inline comments as done.
szepet added a comment.

https://reviews.llvm.org/D22507



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


r277024 - [OpenCL] Generate opaque type for sampler_t and function call for the initializer

2016-07-28 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Jul 28 14:26:30 2016
New Revision: 277024

URL: http://llvm.org/viewvc/llvm-project?rev=277024&view=rev
Log:
[OpenCL] Generate opaque type for sampler_t and function call for the 
initializer

Currently Clang use int32 to represent sampler_t, which have been a source of 
issue for some backends, because in some backends sampler_t cannot be 
represented by int32. They have to depend on kernel argument metadata and use 
IPA to find the sampler arguments and global variables and transform them to 
target specific sampler type.

This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each 
use of file-scope sampler variable, it generates a function call of 
__translate_sampler_initializer. For each initialization of function-scope 
sampler variable, it generates a function call of 
__translate_sampler_initializer.

Each builtin library can implement its own __translate_sampler_initializer(). 
Since the real sampler type tends to be architecture dependent, allowing it to 
be initialized by a library function simplifies backend design. A typical 
implementation of __translate_sampler_initializer could be a table lookup of 
real sampler literal values. Since its argument is always a literal, the 
returned pointer is known at compile time and easily optimized to finally 
become some literal values directly put into image read instructions.

This patch is partially based on Alexey Sotkin's work in Khronos Clang 
(https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b).

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

Added:
cfe/trunk/test/CodeGenOpenCL/sampler.cl
Modified:
cfe/trunk/include/clang/AST/OperationKinds.def
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/include/clang/AST/OperationKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=277024&r1=277023&r2=277024&view=diff
==
--- cfe/trunk/include/clang/AST/OperationKinds.def (original)
+++ cfe/trunk/include/clang/AST/OperationKinds.def Thu Jul 28 14:26:30 2016
@@ -324,6 +324,8 @@ CAST_OPERATION(ZeroToOCLEvent)
 // Convert a pointer to a different address space.
 CAST_OPERATION(AddressSpaceConversion)
 
+// Convert an integer initializer to an OpenCL sampler.
+CAST_OPERATION(IntToOCLSampler)
 
 //===- Binary Operations  
-===//
 // Operators listed in order of precedence.

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=277024&r1=277023&r2=277024&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jul 28 14:26:30 2016
@@ -876,3 +876,7 @@ def InvalidOrNonExistentDirectory : Diag
 def OptionIgnored : DiagGroup<"option-ignored">;
 
 def UnknownArgument : DiagGroup<"unknown-argument">;
+
+// A warning group for warnings about code that clang accepts when
+// compiling OpenCL C/C++ but which is not compatible with the SPIR spec.
+def SpirCompat : DiagGroup<"spir-compat">;
\ No newline at end of file

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=277024&r1=277023&r2=277024&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 28 14:26:30 
2016
@@ -7914,6 +7914,10 @@ def err_event_t_addr_space_qual : Error<
   "the event_t type can only be used with __private address space qualifier">;
 def err_expected_kernel_void_return_type : Error<
   "kernel must have void return type">;
+def err_sampler_initializer_no

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-28 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rL277024: [OpenCL] Generate opaque type for sampler_t and 
function call for the… (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D21567?vs=65928&id=65970#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21567

Files:
  cfe/trunk/include/clang/AST/OperationKinds.def
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
  cfe/trunk/test/CodeGenOpenCL/sampler.cl
  cfe/trunk/test/SemaOpenCL/sampler_t.cl

Index: cfe/trunk/include/clang/AST/OperationKinds.def
===
--- cfe/trunk/include/clang/AST/OperationKinds.def
+++ cfe/trunk/include/clang/AST/OperationKinds.def
@@ -324,6 +324,8 @@
 // Convert a pointer to a different address space.
 CAST_OPERATION(AddressSpaceConversion)
 
+// Convert an integer initializer to an OpenCL sampler.
+CAST_OPERATION(IntToOCLSampler)
 
 //===- Binary Operations  -===//
 // Operators listed in order of precedence.
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -876,3 +876,7 @@
 def OptionIgnored : DiagGroup<"option-ignored">;
 
 def UnknownArgument : DiagGroup<"unknown-argument">;
+
+// A warning group for warnings about code that clang accepts when
+// compiling OpenCL C/C++ but which is not compatible with the SPIR spec.
+def SpirCompat : DiagGroup<"spir-compat">;
\ No newline at end of file
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7914,6 +7914,10 @@
   "the event_t type can only be used with __private address space qualifier">;
 def err_expected_kernel_void_return_type : Error<
   "kernel must have void return type">;
+def err_sampler_initializer_not_integer : Error<
+  "sampler_t initialization requires 32-bit integer, not %0">;
+def warn_sampler_initializer_invalid_bits : Warning<
+  "sampler initializer has invalid %0 bits">, InGroup, DefaultIgnore;
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
Index: cfe/trunk/test/SemaOpenCL/sampler_t.cl
===
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl
@@ -1,31 +1,85 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initial

[PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-07-28 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: doug.gregor, akyrtzi.
ahatanak added a subscriber: cfe-commits.

This patch fixes a stack overflow bug in ASTContext::getObjCEncodingForTypeImpl 
where it keeps expanding a class recursively. I added a check to avoid 
expanding a class if ExpandStructures is false.

https://reviews.llvm.org/D22929

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenObjCXX/encode.mm

Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -224,3 +224,24 @@
   // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
   extern const char x[] = @encode(E);
 }
+
+// This test used to cause infinite recursion.
+template
+struct S {
+  typedef T Ty;
+  Ty *t;
+};
+
+@interface N
+{
+  S a;
+}
+@end
+
+@implementation N
+@end
+
+const char *expand_struct() {
+  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] 
c"{N={S=^{N}}}\00"
+  return @encode(N);
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -5896,18 +5896,20 @@
 ObjCInterfaceDecl *OI = T->castAs()->getInterface();
 S += '{';
 S += OI->getObjCRuntimeNameAsString();
-S += '=';
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  const FieldDecl *Field = cast(Ivars[i]);
-  if (Field->isBitField())
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
-  else
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
-   false, false, false, false, false,
-   EncodePointerToObjCTypedef,
-   NotEncodedT);
+if (ExpandStructures) {
+  S += '=';
+  SmallVector Ivars;
+  DeepCollectObjCIvars(OI, true, Ivars);
+  for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
+const FieldDecl *Field = cast(Ivars[i]);
+if (Field->isBitField())
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+ false, false, false, false, false,
+ EncodePointerToObjCTypedef,
+ NotEncodedT);
+  }
 }
 S += '}';
 return;


Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -224,3 +224,24 @@
   // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
   extern const char x[] = @encode(E);
 }
+
+// This test used to cause infinite recursion.
+template
+struct S {
+  typedef T Ty;
+  Ty *t;
+};
+
+@interface N
+{
+  S a;
+}
+@end
+
+@implementation N
+@end
+
+const char *expand_struct() {
+  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S=^{N}}}\00"
+  return @encode(N);
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -5896,18 +5896,20 @@
 ObjCInterfaceDecl *OI = T->castAs()->getInterface();
 S += '{';
 S += OI->getObjCRuntimeNameAsString();
-S += '=';
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  const FieldDecl *Field = cast(Ivars[i]);
-  if (Field->isBitField())
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
-  else
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
-   false, false, false, false, false,
-   EncodePointerToObjCTypedef,
-   NotEncodedT);
+if (ExpandStructures) {
+  S += '=';
+  SmallVector Ivars;
+  DeepCollectObjCIvars(OI, true, Ivars);
+  for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
+const FieldDecl *Field = cast(Ivars[i]);
+if (Field->isBitField())
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+ false, false, false, false, false,
+ EncodePointerToObjCTypedef,
+ NotEncodedT);
+  }
 }
 S += '}';
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22930: [Parser] only correct delayed typos for conditional expressions when needed.

2016-07-28 Thread David Tarditi via cfe-commits
dtarditi created this revision.
dtarditi added a reviewer: erik.pilkington.
dtarditi added a subscriber: cfe-commits.

r272587 (http://reviews.llvm.org/D20490) fixed an issue where typo correction 
could cause a crash when compiling C programs.The problem was that a typo 
expression could be inadvertently processed twice.r272587 fixed this for 
BinOp expressions.   Conditional expressions can hit the same problem too.
This change adds the two line fix for conditional expressions, as well as a 
small test case illustrating the crash.  

Note that I don't have commit privileges for clang; someone will need to commit 
this for me.  I originally started the review by email and am shifting it over 
to Phrabicator.   The change incorporates the following feedback from Erik 
Pilkington on the original patch submitted by email:
 1. If we’re doing the check at the end of both branches of the if, we might as 
well just move it to after.
 2. It doesn’t make sense to have a failure that only occurs in C mode in 
test/SemaCXX. Maybe just append it to the end of test/Sema/typo-correction.c.

 I see from the prior review that the consensus was that “typo correction is in 
a messy state, we should fix this”. I agree.  There are other problematic 
places in the code where double-processing might or might not occur for C code. 
 An example is the processing of subscript expressions in 
Parser::ParsePostfixExpressionSuffix.  Without clear invariants, it is hard to 
know what to do.

Testing: clang fails on the test case without this change, passes with it.   
The clang test suite results were otherwise the same before and after this 
change.


https://reviews.llvm.org/D22930

Files:
  lib/Parse/ParseExpr.cpp
  test/Sema/typo-correction.c

Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -65,3 +65,18 @@
 void fn_with_unknown(int a, int b) {
   fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of 
undeclared identifier}}
 }
+
+// Two typos in a parenthesized expression or argument list with a conditional
+// expression caused a crash in C mode.
+//
+// r272587 fixed a similar bug for binary operations. The same fix was needed 
for
+// conditional expressions.
+
+int g(int x, int y) {
+  return x + y;
+}
+
+int h() {
+  g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
+  (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -446,14 +446,15 @@
 LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
  OpToken.getKind(), LHS.get(), RHS.get());
 
-// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr 
check.
-if (!getLangOpts().CPlusPlus)
-  continue;
   } else {
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),
  RHS.get());
   }
+  // In this case, ActOnBinOp or ActOnConditionalOp performed the
+  // CorrectDelayedTyposInExpr check.
+  if (!getLangOpts().CPlusPlus)
+continue;
 }
 // Ensure potential typos aren't left undiagnosed.
 if (LHS.isInvalid()) {


Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -65,3 +65,18 @@
 void fn_with_unknown(int a, int b) {
   fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
 }
+
+// Two typos in a parenthesized expression or argument list with a conditional
+// expression caused a crash in C mode.
+//
+// r272587 fixed a similar bug for binary operations. The same fix was needed for
+// conditional expressions.
+
+int g(int x, int y) {
+  return x + y;
+}
+
+int h() {
+  g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
+  (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -446,14 +446,15 @@
 LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
  OpToken.getKind(), LHS.get(), RHS.get());
 
-// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
-if (!getLangOpts().CPlusPlus)
-  continue;
   } else {
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),
  RHS.get());
   }
+  // In this cas

[PATCH] D22931: Add __declspec code_seg support

2016-07-28 Thread Andrew Artz via cfe-commits
kbdsmoke created this revision.
kbdsmoke added a subscriber: cfe-commits.
kbdsmoke set the repository for this revision to rL LLVM.

clang does not support this by default. By default, if you want to utilize 
__declspec to assign a SectionAttr to a function, you should use __declspec 
allocate.
However, this is not valid under MSVC. It works under clang (whether or not 
that is acceptable should be the subject of another patch request)

To avoid a lot of headaches for everyone here's my solution. Double __declspec 
in Attr.td works fine, it seems, and so the fix was fairly trivial. I also 
patch some code to verify code_seg is only ever used on FunctionDecls.

Reason being, without it technically code_seg on variables and so on would be 
valid.

Repository:
  rL LLVM

https://reviews.llvm.org/D22931

Files:
  include/clang/Basic/Attr.td
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2656,6 +2656,10 @@
 return;
   }
 
+  // code_seg only ever applies to functions.
+  if (Attr.getName()->getName() == "code_seg" && !isa(D))
+S.Diag(LiteralLoc, diag::err_attribute_wrong_decl_type) << 
Attr.getName()->getName() << 0;
+
   unsigned Index = Attr.getAttributeSpellingListIndex();
   SectionAttr *NewAttr = S.mergeSectionAttr(D, Attr.getRange(), Str, Index);
   if (NewAttr)
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1397,7 +1397,7 @@
 }
 
 def Section : InheritableAttr {
-  let Spellings = [GCC<"section">, Declspec<"allocate">];
+  let Spellings = [GCC<"section">, Declspec<"allocate">, Declspec<"code_seg">];
   let Args = [StringArgument<"Name">];
   let Subjects = SubjectList<[Function, GlobalVar,
   ObjCMethod, ObjCProperty], ErrorDiag,


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2656,6 +2656,10 @@
 return;
   }
 
+  // code_seg only ever applies to functions.
+  if (Attr.getName()->getName() == "code_seg" && !isa(D))
+S.Diag(LiteralLoc, diag::err_attribute_wrong_decl_type) << Attr.getName()->getName() << 0;
+
   unsigned Index = Attr.getAttributeSpellingListIndex();
   SectionAttr *NewAttr = S.mergeSectionAttr(D, Attr.getRange(), Str, Index);
   if (NewAttr)
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1397,7 +1397,7 @@
 }
 
 def Section : InheritableAttr {
-  let Spellings = [GCC<"section">, Declspec<"allocate">];
+  let Spellings = [GCC<"section">, Declspec<"allocate">, Declspec<"code_seg">];
   let Args = [StringArgument<"Name">];
   let Subjects = SubjectList<[Function, GlobalVar,
   ObjCMethod, ObjCProperty], ErrorDiag,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22931: Add __declspec code_seg support

2016-07-28 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

Needs tests, though. The MSDN sample code is probably a good starting point.



Comment at: lib/Sema/SemaDeclAttr.cpp:2659
@@ -2658,1 +2658,3 @@
 
+  // code_seg only ever applies to functions.
+  if (Attr.getName()->getName() == "code_seg" && !isa(D))

MSDN suggests that it can also be applied to classes to control where special 
member functions live.

I think it might be better to have a separate attribute for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D22931



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


Re: [PATCH] D22931: Add __declspec code_seg support

2016-07-28 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer requested changes to this revision.
majnemer added a reviewer: majnemer.
majnemer added a comment.
This revision now requires changes to proceed.

Thanks for contributing this!  I actually worked on an implementation of this 
feature but never sent it out for review because I couldn't get an answer from 
Microsoft regarding this issue: 
https://connect.microsoft.com/VisualStudio/feedback/details/1203505/pragma-code-seg-and-declspec-code-seg-do-not-interact-correctly-with-nested-classes

I don't think the correct solution to `__declspec(code_seg)`.  Because it has 
special rules with regard to nested classes, we should have a separate 
attribute whose `Subjects` are `Function` and `Class`.  During Sema processing 
of the attribute, I'd staple an //implicit// `SectionAttr` to all nested 
functions.

For future reference, please include full context in your patch.

Also, this needs tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D22931



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-28 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:93
@@ +92,3 @@
+   hasArgument(0, ignoringParenImpCasts(declRefExpr(
+  to(ForwardingReferenceParmMatcher)
+  .bind("call-move"),

aaron.ballman wrote:
> I wonder if there's a reason for this behavior, or if it's simple a matter of 
> not being needed previously and so it was never implemented. @sbenza or 
> @klimek may know. I think we should be fixing the RecursiveASTVisitor, unless 
> there is a valid reason not to (which there may be), though that would be a 
> separate patch (and can happen after we land this one).
Even if the nodes are not visited through the recursive visitor, you can always 
have a matcher for it.
Eg: `hasAnyConstructorInitializer` / `cxxCtorInitializer`.

But what node are you trying to visit here?
The only node I see is `NamingClass`, which is not really a child node.
Like the referred `Decl` in a `DeclRefExpr` is not a child either. You can't 
use `has()` there, you have to use `to()`.


https://reviews.llvm.org/D0



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


Re: [PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-28 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277029: [analyzer] Update the web manual for checker 
developers. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D22874?vs=65762&id=65979#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22874

Files:
  cfe/trunk/www/analyzer/checker_dev_manual.html

Index: cfe/trunk/www/analyzer/checker_dev_manual.html
===
--- cfe/trunk/www/analyzer/checker_dev_manual.html
+++ cfe/trunk/www/analyzer/checker_dev_manual.html
@@ -45,7 +45,13 @@
   Bug Reports
   AST Visitors
   Testing
-  Useful Commands/Debugging Hints
+  Useful Commands/Debugging Hints
+  
+Attaching the Debugger
+Narrowing Down the Problem
+Visualizing the Analysis
+Debug Prints and Tricks
+  
   Additional Sources of Information
   Useful Links
 
@@ -115,17 +121,22 @@
   
   
   Interaction with Checkers
+
+  
   Checkers are not merely passive receivers of the analyzer core changes - they 
   actively participate in the ProgramState construction through the
   GenericDataMap which can be used to store the checker-defined part 
   of the state. Each time the analyzer engine explores a new statement, it 
   notifies each checker registered to listen for that statement, giving it an 
   opportunity to either report a bug or modify the state. (As a rule of thumb, 
   the checker itself should be stateless.) The checkers are called one after another 
   in the predefined order; thus, calling all the checkers adds a chain to the 
-  ExplodedGraph. 
+  ExplodedGraph.
+  
   
   Representing Values
+
+  
   During symbolic execution, http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SVal.html";>SVal 
   objects are used to represent the semantic evaluation of expressions. 
   They can represent things like concrete 
@@ -142,15 +153,17 @@
   This represents a case that is outside the realm of the analyzer's reasoning 
   capabilities. SVals are value objects and their values can be viewed 
   using the .dump() method. Often they wrap persistent objects such as 
-  symbols or regions. 
+  symbols or regions.
+  
+
   
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SymExpr.html";>SymExpr (symbol) 
   is meant to represent abstract, but named, symbolic value. Symbols represent 
   an actual (immutable) value. We might not know what its specific value is, but 
   we can associate constraints with that value as we analyze a path. For 
   example, we might record that the value of a symbol is greater than 
   0, etc.
-  
+  
 
   
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1MemRegion.html";>MemRegion is similar to a symbol.  
@@ -163,17 +176,22 @@
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SymbolicRegion.html";>SymbolicRegion 
   is for. It is a MemRegion that has an associated symbol. Since the 
   symbol is unique and has a unique name; that symbol names the region.
+  
   
-  
+  
   Let's see how the analyzer processes the expressions in the following example:
+  
+
   
   
   int foo(int x) {
  int y = x * 2;
  int z = x;
  ...
   }
   
+  
+
   
 Let's look at how x*2 gets evaluated. When x is evaluated, 
 we first construct an SVal that represents the lvalue of x, in 
@@ -193,13 +211,15 @@
 The second line is similar. When we evaluate x again, we do the same 
 dance, and create an SVal that references the symbol $0. Note, two SVals 
 might reference the same underlying values.
+  
 
 
 To summarize, MemRegions are unique names for blocks of memory. Symbols are 
 unique names for abstract symbolic values. Some MemRegions represents abstract 
 symbolic chunks of memory, and thus are also based on symbols. SVals are just 
 references to values, and can reference either MemRegions, Symbols, or concrete 
 values (e.g., the number 1).
+
 
   

Re: r276977 - [OpenMP] Codegen for use_device_ptr clause.

2016-07-28 Thread Samuel F Antao via cfe-commits
Hi Mike,
 
I've already pushed r276981 and r276988 to fix those failures shortly after I pushed the patch. After that I didn't receive any bot message complaining about that code. 
 
Do you still see the issues?
 
Thanks,
Samuel
 
- Original message -From: Mike Aizatsky To: Samuel F Antao/Watson/IBM@IBMUS, cfe-commits@lists.llvm.orgCc:Subject: Re: r276977 - [OpenMP] Codegen for use_device_ptr clause.Date: Thu, Jul 28, 2016 4:20 PM 
Samuel,
 
I think your change breaks the build:
 
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/26397
 
FAILED: tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGOpenMPRuntime.cpp.obj 
C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~1\cl.exe   /nologo /TP -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\clang\lib\CodeGen -IC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen -IC:\b\slave\sanitizer-windows\llvm\tools\clang\include -Itools\clang\include -Iinclude -IC:\b\slave\sanitizer-windows\llvm\include /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi /Zc:rvalueCast /MD /O2 /Ob2   -UNDEBUG  /EHs-c- /GR- /showIncludes /Fotools\clang\lib\CodeGen\CMakeFiles\clangCodeGen.dir\CGOpenMPRuntime.cpp.obj /Fdtools\clang\lib\CodeGen\CMakeFiles\clangCodeGen.dir\ /FS -c C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5482) : error C3486: a parameter for a lambda cannot have a default argument
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5488) : error C2327: '`anonymous-namespace'::MappableExprsHandler::Directive' : is not a type name, static, or enumerator
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5488) : error C2065: 'Directive' : undeclared identifier
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5488) : error C2228: left of '.getClausesOfKind' must have class/struct/union
        type is 'unknown-type'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5488) : error C2059: syntax error : ')'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5488) : error C2143: syntax error : missing ';' before ''
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5491) : error C2327: '`anonymous-namespace'::MappableExprsHandler::Directive' : is not a type name, static, or enumerator
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5491) : error C2065: 'Directive' : undeclared identifier
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5491) : error C2228: left of '.getClausesOfKind' must have class/struct/union
        type is 'unknown-type'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5491) : error C2059: syntax error : ')'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5491) : error C2143: syntax error : missing ';' before ''
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5493) : error C2143: syntax error : missing ')' before ';'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5494) : error C2327: '`anonymous-namespace'::MappableExprsHandler::Directive' : is not a type name, static, or enumerator
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5494) : error C2065: 'Directive' : undeclared identifier
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5494) : error C2228: left of '.getClausesOfKind' must have class/struct/union
        type is 'unknown-type'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5494) : error C2059: syntax error : ')'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5494) : error C2143: syntax error : missing ';' before ''
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5496) : error C2143: syntax error : missing ')' before ';'
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\CGOpenMPRuntime.cpp(5502) : error C2327: '`anonymous-namespace'::MappableExprsHandler::Directive' : is not a type name, static, or enumerator
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Co

Re: [PATCH] D22926: Static Analyzer - Localizability Checker: New Localizable APIs for macOS Sierra

2016-07-28 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

This doesn't compile for me. It looks like there are two separate declarations 
of 'buttonWithTitleNSButton'.


https://reviews.llvm.org/D22926



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


Re: [PATCH] D22931: Add __declspec code_seg support

2016-07-28 Thread Andrew Artz via cfe-commits
kbdsmoke added a comment.

Indeed I was incorrect, and I agree with your analysis of the problem @majnemer 
I'll try to correct this issue in my own time and get some tests going


Repository:
  rL LLVM

https://reviews.llvm.org/D22931



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


r277029 - [analyzer] Update the web manual for checker developers.

2016-07-28 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jul 28 15:13:14 2016
New Revision: 277029

URL: http://llvm.org/viewvc/llvm-project?rev=277029&view=rev
Log:
[analyzer] Update the web manual for checker developers.

Fix the explanation of how to run tests after migration
from autotools to cmake.

Significantly expand the "debugging" section
with more interesting stuff.

Update the table of contents accordingly.

Fix paragraphs in the overview section.

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

Modified:
cfe/trunk/www/analyzer/checker_dev_manual.html

Modified: cfe/trunk/www/analyzer/checker_dev_manual.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/checker_dev_manual.html?rev=277029&r1=277028&r2=277029&view=diff
==
--- cfe/trunk/www/analyzer/checker_dev_manual.html (original)
+++ cfe/trunk/www/analyzer/checker_dev_manual.html Thu Jul 28 15:13:14 2016
@@ -45,7 +45,13 @@ for developer guidelines and send your q
   Bug Reports
   AST Visitors
   Testing
-  Useful Commands/Debugging Hints
+  Useful Commands/Debugging Hints
+  
+Attaching the Debugger
+Narrowing Down the Problem
+Visualizing the Analysis
+Debug Prints and Tricks
+  
   Additional Sources of 
Information
   Useful Links
 
@@ -115,6 +121,8 @@ for developer guidelines and send your q
   
   
   Interaction with Checkers
+
+  
   Checkers are not merely passive receivers of the analyzer core changes - 
they 
   actively participate in the ProgramState construction through the
   GenericDataMap which can be used to store the checker-defined part 
@@ -123,9 +131,12 @@ for developer guidelines and send your q
   opportunity to either report a bug or modify the state. (As a rule of thumb, 
   the checker itself should be stateless.) The checkers are called one after 
another 
   in the predefined order; thus, calling all the checkers adds a chain to the 
-  ExplodedGraph. 
+  ExplodedGraph.
+  
   
   Representing Values
+
+  
   During symbolic execution, http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SVal.html";>SVal 
   objects are used to represent the semantic evaluation of expressions. 
   They can represent things like concrete 
@@ -142,7 +153,9 @@ for developer guidelines and send your q
   This represents a case that is outside the realm of the analyzer's reasoning 
   capabilities. SVals are value objects and their values can be 
viewed 
   using the .dump() method. Often they wrap persistent objects such 
as 
-  symbols or regions. 
+  symbols or regions.
+  
+
   
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SymExpr.html";>SymExpr
 (symbol) 
   is meant to represent abstract, but named, symbolic value. Symbols represent 
@@ -150,7 +163,7 @@ for developer guidelines and send your q
   we can associate constraints with that value as we analyze a path. For 
   example, we might record that the value of a symbol is greater than 
   0, etc.
-  
+  
 
   
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1MemRegion.html";>MemRegion
 is similar to a symbol.  
@@ -163,9 +176,12 @@ for developer guidelines and send your q
   http://clang.llvm.org/doxygen/classclang_1_1ento_1_1SymbolicRegion.html";>SymbolicRegion
 
   is for. It is a MemRegion that has an associated symbol. Since the 
   symbol is unique and has a unique name; that symbol names the region.
+  
   
-  
+  
   Let's see how the analyzer processes the expressions in the following 
example:
+  
+
   
   
   int foo(int x) {
@@ -174,6 +190,8 @@ for developer guidelines and send your q
  ...
   }
   
+  
+
   
 Let's look at how x*2 gets evaluated. When x is evaluated, 
 we first construct an SVal that represents the lvalue of x, 
in 
@@ -193,6 +211,7 @@ to the MemRegion in the symboli
 The second line is similar. When we evaluate x again, we do the same 
 dance, and create an SVal that references the symbol $0. 
Note, two SVals 
 might reference the same underlying values.
+  
 
 
 To summarize, MemRegions are unique names for blocks of memory. Symbols are 
@@ -200,6 +219,7 @@ unique names for abstract symbolic value
 symbolic chunks of memory, and thus are also based on symbols. SVals are just 
 references to values, and can reference either MemRegions, Symbols, or 
concrete 
 values (e.g., the number 1).
+
 
   

Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-28 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM, too.


https://reviews.llvm.org/D22666



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


Re: [PATCH] D22926: Static Analyzer - Localizability Checker: New Localizable APIs for macOS Sierra

2016-07-28 Thread Kulpreet Chilana via cfe-commits
kulpreet updated this revision to Diff 66006.
kulpreet added a comment.

Sorry, uploaded the wrong patch. This one should compile with the unique 
variable names.


https://reviews.llvm.org/D22926

Files:
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -189,6 +189,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonImage[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonImage, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonTarget[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonTarget, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -271,6 +287,9 @@
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -336,9 +355,6 @@
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActionSheet, setTitle, 0)
 
-  NEW_RECEIVER(NSURLSessionTask)
-  ADD_UNARY_METHOD(NSURLSessionTask, setTaskDescription, 0)
-
   NEW_RECEIVER(UIAccessibilityCustomAction)
   IdentifierInfo *initWithNameUIAccessibilityCustomAction[] = {
   &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("target"),
@@ -363,6 +379,9 @@
 
   NEW_RECEIVER(NSTextField)
   ADD_UNARY_METHOD(NSTextField, setPlaceholderString, 0)
+  ADD_UNARY_METHOD(NSTextField, textFieldWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, wrappingLabelWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, labelWithString, 0)
 
   NEW_RECEIVER(NSAttributedString)
   ADD_UNARY_METHOD(NSAttributedString, initWithString, 0)
@@ -523,9 +542,6 @@
   ADD_METHOD(NSUserNotificationAction,
  actionWithIdentifierNSUserNotificationAction, 2, 1)
 
-  NEW_RECEIVER(NSURLSession)
-  ADD_UNARY_METHOD(NSURLSession, setSessionDescription, 0)
-
   NEW_RECEIVER(UITextField)
   ADD_UNARY_METHOD(UITextField, setText, 0)
   ADD_UNARY_METHOD(UITextField, setPlaceholder, 0)


Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -189,6 +189,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonImage[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonImage, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonTarget[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonTarget, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -271,6 +287,9 @@
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -336,9 +355,6 @@
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActionSheet, setTitle, 0)
 
-  NEW_RECEIVER(NSURLSessionTask)
-  ADD_UNARY_METHOD(NSURLSessionTask, setTaskDescription, 0)
-
   NEW_RECEIVER(UIAccessibilityCustomAction)
   IdentifierInfo *initW

[PATCH] D22940: [OpenCL] Handle -cl-fp32-correctly-rounded-divide-sqrt

2016-07-28 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, nhaustov.
yaxunl added subscribers: cfe-commits, tstellarAMD.

Let the driver pass the option to frontend. Do not set precision metadata for 
division instructions when this option is set. Set function attribute 
"correctly-rounded-divide-sqrt-fp-math" based on this option.

https://reviews.llvm.org/D22940

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenOpenCL/fpmath.cl
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -12,6 +12,7 @@
 // RUN: %clang -S -### -cl-mad-enable %s 2>&1 | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
 // RUN: %clang -S -### -cl-no-signed-zeros %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang -S -### -cl-denorms-are-zero %s 2>&1 | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: %clang -S -### -cl-fp32-correctly-rounded-divide-sqrt %s 2>&1 | FileCheck --check-prefix=CHECK-ROUND-DIV %s
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
@@ -29,6 +30,7 @@
 // CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
 // CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
 // CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-ROUND-DIV: "-cc1" {{.*}} "-cl-fp32-correctly-rounded-divide-sqrt"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
Index: test/CodeGenOpenCL/fpmath.cl
===
--- test/CodeGenOpenCL/fpmath.cl
+++ test/CodeGenOpenCL/fpmath.cl
@@ -1,25 +1,37 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
 float spscalardiv(float a, float b) {
   // CHECK: @spscalardiv
-  // CHECK: fdiv{{.*}}, !fpmath ![[MD:[0-9]+]]
+  // CHECK: #[[ATTR:[0-9]+]]
+  // CHECK: fdiv{{.*}},
+  // NODIVOPT: !fpmath ![[MD:[0-9]+]]
+  // DIVOPT-NOT: !fpmath ![[MD:[0-9]+]]
   return a / b;
 }
 
 float4 spvectordiv(float4 a, float4 b) {
   // CHECK: @spvectordiv
-  // CHECK: fdiv{{.*}}, !fpmath ![[MD]]
+  // CHECK: #[[ATTR]]
+  // CHECK: fdiv{{.*}},
+  // NODIVOPT: !fpmath ![[MD]]
+  // DIVOPT-NOT: !fpmath ![[MD]]
   return a / b;
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
+  // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
 
-// CHECK: ![[MD]] = !{float 2.50e+00}
+// CHECK: attributes #[[ATTR]] = {
+// NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"
+// DIVOPT: "correctly-rounded-divide-sqrt-fp-math"="true"
+// CHECK: }
+// NODIVOPT: ![[MD]] = !{float 2.50e+00}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -568,6 +568,8 @@
Args.hasArg(OPT_cl_fast_relaxed_math));
   Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
 Args.hasArg(OPT_cl_no_signed_zeros));
+  Opts.CorrectlyRoundedDivSqrt =
+  Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.BackendOptions = Args.getAllArgValues(OPT_backend_option);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5227,6 +5227,9 @@
   if (Args.getLastArg(options::OPT_cl_denorms_are_zero)) {
 CmdArgs.push_back("-cl-denorms-are-zero");
   }
+  if (Args.getLastArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt)) {
+CmdArgs.push_back("-cl-fp32-correctly-rounded-divide-sqrt");
+  }
 
   // Forward -f options with positive and negative forms; we translate
   // these by hand.
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2276,8 +2276,13 @@
 
   if (Ops.LHS->getType()->isFPOrFPVectorTy()) {
 llvm::Value *Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
-if (CGF.getLangOpts().OpenCL) {
-  // OpenCL

Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-special-member-functions

2016-07-28 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 66011.
jbcoe added a comment.

Minor changes from review.


https://reviews.llvm.org/D22513

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
  test/clang-tidy/cppcoreguidelines-special-member-functions.cpp

Index: test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyConstructor' defines a copy constructor but does not define a destructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyAssignment {
+  DefinesCopyAssignment &operator=(const DefinesCopyAssignment &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyAssignment' defines a copy assignment operator but does not define a destructor, a copy constructor, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveConstructor {
+  DefinesMoveConstructor(DefinesMoveConstructor &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveConstructor' defines a move constructor but does not define a destructor, a copy constructor, a copy assignment operator or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveAssignment {
+  DefinesMoveAssignment &operator=(DefinesMoveAssignment &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveAssignment' defines a move assignment operator but does not define a destructor, a copy constructor, a copy assignment operator or a move constructor [cppcoreguidelines-special-member-functions]
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  DefinesEverything &operator=(const DefinesEverything &);
+  DefinesEverything(DefinesEverything &&);
+  DefinesEverything &operator=(DefinesEverything &&);
+  ~DefinesEverything();
+};
+
+class DeletesEverything {
+  DeletesEverything(const DeletesEverything &) = delete;
+  DeletesEverything &operator=(const DeletesEverything &) = delete;
+  DeletesEverything(DeletesEverything &&) = delete;
+  DeletesEverything &operator=(DeletesEverything &&) = delete;
+  ~DeletesEverything() = delete;
+};
+
+class DeletesCopyDefaultsMove {
+  DeletesCopyDefaultsMove(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove &operator=(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove(DeletesCopyDefaultsMove &&) = default;
+  DeletesCopyDefaultsMove &operator=(DeletesCopyDefaultsMove &&) = default;
+  ~DeletesCopyDefaultsMove() = default;
+};
Index: test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -- -std=c++03
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyConstructor' defines a copy constructor but does not define a destructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyAssignment {
+  DefinesCopyAssignment &operator=(const DefinesCopyAssignment &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyAssignment' defines a copy assignment operator but does not define a destructor or a copy constructor [cppcoreguidelines-special-member-functions]
+
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+

Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-special-member-functions

2016-07-28 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp:62
@@ +61,3 @@
+std::string
+SpecialMemberFunctionsCheck::join(llvm::ArrayRef 
SMFS,
+ llvm::StringRef AndOr) {

aaron.ballman wrote:
> I think this join function can maybe be replaced by a call to llvm::join() 
> from StringExtras.h?
I want to join the last member function with "and" or "for", `llvm::join` won't 
let me do that.
Thanks for the suggestion though. I need to explore more of llvm/ADT.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h:42-44
@@ +41,5 @@
+
+  using ClassDefId = std::pair;
+
+  using ClassDefiningSpecialMembersMap = llvm::DenseMap>;
+

aaron.ballman wrote:
> Do these need to be public?
I think so, I can't get the specialisation of DenseMapInfo to work otherwise.


Comment at: clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h:62-63
@@ +61,4 @@
+/// Specialisation of DenseMapInfo to allow ClassDefId objects in DenseMaps
+/// FIXME: Move this to the corresponding cpp file as is done for
+/// clang-tidy/readability/IdentifierNamingCheck.cpp. 
+template <>

aaron.ballman wrote:
> Any reason why not to do this as part of this patch?
I've spent days trying. I can't get code to compile if it's moved and can't 
work out why. As the FIXME says, it works in IdentifierNaming.


https://reviews.llvm.org/D22513



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


Re: [PATCH] D22697: [ObjC Availability] Consider lexical context of use of declaration when emitting availability diagnostics

2016-07-28 Thread Manman Ren via cfe-commits
manmanren added a comment.

Yes, this still looks good to me. Please commit.

Manman


https://reviews.llvm.org/D22697



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


Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66017.
sfantao added a comment.

- Rebase.


https://reviews.llvm.org/D21840

Files:
  include/clang/Driver/Action.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1898,7 +1898,7 @@
 
 // Create the offload action with all dependences. When an offload action
 // is created the kinds are propagated to the host action, so we don't have
-// to do that explicitely here.
+// to do that explicitly here.
 OffloadAction::HostDependence HDep(
 *HostAction, *C.getSingleOffloadToolChain(),
 /*BoundArch*/ nullptr, ActiveOffloadKinds);
@@ -2332,142 +2332,293 @@
 }
   }
 }
-/// Collapse an offloading action looking for a job of the given type. The input
-/// action is changed to the input of the collapsed sequence. If we effectively
-/// had a collapse return the corresponding offloading action, otherwise return
-/// null.
-template 
-static OffloadAction *collapseOffloadingAction(Action *&CurAction) {
-  if (!CurAction)
-return nullptr;
-  if (auto *OA = dyn_cast(CurAction)) {
-if (OA->hasHostDependence())
-  if (auto *HDep = dyn_cast(OA->getHostDependence())) {
-CurAction = HDep;
-return OA;
-  }
-if (OA->hasSingleDeviceDependence())
-  if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) {
-CurAction = DDep;
-return OA;
+
+namespace {
+/// Utility class to control the collapse of dependent actions and select the
+/// tools accordingly.
+class ToolSelector final {
+  /// The tool chain this selector refers to.
+  const ToolChain &TC;
+
+  /// The compilation this selector refers to.
+  const Compilation &C;
+
+  /// The base action this selector refers to.
+  const JobAction *BaseAction;
+
+  /// Set to true if the current toolchain refers to host actions.
+  bool IsHostSelector;
+
+  /// Set to true if save-temps and embed-bitcode functionalities are active.
+  bool SaveTemps;
+  bool EmbedBitcode;
+
+  /// Get dependence action or null if that does not exist. If \a CanBeCollapsed
+  /// is false, that action must be legal to collapse or null will be returned.
+  const JobAction *getDependenceAction(const ActionList &Inputs,
+   ActionList &SavedOffloadAction,
+   bool CanBeCollapsed = true) {
+// An option can be collapsed only if it has a single input.
+if (Inputs.size() != 1)
+  return nullptr;
+
+Action *CurAction = *Inputs.begin();
+if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed)
+  return nullptr;
+
+// If the input action is an offload action. Look through it and save any
+// offload action that can be dropped in the event of a collapse.
+if (auto *OA = dyn_cast(CurAction)) {
+  // If the depending action is a device action, we will attempt to collapse
+  // only with other device actions. Otherwise, we would do the same but
+  // with host actions only.
+  if (!IsHostSelector) {
+if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) {
+  CurAction =
+  OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true);
+  if (!CurAction->isCollapsingWithDependingActionLegal() &&
+  CanBeCollapsed)
+return nullptr;
+  SavedOffloadAction.push_back(OA);
+  return dyn_cast(CurAction);
+}
+  } else if (OA->hasHostDependence()) {
+CurAction = OA->getHostDependence();
+if (!CurAction->isCollapsingWithDependingActionLegal() &&
+CanBeCollapsed)
+  return nullptr;
+SavedOffloadAction.push_back(OA);
+return dyn_cast(CurAction);
   }
+  return nullptr;
+}
+
+return dyn_cast(CurAction);
   }
-  return nullptr;
-}
-// Returns a Tool for a given JobAction.  In case the action and its
-// predecessors can be combined, updates Inputs with the inputs of the
-// first combined action. If one of the collapsed actions is a
-// CudaHostAction, updates CollapsedCHA with the pointer to it so the
-// caller can deal with extra handling such action requires.
-static const Tool *selectToolForJob(Compilation &C, bool SaveTemps,
-bool EmbedBitcode, const ToolChain *TC,
-const JobAction *JA,
-const ActionList *&Inputs,
-ActionList &CollapsedOffloadAction) {
-  const Tool *ToolForJob = nullptr;
-  CollapsedOffloadAction.clear();
-
-  // See if we should look for a compiler with an integrated assembler. We match
-  // bottom up, so what we are actually looking for is an assembler job with a
-  // compiler input.
-
-  // Look through offload actions between assembler and backend actions.
-  Action *BackendJA = (isa(JA) 

Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66016.
sfantao added a comment.

- Remove redundant phases from cuda-phases.cu and use DAG check.
- Rebase.


https://reviews.llvm.org/D18172

Files:
  include/clang/Driver/Compilation.h
  lib/Driver/Driver.cpp
  test/Driver/cuda-phases.cu

Index: test/Driver/cuda-phases.cu
===
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -13,194 +13,189 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=BIN %s
-// BIN: 0: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
-// BIN: 2: compiler, {1}, ir, (host-cuda)
-// BIN: 3: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN: 5: compiler, {4}, ir, (device-cuda, sm_30)
-// BIN: 6: backend, {5}, assembler, (device-cuda, sm_30)
-// BIN: 7: assembler, {6}, object, (device-cuda, sm_30)
-// BIN: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
-// BIN: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
-// BIN: 10: linker, {8, 9}, cuda-fatbin, (device-cuda)
-// BIN: 11: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, "device-cuda (nvptx64-nvidia-cuda)" {10}, ir
-// BIN: 12: backend, {11}, assembler, (host-cuda)
-// BIN: 13: assembler, {12}, object, (host-cuda)
-// BIN: 14: linker, {13}, image, (host-cuda)
+// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
+// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
+// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
+// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
+// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
+// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
+// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler
+// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda)
+// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir
+// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda)
+// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda)
+// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda)
 
 //
 // Test single gpu architecture up to the assemble phase.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \
 // RUN: | FileCheck -check-prefix=ASM %s
-// ASM: 0: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// ASM: 1: preprocessor, {0}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM: 2: compiler, {1}, ir, (device-cuda, sm_30)
-// ASM: 3: backend, {2}, assembler, (device-cuda, sm_30)
-// ASM: 4: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {3}, assembler
-// ASM: 5: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// ASM: 6: preprocessor, {5}, cuda-cpp-output, (host-cuda)
-// ASM: 7: compiler, {6}, ir, (host-cuda)
-// ASM: 8: backend, {7}, assembler, (host-cuda)
+// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30)
+// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30)
+// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30)
+// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler
+// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda)
+// ASM-DAG: [[P7:[0-9]+]]: compiler, {[[P6]]}, ir, (host-cuda)
+// ASM-DAG: [[P8:[0-9]+]]: backend, {[[P7]]}, assembler, (host-cuda)
 
 //
 // Test two gpu architectures with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=BIN2 %s
-// BIN2: 0: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN2: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
-// BIN2: 2: compiler, {1}, ir, (host-cuda)
-// BIN2: 3: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN2: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN2: 5: compiler, {4}, ir, (device-cuda, sm_30)
-// BIN2: 6: backend, {5}, assembler, (device-cuda, sm_30)
-// BIN2: 7: assembler, {6}, object, (device-cuda, sm_30)
-// BIN2: 8: 

Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66018.
sfantao added a comment.

- Rebase.


https://reviews.llvm.org/D21843

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- /dev/null
+++ test/Driver/openmp-offload.c
@@ -0,0 +1,37 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -fopenmp-targets
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
+
+/// ###
+
+/// Check error for no -fopenmp option
+// RUN:   %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// RUN:   %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading.
+
+/// ###
+
+/// Check warning for duplicate offloading targets.
+// RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
+// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2988,72 +2988,23 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-namespace {
-enum OpenMPRuntimeKind {
-  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
-  /// without knowing what runtime to target.
-  OMPRT_Unknown,
-
-  /// The LLVM OpenMP runtime. When completed and integrated, this will become
-  /// the default for Clang.
-  OMPRT_OMP,
-
-  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
-  /// this runtime but can swallow the pragmas, and find and link against the
-  /// runtime library itself.
-  OMPRT_GOMP,
-
-  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
-  /// OpenMP runtime. We support this mode for users with existing dependencies
-  /// on this runtime library name.
-  OMPRT_IOMP5
-};
-}
-
-/// Compute the desired OpenMP runtime from the flag provided.
-static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC,
-  const ArgList &Args) {
-  StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
-
-  const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
-  if (A)
-RuntimeName = A->getValue();
-
-  auto RT = llvm::StringSwitch(RuntimeName)
-.Case("libomp", OMPRT_OMP)
-.Case("libgomp", OMPRT_GOMP)
-.Case("libiomp5", OMPRT_IOMP5)
-.Default(OMPRT_Unknown);
-
-  if (RT == OMPRT_Unknown) {
-if (A)
-  TC.getDriver().Diag(diag::err_drv_unsupported_option_argument)
-  << A->getOption().getName() << A->getValue();
-else
-  // FIXME: We could use a nicer diagnostic here.
-  TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
-  }
-
-  return RT;
-}
-
 static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
   const ArgList &Args) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
 options::OPT_fno_openmp, false))
 return;
 
-  switch (getOpenMPRuntime(TC, Args)) {
-  case OMPRT_OMP:
+  switch (TC.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
 break;
-  case OMPRT_GOMP:
+  case Driver::OMPRT_GOMP:
 CmdArgs.push_back("-lgomp

Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66019.
sfantao added a comment.

- Rebase.


https://reviews.llvm.org/D21845

Files:
  lib/Driver/Driver.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -35,3 +35,106 @@
 // RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
 // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
+
+/// ###
+
+/// Check the phases graph when using a single target, different from the host.
+/// We should have an offload action joining the host compile and device
+/// preprocessor and another one joining the device linking outputs to the host
+/// action.
+// RUN:   %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES %s
+// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp)
+// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp)
+// CHK-PHASES: 4: assembler, {3}, object, (host-openmp)
+// CHK-PHASES: 5: linker, {4}, image, (host-openmp)
+// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp)
+// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp)
+// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp)
+// CHK-PHASES: 11: assembler, {10}, object, (device-openmp)
+// CHK-PHASES: 12: linker, {11}, image, (device-openmp)
+// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image
+
+/// ###
+
+/// Check the phases when using multiple targets. Here we also add a library to
+/// make sure it is treated as input by the device.
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-LIB %s
+// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp)
+// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp)
+// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp)
+// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp)
+// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp)
+// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir
+// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp)
+// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp)
+// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp)
+// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir
+// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp)
+// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp)
+// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image
+
+
+/// ###
+
+/// Check the phases when using multiple targets and multiple source files
+// RUN:   echo " " > %t.c
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %t.c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-FILES %s
+// CHK-PHASES-FILES: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-FILES: 1: input, "[[INPUT1:.+\.c]]", c, (host-openmp)
+// CHK-PHASES-FILES: 2: preprocessor, {1}, cpp-output, (host-

Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66020.
sfantao added a comment.

- Add option to dump and test the linker script contents.
- Rebase.


https://reviews.llvm.org/D21847

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -138,3 +138,104 @@
 // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp)
 // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp)
 // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image
+
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+/// We use -fopenmp-dump-offload-linker-script to dump the linker script and
+/// check its contents.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS -check-prefix=CHK-LKS -check-prefix=CHK-LKS-REG %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST -check-prefix=CHK-LKS -check-prefix=CHK-LKS-ST %s
+
+// Make sure we are not dumping the script unless the user requested it.
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+
+//
+// Check the linker script contains what we expect.
+//
+// CHK-LKS: /*
+// CHK-LKS: OpenMP Offload Linker Script.
+// CHK-LKS-NODUMP-NOT:  OpenMP Offload Linker Script.
+// CHK-LKS: */
+// CHK-LKS: TARGET(binary)
+// CHK-LKS-REG: INPUT([[T1BIN:.+\.out]])
+// CHK-LKS-REG: INPUT([[T2BIN:.+\.out]])
+// CHK-LKS-ST: INPUT([[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]])
+// CHK-LKS-ST: INPUT([[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]])
+// CHK-LKS: SECTIONS
+// CHK-LKS: {
+// CHK-LKS:   .omp_offloading :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   {
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: [[T1BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .);
+// CHK-LKS: [[T2BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .);
+// CHK-LKS:   }
+// CHK-LKS:   .omp_offloading.entries :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   SUBALIGN(0x01)
+// CHK-LKS:   {
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_begin = .);
+// CHK-LKS: *(.omp_offloading.entries)
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_end = .);
+// CHK-LKS:   }
+// CHK-LKS: }
+// CHK-LKS: INSERT BEFORE .data
+
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN]]"

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-07-28 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 66023.
sfantao added a comment.

- Fix bug in conditional.
- Rebase.


https://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,681 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// The index of the host input in the list of inputs.
+static unsigned HostInputIndex = ~0u;
+
+/// Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
+StringRef &Triple) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// Generic file handler interface.
+class FileHandler {
+public:
+  /// Update the file handler with information from the header of the bundled
+  /// file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundled is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Input) = 0;
+  /// Read the current bundle and write the result into the stream \a OS.
+  virtual void

  1   2   >