[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a comment.
This revision now requires changes to proceed.

Are we sure this will not fail on Windows? i.e. have you built/run the tests on 
Windws ARM or X86_64?



> Tools.cpp:4787
> options::OPT_fnoxray_instrument, false)) {
> -CmdArgs.push_back("-fxray-instrument");
> +const char* const XRayInstrumentOption = "-fxray-instrument";
> +switch(getToolChain().getArch()) {

Why can't this just be a `const string`, or a `const StringRef`?

> Tools.cpp:4796
> +  Feature += " on ";
> +  Feature += Triple.getArchName().data();
> +  D.Diag(diag::err_drv_clang_unsupported) << Feature;

I'm not a fan of calling `.data()` here -- if this returns a `StringRef` I'd 
much rather turn it into a string directly. Either that or you can even string 
these together. Say something like:

  default:
D.Diag(...) << (XRayInstrumentOption + " on " + Triple.getArchName().str());
break;

> Tools.cpp:4799
> +  break;
> +} }
> +CmdArgs.push_back(XRayInstrumentOption);

As part of my submitting this change upstream, I had to format it accordingly 
with `clang-format` -- you might want to do the same so that the formatting is 
in-line with the LLVM developers style guidelines.

https://reviews.llvm.org/D24799



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


[PATCH] D25303: [coroutines] Fix re-building of dependent coroutine promise_type

2016-10-06 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: rsmith, GorNishanov, majnemer.
EricWF added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

When using TreeTransform to rebuild a coroutine the coroutine `promise_type` 
variable is not transformed because it's stored in the `FunctionScopeInfo` and 
not as a regular sub-statement of the function.

This patch attempts to fix this by rebuilding the promise variable at the start 
of transforming a `CoroutineBodyStmt`. Additionally this patch changes 
`TransformCoroutineBodyStmt` so that it always re-builds the coroutine body. Is 
there a better alternative to always rebuilding the body? Or is always 
rebuilding sufficient for now?


https://reviews.llvm.org/D25303

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -52,21 +52,21 @@
   using promise_type = Promise;
 };
 
-void no_specialization() {
-  co_await a; // expected-error {{implicit instantiation of undefined template 'std::experimental::coroutine_traits'}}
+void no_specialization() { // expected-error {{implicit instantiation of undefined template 'std::experimental::coroutine_traits'}}
+  co_await a;
 }
 
 template 
 struct std::experimental::coroutine_traits {};
 
-int no_promise_type() {
-  co_await a; // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
+int no_promise_type() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
+  co_await a;
 }
 
 template <>
 struct std::experimental::coroutine_traits { typedef int promise_type; };
-double bad_promise_type(double) {
-  co_await a; // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}}
+double bad_promise_type(double) { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}}
+  co_await a;
 }
 
 template <>
@@ -77,7 +77,7 @@
   co_yield 0; // expected-error {{no member named 'yield_value' in 'std::experimental::coroutine_traits::promise_type'}}
 }
 
-struct promise; // expected-note 2{{forward declaration}}
+struct promise; // expected-note 3{{forward declaration}}
 template 
 struct std::experimental::coroutine_traits { using promise_type = promise; };
 
@@ -94,6 +94,12 @@
   // expected-error@-2 {{incomplete definition of type 'promise'}}
   co_await a;
 }
+template 
+void undefined_promise_template(T) { // expected-error {{variable has incomplete type 'promise_type'}}
+  // FIXME: This diagnostic doesn't make any sense.
+  co_await a;
+}
+template void undefined_promise_template(int); // expected-note {{requested here}}
 
 struct yielded_thing { const char *p; short a, b; };
 
@@ -299,6 +305,16 @@
   co_await a;
 }
 
+struct not_class_tag {};
+template <>
+struct std::experimental::coroutine_traits { using promise_type = int; };
+
+template 
+void promise_type_not_class(T) {
+  // expected-error@-1 {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}}
+  co_await a;
+}
+template void promise_type_not_class(not_class_tag); // expected-note {{requested here}}
 
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1326,6 +1326,16 @@
 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
   }
 
+  /// \brief Build a new coroutine body.
+  ///
+  /// By default, performs semantic analysis to build the new body.
+  /// Subclasses may override this routine to provide different behavior.
+  StmtResult RebuildCoroutineBodyStmt(Stmt *Body) {
+auto *FD = dyn_cast(getSema().CurContext);
+assert(FD); // FIXME this assertion should never fire
+return getSema().ActOnFinishCoroutineBody(FD, Body);
+  }
+
   /// \brief Build a new Objective-C \@try statement.
   ///
   /// By default, performs semantic analysis to build the new statement.
@@ -6651,8 +6661,25 @@
 template
 StmtResult
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // The coroutine body should be re-formed by the caller if necessary.
-  return getDerived().TransformStmt(S->getBody());
+  // FIXME: Don't rebuild the entire coroutine body.
+  // The coroutine body should only be re-formed by the caller if necessary.
+  FunctionScopeInfo *FS = 

r283420 - [Driver] Add driver support for Fuchsia

2016-10-06 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Oct  6 01:08:09 2016
New Revision: 283420

URL: http://llvm.org/viewvc/llvm-project?rev=283420=rev
Log:
[Driver] Add driver support for Fuchsia

Provide toolchain and tool support for Fuchsia operating system.
Fuchsia uses compiler-rt as the runtime library and libc++, libc++abi
and libunwind as the C++ standard library. lld is used as a default
linker.

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

Added:
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=283420=283419=283420=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  6 01:08:09 2016
@@ -823,6 +823,28 @@ public:
   }
 };
 
+// Fuchsia Target
+template
+class FuchsiaTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions , const llvm::Triple ,
+MacroBuilder ) const override {
+Builder.defineMacro("__Fuchsia__");
+Builder.defineMacro("__ELF__");
+if (Opts.POSIXThreads)
+  Builder.defineMacro("_REENTRANT");
+// Required by the libc++ locale support.
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
+public:
+  FuchsiaTargetInfo(const llvm::Triple ,
+const TargetOptions )
+  : OSTargetInfo(Triple, Opts) {
+this->MCountName = "__mcount";
+  }
+};
+
 // WebAssembly target
 template 
 class WebAssemblyOSTargetInfo : public OSTargetInfo {
@@ -8271,6 +8293,8 @@ static TargetInfo *AllocateTarget(const
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 default:
   return new AArch64leTargetInfo(Triple, Opts);
 }
@@ -8639,6 +8663,8 @@ static TargetInfo *AllocateTarget(const
   return new HaikuTargetInfo(Triple, Opts);
 case llvm::Triple::NaCl:
   return new NaClTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::PS4:
   return new PS4OSTargetInfo(Triple, Opts);
 default:

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=283420=283419=283420=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct  6 01:08:09 2016
@@ -3075,6 +3075,9 @@ const ToolChain ::getToolChain(co
 case llvm::Triple::NaCl:
   TC = new toolchains::NaClToolChain(*this, Target, Args);
   break;
+case llvm::Triple::Fuchsia:
+  TC = new toolchains::Fuchsia(*this, Target, Args);
+  break;
 case llvm::Triple::Solaris:
   TC = new toolchains::Solaris(*this, Target, Args);
   break;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=283420=283419=283420=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct  6 01:08:09 2016
@@ -4761,6 +4761,108 @@ void Linux::addProfileRTLibs(const llvm:
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
 
+/// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
+
+Fuchsia::Fuchsia(const Driver , const llvm::Triple ,
+ const ArgList )
+: Generic_ELF(D, Triple, Args) {
+
+  getFilePaths().push_back(D.SysRoot + "/lib");
+  getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia");
+
+  // Use LLD by default.
+  DefaultLinker = "lld";
+}
+
+Tool *Fuchsia::buildAssembler() const {
+  return new tools::gnutools::Assembler(*this);
+}
+
+Tool *Fuchsia::buildLinker() const {
+  return new tools::fuchsia::Linker(*this);
+}
+
+ToolChain::RuntimeLibType Fuchsia::GetRuntimeLibType(
+const ArgList ) const {
+  if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
+StringRef Value = A->getValue();
+if (Value != "compiler-rt")
+  getDriver().Diag(diag::err_drv_invalid_rtlib_name)
+<< A->getAsString(Args);
+  }
+
+  return ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::CXXStdlibType
+Fuchsia::GetCXXStdlibType(const ArgList ) const {
+  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
+StringRef Value = A->getValue();
+if (Value != "libc++")
+  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+<< A->getAsString(Args);
+  }
+
+  return ToolChain::CST_Libcxx;

[Clang-Tidy]: modernize-avoid-bind erroneous scope resolution.

2016-10-06 Thread Idriss RIOUAK via cfe-commits
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.The check is modernize-avoid-bind.Consider the following:void bar(int x, int y);namespace N{  void bar(int x, int y);}void foo(){  auto Test = std::bind(N::bar,1,1);}clang-tidy’s modernize-avoid-bind check suggests writing:void foo(){  auto Test =[] {return bar(1,1);};}instead of:void foo(){  auto Test = [] {return N::bar(1,1);};}So clang-tidy has proposed an incorrect Fix.This is my proposal patch:

AvoidBindCheck.patch
Description: Binary data
And this is my proposal testcase:

modernize-avoid-bind.patch
Description: Binary data
Should I have to open a report on BugZilla?
Idriss Riouakidriss.rio...@studenti.unipr.itCorso di Laurea in scienze informatica.Dipartimento di Matematica e Informatica.




smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r283424 - [clang-move] Cleanup around replacements.

2016-10-06 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct  6 03:29:32 2016
New Revision: 283424

URL: http://llvm.org/viewvc/llvm-project?rev=283424=rev
Log:
[clang-move] Cleanup around replacements.

Summary:
cleanup the remaining empty namespace after moving out the
class defintitions.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/test/clang-move/move-class.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=283424=283423=283424=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Oct  6 03:29:32 2016
@@ -240,11 +240,12 @@ ClangMoveAction::CreateASTConsumer(clang
 }
 
 ClangMoveTool::ClangMoveTool(
-  const MoveDefinitionSpec ,
-  std::map ,
-  llvm::StringRef OriginalRunningDirectory)
-  : Spec(MoveSpec), FileToReplacements(FileToReplacements),
-OriginalRunningDirectory(OriginalRunningDirectory) {
+const MoveDefinitionSpec ,
+std::map ,
+llvm::StringRef OriginalRunningDirectory, llvm::StringRef FallbackStyle)
+: Spec(MoveSpec), FileToReplacements(FileToReplacements),
+  OriginalRunningDirectory(OriginalRunningDirectory),
+  FallbackStyle(FallbackStyle) {
   Spec.Name = llvm::StringRef(Spec.Name).ltrim(':');
   if (!Spec.NewHeader.empty())
 CCIncludes.push_back("#include \"" + Spec.NewHeader + "\"\n");
@@ -364,13 +365,27 @@ void ClangMoveTool::addIncludes(llvm::St
 
 void ClangMoveTool::removeClassDefinitionInOldFiles() {
   for (const auto  : RemovedDecls) {
-auto EndLoc = getLocForEndOfDecl(MovedDecl.Decl, MovedDecl.SM);
+const auto  = *MovedDecl.SM;
+auto EndLoc = getLocForEndOfDecl(MovedDecl.Decl, );
 clang::tooling::Replacement RemoveReplacement(
-*MovedDecl.SM, clang::CharSourceRange::getTokenRange(
-   MovedDecl.Decl->getLocStart(), EndLoc),
+SM, 
clang::CharSourceRange::getTokenRange(MovedDecl.Decl->getLocStart(),
+  EndLoc),
 "");
 std::string FilePath = RemoveReplacement.getFilePath().str();
 addOrMergeReplacement(RemoveReplacement, [FilePath]);
+
+llvm::StringRef Code =
+SM.getBufferData(SM.getFileID(MovedDecl.Decl->getLocation()));
+format::FormatStyle Style =
+format::getStyle("file", FilePath, FallbackStyle);
+auto CleanReplacements = format::cleanupAroundReplacements(
+Code, FileToReplacements[FilePath], Style);
+
+if (!CleanReplacements) {
+  llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
+  continue;
+}
+FileToReplacements[FilePath] = *CleanReplacements;
   }
 }
 

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=283424=283423=283424=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Thu Oct  6 03:29:32 2016
@@ -50,7 +50,7 @@ public:
   ClangMoveTool(
   const MoveDefinitionSpec ,
   std::map ,
-  llvm::StringRef OriginalRunningDirectory);
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef Style);
 
   void registerMatchers(ast_matchers::MatchFinder *Finder);
 
@@ -95,6 +95,8 @@ private:
   // directory when analyzing the source file. We save the original working
   // directory in order to get the absolute file path for the fields in Spec.
   std::string OriginalRunningDirectory;
+  // The name of a predefined code style.
+  std::string FallbackStyle;
 };
 
 class ClangMoveAction : public clang::ASTFrontendAction {
@@ -102,8 +104,9 @@ public:
   ClangMoveAction(
   const ClangMoveTool::MoveDefinitionSpec ,
   std::map ,
-  llvm::StringRef OriginalRunningDirectory)
-  : MoveTool(spec, FileToReplacements, OriginalRunningDirectory) {
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef FallbackStyle)
+  : MoveTool(spec, FileToReplacements, OriginalRunningDirectory,
+ FallbackStyle) {
 MoveTool.registerMatchers();
   }
 
@@ -123,18 +126,21 @@ public:
   ClangMoveActionFactory(
   const ClangMoveTool::MoveDefinitionSpec ,
   std::map ,
-  llvm::StringRef OriginalRunningDirectory)
+  

[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-06 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D25227



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


r283432 - [Sema] Fix PR30520: Handle incomplete field types in transparent_union unions

2016-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Oct  6 04:47:29 2016
New Revision: 283432

URL: http://llvm.org/viewvc/llvm-project?rev=283432=rev
Log:
[Sema] Fix PR30520: Handle incomplete field types in transparent_union unions

This commit fixes a crash that happens when clang is analyzing a
transparent_union attribute on a union which has a field with incomplete type.

rdar://28630028

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

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=283432=283431=283432=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  6 04:47:29 2016
@@ -3044,10 +3044,14 @@ static void handleTransparentUnionAttr(S
 return;
   }
 
+  if (FirstType->isIncompleteType())
+return;
   uint64_t FirstSize = S.Context.getTypeSize(FirstType);
   uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
   for (; Field != FieldEnd; ++Field) {
 QualType FieldType = Field->getType();
+if (FieldType->isIncompleteType())
+  return;
 // FIXME: this isn't fully correct; we also need to test whether the
 // members of the union would all have the same calling convention as the
 // first member of the union. Checking just the size and alignment isn't

Modified: cfe/trunk/test/Sema/transparent-union.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/transparent-union.c?rev=283432=283431=283432=diff
==
--- cfe/trunk/test/Sema/transparent-union.c (original)
+++ cfe/trunk/test/Sema/transparent-union.c Thu Oct  6 04:47:29 2016
@@ -89,3 +89,12 @@ union pr15134v2 {
 unsigned int u3;
   } __attribute__((aligned(8)));
 } __attribute__((transparent_union));
+
+union pr30520v { void b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'void'}}
+
+union pr30520a { int b[]; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'int []'}}
+
+// expected-note@+1 2 {{forward declaration of 'struct stb'}}
+union pr30520s { struct stb b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'struct stb'}}
+
+union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); 
// expected-error {{field has incomplete type 'struct stb'}}


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


[clang-tools-extra] r283425 - [clang-move] Move comments which are associated with the moved class.

2016-10-06 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct  6 03:59:24 2016
New Revision: 283425

URL: http://llvm.org/viewvc/llvm-project?rev=283425=rev
Log:
[clang-move] Move comments which are associated with the moved class.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=283425=283424=283425=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Oct  6 03:59:24 2016
@@ -94,6 +94,64 @@ private:
   ClangMoveTool *const MoveTool;
 };
 
+// Expand to get the end location of the line where the EndLoc of the given
+// Decl.
+SourceLocation
+getLocForEndOfDecl(const clang::Decl *D, const SourceManager *SM,
+   const LangOptions  = clang::LangOptions()) {
+  std::pair LocInfo = SM->getDecomposedLoc(D->getLocEnd());
+  // Try to load the file buffer.
+  bool InvalidTemp = false;
+  llvm::StringRef File = SM->getBufferData(LocInfo.first, );
+  if (InvalidTemp)
+return SourceLocation();
+
+  const char *TokBegin = File.data() + LocInfo.second;
+  // Lex from the start of the given location.
+  Lexer Lex(SM->getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
+TokBegin, File.end());
+
+  llvm::SmallVector Line;
+  // FIXME: this is a bit hacky to get ReadToEndOfLine work.
+  Lex.setParsingPreprocessorDirective(true);
+  Lex.ReadToEndOfLine();
+  SourceLocation EndLoc  = D->getLocEnd().getLocWithOffset(Line.size());
+  // If we already reach EOF, just return the EOF SourceLocation;
+  // otherwise, move 1 offset ahead to include the trailing newline character
+  // '\n'.
+  return SM->getLocForEndOfFile(LocInfo.first) == EndLoc
+ ? EndLoc
+ : EndLoc.getLocWithOffset(1);
+}
+
+// Get full range of a Decl including the comments associated with it.
+clang::CharSourceRange
+GetFullRange(const clang::SourceManager *SM, const clang::Decl *D,
+ const clang::LangOptions  = clang::LangOptions()) {
+  clang::SourceRange Full = D->getSourceRange();
+  Full.setEnd(getLocForEndOfDecl(D, SM));
+  // Expand to comments that are associated with the Decl.
+  if (const auto* Comment =
+  D->getASTContext().getRawCommentForDeclNoCache(D)) {
+if (SM->isBeforeInTranslationUnit(Full.getEnd(), Comment->getLocEnd()))
+  Full.setEnd(Comment->getLocEnd());
+// FIXME: Don't delete a preceding comment, if there are no other entities
+// it could refer to.
+if (SM->isBeforeInTranslationUnit(Comment->getLocStart(),
+  Full.getBegin()))
+  Full.setBegin(Comment->getLocStart());
+  }
+
+  return clang::CharSourceRange::getCharRange(Full);
+}
+
+std::string getDeclarationSourceText(const clang::Decl *D,
+ const clang::SourceManager *SM) {
+  llvm::StringRef SourceText = clang::Lexer::getSourceText(
+  GetFullRange(SM, D), *SM, clang::LangOptions());
+  return SourceText.str();
+}
+
 clang::tooling::Replacement
 getReplacementInChangedCode(const clang::tooling::Replacements ,
 const clang::tooling::Replacement ) {
@@ -147,26 +205,6 @@ std::vector GetNamespaces(c
   return Namespaces;
 }
 
-SourceLocation getLocForEndOfDecl(const clang::Decl *D,
-  const clang::SourceManager *SM) {
-  auto End = D->getLocEnd();
-  clang::SourceLocation AfterSemi = clang::Lexer::findLocationAfterToken(
-  End, clang::tok::semi, *SM, clang::LangOptions(),
-  /*SkipTrailingWhitespaceAndNewLine=*/true);
-  if (AfterSemi.isValid())
-End = AfterSemi.getLocWithOffset(-1);
-  return End;
-}
-
-std::string getDeclarationSourceText(const clang::Decl *D,
- const clang::SourceManager *SM) {
-  auto EndLoc = getLocForEndOfDecl(D, SM);
-  llvm::StringRef SourceText = clang::Lexer::getSourceText(
-  clang::CharSourceRange::getTokenRange(D->getLocStart(), EndLoc), *SM,
-  clang::LangOptions());
-  return SourceText.str() + "\n";
-}
-
 clang::tooling::Replacements
 createInsertedReplacements(const std::vector ,
const std::vector ,
@@ -178,8 +216,12 @@ createInsertedReplacements(const std::ve
   // FIXME: Add header guard.
   for (const auto  : Includes)
 AllIncludesString += Include;
-  clang::tooling::Replacement InsertInclude(FileName, 0, 0, AllIncludesString);
-  addOrMergeReplacement(InsertInclude, );
+
+  if (!AllIncludesString.empty()) {
+

[PATCH] D25308: [Sema] Ignore transparent_union attributes in C++

2016-10-06 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: rnk, aaron.ballman.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

While working on fixing PR30520 yesterday I noticed that clang also crashes on 
code like this:

  template
  union u { T b; } __attribute__((transparent_union));

I mentioned in https://reviews.llvm.org/D25273 that I plan on fixing it 
properly by instantiating the attribute, but, after looking more into it, I 
discovered that we don't really support 'transparent_union' in C++ at all. This 
is why I decided to go with the approach that's presented in this patch: the 
attribute is completely ignored when clang is in C++ mode, and thus the crash 
is avoided.

I wasn't sure if we should we emit an error or a warning when ignoring this 
attribute and if we need any diagnostics in Gnu mode at all. That's why in this 
initial patch doesn't emit a diagnostic when ignoring this attribute. Please 
let me know whether we need to show one or not.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D25308

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-gnu.cpp


Index: test/SemaCXX/attr-gnu.cpp
===
--- test/SemaCXX/attr-gnu.cpp
+++ test/SemaCXX/attr-gnu.cpp
@@ -27,3 +27,19 @@
   void test3() __attribute__((cf_unknown_transfer)) override {} // Ok, not 
known to GCC.
 };
 }
+
+template
+union Tu { T b; } __attribute__((transparent_union));
+
+template
+union Tu2 { int x; T b; } __attribute__((transparent_union));
+
+union Tu3 { int x; } __attribute((transparent_union));
+
+void tuTest1(Tu u); // expected-note {{candidate function not viable: no 
known conversion from 'int' to 'Tu' for 1st argument}}
+void tuTest2(Tu3 u); // expected-note {{candidate function not viable: no 
known conversion from 'int' to 'Tu3' for 1st argument}}
+void tu() {
+  int x = 2;
+  tuTest1(x); // expected-error {{no matching function for call to 'tuTest1'}}
+  tuTest2(x); // expected-error {{no matching function for call to 'tuTest2'}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3008,6 +3008,10 @@
 
 static void handleTransparentUnionAttr(Sema , Decl *D,
const AttributeList ) {
+  if (S.getLangOpts().CPlusPlus) {
+return;
+  }
+
   // Try to find the underlying union declaration.
   RecordDecl *RD = nullptr;
   TypedefNameDecl *TD = dyn_cast(D);


Index: test/SemaCXX/attr-gnu.cpp
===
--- test/SemaCXX/attr-gnu.cpp
+++ test/SemaCXX/attr-gnu.cpp
@@ -27,3 +27,19 @@
   void test3() __attribute__((cf_unknown_transfer)) override {} // Ok, not known to GCC.
 };
 }
+
+template
+union Tu { T b; } __attribute__((transparent_union));
+
+template
+union Tu2 { int x; T b; } __attribute__((transparent_union));
+
+union Tu3 { int x; } __attribute((transparent_union));
+
+void tuTest1(Tu u); // expected-note {{candidate function not viable: no known conversion from 'int' to 'Tu' for 1st argument}}
+void tuTest2(Tu3 u); // expected-note {{candidate function not viable: no known conversion from 'int' to 'Tu3' for 1st argument}}
+void tu() {
+  int x = 2;
+  tuTest1(x); // expected-error {{no matching function for call to 'tuTest1'}}
+  tuTest2(x); // expected-error {{no matching function for call to 'tuTest2'}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3008,6 +3008,10 @@
 
 static void handleTransparentUnionAttr(Sema , Decl *D,
const AttributeList ) {
+  if (S.getLangOpts().CPlusPlus) {
+return;
+  }
+
   // Try to find the underlying union declaration.
   RecordDecl *RD = nullptr;
   TypedefNameDecl *TD = dyn_cast(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-06 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73759.
rmaprath added a comment.

Final patch to be committed, with all the remaining comments addressed.


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp
  test/std/re/re.regex/re.regex.assign/assign.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
  test/std/thread/futures/futures.async/async.pass.cpp
  test/std/thread/futures/futures.promise/dtor.pass.cpp
  test/std/thread/futures/futures.promise/get_future.pass.cpp
  test/std/thread/futures/futures.promise/move_ctor.pass.cpp
  test/std/thread/futures/futures.promise/set_exception.pass.cpp
  test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
  test/std/thread/futures/futures.promise/set_value_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_void.pass.cpp
  test/std/thread/futures/futures.shared_future/get.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
  test/std/thread/futures/futures.unique_future/get.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -33,7 +32,7 @@
 void* operator new(std::size_t s) throw(std::bad_alloc)
 {
 if (throw_one == 0)
-throw std::bad_alloc();
+TEST_THROW(std::bad_alloc());
 --throw_one;
 ++outstanding_new;
 void* ret = std::malloc(s);
@@ -118,6 +117,7 @@
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
 void test_throwing_new_during_thread_creation() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
@@ -142,6 +142,7 @@
 }
 f_run = false;
 throw_one = 0xFFF;
+#endif
 }
 
 int main()
@@ -162,6 +163,7 @@
 assert(G::op_run);
 }
 G::op_run = false;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -178,6 +180,7 @@
 assert(!G::op_run);
 }
 }
+#endif
 #if TEST_STD_VER >= 11
 {
 assert(G::n_alive == 0);
Index: test/std/thread/futures/futures.unique_future/get.pass.cpp
===
--- test/std/thread/futures/futures.unique_future/get.pass.cpp
+++ test/std/thread/futures/futures.unique_future/get.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -22,6 +21,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 void func1(std::promise p)
 {
 std::this_thread::sleep_for(std::chrono::milliseconds(500));
@@ -73,6 +74,7 @@
 assert(f.get() == 3);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -89,6 +91,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef int& T;
@@ -100,6 +103,7 @@
 assert(f.get() == 5);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -116,6 +120,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef void T;
@@ -127,6 +132,7 @@
 f.get();
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -143,5 +149,6 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 }
Index: test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
===
--- test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
+++ test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
@@ -7,7 +7,6 @@
 //
 

r283428 - Fix PR30440: Initialize FunctionTypeDepth in CXXNameMangler

2016-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Oct  6 04:37:15 2016
New Revision: 283428

URL: http://llvm.org/viewvc/llvm-project?rev=283428=rev
Log:
Fix PR30440: Initialize FunctionTypeDepth in CXXNameMangler

This commit fixes PR 30440 by initializing CXXNameMangler's FunctionTypeDepth
in the two constructors added in r274222 (The commit that caused this
regression).

rdar://28455269

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

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=283428=283427=283428=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Oct  6 04:37:15 2016
@@ -405,14 +405,14 @@ public:
   CXXNameMangler(CXXNameMangler , raw_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler , llvm::raw_null_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {

Modified: cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp?rev=283428=283427=283428=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp Thu Oct  6 04:37:15 2016
@@ -219,3 +219,16 @@ void f19_test(N19::C
 }
 // f19_test(N19::C, N19::F, N19::D)
 // CHECK-DAG: define void 
@_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
+
+namespace pr30440 {
+
+template void g(F);
+template auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
+}
+// CHECK-DAG: define {{.*}} 
@_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(
+
+void pr30440_test () {
+  h();
+}
+
+}


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


r283430 - Add missing -no-canonical-prefixes.

2016-10-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct  6 04:40:37 2016
New Revision: 283430

URL: http://llvm.org/viewvc/llvm-project?rev=283430=rev
Log:
Add missing -no-canonical-prefixes.

Modified:
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=283430=283429=283430=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Thu Oct  6 04:40:37 2016
@@ -1,4 +1,4 @@
-// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: %clang %s -### -no-canonical-prefixes --target=x86_64-unknown-fuchsia \
 // RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-fuse-init-array"

Modified: cfe/trunk/test/Driver/fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.cpp?rev=283430=283429=283430=diff
==
--- cfe/trunk/test/Driver/fuchsia.cpp (original)
+++ cfe/trunk/test/Driver/fuchsia.cpp Thu Oct  6 04:40:37 2016
@@ -1,4 +1,4 @@
-// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia \
+// RUN: %clangxx %s -### -no-canonical-prefixes 
--target=x86_64-unknown-fuchsia \
 // RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-fuse-init-array"


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


[PATCH] D25309: [clang-move] Support moving multiple classes in one run.

2016-10-06 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25309

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  test/clang-move/Inputs/database_template.json
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/Inputs/multiple_class_test.h
  test/clang-move/move-multiple-classes.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -210,7 +210,7 @@
 
 TEST(ClangMove, MoveHeaderAndCC) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldHeader = "foo.h";
   Spec.OldCC = "foo.cc";
   Spec.NewHeader = "new_foo.h";
@@ -225,7 +225,7 @@
 
 TEST(ClangMove, MoveHeaderOnly) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldHeader = "foo.h";
   Spec.NewHeader = "new_foo.h";
   auto Results = runClangMoveOnCode(Spec);
@@ -236,7 +236,7 @@
 
 TEST(ClangMove, MoveCCOnly) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldCC = "foo.cc";
   Spec.NewCC = "new_foo.cc";
   std::string ExpectedHeader = "#include \"foo.h\"\n\n";
@@ -248,7 +248,7 @@
 
 TEST(ClangMove, MoveNonExistClass) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "NonExistFoo";
+  Spec.Names = "NonExistFoo";
   Spec.OldHeader = "foo.h";
   Spec.OldCC = "foo.cc";
   Spec.NewHeader = "new_foo.h";
Index: test/clang-move/move-multiple-classes.cpp
===
--- /dev/null
+++ test/clang-move/move-multiple-classes.cpp
@@ -0,0 +1,44 @@
+// RUN: mkdir -p %T/clang-move/build
+// RUN: sed 's|$test_dir|%/T/clang-move|g' %S/Inputs/database_template.json > %T/clang-move/compile_commands.json
+// RUN: cp %S/Inputs/multiple_class_test*  %T/clang-move/
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo;b::Foo2" -new_cc=%T/clang-move/new_multiple_class_test.cpp -new_header=%T/clang-move/new_multiple_class_test.h -old_cc=%T/clang-move/multiple_class_test.cpp -old_header=../clang-move/multiple_class_test.h %T/clang-move/multiple_class_test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_multiple_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_multiple_class_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/multiple_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/multiple_class_test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// CHECK-OLD-TEST-H: namespace c {
+// CHECK-OLD-TEST-H: class Bar {
+// CHECK-OLD-TEST-H: public:
+// CHECK-OLD-TEST-H:   int f();
+// CHECK-OLD-TEST-H: };
+// CHECK-OLD-TEST-H: } // namespace c
+
+// CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: namespace c {
+// CHECK-OLD-TEST-CPP: int Bar::f() {
+// CHECK-OLD-TEST-CPP:   return 0;
+// CHECK-OLD-TEST-CPP: }
+// CHECK-OLD-TEST-CPP: } // namespace c
+
+// CHECK-NEW-TEST-H: namespace a {
+// CHECK-NEW-TEST-H: class Foo {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace a
+// CHECK-NEW-TEST-H: namespace b {
+// CHECK-NEW-TEST-H: class Foo2 {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace b
+
+// CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
+// CHECK-NEW-TEST-CPP: namespace a {
+// CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace a
+// CHECK-NEW-TEST-CPP: namespace b {
+// CHECK-NEW-TEST-CPP: int Foo2::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace b
Index: test/clang-move/Inputs/multiple_class_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/multiple_class_test.h
@@ -0,0 +1,20 @@
+namespace a {
+class Foo {
+public:
+  int f();
+};
+} // namespace a
+
+namespace b {
+class Foo2 {
+public:
+  int f();
+};
+} // namespace b
+
+namespace c {
+class Bar {
+public:
+  int f();
+};
+} // namespace c
Index: test/clang-move/Inputs/multiple_class_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/multiple_class_test.cpp
@@ -0,0 +1,19 @@
+#include "multiple_class_test.h"
+
+namespace a {
+int Foo::f() {
+  return 0;
+}
+} // namespace a
+
+namespace b {
+int Foo2::f() {
+  return 0;
+}
+} // namespace b
+
+namespace c {
+int Bar::f() {
+  return 0;
+}
+} // namespace c
Index: test/clang-move/Inputs/database_template.json
===

[PATCH] D25303: [coroutines] Fix re-building of dependent coroutine promise_type

2016-10-06 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

This is all wrong. Sorry for the noise.


https://reviews.llvm.org/D25303



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


[libcxx] r283441 - [libcxx] Recover no-exceptions XFAILs - I

2016-10-06 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct  6 06:15:41 2016
New Revision: 283441

URL: http://llvm.org/viewvc/llvm-project?rev=283441=rev
Log:
[libcxx] Recover no-exceptions XFAILs - I

First batch of changes to get some of these XFAILs working in the
no-exceptions libc++ variant.

Changed some XFAILs to UNSUPPORTED where the test is all about exception
handling. In other cases, used the test macros TEST_THROW and
TEST_HAS_NO_EXCEPTIONS to conditionally exclude those parts of the test
that concerns exception handling behaviour.

Reviewers: EricWF, mclow.lists

Differential revision: https://reviews.llvm.org/D24562

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/dtor.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/get_future.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_exception.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_value_void.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.shared_future/get.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.unique_future/get.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp Thu Oct  6 
06:15:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -25,6 +24,7 @@
 
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 size_t size = strlen(data);
 if (size > 0)
 {
@@ -37,6 +37,7 @@ extern "C" void LLVMFuzzerTestOneInput(c
 }
 catch (std::regex_error &) {}
 }
+#endif
 }
 
 

Modified: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp Thu Oct  
6 06:15:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template > class 
basic_regex;
@@ -27,6 +26,7 @@ int main()
 assert(r2.mark_count() == 2);
 assert(std::regex_search("ab", r2));
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 bool caught = false;
 try { r2.assign("(def", std::regex::extended); }
 catch(std::regex_error &) { caught = true; }
@@ -34,4 +34,5 @@ int main()
 assert(r2.flags() == std::regex::ECMAScript);
 assert(r2.mark_count() == 2);
 assert(std::regex_search("ab", r2));
+#endif
 }

Modified: 
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
Thu Oct  6 06:15:41 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
+// 

[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 73781.
arphaman added a comment.

Slight update: There's no need to pass `CFGBlock` into `isBuiltinUnreachable`.


Repository:
  rL LLVM

https://reviews.llvm.org/D25321

Files:
  lib/Analysis/ReachableCode.cpp
  test/Sema/warn-unreachable.c


Index: test/Sema/warn-unreachable.c
===
--- test/Sema/warn-unreachable.c
+++ test/Sema/warn-unreachable.c
@@ -396,3 +396,40 @@
   else
 calledFun();
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,15 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const Stmt *S) {
+  if (const DeclRefExpr *DRE = dyn_cast(S)) {
+const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
+return FDecl && FDecl->getIdentifier() &&
+   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  }
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -574,8 +583,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {


Index: test/Sema/warn-unreachable.c
===
--- test/Sema/warn-unreachable.c
+++ test/Sema/warn-unreachable.c
@@ -396,3 +396,40 @@
   else
 calledFun();
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,15 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const Stmt *S) {
+  if (const DeclRefExpr *DRE = dyn_cast(S)) {
+const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
+return FDecl && FDecl->getIdentifier() &&
+   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  }
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -574,8 +583,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r283452 - Mark issues 2514, 2519, 2536 and 2475 as done

2016-10-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Oct  6 08:59:18 2016
New Revision: 283452

URL: http://llvm.org/viewvc/llvm-project?rev=283452=rev
Log:
Mark issues 2514, 2519, 2536 and 2475 as done

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283452=283451=283452=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Thu Oct  6 08:59:18 2016
@@ -68,14 +68,14 @@
 http://wg21.link/LWG2394;>2394locale::name specification 
unclear - what is implementation-defined?Issaquah
 http://wg21.link/LWG2460;>2460LWG issue 
2408 and value categoriesIssaquah
 http://wg21.link/LWG2468;>2468Self-move-assignment of 
library typesIssaquah
-http://wg21.link/LWG2475;>2475Allow 
overwriting of std::basic_string terminator with charT() to allow cleaner 
interoperation with legacy APIsIssaquah
+http://wg21.link/LWG2475;>2475Allow 
overwriting of std::basic_string terminator with charT() to allow cleaner 
interoperation with legacy APIsIssaquahNothing to 
do.
 http://wg21.link/LWG2503;>2503multiline 
option should be added to syntax_option_typeIssaquah
 http://wg21.link/LWG2510;>2510Tag types 
should not be DefaultConstructibleIssaquah
-http://wg21.link/LWG2514;>2514Type 
traits must not be finalIssaquah
-http://wg21.link/LWG2519;>2519Iterator 
operator-= has gratuitous undefined 
behaviourIssaquah
+http://wg21.link/LWG2514;>2514Type 
traits must not be finalIssaquahNothing to do
+http://wg21.link/LWG2519;>2519Iterator 
operator-= has gratuitous undefined behaviourIssaquahNothing 
to do
 http://wg21.link/LWG2531;>2531future::get should explicitly 
state that the shared state is releasedIssaquah
 http://wg21.link/LWG2534;>2534Constrain 
rvalue stream operatorsIssaquah
-http://wg21.link/LWG2536;>2536What 
should  do?Issaquah
+http://wg21.link/LWG2536;>2536What 
should complex.h do?IssaquahWe already do 
this
 http://wg21.link/LWG2540;>2540unordered_multimap::insert 
hint iteratorIssaquah
 http://wg21.link/LWG2543;>2543LWG 2148 
(hash support for enum types) seems 
under-specifiedIssaquah
 http://wg21.link/LWG2544;>2544istreambuf_iterator(basic_streambuf* s) effects unclear when s is 0Issaquah
@@ -141,15 +141,15 @@
 2358 - We already do this; I improved the tests
 2394 - 
 2460 - 
-2468 - 
-2475 - 
+2468 - I think we already do this; but will need to survey the libray 
to be sure
+2475 - Nothing to do here. 
 2503 - 
-2510 - 
-2514 - 
-2519 - 
+2510 - Need to write tests for all the tag types
+2514 - Nothing to do; We don't mark any of the type traits as final. 
+2519 - This is just wording cleanup. 
 2531 - 
 2534 - 
-2536 - 
+2536 - We already do this. 
 2540 - 
 2543 - 
 2544 - 


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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-06 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Please add a test. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D25305



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


[PATCH] D19063: clang-format: Fixed line merging of more than two lines

2016-10-06 Thread Cameron via cfe-commits
cameron314 added a comment.

I'll commit this in a few days, when I have some time to reintegrate it to the 
trunk. Thanks!


https://reviews.llvm.org/D19063



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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-10-06 Thread Ziv Izhar via cfe-commits
zizhar updated this revision to Diff 73760.
zizhar added a comment.

fixed :)


https://reviews.llvm.org/D15075

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/Headers/intrin.h
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -28,6 +28,16 @@
   asm ("nop" : : : "204"); // expected-error {{unknown register name '204' in asm}}
   asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
   asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+  register void *clobber_conflict asm ("%rcx");
+  register void *no_clobber_conflict asm ("%rax");
+  int a,b,c;
+  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
 }
 
 // rdar://6094010
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -22,6 +22,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 using namespace clang;
 using namespace sema;
@@ -137,6 +138,56 @@
   return false;
 }
 
+// Extracting the register name from the Expression value,
+// if there is no register name to extract, returns ""
+StringRef ExtractRegisterName(const Expr *Expression,
+  const TargetInfo ) {
+  Expression = Expression->IgnoreImpCasts();
+  if (const DeclRefExpr *AsmDeclRef = dyn_cast(Expression)) {
+// Handle cases where the expression is a variable
+const VarDecl *Variable = dyn_cast(AsmDeclRef->getDecl());
+if (Variable && Variable->getStorageClass() == SC_Register) {
+  if (AsmLabelAttr *Attr = Variable->getAttr())
+return Target.isValidGCCRegisterName(Attr->getLabel())
+? Target.getNormalizedGCCRegisterName(Attr->getLabel(), true)
+: "";
+}
+  }
+  return "";
+}
+
+// Checks if there is a conflict between the input and output lists with the
+// clobbers list. If there's a conflict, returns the location of the
+// conflicted clobber, else returns nullptr
+SourceLocation
+GetClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints,
+StringLiteral **Clobbers, int NumClobbers,
+const TargetInfo , ASTContext ) {
+  llvm::StringSet<> InOutVars;
+  // Collect all the input and output registers from the extended asm statement
+  // in order to check for conflicts with the clobber list
+  for (int i = 0; i < Exprs.size(); ++i) {
+StringRef Constraint = Constraints[i]->getString();
+StringRef InOutReg = Target.getConstraintRegister(
+  Constraint, ExtractRegisterName(Exprs[i], Target));
+if (InOutReg != "")
+  InOutVars.insert(InOutReg);
+  }
+  // Check for each item in the clobber list if it conflicts with the input
+  // or output
+  for (int i = 0; i < NumClobbers; ++i) {
+StringRef Clobber = Clobbers[i]->getString();
+// We only check registers, therefore we don't check cc and memory clobbers
+if (Clobber == "cc" || Clobber == "memory")
+  continue;
+Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
+// Go over the output's registers we collected
+if (InOutVars.count(Clobber))
+  return Clobbers[i]->getLocStart();
+  }
+  return SourceLocation();
+}
+
 StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
  bool IsVolatile, unsigned NumOutputs,
  unsigned NumInputs, IdentifierInfo **Names,
@@ -542,7 +593,14 @@
   << InputExpr->getSourceRange();
 return StmtError();
   }
-
+
+  // Check for conflicts between clobber list and input or output lists
+  SourceLocation ConstraintLoc =

[PATCH] D25311: Add FixItHint for missing #include (err_module_unimported_use_header)

2016-10-06 Thread Sam McCall via cfe-commits
sammccall added a reviewer: rsmith.
sammccall added a comment.

(First patch, so please spell out mistakes!)

I think the big question is whether it's okay to depend on Format.


https://reviews.llvm.org/D25311



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


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

2016-10-06 Thread Andi via cfe-commits
Abpostelnicu updated this revision to Diff 73766.
Abpostelnicu marked 3 inline comments as done.

https://reviews.llvm.org/D22910

Files:
  lib/AST/Expr.cpp


Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,22 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increment and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| Op == OO_PlusPlus || Op == OO_Minus) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || 
FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {


Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,22 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increment and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| Op == OO_PlusPlus || Op == OO_Minus) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2016-10-06 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, asl.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: beanz.

Add LIBUNWIND_* directories to include path only if they were actually
found, in order to fix the CMake error. Both of the directories are
usually unnecessary since libcxxabi uses only the common part of
unwind.h that is supplied both by GCC and Clang.


https://reviews.llvm.org/D25314

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -390,8 +390,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -390,8 +390,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker flags
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-06 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

Committed as r283441.

Thanks!


https://reviews.llvm.org/D24562



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


[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: dblaikie, krememek.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes the issue of clang emitting an unreachable warning when it 
encounters unreachable `__builtin_unreachable()` statements. It detects 
references to `__builtin_unreachable` and doesn't emit an unreachable warning 
for them.


Repository:
  rL LLVM

https://reviews.llvm.org/D25321

Files:
  lib/Analysis/ReachableCode.cpp
  test/Sema/warn-unreachable.c


Index: test/Sema/warn-unreachable.c
===
--- test/Sema/warn-unreachable.c
+++ test/Sema/warn-unreachable.c
@@ -396,3 +396,40 @@
   else
 calledFun();
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,15 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const CFGBlock *B, const Stmt *S) {
+  if (const DeclRefExpr *DRE = dyn_cast(S)) {
+const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
+return FDecl && FDecl->getIdentifier() &&
+   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  }
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -574,8 +583,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(B, S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {


Index: test/Sema/warn-unreachable.c
===
--- test/Sema/warn-unreachable.c
+++ test/Sema/warn-unreachable.c
@@ -396,3 +396,40 @@
   else
 calledFun();
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,15 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const CFGBlock *B, const Stmt *S) {
+  if (const DeclRefExpr *DRE = dyn_cast(S)) {
+const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
+return FDecl && FDecl->getIdentifier() &&
+   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  }
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -574,8 +583,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(B, S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-06 Thread Björn Pettersson A via cfe-commits
Thanks! Now I’ve been able to commit D24955.
/Björn

On Wed, Oct 5, 2016 at 9:18 PM, Nemanja Ivanovic 
> wrote:
OK, will remove optimization and the selects and commit this now.
Sorry about the delay.

On Wed, Oct 5, 2016 at 9:16 PM, Sanjay Patel 
> wrote:
You should not need to account for any nsw/nuw flags if the clang test does not 
enable the optimizer.
Ie, D24955 should not be running at -O0.

On Wed, Oct 5, 2016 at 1:09 PM, Nemanja Ivanovic 
> wrote:
OK, I get testing that I'm fine with if I remove the -O2 and the checks for 
'select i1'.
Does that change suffice for the purposes of https://reviews.llvm.org/D24955?
Namely, do I need to account for the possible addition of nsw/nuw flags to the 
add instructions even without -O2?

On Wed, Oct 5, 2016 at 8:24 PM, Sanjay Patel 
> wrote:
spatel added a comment.

In https://reviews.llvm.org/D24397#562469, @bjope wrote:

> (I'm still hesitating about commiting https://reviews.llvm.org/D24955 in llvm 
> since that would make these clang tests fail...)


You can't do that. Bots will send you fail mail all day as they choke on the 
clang tests - speaking from experience. :)
We either need to fix or revert this commit in order to let 
https://reviews.llvm.org/D24955 proceed.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397






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


[PATCH] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-10-06 Thread Eric Liu via cfe-commits
ioeric added a comment.

Test phab...sorry spamming...


https://reviews.llvm.org/D24380



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73780.
malcolm.parsons added a comment.

Add functional casts to tests and doc.


https://reviews.llvm.org/D25316

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp

Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = static_cast(l);
+
+  const int i2 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto i2 = static_cast(l);
+
+  A *a = new B();
+  B *b1 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = static_cast(a);
+
+  B *const b2 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *const b2 = static_cast(a);
+
+  const B *b3 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b3 = static_cast(a);
+
+  B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = static_cast(*a);
+
+  const B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto  = static_cast(*a);
+  
+  // Don't warn when auto is already being used.
+  auto i3 = static_cast(l);
+  auto *b6 = static_cast(a);
+  auto  = static_cast(*a);
+}
+
+void f_dynamic_cast() {
+  A *a = new B();
+  B *b1 = dynamic_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = dynamic_cast(a);
+
+  B  = dynamic_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = dynamic_cast(*a);
+}
+
+void f_reinterpret_cast() {
+  auto *a = new A();
+  C *c1 = reinterpret_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = reinterpret_cast(a);
+
+  C  = reinterpret_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = reinterpret_cast(*a);
+}
+
+void f_const_cast() {
+  const A *a1 = new A();
+  A *a2 = const_cast(a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *a2 = const_cast(a1);
+  A  = const_cast(*a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = const_cast(*a1);
+}
+
+void f_cstyle_cast() {
+  auto *a = new A();
+  C *c1 = (C *)a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = (C *)a;
+
+  C  = (C &)*a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = (C &)*a;
+}
+
+void f_functional_cast() {
+  long l = 1;
+  int i1 = int(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  i1 = int(l);
+
+  B b;
+  A a = A(b);
+}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 

[PATCH] D25117: [Driver] Add driver support for Fuchsia

2016-10-06 Thread Petr Hosek via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283420: [Driver] Add driver support for Fuchsia (authored by 
phosek).

Changed prior to commit:
  https://reviews.llvm.org/D25117?vs=73562=73784#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25117

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/fuchsia.c
  cfe/trunk/test/Driver/fuchsia.cpp

Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -0,0 +1,40 @@
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -rtlib=libgcc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
+// CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -static 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-lc"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SHARED
+// CHECK-SHARED-NOT: "-pie"
+// CHECK-SHARED: "-shared"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -r 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE-NOT: "-pie"
+// CHECK-RELOCATABLE-NOT: "--build-id"
+// CHECK-RELOCATABLE: "-r"
Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -0,0 +1,33 @@
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-isystem" "[[SYSROOT]]{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -stdlib=libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STDLIB
+// CHECK-STDLIB: error: invalid library name in argument '-stdlib=libstdc++'
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-lm"
+// CHECK-STATIC: "-lc"
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -1008,6 +1008,39 @@
   std::string NaClArmMacrosPath;
 };
 
+class LLVM_LIBRARY_VISIBILITY Fuchsia : public Generic_ELF {
+public:
+  Fuchsia(const Driver , const llvm::Triple ,
+  const llvm::opt::ArgList );
+
+  bool isPIEDefault() const override { return true; }
+  bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
+return llvm::DebuggerKind::GDB;
+  }
+
+  RuntimeLibType
+  GetRuntimeLibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType
+  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+
+  void addClangTargetOptions(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const 

[PATCH] D25282: [clang-move] Cleanup around replacements.

2016-10-06 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283424: [clang-move] Cleanup around replacements. (authored 
by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25282?vs=73663=73786#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25282

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.h
  clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
  clang-tools-extra/trunk/test/clang-move/move-class.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -161,7 +161,7 @@
   assert(!EC);
   (void)EC;
   auto Factory = llvm::make_unique(
-  Spec, FileToReplacements, InitialDirectory.str());
+  Spec, FileToReplacements, InitialDirectory.str(), "LLVM");
 
   tooling::runToolOnCodeWithArgs(
   Factory->create(), TestCC, {"-std=c++11"}, TestCCName, "clang-move",
Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
@@ -86,7 +86,7 @@
  Twine(EC.message()));
 
   auto Factory = llvm::make_unique(
-  Spec, Tool.getReplacements(), InitialDirectory.str());
+  Spec, Tool.getReplacements(), InitialDirectory.str(), Style);
 
   int CodeStatus = Tool.run(Factory.get());
   if (CodeStatus)
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -240,11 +240,12 @@
 }
 
 ClangMoveTool::ClangMoveTool(
-  const MoveDefinitionSpec ,
-  std::map ,
-  llvm::StringRef OriginalRunningDirectory)
-  : Spec(MoveSpec), FileToReplacements(FileToReplacements),
-OriginalRunningDirectory(OriginalRunningDirectory) {
+const MoveDefinitionSpec ,
+std::map ,
+llvm::StringRef OriginalRunningDirectory, llvm::StringRef FallbackStyle)
+: Spec(MoveSpec), FileToReplacements(FileToReplacements),
+  OriginalRunningDirectory(OriginalRunningDirectory),
+  FallbackStyle(FallbackStyle) {
   Spec.Name = llvm::StringRef(Spec.Name).ltrim(':');
   if (!Spec.NewHeader.empty())
 CCIncludes.push_back("#include \"" + Spec.NewHeader + "\"\n");
@@ -364,13 +365,27 @@
 
 void ClangMoveTool::removeClassDefinitionInOldFiles() {
   for (const auto  : RemovedDecls) {
-auto EndLoc = getLocForEndOfDecl(MovedDecl.Decl, MovedDecl.SM);
+const auto  = *MovedDecl.SM;
+auto EndLoc = getLocForEndOfDecl(MovedDecl.Decl, );
 clang::tooling::Replacement RemoveReplacement(
-*MovedDecl.SM, clang::CharSourceRange::getTokenRange(
-   MovedDecl.Decl->getLocStart(), EndLoc),
+SM, clang::CharSourceRange::getTokenRange(MovedDecl.Decl->getLocStart(),
+  EndLoc),
 "");
 std::string FilePath = RemoveReplacement.getFilePath().str();
 addOrMergeReplacement(RemoveReplacement, [FilePath]);
+
+llvm::StringRef Code =
+SM.getBufferData(SM.getFileID(MovedDecl.Decl->getLocation()));
+format::FormatStyle Style =
+format::getStyle("file", FilePath, FallbackStyle);
+auto CleanReplacements = format::cleanupAroundReplacements(
+Code, FileToReplacements[FilePath], Style);
+
+if (!CleanReplacements) {
+  llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
+  continue;
+}
+FileToReplacements[FilePath] = *CleanReplacements;
   }
 }
 
Index: clang-tools-extra/trunk/clang-move/ClangMove.h
===
--- clang-tools-extra/trunk/clang-move/ClangMove.h
+++ clang-tools-extra/trunk/clang-move/ClangMove.h
@@ -50,7 +50,7 @@
   ClangMoveTool(
   const MoveDefinitionSpec ,
   std::map ,
-  llvm::StringRef OriginalRunningDirectory);
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef Style);
 
   void registerMatchers(ast_matchers::MatchFinder *Finder);
 
@@ -95,15 +95,18 @@
   // directory when analyzing the source file. We save the original working
   // directory in order to get the absolute file path for the fields in Spec.
   std::string OriginalRunningDirectory;
+  // The name of a predefined code style.
+  std::string FallbackStyle;
 };
 
 class ClangMoveAction : public clang::ASTFrontendAction {
 public:
   ClangMoveAction(
   const 

[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2016-10-06 Thread Bruce Mitchener via cfe-commits
brucem updated this revision to Diff 73790.
brucem added a comment.

Address comments from mclow.


https://reviews.llvm.org/D25241

Files:
  include/vector
  test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp


Index: test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#endif
+}
Index: include/vector
===
--- include/vector
+++ include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), 
_VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 


Index: test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#endif
+}
Index: include/vector
===
--- include/vector
+++ include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: angelgarcia, aaron.ballman, klimek.
malcolm.parsons added subscribers: cfe-commits, Eugene.Zelenko.

Extend modernize-use-auto to cases when variable is assigned with cast.

e.g.
Type *Ptr1 = dynamic_cast(Ptr2);


https://reviews.llvm.org/D25316

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp

Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = static_cast(l);
+
+  const int i2 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto i2 = static_cast(l);
+
+  A *a = new B();
+  B *b1 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = static_cast(a);
+
+  B *const b2 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *const b2 = static_cast(a);
+
+  const B *b3 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b3 = static_cast(a);
+
+  B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = static_cast(*a);
+
+  const B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto  = static_cast(*a);
+  
+  // Don't warn when auto is already being used.
+  auto i3 = static_cast(l);
+  auto *b6 = static_cast(a);
+  auto  = static_cast(*a);
+}
+
+void f_dynamic_cast() {
+  A *a = new B();
+  B *b1 = dynamic_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = dynamic_cast(a);
+
+  B  = dynamic_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = dynamic_cast(*a);
+}
+
+void f_reinterpret_cast() {
+  auto *a = new A();
+  C *c1 = reinterpret_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = reinterpret_cast(a);
+
+  C  = reinterpret_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = reinterpret_cast(*a);
+}
+
+void f_const_cast() {
+  const A *a1 = new A();
+  A *a2 = const_cast(a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *a2 = const_cast(a1);
+  A  = const_cast(*a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = const_cast(*a1);
+}
+
+void f_cstyle_cast() {
+  auto *a = new A();
+  C *c1 = (C *)a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = (C *)a;
+
+  C  = (C &)*a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = (C &)*a;
+}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // 

[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-06 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283425: [clang-move] Move comments which are associated with 
the moved class. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25227?vs=73463=73785#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25227

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.h
  clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -29,16 +29,19 @@
 const char TestCCName[] = "foo.cc";
 
 const char TestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
+  "// This is a Foo class\n"
+  "// which is used in\n"
+  "// test.\n"
   "class Foo {\n"
   "public:\n"
   "  void f();\n"
   "\n"
   "private:\n"
   "  C1 *c1;\n"
   "  static int b;\n"
-  "};\n"
+  "}; // abc\n"
   "\n"
   "class Foo2 {\n"
   "public:\n"
@@ -51,19 +54,29 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
   "}\n"
   "\n"
+  "// comment5\n"
+  "// comment5\n"
   "void Foo::f() { f1(); }\n"
   "\n"
+  "/\n"
+  "// comment //\n"
+  "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
   "  f1();\n"
@@ -73,7 +86,7 @@
   "} // namespace a\n";
 
 const char ExpectedTestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
   "\n"
   "class Foo2 {\n"
@@ -87,12 +100,17 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
@@ -106,31 +124,44 @@
   "} // namespace a\n";
 
 const char ExpectedNewHeader[] = "namespace a {\n"
- "class C1;\n"
+ "class C1; // test\n"
  "namespace b {\n"
+ "// This is a Foo class\n"
+ "// which is used in\n"
+ "// test.\n"
  "class Foo {\n"
  "public:\n"
  "  void f();\n"
  "\n"
  "private:\n"
  "  C1 *c1;\n"
  "  static int b;\n"
- "};\n"
+ "}; // abc\n"
  "} // namespace b\n"
  

[PATCH] D25273: Fix PR30520: Fix incomplete type crash when dealing with transparent_union attribute

2016-10-06 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283432: [Sema] Fix PR30520: Handle incomplete field types in 
transparent_union unions (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25273?vs=73626=73789#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25273

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/transparent-union.c


Index: cfe/trunk/test/Sema/transparent-union.c
===
--- cfe/trunk/test/Sema/transparent-union.c
+++ cfe/trunk/test/Sema/transparent-union.c
@@ -89,3 +89,12 @@
 unsigned int u3;
   } __attribute__((aligned(8)));
 } __attribute__((transparent_union));
+
+union pr30520v { void b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'void'}}
+
+union pr30520a { int b[]; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'int []'}}
+
+// expected-note@+1 2 {{forward declaration of 'struct stb'}}
+union pr30520s { struct stb b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'struct stb'}}
+
+union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); 
// expected-error {{field has incomplete type 'struct stb'}}
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3044,10 +3044,14 @@
 return;
   }
 
+  if (FirstType->isIncompleteType())
+return;
   uint64_t FirstSize = S.Context.getTypeSize(FirstType);
   uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
   for (; Field != FieldEnd; ++Field) {
 QualType FieldType = Field->getType();
+if (FieldType->isIncompleteType())
+  return;
 // FIXME: this isn't fully correct; we also need to test whether the
 // members of the union would all have the same calling convention as the
 // first member of the union. Checking just the size and alignment isn't


Index: cfe/trunk/test/Sema/transparent-union.c
===
--- cfe/trunk/test/Sema/transparent-union.c
+++ cfe/trunk/test/Sema/transparent-union.c
@@ -89,3 +89,12 @@
 unsigned int u3;
   } __attribute__((aligned(8)));
 } __attribute__((transparent_union));
+
+union pr30520v { void b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'void'}}
+
+union pr30520a { int b[]; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'int []'}}
+
+// expected-note@+1 2 {{forward declaration of 'struct stb'}}
+union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
+
+union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3044,10 +3044,14 @@
 return;
   }
 
+  if (FirstType->isIncompleteType())
+return;
   uint64_t FirstSize = S.Context.getTypeSize(FirstType);
   uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
   for (; Field != FieldEnd; ++Field) {
 QualType FieldType = Field->getType();
+if (FieldType->isIncompleteType())
+  return;
 // FIXME: this isn't fully correct; we also need to test whether the
 // members of the union would all have the same calling convention as the
 // first member of the union. Checking just the size and alignment isn't
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24932: Fix PR 30440

2016-10-06 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283428: Fix PR30440: Initialize FunctionTypeDepth in 
CXXNameMangler (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D24932?vs=72526=73787#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24932

Files:
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp


Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -405,14 +405,14 @@
   CXXNameMangler(CXXNameMangler , raw_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler , llvm::raw_null_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {
Index: cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
===
--- cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
+++ cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
@@ -219,3 +219,16 @@
 }
 // f19_test(N19::C, N19::F, N19::D)
 // CHECK-DAG: define void 
@_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
+
+namespace pr30440 {
+
+template void g(F);
+template auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
+}
+// CHECK-DAG: define {{.*}} 
@_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(
+
+void pr30440_test () {
+  h();
+}
+
+}


Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -405,14 +405,14 @@
   CXXNameMangler(CXXNameMangler , raw_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler , llvm::raw_null_ostream _)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {
Index: cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
===
--- cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
+++ cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp
@@ -219,3 +219,16 @@
 }
 // f19_test(N19::C, N19::F, N19::D)
 // CHECK-DAG: define void @_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
+
+namespace pr30440 {
+
+template void g(F);
+template auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
+}
+// CHECK-DAG: define {{.*}} @_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(
+
+void pr30440_test () {
+  h();
+}
+
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283444 - [modules] Allow VarDecls with initializers to use special var abbrev.

2016-10-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Oct  6 08:04:54 2016
New Revision: 283444

URL: http://llvm.org/viewvc/llvm-project?rev=283444=rev
Log:
[modules] Allow VarDecls with initializers to use special var abbrev.

Update storage sizes to fit the (past) changes in the VarDecl's data model.
Update some comments.

Patch partially reviewed by Richard Smith as part of 
https://reviews.llvm.org/D24508

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=283444=283443=283444=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Oct  6 08:04:54 2016
@@ -1236,7 +1236,7 @@ ASTDeclReader::RedeclarableResult ASTDec
 
   if (uint64_t Val = Record[Idx++]) {
 VD->setInit(Reader.ReadExpr(F));
-if (Val > 1) {
+if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
   EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
   Eval->CheckedICE = true;
   Eval->IsICE = Val == 3;

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=283444=283443=283444=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Oct  6 08:04:54 2016
@@ -942,8 +942,6 @@ void ASTDeclWriter::VisitVarDecl(VarDecl
   D->getDeclName().getNameKind() == DeclarationName::Identifier &&
   !D->hasExtInfo() &&
   D->getFirstDecl() == D->getMostRecentDecl() &&
-  D->getInitStyle() == VarDecl::CInit &&
-  D->getInit() == nullptr &&
   D->getKind() == Decl::Var &&
   !D->isInline() &&
   !D->isConstexpr() &&
@@ -1880,9 +1878,9 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
   Abv->Add(BitCodeAbbrevOp(0));   // hasExtInfo
   // VarDecl
-  Abv->Add(BitCodeAbbrevOp(0));   // StorageClass
-  Abv->Add(BitCodeAbbrevOp(0));   // getTSCSpec
-  Abv->Add(BitCodeAbbrevOp(0));   // 
hasCXXDirectInitializer
+  Abv->Add(BitCodeAbbrevOp(0));   // SClass
+  Abv->Add(BitCodeAbbrevOp(0));   // TSCSpec
+  Abv->Add(BitCodeAbbrevOp(0));   // InitStyle
   Abv->Add(BitCodeAbbrevOp(0));   // Linkage
   Abv->Add(BitCodeAbbrevOp(0));   // HasInit
   Abv->Add(BitCodeAbbrevOp(0));   // 
HasMemberSpecializationInfo
@@ -1956,9 +1954,9 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
   Abv->Add(BitCodeAbbrevOp(0));   // hasExtInfo
   // VarDecl
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // StorageClass
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getTSCSpec
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // CXXDirectInitializer
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
@@ -1969,8 +1967,8 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
   Abv->Add(BitCodeAbbrevOp(0)); // 
isPrevDeclInSameScope
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));


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


[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

2016-10-06 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 73828.
agutowski marked an inline comment as done.
agutowski added a comment.

fix return value and comment


https://reviews.llvm.org/D25334

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c
  test/Headers/ms-intrin.cpp


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1148,11 +1148,6 @@
 : "%edi", "%esi", "%ecx");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
-__stosb(unsigned char *__dst, unsigned char __x, size_t __n) {
-  __asm__("rep stosb" : : "D"(__dst), "a"(__x), "c"(__n)
-: "%edi", "%ecx");
-}
-static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
   __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n)
 : "%edi", "%ecx");
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7599,7 +7599,19 @@
 HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
 return HigherBits;
   }
+
+  case X86::BI__stosb: {
+// We treat __stosb as a volatile memset - it may not generate "rep stosb"
+// instruction, but it will create a memset that won't be optimized away.
+const FunctionDecl *FD = E->getDirectCallee();
+Address Dest = EmitPointerWithAlignment(E->getArg(0));
+Value *ByteVal = EmitScalarExpr(E->getArg(1));
+Value *SizeVal = EmitScalarExpr(E->getArg(2));
+EmitNonNullArgCheck(RValue::get(Dest.getPointer()), 
E->getArg(0)->getType(),
+E->getArg(0)->getExprLoc(), FD, 0);
+return Builder.CreateMemSet(Dest, ByteVal, SizeVal, true);
   }
+  }
 }
 
 
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -2071,6 +2071,8 @@
 TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
 TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
 
+TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN
Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -14,6 +14,22 @@
 
 #include 
 
+#if defined(__i386__) || defined(__x86_64__)
+void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
+  return __stosb(Dest, Data, Count);
+}
+
+// CHECK-I386: define{{.*}}void @test__stosb
+// CHECK-I386:   tail call void @llvm.memset.p0i8.i32(i8* %Dest, i8 %Data, i32 
%Count, i32 1, i1 true)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64: define{{.*}}void @test__stosb
+// CHECK-X64:   tail call void @llvm.memset.p0i8.i64(i8* %Dest, i8 %Data, i64 
%Count, i32 1, i1 true)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+#endif
+
 void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) {
   return _InterlockedExchangePointer(Target, Value);
 }
Index: test/Headers/ms-intrin.cpp
===
--- test/Headers/ms-intrin.cpp
+++ test/Headers/ms-intrin.cpp
@@ -38,7 +38,6 @@
   __movsd(0, 0, 0);
   __movsw(0, 0, 0);
 
-  __stosb(0, 0, 0);
   __stosd(0, 0, 0);
   __stosw(0, 0, 0);
 


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1148,11 +1148,6 @@
 : "%edi", "%esi", "%ecx");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
-__stosb(unsigned char *__dst, unsigned char __x, size_t __n) {
-  __asm__("rep stosb" : : "D"(__dst), "a"(__x), "c"(__n)
-: "%edi", "%ecx");
-}
-static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
   __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n)
 : "%edi", "%ecx");
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7599,7 +7599,19 @@
 HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
 return HigherBits;
   }
+
+  case X86::BI__stosb: {
+// We treat __stosb as a volatile memset - it may not generate "rep stosb"
+// instruction, but it will create a memset that won't be optimized away.
+const FunctionDecl *FD = E->getDirectCallee();
+Address Dest = EmitPointerWithAlignment(E->getArg(0));
+Value *ByteVal = EmitScalarExpr(E->getArg(1));
+Value *SizeVal = EmitScalarExpr(E->getArg(2));
+EmitNonNullArgCheck(RValue::get(Dest.getPointer()), 

[PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-10-06 Thread Keno Fischer via cfe-commits
loladiro added a comment.

Bump, please do take another close look at the latest update, particularly with 
respecting to marking things constexpr that are not so in C++11.


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73831.
malcolm.parsons added a comment.

Mention in release notes.


https://reviews.llvm.org/D25316

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp

Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = static_cast(l);
+
+  const int i2 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto i2 = static_cast(l);
+
+  A *a = new B();
+  B *b1 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = static_cast(a);
+
+  B *const b2 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *const b2 = static_cast(a);
+
+  const B *b3 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b3 = static_cast(a);
+
+  B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = static_cast(*a);
+
+  const B  = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto  = static_cast(*a);
+  
+  // Don't warn when auto is already being used.
+  auto i3 = static_cast(l);
+  auto *b6 = static_cast(a);
+  auto  = static_cast(*a);
+}
+
+void f_dynamic_cast() {
+  A *a = new B();
+  B *b1 = dynamic_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = dynamic_cast(a);
+
+  B  = dynamic_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = dynamic_cast(*a);
+}
+
+void f_reinterpret_cast() {
+  auto *a = new A();
+  C *c1 = reinterpret_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = reinterpret_cast(a);
+
+  C  = reinterpret_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = reinterpret_cast(*a);
+}
+
+void f_const_cast() {
+  const A *a1 = new A();
+  A *a2 = const_cast(a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *a2 = const_cast(a1);
+  A  = const_cast(*a1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = const_cast(*a1);
+}
+
+void f_cstyle_cast() {
+  auto *a = new A();
+  C *c1 = (C *)a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = (C *)a;
+
+  C  = (C &)*a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = (C &)*a;
+}
+
+void f_functional_cast() {
+  long l = 1;
+  int i1 = int(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  i1 = int(l);
+
+  B b;
+  A a = A(b);
+}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when 

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 73855.

https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283499 - [analyzer] Add explanation why analyzer report is not generated (fix for PR12421).

2016-10-06 Thread Anton Yartsev via cfe-commits
Author: ayartsev
Date: Thu Oct  6 16:42:21 2016
New Revision: 283499

URL: http://llvm.org/viewvc/llvm-project?rev=283499=rev
Log:
[analyzer] Add explanation why analyzer report is not generated (fix for 
PR12421).

Currently if the path diagnostic consumer (e.g HTMLDiagnostics and 
PlistDiagnostics) do not support cross file diagnostics then the path 
diagnostic report is silently omitted in the case of cross file diagnostics. 
The patch adds a little verbosity to Clang in this case.
The patch also adds help entry for the "--analyzer-output" driver option.

Added:
cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.c
cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.h
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=283499=283498=283499=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct  6 16:42:21 2016
@@ -2005,7 +2005,8 @@ def _CLASSPATH : Separate<["--"], "CLASS
 def _all_warnings : Flag<["--"], "all-warnings">, Alias;
 def _analyze_auto : Flag<["--"], "analyze-auto">, Flags<[DriverOption]>;
 def _analyzer_no_default_checks : Flag<["--"], "analyzer-no-default-checks">, 
Flags<[DriverOption]>;
-def _analyzer_output : JoinedOrSeparate<["--"], "analyzer-output">, 
Flags<[DriverOption]>;
+def _analyzer_output : JoinedOrSeparate<["--"], "analyzer-output">, 
Flags<[DriverOption]>,
+  HelpText<"Static analyzer report output format 
(html|plist|plist-multi-file|plist-html|text).">;
 def _analyze : Flag<["--"], "analyze">, Flags<[DriverOption, CoreOption]>,
   HelpText<"Run the static analyzer">;
 def _assemble : Flag<["--"], "assemble">, Alias;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=283499=283498=283499=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Thu Oct  6 16:42:21 
2016
@@ -211,6 +211,12 @@ void PathDiagnosticConsumer::HandlePathD
 const SourceManager  = D->path.front()->getLocation().getManager();
 SmallVector WorkList;
 WorkList.push_back(>path);
+SmallString<128> buf;
+llvm::raw_svector_ostream warning(buf);
+warning << "warning: Path diagnostic report is not generated. Current "
+<< "output format does not support diagnostics that cross file "
+<< "boundaries. Refer to --analyzer-output for valid output "
+<< "formats\n";
 
 while (!WorkList.empty()) {
   const PathPieces  = *WorkList.pop_back_val();
@@ -222,19 +228,25 @@ void PathDiagnosticConsumer::HandlePathD
 
 if (FID.isInvalid()) {
   FID = SMgr.getFileID(L);
-} else if (SMgr.getFileID(L) != FID)
-  return; // FIXME: Emit a warning?
+} else if (SMgr.getFileID(L) != FID) {
+  llvm::errs() << warning.str();
+  return;
+}
 
 // Check the source ranges.
 ArrayRef Ranges = piece->getRanges();
 for (ArrayRef::iterator I = Ranges.begin(),
  E = Ranges.end(); I != E; ++I) {
   SourceLocation L = SMgr.getExpansionLoc(I->getBegin());
-  if (!L.isFileID() || SMgr.getFileID(L) != FID)
-return; // FIXME: Emit a warning?
+  if (!L.isFileID() || SMgr.getFileID(L) != FID) {
+llvm::errs() << warning.str();
+return;
+  }
   L = SMgr.getExpansionLoc(I->getEnd());
-  if (!L.isFileID() || SMgr.getFileID(L) != FID)
-return; // FIXME: Emit a warning?
+  if (!L.isFileID() || SMgr.getFileID(L) != FID) {
+llvm::errs() << warning.str();
+return;
+  }
 }
 
 if (const PathDiagnosticCallPiece *call =

Added: cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.c?rev=283499=auto
==
--- cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.c (added)
+++ cfe/trunk/test/Analysis/diagnostics/diag-cross-file-boundaries.c Thu Oct  6 
16:42:21 2016
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=html -o 
PR12421.html %s 2>&1 | FileCheck %s
+
+// Test for PR12421
+#include "diag-cross-file-boundaries.h"
+
+int main(){
+  f();
+  return 0;
+}
+
+// CHECK: warning: Path diagnostic report 

r283489 - [modules] Be sure to emit local specializations of imported templates, even if

2016-10-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  6 15:30:51 2016
New Revision: 283489

URL: http://llvm.org/viewvc/llvm-project?rev=283489=rev
Log:
[modules] Be sure to emit local specializations of imported templates, even if
the resulting specialization is not referenced by the rest of the AST. This
both avoids performing unnecessary reinstantiations in downstream users of the
AST file and fixes a bug (breaking modules self-host right now) where we would
sometimes fail to emit a definition of a class template specialization if we
imported just a declaration of it from elsewhere (see new testcase for reduced
example).

Added:
cfe/trunk/test/Modules/Inputs/merge-template-specializations/
cfe/trunk/test/Modules/Inputs/merge-template-specializations/a.h
cfe/trunk/test/Modules/Inputs/merge-template-specializations/b.h
cfe/trunk/test/Modules/Inputs/merge-template-specializations/c.h

cfe/trunk/test/Modules/Inputs/merge-template-specializations/module.modulemap
cfe/trunk/test/Modules/merge-template-specializations.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/cxx-templates.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=283489=283488=283489=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Oct  6 15:30:51 2016
@@ -373,9 +373,10 @@ private:
   /// it.
   llvm::SmallSetVector UpdatedDeclContexts;
 
-  /// \brief Keeps track of visible decls that were added in DeclContexts
-  /// coming from another AST file.
-  SmallVector UpdatingVisibleDecls;
+  /// \brief Keeps track of declarations that we must emit, even though we're
+  /// not guaranteed to be able to find them by walking the AST starting at the
+  /// translation unit.
+  SmallVector DeclsToEmitEvenIfUnreferenced;
 
   /// \brief The set of Objective-C class that have categories we
   /// should serialize.
@@ -667,6 +668,14 @@ private:
   void CompletedTagDefinition(const TagDecl *D) override;
   void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
   void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
+  void AddedCXXTemplateSpecialization(
+  const ClassTemplateDecl *TD,
+  const ClassTemplateSpecializationDecl *D) override;
+  void AddedCXXTemplateSpecialization(
+  const VarTemplateDecl *TD,
+  const VarTemplateSpecializationDecl *D) override;
+  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
+  const FunctionDecl *D) override;
   void ResolvedExceptionSpec(const FunctionDecl *FD) override;
   void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
   void ResolvedOperatorDelete(const CXXDestructorDecl *DD,

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=283489=283488=283489=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct  6 15:30:51 2016
@@ -4472,8 +4472,9 @@ uint64_t ASTWriter::WriteASTCore(Sema 
  Number.second));
 
   // Make sure visible decls, added to DeclContexts previously loaded from
-  // an AST file, are registered for serialization.
-  for (const auto *I : UpdatingVisibleDecls) {
+  // an AST file, are registered for serialization. Likewise for template
+  // specializations added to imported templates.
+  for (const auto *I : DeclsToEmitEvenIfUnreferenced) {
 GetDeclRef(I);
   }
 
@@ -5818,9 +5819,9 @@ void ASTWriter::AddedVisibleDecl(const D
 // that we write out all of its lookup results so we don't get a nasty
 // surprise when we try to emit its lookup table.
 for (auto *Child : DC->decls())
-  UpdatingVisibleDecls.push_back(Child);
+  DeclsToEmitEvenIfUnreferenced.push_back(Child);
   }
-  UpdatingVisibleDecls.push_back(D);
+  DeclsToEmitEvenIfUnreferenced.push_back(D);
 }
 
 void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) 
{
@@ -5989,3 +5990,39 @@ void ASTWriter::AddedAttributeToRecord(c
 return;
   DeclUpdates[Record].push_back(DeclUpdate(UPD_ADDED_ATTR_TO_RECORD, Attr));
 }
+
+void ASTWriter::AddedCXXTemplateSpecialization(
+const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) {
+  assert(!WritingAST && "Already writing the AST!");
+
+  if (!TD->getFirstDecl()->isFromASTFile())
+return;
+  if (Chain && Chain->isProcessingUpdateRecords())
+return;
+
+  DeclsToEmitEvenIfUnreferenced.push_back(D);
+}
+
+void ASTWriter::AddedCXXTemplateSpecialization(
+const 

[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Please add tests with

  long long p = static_cast(4);

and the same with const at beginning. I remember I had problems with this last 
time (Type->SourceRange was returning only source range for the first token.
I will review patch later.


https://reviews.llvm.org/D25316



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


[PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator, wh

2016-10-06 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D23236#561467, @parallaxe wrote:

> In https://reviews.llvm.org/D23236#557898, @dcoughlin wrote:
>
> > Upon reflection, I don't think this is the right approach.
> >
> > Desugaring any AttributedType in the return type seems like a really, 
> > really big hammer and could be an unexpected surprise for future attributed 
> > types where this is not the right behavior. I think a better approach for 
> > the nullability issue would be to update `lookThroughImplicitCasts()` in 
> > NullabilityChecker.cpp to look though `ExprWithCleanups` expressions just 
> > like it currently does for implicit casts.
> >
> > What do you think?
>
>
> As far as I understand the code, I would leave my change as it is.


You definitely can't just desugar the return type before passing it to 
InitializedEntity::InitializeResult().  Doing so would place a potential 
landmine for someone to trip over in the future for cases where the type 
qualifier has a real semantic meaning. For nullability qualifiers desugaring 
seems mostly harmless (except for the diagnostic regressions) but for an 
arbitrary type qualifier I don't think this is acceptable.

> The part of the code I have changed tries to guess the return-type for the 
> expression inside the return-stmt. At this point, no type could be computed 
> (as RelatedRetType.isNull() is true). Assuming that any annotation that the 
> return-type of the function has, will also apply to the return-type of the 
> expression, might be misleading.

This code doesn't assume that the the return type of the function is the return 
type of the expression. Instead, it uses the return type of the function to 
drive semantic analysis of the expression and apply any conversions needed from 
the type of the returned expression to the return type of the function. (In 
this case a 'NullToPointer' conversion). These conversions are often 
represented as implicit casts, added by Sema, in the AST. See 
InitializationSequence::Perform() for all the kinds of implicit conversions 
that can go on here. It is important to record these casts so that any codegen 
needed to perform the conversions/casts can be emitted at the right place. If 
such a conversion is not allowed, a diagnostic will be emitted.

> The improvements of the warnings in nullability.m are a good sign of this 
> (which would be lost when I would just make a change in the 
> NullabilityChecker).

The diagnostics changes to Sema/nullability.m in this patch would be a 
regression. Those diagnostic tests are there explicitly to test the 
functionality implemented in mergeInterfaceMethodToImpl() in SemaDeclObjC.cpp. 
This code takes a nullability annotation on a return type from a declaration 
and makes sure that the return type in the definition has the same nullability 
even if the programmer did not explicitly write it. This means that, for 
example, the return type of -[NSMerge methodA:] in the `@implementation` is 
supposed to be 'NSFoo * _Nonnull' since in the `@interface` it is annotated 
with 'nonnull'. You can see the merged return type for the method declaration 
by passing `-Xclang -ast-dump` to the driver.


https://reviews.llvm.org/D23236



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

Updated the docs. I'll look into the test case tomorrow.


https://reviews.llvm.org/D25338



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


[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added a comment.

Hi Elad,

Is there any reason why you can't explicit model this in your build system by 
pre-building the intrinsics and pointing to a module cache path containing the 
pcm files? By doing that we don't need to have a specific compile flag.


https://reviews.llvm.org/D25337



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added a comment.

Testcase?



> clang.rst:398
> +  Print the library path for the currently used compiler runtime library
> +  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
>  

You can probably drop the "appropriately"

> Options.td:1865
> +  HelpText<"Print the library path for the currently used compiler runtime "
> +   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" 
> appropriately)">;
>  def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;

Same here

https://reviews.llvm.org/D25338



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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Richard Smith via cfe-commits
rsmith added inline comments.


> SemaDecl.cpp:3692-3693
> +  // Demote the newly parsed definition to a fake declaration.
> +  // FIXME: Sema::AddInitializationToDecl still allows two definitions,
> +  // which make the AST variants inconsistent.
> +  assert (Def != New && "There is only one definition!");

We always get here after calling that, don't we? So we only briefly have two 
definitions, between the point at which we attach the definition and now. If 
that's what you're referring to here, this comment could be clearer about it.

> SemaDecl.cpp:3695
> +  assert (Def != New && "There is only one definition!");
> +  New->demoteThisDefinitionToDeclaration();
>  } else if (Old->isStaticDataMember() &&

You should also call `makeMergedDefinitionVisible(Def, New->getLocation())` 
here (and also call it for `Def`'s enclosing template if this is a variable 
template definition) to make the prior definition visible.

> ASTReaderDecl.cpp:3083-3087
> +// Fast track.
> +if (PrevVD->isThisDeclarationADefinition()) {
> +  VD->demoteThisDefinitionToDeclaration();
> +  return;
> +}

I don't think this is worthwhile, since it's the first thing the loop below 
will check.

> ASTReaderDecl.cpp:3089
> +
> +for (VarDecl *CurD = D->First; CurD; CurD = CurD->getPreviousDecl())
> +  if (CurD->isThisDeclarationADefinition()) {

You should start at `PrevVD` not at `D->First`. This loop will currently only 
iterate once.

> ASTReaderDecl.cpp:3090
> +for (VarDecl *CurD = D->First; CurD; CurD = CurD->getPreviousDecl())
> +  if (CurD->isThisDeclarationADefinition()) {
> +// If we found another definition on the chain, demote the current 
> one.

You can also bail out early and demote the current definition if you reach a 
previous demoted definition. That would reduce this from quadratic-time to 
linear-time.

> v.g.vassilev wrote in ASTWriterDecl.cpp:896-897
> I thought we might need this for c-style `void f(struct S arg)`-like 
> constructs where we might need to demote if we merge ParmVarDecls.

We'll still have only one `ParmVarDecl` per `FunctionDecl`, and no-one cares 
whether a `ParmVarDecl` is a definition. Also, you assert that the flag is 
always false in this case below.

https://reviews.llvm.org/D24508



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


r283498 - Add another .def file to module map to fix modules buildbot's displeasure.

2016-10-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  6 16:31:04 2016
New Revision: 283498

URL: http://llvm.org/viewvc/llvm-project?rev=283498=rev
Log:
Add another .def file to module map to fix modules buildbot's displeasure.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=283498=283497=283498=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Thu Oct  6 16:31:04 2016
@@ -38,6 +38,7 @@ module Clang_Basic {
   textual header "Basic/BuiltinsSystemZ.def"
   textual header "Basic/BuiltinsWebAssembly.def"
   textual header "Basic/BuiltinsX86.def"
+  textual header "Basic/BuiltinsX86_64.def"
   textual header "Basic/BuiltinsXCore.def"
   textual header "Basic/DiagnosticOptions.def"
   textual header "Basic/LangOptions.def"


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


[PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator, wh

2016-10-06 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

I left out the example I was describing above for 
'InitializationSequence::Perform()':

  @interface Bar
  - (nonnull Bar *)method;
  @end
  
  @implementation Bar
  - (Bar *)method {
return 0;
  }
  @end


https://reviews.llvm.org/D23236



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


[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

2016-10-06 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: rsmith, GorNishanov, majnemer.
EricWF added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

This patch adds semantic checking and building of the fall-through `co_return;` 
statement as well as the `p.set_exception(std::current_exception())` call for 
handling uncaught exceptions.

The fall-through statement is built and checked according to:

> [dcl.fct.def.coroutine]/4
>  The unqualified-ids return_void and return_value are looked up in the scope 
> of class P. If
>  both are found, the program is ill-formed. If the unqualified-id return_void 
> is found, flowing
>  off the end of a coroutine is equivalent to a co_return with no operand. 
> Otherwise, flowing off
>  the end of a coroutine results in undefined behavior.

Similarly the `set_exception` call is only built when that unqualified-id is 
found in the scope of class P.

Additionally this patch adds fall-through warnings for non-void returning 
coroutines. Since it's surprising undefined behavior I thought it would be 
important to add the warning right away.


https://reviews.llvm.org/D25349

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -313,6 +313,47 @@
   co_await a;
 }
 
+struct bad_promise_6 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void return_value(int) const;
+  void return_value(int);
+};
+coro bad_implicit_return() { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+
+struct bad_promise_7 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void set_exception(int *);
+};
+coro no_std_current_exc() {
+  // expected-error@-1 {{you need to include  before defining a coroutine that declares 'set_exception'}}
+  co_await a;
+}
+
+namespace std {
+int *current_exception();
+}
+
+struct bad_promise_8 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void return_void();
+  void set_exception();   // expected-note {{function not viable}}
+  void set_exception(int *) __attribute__((unavailable)); // expected-note {{explicitly made unavailable}}
+  void set_exception(void *); // expected-note {{candidate function}}
+};
+coro calls_set_exception() {
+  // expected-error@-1 {{call to unavailable member function 'set_exception'}}
+  co_await a;
+}
 
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
Index: test/SemaCXX/coreturn.cpp
===
--- /dev/null
+++ test/SemaCXX/coreturn.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+
+struct awaitable {
+  bool await_ready();
+  void await_suspend(); // FIXME: coroutine_handle
+  void await_resume();
+} a;
+
+struct suspend_always {
+  bool await_ready() { return false; }
+  void await_suspend() {}
+  void await_resume() {}
+};
+
+struct suspend_never {
+  bool await_ready() { return true; }
+  void await_suspend() {}
+  void await_resume() {}
+};
+
+namespace std {
+namespace experimental {
+
+template 
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template 
+struct coroutine_handle {};
+}
+}
+
+struct promise_void {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  awaitable yield_value(int);
+  void return_void();
+};
+
+struct promise_float {
+  float get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  awaitable yield_value(int);
+  void return_void();
+};
+
+struct promise_int {
+  int get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  awaitable yield_value(int);
+  void return_value(int);
+};
+
+template 
+struct std::experimental::coroutine_traits { using promise_type = promise_void; };
+
+template 
+struct std::experimental::coroutine_traits { using promise_type = promise_float; };
+
+template 
+struct std::experimental::coroutine_traits { using promise_type = promise_int; };
+
+void test0() { co_await a; }
+float test1() { co_await a; }
+
+int test2() {
+  co_await a;
+} // expected-warning {{control reaches end of non-void coroutine}}
+
+int test3() 

[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-06 Thread Steve O'Brien via cfe-commits
elsteveogrande added inline comments.


> PrintPreprocessedOutput.cpp:329-330
> +static std::string sanitizePath(StringRef Path) {
> +  std::string Result;
> +  Result.reserve(Path.size() * 2);
> +  while (!Path.empty()) {

Note: I'm //pretty// sure this is about as efficient as it gets for 
string-building (and then also, string-builds will tend to happen only once per 
include).  The string has its internal char-vector-like structure, pre-sized to 
a generous amount, so extra futzing should not occur, making this `O(length of 
strings appended to it)`; and the return should optimize away so that it's not 
copied.

More importantly though, this is now quite a bit cleaner.

https://reviews.llvm.org/D25153



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


[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

2016-10-06 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Daniel, please, add reviewers to this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D25326



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


[PATCH] D24752: [Modules] Add missing dependencies to clang builtins modulemap

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.


> eladcohen wrote in module.modulemap:133
> emmintrin.h is already included explicitly in wmmintrin.h & __wmmintrin_aes.h.
> 
> If a user includes / there is no problem, since the 
> intel submodule has an 'export *' directive and both aes & sse2 will be 
> imported.
> 
> However, if the user only includes  (like in the 2nd half of the 
> test I added), and uses modules, then any use of the '___m128i' type (which 
> is used in the aes intrinsics and declared in sse2) will result with the 
> error:
> "File tst.c Line 11: missing '#include '; declaration of 
> '___m128i' must be imported from module '_Builtin_intrinsics.intel.sse2' 
> before it is required"
> 
> IIUC the possible fixes for this are adding 'export *' or 'export sse2' to 
> the aes submodule.

I see, if you need the type to use the exported functions it makes sense to 
re-export it. It might be worth adding a comment // note: for ___m128i

https://reviews.llvm.org/D24752



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


[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

2016-10-06 Thread Hans Wennborg via cfe-commits
hans added inline comments.


> CGBuiltin.cpp:7604
> +  case X86::BI__stosb: {
> +// we treat __stosb as volatile memset  - it may not generate "rep stosb"
> +// instruction, but it will create a memset that won't be optimized away

Nit: I'd suggest capital w for "We" and ending the sentence with a period. I 
see many other comments in the file don't do this, but we can at least set a 
good example :-)

> CGBuiltin.cpp:7610
> +Value *SizeVal = EmitScalarExpr(E->getArg(2));
> +EmitNonNullArgCheck(RValue::get(Dest.getPointer()), 
> E->getArg(0)->getType(),
> +E->getArg(0)->getExprLoc(), FD, 0);

Hmm, does the __stosb intrinsic require Dest to be non-null (e.g. would 
Dest=NULL, Count=0 be OK?) I'm not even sure what llvm's memset requires 
actually.

> CGBuiltin.cpp:7613
> +Builder.CreateMemSet(Dest, ByteVal, SizeVal, true);
> +return Dest.getPointer();
>}

Why is it returning Dest here, and not the result of Builder.CreateMemSet?

https://reviews.llvm.org/D25334



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Serge Rogatch via cfe-commits
rSerge updated this revision to Diff 73824.

https://reviews.llvm.org/D24799

Files:
  lib/Driver/Tools.cpp
  test/Driver/xray-instrument.c


Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4784,7 +4784,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4784,7 +4784,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D25316#563654, @Eugene.Zelenko wrote:

> I think will be good idea to handle LLVM casts and getAs<> methods too. There 
> are plenty of them in LLVM/Clang/etc code used for variable initialization.


Yes.
I plan to do that, but maybe in another changeset.


https://reviews.llvm.org/D25316



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Please mention this enhancement in in docs/ReleaseNotes.rst (in alphabetical 
order).


https://reviews.llvm.org/D25316



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


[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

2016-10-06 Thread Albert Gutowski via cfe-commits
agutowski marked an inline comment as done.
agutowski added inline comments.


> hans wrote in CGBuiltin.cpp:7613
> Why is it returning Dest here, and not the result of Builder.CreateMemSet?

My mistake (that's what memset returns), thanks!

https://reviews.llvm.org/D25334



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


[PATCH] D25343: [OpenCL] Add noduplicate to group functions opencl-c.h

2016-10-06 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader.
yaxunl added subscribers: cfe-commits, b-sumner.

Certain OpenCL builtin functions are supposed to be executed by all threads in 
a work group or sub group. Such functions should not be duplicated during 
transformation. It makes sense to mark them with noduplicate attribute.


https://reviews.llvm.org/D25343

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -17,6 +17,7 @@
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 #define __ovld __attribute__((overloadable))
+#define __nodup __attribute__((noduplicate))
 
 // Optimizations
 #define __purefn __attribute__((pure))
@@ -13822,7 +13823,7 @@
  * image objects and then want to read the updated data.
  */
 
-void __ovld barrier(cl_mem_fence_flags flags);
+void __ovld __nodup barrier(cl_mem_fence_flags flags);
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
@@ -13835,8 +13836,8 @@
   memory_scope_sub_group
 } memory_scope;
 
-void __ovld work_group_barrier(cl_mem_fence_flags flags, memory_scope scope);
-void __ovld work_group_barrier(cl_mem_fence_flags flags);
+void __ovld __nodup work_group_barrier(cl_mem_fence_flags flags, memory_scope scope);
+void __ovld __nodup work_group_barrier(cl_mem_fence_flags flags);
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // OpenCL v1.1 s6.11.9, v1.2 s6.12.9 - Explicit Memory Fence Functions
@@ -16559,101 +16560,101 @@
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
-int __ovld work_group_all(int predicate);
-int __ovld work_group_any(int predicate);
+int __ovld __nodup work_group_all(int predicate);
+int __ovld __nodup work_group_any(int predicate);
 
 #ifdef cl_khr_fp16
-half __ovld work_group_broadcast(half a, size_t local_id);
-half __ovld work_group_broadcast(half a, size_t x, size_t y);
-half __ovld work_group_broadcast(half a, size_t x, size_t y, size_t z);
+half __ovld __nodup work_group_broadcast(half a, size_t local_id);
+half __ovld __nodup work_group_broadcast(half a, size_t x, size_t y);
+half __ovld __nodup work_group_broadcast(half a, size_t x, size_t y, size_t z);
 #endif
-int __ovld work_group_broadcast(int a, size_t local_id);
-int __ovld work_group_broadcast(int a, size_t x, size_t y);
-int __ovld work_group_broadcast(int a, size_t x, size_t y, size_t z);
-uint __ovld work_group_broadcast(uint a, size_t local_id);
-uint __ovld work_group_broadcast(uint a, size_t x, size_t y);
-uint __ovld work_group_broadcast(uint a, size_t x, size_t y, size_t z);
-long __ovld work_group_broadcast(long a, size_t local_id);
-long __ovld work_group_broadcast(long a, size_t x, size_t y);
-long __ovld work_group_broadcast(long a, size_t x, size_t y, size_t z);
-ulong __ovld work_group_broadcast(ulong a, size_t local_id);
-ulong __ovld work_group_broadcast(ulong a, size_t x, size_t y);
-ulong __ovld work_group_broadcast(ulong a, size_t x, size_t y, size_t z);
-float __ovld work_group_broadcast(float a, size_t local_id);
-float __ovld work_group_broadcast(float a, size_t x, size_t y);
-float __ovld work_group_broadcast(float a, size_t x, size_t y, size_t z);
+int __ovld __nodup work_group_broadcast(int a, size_t local_id);
+int __ovld __nodup work_group_broadcast(int a, size_t x, size_t y);
+int __ovld __nodup work_group_broadcast(int a, size_t x, size_t y, size_t z);
+uint __ovld __nodup work_group_broadcast(uint a, size_t local_id);
+uint __ovld __nodup work_group_broadcast(uint a, size_t x, size_t y);
+uint __ovld __nodup work_group_broadcast(uint a, size_t x, size_t y, size_t z);
+long __ovld __nodup work_group_broadcast(long a, size_t local_id);
+long __ovld __nodup work_group_broadcast(long a, size_t x, size_t y);
+long __ovld __nodup work_group_broadcast(long a, size_t x, size_t y, size_t z);
+ulong __ovld __nodup work_group_broadcast(ulong a, size_t local_id);
+ulong __ovld __nodup work_group_broadcast(ulong a, size_t x, size_t y);
+ulong __ovld __nodup work_group_broadcast(ulong a, size_t x, size_t y, size_t z);
+float __ovld __nodup work_group_broadcast(float a, size_t local_id);
+float __ovld __nodup work_group_broadcast(float a, size_t x, size_t y);
+float __ovld __nodup work_group_broadcast(float a, size_t x, size_t y, size_t z);
 #ifdef cl_khr_fp64
-double __ovld work_group_broadcast(double a, size_t local_id);
-double __ovld work_group_broadcast(double a, size_t x, size_t y);
-double __ovld work_group_broadcast(double a, size_t x, size_t y, size_t z);
+double __ovld __nodup work_group_broadcast(double a, size_t local_id);
+double __ovld __nodup work_group_broadcast(double a, size_t x, size_t y);
+double __ovld __nodup work_group_broadcast(double a, size_t x, size_t y, size_t z);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld work_group_reduce_add(half x);
-half __ovld work_group_reduce_min(half x);
-half __ovld work_group_reduce_max(half x);

[PATCH] D25296: [coroutines] Fix co_return statement for initializer list arguments

2016-10-06 Thread Gor Nishanov via cfe-commits
GorNishanov added a comment.

LGTM, but, I cannot approve clang patches. Let's wait on @rsmith to give the go 
ahead.


https://reviews.llvm.org/D25296



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


[PATCH] D25309: [clang-move] Support moving multiple classes in one run.

2016-10-06 Thread Haojian Wu via cfe-commits
hokein added inline comments.


> ioeric wrote in ClangMove.cpp:316
> What would happen if `InMovedClassNames == false`?

"InMovedClassNames" should not be false in the matcher. Added an assert.

https://reviews.llvm.org/D25309



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


[PATCH] D25309: [clang-move] Support moving multiple classes in one run.

2016-10-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 73819.
hokein marked 7 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D25309

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  test/clang-move/Inputs/database_template.json
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/Inputs/multiple_class_test.h
  test/clang-move/move-class.cpp
  test/clang-move/move-multiple-classes.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -210,7 +210,7 @@
 
 TEST(ClangMove, MoveHeaderAndCC) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldHeader = "foo.h";
   Spec.OldCC = "foo.cc";
   Spec.NewHeader = "new_foo.h";
@@ -225,7 +225,7 @@
 
 TEST(ClangMove, MoveHeaderOnly) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldHeader = "foo.h";
   Spec.NewHeader = "new_foo.h";
   auto Results = runClangMoveOnCode(Spec);
@@ -236,7 +236,7 @@
 
 TEST(ClangMove, MoveCCOnly) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "a::b::Foo";
+  Spec.Names = "a::b::Foo";
   Spec.OldCC = "foo.cc";
   Spec.NewCC = "new_foo.cc";
   std::string ExpectedHeader = "#include \"foo.h\"\n\n";
@@ -248,7 +248,7 @@
 
 TEST(ClangMove, MoveNonExistClass) {
   move::ClangMoveTool::MoveDefinitionSpec Spec;
-  Spec.Name = "NonExistFoo";
+  Spec.Names = "NonExistFoo";
   Spec.OldHeader = "foo.h";
   Spec.OldCC = "foo.cc";
   Spec.NewHeader = "new_foo.h";
Index: test/clang-move/move-multiple-classes.cpp
===
--- /dev/null
+++ test/clang-move/move-multiple-classes.cpp
@@ -0,0 +1,53 @@
+// RUN: mkdir -p %T/clang-move/build
+// RUN: sed 's|$test_dir|%/T/clang-move|g' %S/Inputs/database_template.json > %T/clang-move/compile_commands.json
+// RUN: cp %S/Inputs/multiple_class_test*  %T/clang-move/
+// RUN: cd %T/clang-move
+// RUN: clang-move -names="a::Move1, b::Move2,c::Move3" -new_cc=%T/clang-move/new_multiple_class_test.cpp -new_header=%T/clang-move/new_multiple_class_test.h -old_cc=%T/clang-move/multiple_class_test.cpp -old_header=../clang-move/multiple_class_test.h %T/clang-move/multiple_class_test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_multiple_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_multiple_class_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/multiple_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/multiple_class_test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// CHECK-OLD-TEST-H: namespace c {
+// CHECK-OLD-TEST-H: class NoMove {
+// CHECK-OLD-TEST-H: public:
+// CHECK-OLD-TEST-H:   int f();
+// CHECK-OLD-TEST-H: };
+// CHECK-OLD-TEST-H: } // namespace c
+
+// CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: namespace c {
+// CHECK-OLD-TEST-CPP: int NoMove::f() {
+// CHECK-OLD-TEST-CPP:   return 0;
+// CHECK-OLD-TEST-CPP: }
+// CHECK-OLD-TEST-CPP: } // namespace c
+
+// CHECK-NEW-TEST-H: namespace a {
+// CHECK-NEW-TEST-H: class Move1 {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace a
+// CHECK-NEW-TEST-H: namespace b {
+// CHECK-NEW-TEST-H: class Move2 {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace b
+// CHECK-NEW-TEST-H: namespace c {
+// CHECK-NEW-TEST-H: class Move3 {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace c
+
+// CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
+// CHECK-NEW-TEST-CPP: namespace a {
+// CHECK-NEW-TEST-CPP: int Move1::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace a
+// CHECK-NEW-TEST-CPP: namespace b {
+// CHECK-NEW-TEST-CPP: int Move2::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace b
+// CHECK-NEW-TEST-CPP: namespace c {
+// CHECK-NEW-TEST-CPP: int Move3::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace c
Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.cpp
@@ -3,15 +3,15 @@
 // RUN: cp %S/Inputs/test*  %T/clang-move/
 // RUN: touch %T/clang-move/test2.h
 // RUN: cd %T/clang-move
-// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=../clang-move/test.cpp -old_header=../clang-move/test.h %T/clang-move/test.cpp
+// RUN: clang-move -names="a::Foo" 

[PATCH] D25309: [clang-move] Support moving multiple classes in one run.

2016-10-06 Thread Eric Liu via cfe-commits
ioeric added inline comments.


> hokein wrote in ClangMove.cpp:316
> "InMovedClassNames" should not be false in the matcher. Added an assert.

I think you should instead exit early if `ClassNames.empty()` or assert not 
empty.

> ClangMove.cpp:299
> +  for (StringRef ClassName : ClassNames) {
> +// Removed the preceding and trailing space of ClassName.
> +// And removed the global scope operator "::" since we always regard the

The comment is trivial.

> ClangMove.cpp:302
> +// ClassName as a global name.
> +llvm::StringRef GlobalClassName = ClassName.trim(' ').ltrim(':');
> +const auto HasName = hasName(("::" + GlobalClassName).str());

Can we use `trim()` with default argument?

> multiple_class_test.cpp:19
> +}
> +int NoMove::f() {
> +  return 0;

What I wanted to see is another *moved* class because there was no test case 
where multiple classes are moved into the same namespace.

https://reviews.llvm.org/D25309



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Serge Rogatch via cfe-commits
rSerge added a comment.

In https://reviews.llvm.org/D24799#563058, @dberris wrote:

> Are we sure this will not fail on Windows? i.e. have you built/run the tests 
> on Windws ARM or X86_64?


The test itself passes for `arm-pc-win32` and `x86_64-pc-win32` on my machine. 
So in this sense it doesn't fail.
However, the feature of this patch doesn't cover the OS part of the triple: 
currently because of `mprotect` and other Linux-only code, XRay is only 
supported on Linux. However, clang (also with this patch) doesn't check for 
Linux target, and on non-Linux machines either LLVM backend will emit an error 
later (saying that XRay is not supported on Thumb - this happens because 
Windows is Thumb-only for ARM target), or I expect linker errors because code 
generation on Windows references some API of compiler-rt, which doesn't get 
compiled on Windows, even if it's x86_64.



> dberris wrote in Tools.cpp:4787
> Why can't this just be a `const string`, or a `const StringRef`?

Is there any advantage over `const char* const` here?

> dberris wrote in Tools.cpp:4796
> I'm not a fan of calling `.data()` here -- if this returns a `StringRef` I'd 
> much rather turn it into a string directly. Either that or you can even 
> string these together. Say something like:
> 
>   default:
> D.Diag(...) << (XRayInstrumentOption + " on " + 
> Triple.getArchName().str());
> break;

It returns `StringRef`. `.str()` would construct a `std::string`, which seems 
unnecessary.  Of course this piece is not performance-critical, but why not to 
just use `operator+=` taking as the argument `const char* const`?

> dberris wrote in Tools.cpp:4799
> As part of my submitting this change upstream, I had to format it accordingly 
> with `clang-format` -- you might want to do the same so that the formatting 
> is in-line with the LLVM developers style guidelines.

Done.

https://reviews.llvm.org/D24799



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


[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.

2016-10-06 Thread Elad Cohen via cfe-commits
eladcohen created this revision.
eladcohen added reviewers: hans, rnk, zvi, rsmith, chandlerc.
eladcohen added a subscriber: cfe-commits.

-fexclusive-builtin-modules enables the clang 'modules' feature exclusively for 
the clang intrinsic header files.

The end goal of this effort is to have this option on by default for x86 
targets so we could reduce the long compile time of the x86 intrinsic header 
files.


https://reviews.llvm.org/D25337

Files:
  docs/Modules.rst
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/CodeGen/3dnow-builtins.c
  test/CodeGen/adc-builtins.c
  test/CodeGen/adx-builtins.c
  test/CodeGen/attr-target-x86-mmx.c
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx-cmp-builtins.c
  test/CodeGen/avx-shuffle-builtins.c
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512cdintrin.c
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512er-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512ifma-builtins.c
  test/CodeGen/avx512ifmavl-builtins.c
  test/CodeGen/avx512pf-builtins.c
  test/CodeGen/avx512vbmi-builtins.c
  test/CodeGen/avx512vbmivl-builtin.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/avx512vlcd-builtins.c
  test/CodeGen/avx512vldq-builtins.c
  test/CodeGen/bitscan-builtins.c
  test/CodeGen/bmi-builtins.c
  test/CodeGen/bmi2-builtins.c
  test/CodeGen/builtin-clflushopt.c
  test/CodeGen/f16c-builtins.c
  test/CodeGen/fma-builtins.c
  test/CodeGen/fma4-builtins.c
  test/CodeGen/fsgsbase-builtins.c
  test/CodeGen/lzcnt-builtins.c
  test/CodeGen/mmx-builtins.c
  test/CodeGen/pku.c
  test/CodeGen/popcnt-builtins.c
  test/CodeGen/prefetchw-builtins.c
  test/CodeGen/rd-builtins.c
  test/CodeGen/rdrand-builtins.c
  test/CodeGen/rtm-builtins.c
  test/CodeGen/sha-builtins.c
  test/CodeGen/sse-builtins.c
  test/CodeGen/sse2-builtins.c
  test/CodeGen/sse3-builtins.c
  test/CodeGen/sse41-builtins.c
  test/CodeGen/sse42-builtins.c
  test/CodeGen/sse4a-builtins.c
  test/CodeGen/ssse3-builtins.c
  test/CodeGen/target-builtin-error-2.c
  test/CodeGen/target-builtin-error.c
  test/CodeGen/target-builtin-noerror.c
  test/CodeGen/target-features-error-2.c
  test/CodeGen/tbm-builtins.c
  test/CodeGen/xop-builtins.c
  test/CodeGenCXX/mangle-ms-vector-types.cpp
  test/Driver/modules.m
  test/Driver/modules.mm
  test/Headers/x86-intrinsics-headers.c
  test/Headers/x86intrin-2.c
  test/Headers/x86intrin.c
  test/Headers/x86intrin.cpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -268,6 +268,12 @@
 config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ') )
 config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) )
 config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) )
+config.substitutions.append( ('%use_builtin_modules',
+  ' -fmodules -fmodule-map-file=' + 
+  getClangBuiltinIncludeDir(config.clang) +
+  '/module.modulemap '
+  '-fmodules-cache-path=%t_builtin_modules '
+  '-fmodules-validate-system-headers ' ))
 
 # The host triple might not be set, at least if we're compiling clang from
 # an already installed llvm.
Index: test/Headers/x86intrin.cpp
===
--- test/Headers/x86intrin.cpp
+++ test/Headers/x86intrin.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
+
+// RUN: %clang_cc1 %use_builtin_modules -fsyntax-only -ffreestanding %s -verify
+
 // expected-no-diagnostics
 
 #if defined(i386) || defined(__x86_64__)
Index: test/Headers/x86intrin.c
===
--- test/Headers/x86intrin.c
+++ test/Headers/x86intrin.c
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify
+
+// RUN: %clang_cc1 %use_builtin_modules -fsyntax-only -ffreestanding %s -verify
+// RUN: %clang_cc1 %use_builtin_modules -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify
+// RUN: %clang_cc1 %use_builtin_modules -fsyntax-only -ffreestanding -x c++ %s -verify
+
 // expected-no-diagnostics
 
 #if defined(i386) || defined(__x86_64__)
Index: test/Headers/x86intrin-2.c
===
--- test/Headers/x86intrin-2.c
+++ test/Headers/x86intrin-2.c
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify
+
+// RUN: 

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: ddunbar.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: dberris.

Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.

The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:

  clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name)

in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" 
appropriately)">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
 
 .. option:: -print-prog-name=
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" appropriately)">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25258: [coroutines] Create allocation and deallocation sub-statements.

2016-10-06 Thread Gor Nishanov via cfe-commits
GorNishanov updated this revision to Diff 73835.
GorNishanov added a comment.

Addressed review comments. Anything else, @rsmith?

1. compute default new align and pass it to coro.id
2. fix typo in comment


https://reviews.llvm.org/D25258

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -143,13 +143,12 @@
 }
 
 void only_coreturn() {
-  co_return; // expected-warning {{'co_return' used in a function that uses neither 'co_await' nor 'co_yield'}}
+  co_return; // OK
 }
 
 void mixed_coreturn(bool b) {
   if (b)
-// expected-warning@+1 {{'co_return' used in a function that uses neither}}
-co_return; // expected-note {{use of 'co_return'}}
+co_return; // expected-note {{use of 'co_return' here}}
   else
 return; // expected-error {{not allowed in coroutine}}
 }
Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+namespace std {
+namespace experimental {
+template 
+struct coroutine_traits; // expected-note {{declared here}}
+}
+}
+
+struct suspend_always {
+  bool await_ready() { return false; }
+  void await_suspend() {}
+  void await_resume() {}
+};
+
+struct global_new_delete_tag {};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() {}
+suspend_always initial_suspend() { return {}; }
+suspend_always final_suspend() { return {}; }
+void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f0( 
+extern "C" void f0(global_new_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call i8* @_Znwm(i64 %[[SIZE]])
+
+  // CHECK: coro.destroy.label:
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame()
+  // CHECK: %[[MEM:.+]] = call i8* @llvm.coro.free(token %[[ID]], i8* %[[FRAME]])
+  // CHECK: call void @_ZdlPv(i8* %[[MEM]])
+  co_return;
+}
+
+struct promise_new_tag {};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void *operator new(unsigned long);
+void get_return_object() {}
+suspend_always initial_suspend() { return {}; }
+suspend_always final_suspend() { return {}; }
+void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f1( 
+extern "C" void f1(promise_new_tag ) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call i8* @_ZNSt12experimental16coroutine_traitsIJv15promise_new_tagEE12promise_typenwEm(i64 %[[SIZE]])
+
+  // CHECK: coro.destroy.label:
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame()
+  // CHECK: %[[MEM:.+]] = call i8* @llvm.coro.free(token %[[ID]], i8* %[[FRAME]])
+  // CHECK: call void @_ZdlPv(i8* %[[MEM]])
+  co_return;
+}
+
+struct promise_delete_tag {};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void operator delete(void*);
+void get_return_object() {}
+suspend_always initial_suspend() { return {}; }
+suspend_always final_suspend() { return {}; }
+void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f2( 
+extern "C" void f2(promise_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call i8* @_Znwm(i64 %[[SIZE]])
+
+  // CHECK: coro.destroy.label:
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame()
+  // CHECK: %[[MEM:.+]] = call i8* @llvm.coro.free(token %[[ID]], i8* %[[FRAME]])
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv18promise_delete_tagEE12promise_typedlEPv(i8* %[[MEM]])
+  co_return;
+}
+
+struct promise_sized_delete_tag {};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void operator delete(void*, unsigned long);
+void get_return_object() {}
+suspend_always initial_suspend() { return {}; }
+suspend_always final_suspend() { return {}; }
+void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f3( 
+extern "C" void f3(promise_sized_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call i8* @_Znwm(i64 %[[SIZE]])
+
+  // CHECK: coro.destroy.label:
+  // CHECK: %[[FRAME:.+]] = call i8* 

[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I think will be good idea to handle LLVM casts and getAs<> methods too. There 
are plenty of them in LLVM/Clang/etc code used for variable initialization.

See also https://reviews.llvm.org/D17765 for Boost related ideas.


https://reviews.llvm.org/D25316



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


[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

2016-10-06 Thread Albert Gutowski via cfe-commits
agutowski created this revision.
agutowski added reviewers: rnk, hans, thakis, majnemer.
agutowski added a subscriber: cfe-commits.

We need __stosb to be an intrinsic, because SecureZeroMemory function uses it 
without including intrin.h. Implementing it as a volatile memset is not 
consistent with MSDN specification, but it gives us target-independent IR while 
keeping the most important properties of __stosb.


https://reviews.llvm.org/D25334

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c
  test/Headers/ms-intrin.cpp


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1148,11 +1148,6 @@
 : "%edi", "%esi", "%ecx");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
-__stosb(unsigned char *__dst, unsigned char __x, size_t __n) {
-  __asm__("rep stosb" : : "D"(__dst), "a"(__x), "c"(__n)
-: "%edi", "%ecx");
-}
-static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
   __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n)
 : "%edi", "%ecx");
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7599,7 +7599,20 @@
 HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
 return HigherBits;
   }
+
+  case X86::BI__stosb: {
+// we treat __stosb as volatile memset  - it may not generate "rep stosb"
+// instruction, but it will create a memset that won't be optimized away
+const FunctionDecl *FD = E->getDirectCallee();
+Address Dest = EmitPointerWithAlignment(E->getArg(0));
+Value *ByteVal = EmitScalarExpr(E->getArg(1));
+Value *SizeVal = EmitScalarExpr(E->getArg(2));
+EmitNonNullArgCheck(RValue::get(Dest.getPointer()), 
E->getArg(0)->getType(),
+E->getArg(0)->getExprLoc(), FD, 0);
+Builder.CreateMemSet(Dest, ByteVal, SizeVal, true);
+return Dest.getPointer();
   }
+  }
 }
 
 
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -2071,6 +2071,8 @@
 TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
 TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
 
+TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN
Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -14,6 +14,22 @@
 
 #include 
 
+#if defined(__i386__) || defined(__x86_64__)
+void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
+  return __stosb(Dest, Data, Count);
+}
+
+// CHECK-I386: define{{.*}}void @test__stosb
+// CHECK-I386:   tail call void @llvm.memset.p0i8.i32(i8* %Dest, i8 %Data, i32 
%Count, i32 1, i1 true)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64: define{{.*}}void @test__stosb
+// CHECK-X64:   tail call void @llvm.memset.p0i8.i64(i8* %Dest, i8 %Data, i64 
%Count, i32 1, i1 true)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+#endif
+
 void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) {
   return _InterlockedExchangePointer(Target, Value);
 }
Index: test/Headers/ms-intrin.cpp
===
--- test/Headers/ms-intrin.cpp
+++ test/Headers/ms-intrin.cpp
@@ -38,7 +38,6 @@
   __movsd(0, 0, 0);
   __movsw(0, 0, 0);
 
-  __stosb(0, 0, 0);
   __stosd(0, 0, 0);
   __stosw(0, 0, 0);
 


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1148,11 +1148,6 @@
 : "%edi", "%esi", "%ecx");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
-__stosb(unsigned char *__dst, unsigned char __x, size_t __n) {
-  __asm__("rep stosb" : : "D"(__dst), "a"(__x), "c"(__n)
-: "%edi", "%ecx");
-}
-static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
   __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n)
 : "%edi", "%ecx");
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7599,7 +7599,20 @@
 HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
 return HigherBits;
   }
+
+  case X86::BI__stosb: {
+// we treat __stosb as volatile memset  - it may not generate "rep stosb"
+// instruction, but it will create a memset that won't be optimized 

[PATCH] D25335: [OpenCL] Allow partial initializer for array and struct

2016-10-06 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader.
yaxunl added a subscriber: cfe-commits.

Currently Clang allows partial initializer for C99 but not for OpenCL, e.g.

float a[16][16] = {1.0f, 2.0f};

is allowed in C99 but not allowed in OpenCL.

This patch fixes that.


https://reviews.llvm.org/D25335

Files:
  lib/Sema/SemaInit.cpp
  test/CodeGenOpenCL/partial_initializer.cl


Index: test/CodeGenOpenCL/partial_initializer.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/partial_initializer.cl
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s 
-O0 -o - | FileCheck %s
+
+// CHECK: %struct.StrucTy = type { i32, i32, i32 }
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHEC:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 x 
float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 
+// CHECK: @GS = addrspace(1) global %struct.StrucTy { i32 1, i32 2, i32 0 }, 
align 4
+// CHECK: @GV1 = addrspace(1) global <4 x i32> , 
align 16
+// CHECK: @GV2 = addrspace(1) global <4 x i32> , 
align 16
+// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, 
i32 0 }, align 4
+
+typedef __attribute__(( ext_vector_type(2) ))  int int2;
+typedef __attribute__(( ext_vector_type(4) ))  int int4;
+
+float GA[6][6]  = {1.0f, 2.0f};
+
+typedef struct {
+  int x;
+  int y;
+  int z;
+} StrucTy;
+
+StrucTy GS = {1, 2};
+
+int4 GV1 = (int4)((int2)(1,2),3,4);
+int4 GV2 = (int4)(1);
+
+// CHECK-LABEL: define spir_func void @f()
+
+void f(void) {
+  // CHECK: %[[A:.*]] = alloca [6 x [6 x float]], align 4
+  // CHECK: %[[S:.*]] = alloca %struct.StrucTy, align 4
+  // CHECK: %[[V1:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral1:.*]] = alloca <2 x i32>, align 8
+  // CHECK: %[[V2:.*]] = alloca <4 x i32>, align 16
+
+  // CHECK: %[[v0:.*]] = bitcast [6 x [6 x float]]* %A to i8*
+  // CHECK: call void @llvm.memset.p0i8.i32(i8* %[[v0]], i8 0, i32 144, i32 4, 
i1 false)
+  // CHECK: %[[v1:.*]] = bitcast i8* %[[v0]] to [6 x [6 x float]]*
+  // CHECK: %[[v2:.*]] = getelementptr [6 x [6 x float]], [6 x [6 x float]]* 
%[[v1]], i32 0, i32 0
+  // CHECK: %[[v3:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 0
+  // CHECK: store float 1.00e+00, float* %[[v3]]
+  // CHECK: %[[v4:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 1
+  // CHECK: store float 2.00e+00, float* %[[v4]]
+  float A[6][6]  = {1.0f, 2.0f};
+
+  // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast 
(%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false)
+  StrucTy S = {1, 2};
+
+  // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[v6:.*]] = load <2 x i32>, <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[vext:.*]] = shufflevector <2 x i32> %[[v6]], <2 x i32> undef, 
<4 x i32> 
+  // CHECK: %[[vecinit:.*]] = shufflevector <4 x i32> %[[vext]], <4 x i32> 
undef, <4 x i32> 
+  // CHECK: %[[vecinit2:.*]] = insertelement <4 x i32> %[[vecinit]], i32 3, 
i32 2
+  // CHECK: %[[vecinit3:.*]] = insertelement <4 x i32> %[[vecinit2]], i32 4, 
i32 3
+  // CHECK: store <4 x i32> %[[vecinit3]], <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: %[[v7:.*]] = load <4 x i32>, <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: store <4 x i32> %[[v7]], <4 x i32>* %[[V1]], align 16
+  int4 V1 = (int4)((int2)(1,2),3,4);
+
+  // CHECK: store <4 x i32> , <4 x i32>* %[[V2]], 
align 16
+  int4 V2 = (int4)(1);
+
+}
+
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1229,8 +1229,9 @@
   //   subaggregate, brace elision is assumed and the initializer is
   //   considered for the initialization of the first member of
   //   the subaggregate.
-  if (!SemaRef.getLangOpts().OpenCL && 
-  (ElemType->isAggregateType() || ElemType->isVectorType())) {
+  // OpenCL vector initializer is handled elsewhere.
+  if ((!SemaRef.getLangOpts().OpenCL && ElemType->isVectorType()) ||
+  ElemType->isAggregateType()) {
 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
   StructuredIndex);
 ++StructuredIndex;


Index: test/CodeGenOpenCL/partial_initializer.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/partial_initializer.cl
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s -O0 -o - | FileCheck %s
+
+// CHECK: %struct.StrucTy = type { i32, i32, 

r283487 - [Sema] Replace smart quote with "'" in comment.

2016-10-06 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Oct  6 14:47:56 2016
New Revision: 283487

URL: http://llvm.org/viewvc/llvm-project?rev=283487=rev
Log:
[Sema] Replace smart quote with "'" in comment.

Looks like the smart quote was copy/pasted from the C++ standard.

The smart quote was not encoded as valid UTF-8 (?), even though vim was
detecting the file as UTF-8.  This broke the clang-format Python script,
which tried to read the file using the same encoding as vim detected.

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=283487=283486=283487=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  6 14:47:56 2016
@@ -13687,7 +13687,7 @@ static bool captureInLambda(LambdaScopeI
 // C++ [expr.prim.lambda]p5:
 //   The closure type for a lambda-expression has a public inline 
 //   function call operator [...]. This function call operator is 
-//   declared const (9.3.1) if and only if the lambda-expression’s 
+//   declared const (9.3.1) if and only if the lambda-expression's 
 //   parameter-declaration-clause is not followed by mutable.
 DeclRefType = CaptureType.getNonReferenceType();
 if (!LSI->Mutable && !CaptureType->isReferenceType())


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


[PATCH] D25309: [clang-move] Support moving multiple classes in one run.

2016-10-06 Thread Eric Liu via cfe-commits
ioeric added inline comments.


> ClangMove.cpp:295
>  void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
> -  std::string FullyQualifiedName = "::" + Spec.Name;
> +  auto ParseNames = [](llvm::StringRef Names) {
> +SmallVector ClassNames;

Why create this lambda if it's only used once? I think you can save a few lines 
by just inlining this.

> ClangMove.cpp:303
> +  for (StringRef ClassName : ClassNames) {
> +const auto HasName = hasName(("::" + ClassName.ltrim(":")).str());
> +if (InMovedClassNames)

I'd also allow whitespaces around separators, e.g.  `a::b::X, a::b::Y`. Maybe 
also `trim()` the name.

> ClangMove.cpp:304
> +const auto HasName = hasName(("::" + ClassName.ltrim(":")).str());
> +if (InMovedClassNames)
> +  InMovedClassNames = anyOf(*InMovedClassNames, HasName);

Does this work?

  InMovedClassNames = InMovedClassNames ? ... : ...

> ClangMove.cpp:316
>auto InMovedClass =
> -  hasDeclContext(cxxRecordDecl(hasName(FullyQualifiedName)));
> +  hasDeclContext(cxxRecordDecl(*InMovedClassNames));
>  

What would happen if `InMovedClassNames == false`?

> ClangMove.h:40
>struct MoveDefinitionSpec {
> -// A fully qualified name, e.g. "X", "a::X".
> -std::string Name;
> +// A semicolon-separated list of fully qualified names, e.g. "Foo",
> +// "a::Foo;b::Foo".

I'd use commas as separator. Eyeballs can easily mix ";" with ":".

> ClangMoveMain.cpp:41
> +cl::opt
> +Name("name", cl::desc("A semicolon-separated list of the names of 
> classes "
> +  "being moved, e.g. \"Foo\", \"a::Foo;b::Foo\"."),

Same here if semi->comma.

And I'd name this `Names` and `names`

> multiple_class_test.cpp:15
> +
> +namespace c {
> +int Bar::f() {

Can you add one more moved class that is also in `namespace c`?

https://reviews.llvm.org/D25309



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


[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


> ReachableCode.cpp:64
> +const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
> +return FDecl && FDecl->getIdentifier() &&
> +   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;

Maybe also wrap the inner dyn_cast in an if for symmetry?

  static bool isBuiltinUnreachable(const Stmt *S) {
if (const auto *DRE = dyn_cast(S))
  if (const auto *FDecl = dyn_cast(DRE->getDecl()))
return FDecl->getIdentifier() &&
   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
return false;
  }

Repository:
  rL LLVM

https://reviews.llvm.org/D25321



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


r283508 - PR25890: Fix incoherent error handling in PerformImplicitConversion and

2016-10-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  6 18:12:58 2016
New Revision: 283508

URL: http://llvm.org/viewvc/llvm-project?rev=283508=rev
Log:
PR25890: Fix incoherent error handling in PerformImplicitConversion and
CheckSingleAssignmentConstraints. These no longer produce ExprError() when they
have not emitted an error, and reliably inform the caller when they *have*
emitted an error.

This fixes some serious issues where we would fail to emit any diagnostic for
invalid code and then attempt to emit code for an invalid AST, and conversely
some issues where we would emit two diagnostics for the same problem.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/except/except.spec/p5-pointers.cpp
cfe/trunk/test/SemaCXX/ambig-user-defined-conversions.cpp
cfe/trunk/test/SemaCXX/derived-to-base-ambig.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=283508=283507=283508=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct  6 18:12:58 2016
@@ -8835,15 +8835,23 @@ public:
CastKind ,
bool ConvertRHS = true);
 
-  // CheckSingleAssignmentConstraints - Currently used by
-  // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
-  // this routine performs the default function/array converions, if ConvertRHS
-  // is true.
-  AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType,
- ExprResult ,
- bool Diagnose = true,
- bool DiagnoseCFAudited = 
false,
- bool ConvertRHS = true);
+  /// Check assignment constraints for an assignment of RHS to LHSType.
+  ///
+  /// \brief LHSType The destination type for the assignment.
+  /// \brief RHS The source expression for the assignment.
+  /// \brief Diagnose If \c true, diagnostics may be produced when checking
+  ///for assignability. If a diagnostic is produced, \p RHS will be
+  ///set to ExprError(). Note that this function may still return
+  ///without producing a diagnostic, even for an invalid assignment.
+  /// \brief DiagnoseCFAudited If \c true, the target is a function parameter
+  ///in an audited Core Foundation API and does not need to be checked
+  ///for ARC retain issues.
+  /// \brief ConvertRHS If \c true, \p RHS will be updated to model the
+  ///conversions necessary to perform the assignment. If \c false,
+  ///\p Diagnose must also be \c false.
+  AssignConvertType CheckSingleAssignmentConstraints(
+  QualType LHSType, ExprResult , bool Diagnose = true,
+  bool DiagnoseCFAudited = false, bool ConvertRHS = true);
 
   // \brief If the lhs type is a transparent union, check whether we
   // can initialize the transparent union with the given expression.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=283508=283507=283508=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  6 18:12:58 2016
@@ -7793,6 +7793,10 @@ Sema::CheckSingleAssignmentConstraints(Q
bool Diagnose,
bool DiagnoseCFAudited,
bool ConvertRHS) {
+  // We need to be able to tell the caller whether we diagnosed a problem, if
+  // they ask us to issue diagnostics.
+  assert((ConvertRHS || !Diagnose) && "can't indicate whether we diagnosed");
+
   // If ConvertRHS is false, we want to leave the caller's RHS untouched. 
Sadly,
   // we can't avoid *all* modifications at the moment, so we need some 
somewhere
   // to put the updated value.
@@ -7804,9 +7808,9 @@ Sema::CheckSingleAssignmentConstraints(Q
   // C++ 5.17p3: If the left operand is not of class type, the
   // expression is implicitly converted (C++ 4) to the
   // cv-unqualified type of the left operand.
-  ExprResult Res;
+  QualType RHSType = RHS.get()->getType();
   if (Diagnose) {
-Res = PerformImplicitConversion(RHS.get(), 
LHSType.getUnqualifiedType(),
+RHS = PerformImplicitConversion(RHS.get(), 
LHSType.getUnqualifiedType(),
 AA_Assigning);
   } else {
 ImplicitConversionSequence ICS 

[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

2016-10-06 Thread Gor Nishanov via cfe-commits
GorNishanov added a comment.

shipit 



> coreturn.cpp:36
> +  suspend_always final_suspend();
> +  awaitable yield_value(int);
> +  void return_void();

No need to hve yield_value here, unless you want to use co_yield expression in 
the coroutine. In this file, we are using co_await only.  (Same comment for 
promise_float and promise_int)

https://reviews.llvm.org/D25349



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


[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

2016-10-06 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


> GorNishanov wrote in coreturn.cpp:36
> No need to hve yield_value here, unless you want to use co_yield expression 
> in the coroutine. In this file, we are using co_await only.  (Same comment 
> for promise_float and promise_int)

Ack. I'll add them back if I need them.

https://reviews.llvm.org/D25349



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


[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

2016-10-06 Thread David Majnemer via cfe-commits
majnemer added inline comments.


> AnalysisBasedWarnings.cpp:537
>if (const FunctionDecl *FD = dyn_cast(D)) {
> -ReturnsVoid = FD->getReturnType()->isVoidType();
> +if (const CoroutineBodyStmt *CBody = dyn_cast(Body))
> +  ReturnsVoid = CBody->getFallthroughHandler() != nullptr;

`const auto *`

https://reviews.llvm.org/D25349



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


[PATCH] D25349: [coroutines] Build fallthrough and set_exception statements.

2016-10-06 Thread Gor Nishanov via cfe-commits
GorNishanov added a comment.

LGTM, but, will need to wait for @rsmith to sign off.


https://reviews.llvm.org/D25349



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


[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

2016-10-06 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Funny facts about the Environment:

(a) Environment allows taking SVals of ReturnStmt, which is not an expression, 
by transparently converting it into its sub-expression. In fact, it only stores 
expressions.

Having just noticed (a), i also understand that (a) is not of direct importance 
to the question, however:

(b)  With a similar trick, Environment allows taking SVal of literal 
expressions, but never stores literal expressions. Instead, it reconstructs the 
constant value by looking at the literal and returns the freshly constructed 
value when asked.

This leads to "return 0;" and "return 1;" branches having the same program 
state. The difference should have been within Environment (return values are 
different), however return values are literals, and they aren't stored in the 
Environment, and hence the Environment is equal in both states. If only the 
function returned, say, 0 and i, the problem wouldn't have been there.

This leaves us with two options:

1. Tell the Environment to store everything. This would make things heavy. 
However, i do not completely understand the consequences of this bug at the 
moment - perhaps there would be more problems due to this state merging unless 
we start storing everything.

2. Rely on the ProgramPoint to remember where we are. After all, why do we 
merge when program points should clearly be different? The program point that 
fails us is CallExitBegin - we could construct it with ReturnStmt and its block 
count to discriminate between different returns. It should fix this issue, and 
is similar to the approach taken in this patch (just puts things to their own 
place), however, as i mentioned, there might be more problems with misbehavior 
(b) of the Environment, need to think.

Finally, i'm not quite sure why CallExitBegin is at all necessary. I wonder if 
we could just remove it and jump straight to Bind Return Value, also need to 
think.


Repository:
  rL LLVM

https://reviews.llvm.org/D25326



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


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

The change from an algorithmic POV looks good but I can't speak to whether or 
not the approach is sound, I'll leave that to @rsmith.



> majnemer wrote in PrintPreprocessedOutput.cpp:404
> !SearchPath.empty()

This review comment was never addressed.

https://reviews.llvm.org/D25153



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-06 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


> rSerge wrote in Tools.cpp:4787
> Is there any advantage over `const char* const` here?

This same value is turned into a string later on anyway. You can make it a 
std::string and std::move(...) it at the call to CmdArgs.push_back(...).

> rSerge wrote in Tools.cpp:4796
> It returns `StringRef`. `.str()` would construct a `std::string`, which seems 
> unnecessary.  Of course this piece is not performance-critical, but why not 
> to just use `operator+=` taking as the argument `const char* const`?

.data() doesn't necessarily have a null terminator.

Constructing a string out of successive +'s invoke move constructors on 
std::string, which makes it as efficient if not more efficient than growing a 
single string this way. At any rate it's much more readable if you did it in a 
single line.

https://reviews.llvm.org/D24799



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


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-06 Thread Steve O'Brien via cfe-commits
elsteveogrande added inline comments.


> PrintPreprocessedOutput.cpp:388-394
> +  if (SearchPath.size() > 0) {
> +// Print out info about the search path within this comment.  We need
> +// to escape it because we're printing a quoted string within the
> +// comment block.
> +OS << " path=\"" << sanitizePath(SearchPath) << "\"";
> +  } else {
> +OS << " absolute";

facepalm -- how did I miss that `size() > 0`.  I'll fix that along with the 
next batch of updates.

Or another idea.  To get this out the door, perhaps I just drop this and 
`sanitizePath`?  The essential part (for me) is getting the `-dI` option 
working, and printing at least the `#include`s.  More useful diagnostic info 
can get tacked on later perhaps.

https://reviews.llvm.org/D25153



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


[PATCH] D25343: [OpenCL] Mark group functions as noduplicate in opencl-c.h

2016-10-06 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

These should be convergent instead


https://reviews.llvm.org/D25343



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


Re: [PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread David Blaikie via cfe-commits
On Thu, Oct 6, 2016 at 6:16 AM Alex Lorenz  wrote:

> arphaman created this revision.
> arphaman added reviewers: dblaikie, krememek.
> arphaman added a subscriber: cfe-commits.
> arphaman set the repository for this revision to rL LLVM.
>
> This patch fixes the issue of clang emitting an unreachable warning when
> it encounters unreachable `__builtin_unreachable()` statements. It detects
> references to `__builtin_unreachable` and doesn't emit an unreachable
> warning for them.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D25321
>
> Files:
>   lib/Analysis/ReachableCode.cpp
>   test/Sema/warn-unreachable.c
>
>
> Index: test/Sema/warn-unreachable.c
> ===
> --- test/Sema/warn-unreachable.c
> +++ test/Sema/warn-unreachable.c
> @@ -396,3 +396,40 @@
>else
>  calledFun();
>  }
> +
> +int pr13910_foo(int x) {
> +  if (x == 1)
> +return 0;
> +  else
> +return x;
> +  __builtin_unreachable(); // expected no warning
> +}
> +
> +int pr13910_bar(int x) {
> +  switch (x) {
> +  default:
> +return x + 1;
> +  }
> +  pr13910_foo(x); // expected-warning {{code will never be executed}}
> +}
> +
> +int pr13910_bar2(int x) {
> +  if (x == 1)
> +return 0;
> +  else
> +return x;
> +  pr13910_foo(x);  // expected-warning {{code will never be
> executed}}
> +  __builtin_unreachable(); // expected no warning
> +  pr13910_foo(x);  // expected-warning {{code will never be
> executed}}
>

Seems strange to have two warnings here ^ is that a separate bug?


> +}
> +
> +void pr13910_noreturn() {
> +  raze();
> +  __builtin_unreachable(); // expected no warning
> +}
> +
> +void pr13910_assert() {
> +  myassert(0 && "unreachable");
> +  return;
> +  __builtin_unreachable(); // expected no warning
> +}
> Index: lib/Analysis/ReachableCode.cpp
> ===
> --- lib/Analysis/ReachableCode.cpp
> +++ lib/Analysis/ReachableCode.cpp
> @@ -58,6 +58,15 @@
>return false;
>  }
>
> +static bool isBuiltinUnreachable(const CFGBlock *B, const Stmt *S) {
> +  if (const DeclRefExpr *DRE = dyn_cast(S)) {
> +const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
> +return FDecl && FDecl->getIdentifier() &&
> +   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
> +  }
> +  return false;
> +}
> +
>  static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
>// Look to see if the current control flow ends with a 'return', and
> see if
>// 'S' is a substatement. The 'return' may not be the last element in
> the
> @@ -574,8 +583,7 @@
>
>if (isa(S)) {
>  UK = reachable_code::UK_Break;
> -  }
> -  else if (isTrivialDoWhile(B, S)) {
> +  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(B, S)) {
>  return;
>}
>else if (isDeadReturn(B, S)) {
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread Alex L via cfe-commits
On 6 October 2016 at 15:50, David Blaikie  wrote:

>
>
> On Thu, Oct 6, 2016 at 6:16 AM Alex Lorenz  wrote:
>
>> arphaman created this revision.
>> arphaman added reviewers: dblaikie, krememek.
>> arphaman added a subscriber: cfe-commits.
>> arphaman set the repository for this revision to rL LLVM.
>>
>> This patch fixes the issue of clang emitting an unreachable warning when
>> it encounters unreachable `__builtin_unreachable()` statements. It detects
>> references to `__builtin_unreachable` and doesn't emit an unreachable
>> warning for them.
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D25321
>>
>> Files:
>>   lib/Analysis/ReachableCode.cpp
>>   test/Sema/warn-unreachable.c
>>
>>
>> Index: test/Sema/warn-unreachable.c
>> ===
>> --- test/Sema/warn-unreachable.c
>> +++ test/Sema/warn-unreachable.c
>> @@ -396,3 +396,40 @@
>>else
>>  calledFun();
>>  }
>> +
>> +int pr13910_foo(int x) {
>> +  if (x == 1)
>> +return 0;
>> +  else
>> +return x;
>> +  __builtin_unreachable(); // expected no warning
>> +}
>> +
>> +int pr13910_bar(int x) {
>> +  switch (x) {
>> +  default:
>> +return x + 1;
>> +  }
>> +  pr13910_foo(x); // expected-warning {{code will never be executed}}
>> +}
>> +
>> +int pr13910_bar2(int x) {
>> +  if (x == 1)
>> +return 0;
>> +  else
>> +return x;
>> +  pr13910_foo(x);  // expected-warning {{code will never be
>> executed}}
>> +  __builtin_unreachable(); // expected no warning
>> +  pr13910_foo(x);  // expected-warning {{code will never be
>> executed}}
>>
>
> Seems strange to have two warnings here ^ is that a separate bug?
>

It seems that it might be, yeah. For example, clang emits two unreachable
warnings for the two `foo` calls in this code:

int foo() {
  return 0;
}
int bar(int x) {
  if (x == 0)
return x + 1;
  else
return x;
  foo();
  return 0;
  foo();
}

But just one when the `return 0` that's between the two `foo` calls is
removed. It doesn't seem like there's a PR for this issue, I'll file one
later on today.



>
>
>> +}
>> +
>> +void pr13910_noreturn() {
>> +  raze();
>> +  __builtin_unreachable(); // expected no warning
>> +}
>> +
>> +void pr13910_assert() {
>> +  myassert(0 && "unreachable");
>> +  return;
>> +  __builtin_unreachable(); // expected no warning
>> +}
>> Index: lib/Analysis/ReachableCode.cpp
>> ===
>> --- lib/Analysis/ReachableCode.cpp
>> +++ lib/Analysis/ReachableCode.cpp
>> @@ -58,6 +58,15 @@
>>return false;
>>  }
>>
>> +static bool isBuiltinUnreachable(const CFGBlock *B, const Stmt *S) {
>> +  if (const DeclRefExpr *DRE = dyn_cast(S)) {
>> +const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
>> +return FDecl && FDecl->getIdentifier() &&
>> +   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
>> +  }
>> +  return false;
>> +}
>> +
>>  static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
>>// Look to see if the current control flow ends with a 'return', and
>> see if
>>// 'S' is a substatement. The 'return' may not be the last element in
>> the
>> @@ -574,8 +583,7 @@
>>
>>if (isa(S)) {
>>  UK = reachable_code::UK_Break;
>> -  }
>> -  else if (isTrivialDoWhile(B, S)) {
>> +  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(B, S)) {
>>  return;
>>}
>>else if (isDeadReturn(B, S)) {
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24085: arm: Fix ttype encoding assertion failure.

2016-10-06 Thread Logan Chien via cfe-commits
logan added inline comments.


> mclow.lists wrote in cxa_personality.cpp:363
> It's not clear to me how this accomplishes what you want.
> You're looking for `00/10/90`, right?  Why not just check for that?
> 
> Why are you anding with 0x0f ?
> Before, this would pass only a single value - `DW_EH_PE_absptr` (aka 0)
> With this change, it passes 32 values: 00, 03, 10, 13, 20, 23, and so on.
> 
> Was that your intent?

`ttypeEncoding` is encoded with following rules:

1. Lower 4 bits stand for the representation of the data, such as `absptr`, 
`uleb128`, `udata1`, `udata2`, `udata4`, `udata8`, etc.  These bits control the 
way we extract the bytes from the exception table.

2. Upper 4 bits stand for the post processing action, such as `pcrel`, 
`indirect`, etc.  For example, if `pcrel` is specified, then we should add the 
value, which was read in step 1, with the address of the value.

My intention is to weaken the assertion (only assert the essential assumption) 
so that we don't have to alter the assertion  if there are new configurations 
that I am not aware of or new compiler which is generating different 
ttypeEncoding.

Since the upcoming lines (L365) only uses `sizeof(uintptr_t)` to decode the 
TType pointer, it is not necessary to impose restriction on the upper 4 bits.  
That's the reason why I wrote `ttypeEncoding & 0xf`.  For the same reason, both 
`absptr` and `udata` have the same meaning (4 bytes in the exception table) in 
this context, thus I am adding extra `(ttypeEncoding & 0x0f) == 
DW_EH_PE_udata4`.

https://reviews.llvm.org/D24085



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


[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

2016-10-06 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, dcoughlin, NoQ.
danielmarjamaki set the repository for this revision to rL LLVM.

Returns when calling an inline function should not be merged in the 
ExplodedGraph unless they are same.

Background post on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2016-October/051001.html

Here is an example patch that solves my false positives and also fixes 2 false 
negatives in existing tests.

What do you think about this approach?


Repository:
  rL LLVM

https://reviews.llvm.org/D25326

Files:
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/inlining/InlineObjCClassMethod.m
  test/Analysis/unreachable-code-path.c


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -194,3 +194,14 @@
 break;
   }
 }
+
+extern int table[];
+static int inlineFunction(const int i) {
+  if (table[i] != 0) // <- SVal for table[0] is unknown
+return 1;
+  return 0;
+}
+void test13(int i) {
+  int x = inlineFunction(i);
+  x && x < 10;
+}
Index: test/Analysis/inlining/InlineObjCClassMethod.m
===
--- test/Analysis/inlining/InlineObjCClassMethod.m
+++ test/Analysis/inlining/InlineObjCClassMethod.m
@@ -174,12 +174,12 @@
 @implementation MyClassSelf
 + (int)testClassMethodByKnownVarDecl {
   int y = [MyParentSelf testSelf];
-  return 5/y; // Should warn here.
+  return 5/y; // expected-warning{{Division by zero}}
 }
 @end
 int foo2() {
   int y = [MyParentSelf testSelf];
-  return 5/y; // Should warn here.
+  return 5/y; // expected-warning{{Division by zero}}
 }
 
 // TODO: We do not inline 'getNum' in the following case, where the value of 
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -23,6 +23,8 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
 
+REGISTER_TRAIT_WITH_PROGRAMSTATE(LastStmt, const void *)
+
 using namespace clang;
 using namespace ento;
 
@@ -986,7 +988,8 @@
   if (RS->getRetValue()) {
 for (ExplodedNodeSet::iterator it = dstPreVisit.begin(),
   ei = dstPreVisit.end(); it != ei; ++it) {
-  B.generateNode(RS, *it, (*it)->getState());
+  ProgramStateRef State = (*it)->getState();
+  B.generateNode(RS, *it, State->set((const void*)RS));
 }
   }
 }


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -194,3 +194,14 @@
 break;
   }
 }
+
+extern int table[];
+static int inlineFunction(const int i) {
+  if (table[i] != 0) // <- SVal for table[0] is unknown
+return 1;
+  return 0;
+}
+void test13(int i) {
+  int x = inlineFunction(i);
+  x && x < 10;
+}
Index: test/Analysis/inlining/InlineObjCClassMethod.m
===
--- test/Analysis/inlining/InlineObjCClassMethod.m
+++ test/Analysis/inlining/InlineObjCClassMethod.m
@@ -174,12 +174,12 @@
 @implementation MyClassSelf
 + (int)testClassMethodByKnownVarDecl {
   int y = [MyParentSelf testSelf];
-  return 5/y; // Should warn here.
+  return 5/y; // expected-warning{{Division by zero}}
 }
 @end
 int foo2() {
   int y = [MyParentSelf testSelf];
-  return 5/y; // Should warn here.
+  return 5/y; // expected-warning{{Division by zero}}
 }
 
 // TODO: We do not inline 'getNum' in the following case, where the value of 
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -23,6 +23,8 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
 
+REGISTER_TRAIT_WITH_PROGRAMSTATE(LastStmt, const void *)
+
 using namespace clang;
 using namespace ento;
 
@@ -986,7 +988,8 @@
   if (RS->getRetValue()) {
 for (ExplodedNodeSet::iterator it = dstPreVisit.begin(),
   ei = dstPreVisit.end(); it != ei; ++it) {
-  B.generateNode(RS, *it, (*it)->getState());
+  ProgramStateRef State = (*it)->getState();
+  B.generateNode(RS, *it, State->set((const void*)RS));
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283448 - Allocate after the early exit checks. NFC.

2016-10-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Oct  6 08:18:06 2016
New Revision: 283448

URL: http://llvm.org/viewvc/llvm-project?rev=283448=rev
Log:
Allocate after the early exit checks. NFC.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=283448=283447=283448=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Oct  6 08:18:06 2016
@@ -2320,8 +2320,6 @@ template
 void ASTDeclReader::mergeRedeclarable(Redeclarable *DBase,
   RedeclarableResult ,
   DeclID TemplatePatternID) {
-  T *D = static_cast(DBase);
-
   // If modules are not available, there is no reason to perform this merge.
   if (!Reader.getContext().getLangOpts().Modules)
 return;
@@ -2330,6 +2328,8 @@ void ASTDeclReader::mergeRedeclarable(Re
   if (!DBase->isFirstDecl())
 return;
 
+  T *D = static_cast(DBase);
+
   if (auto *Existing = Redecl.getKnownMergeTarget())
 // We already know of an existing declaration we should merge with.
 mergeRedeclarable(D, cast(Existing), Redecl, TemplatePatternID);


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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


> rsmith wrote in SemaTemplate.cpp:509
> This function still appears to be able to return true (indicating to the 
> caller that a diagnostic was produced) without actually producing a 
> diagnostic.

Is it better now?

> rsmith wrote in SemaTemplate.cpp:505
> Why do we not issue a diagnostic in this case for a `VarDecl` when `Complain` 
> is true and no definition is available? It seems like we should either be 
> diagnosing this or asserting that it can't happen.

I believe it is not implemented, i.e. we didn't have this diagnostics when 
`VarDecl::getInstantiatedFromStaticDataMember` is true. I added a FIXME: for a 
future enhancement.

> rsmith wrote in ASTWriterDecl.cpp:896-897
> Sink this flag into the "not for `ParmVarDecl`" block below.

I thought we might need this for c-style `void f(struct S arg)`-like constructs 
where we might need to demote if we merge ParmVarDecls.

> rsmith wrote in ASTWriterDecl.cpp:1965
> Hmm. The width of the `InitStyle` field is definitely wrong right now, but 
> should be fixed separately from this change. It looks like we don't hit this 
> today because we don't use this abbreviation for a variable with an 
> initializer. In addition to fixing the width of this field, we should also 
> remove the `getInit() == nullptr` check when selecting the abbreviation in 
> `ASTDeclWriter::VisitVarDecl`.

Committed in r283444.

https://reviews.llvm.org/D24508



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


r283460 - [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252

2016-10-06 Thread David Sheinkman via cfe-commits
Author: davidsh
Date: Thu Oct  6 10:47:36 2016
New Revision: 283460

URL: http://llvm.org/viewvc/llvm-project?rev=283460=rev
Log:
[OpenMP] Check if the template specialization is mappable instead of 
specialized template Differential Revision: https://reviews.llvm.org/D25252

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=283460=283459=283460=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Oct  6 10:47:36 2016
@@ -10523,9 +10523,6 @@ static bool IsCXXRecordForMappable(Sema
   if (!RD || RD->isInvalidDecl())
 return true;
 
-  if (auto *CTSD = dyn_cast(RD))
-if (auto *CTD = CTSD->getSpecializedTemplate())
-  RD = CTD->getTemplatedDecl();
   auto QTy = SemaRef.Context.getRecordType(RD);
   if (RD->isDynamicClass()) {
 SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy;

Modified: cfe/trunk/test/OpenMP/target_map_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_messages.cpp?rev=283460=283459=283460=diff
==
--- cfe/trunk/test/OpenMP/target_map_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_messages.cpp Thu Oct  6 10:47:36 2016
@@ -347,6 +347,15 @@ public:
   S5(int v):a(v) { }
 };
 
+template 
+struct S6;
+
+template<>
+struct S6  // expected-note {{mappable type cannot be polymorphic}}
+{
+   virtual void foo();
+};
+
 S3 h;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
 
@@ -451,6 +460,7 @@ int main(int argc, char **argv) {
   int i;
   int  = i;
   int *k = 
+  S6 m;
   int x;
   int y;
   int to, tofrom, always;
@@ -513,6 +523,8 @@ int main(int argc, char **argv) {
   {}
 #pragma omp target firstprivate(j) map(j)  // expected-error {{firstprivate 
variable cannot be in a map clause in '#pragma omp target' directive}} 
expected-note {{defined as firstprivate}}
   {}
+#pragma omp target map(m) // expected-error {{type 'S6' is not mappable 
to target}}
+  {}
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif


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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 73803.
v.g.vassilev marked 4 inline comments as done.
v.g.vassilev added a comment.

Rebase, comments some more fixes.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/Inputs/merge-class-definition-visibility/a.h
  test/Modules/Inputs/merge-class-definition-visibility/b.h
  test/Modules/Inputs/merge-class-definition-visibility/c.h
  test/Modules/Inputs/merge-class-definition-visibility/d.h
  test/Modules/Inputs/merge-class-definition-visibility/e.h
  test/Modules/merge-class-definition-visibility.cpp
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/merge-class-definition-visibility.cpp
===
--- test/Modules/merge-class-definition-visibility.cpp
+++ test/Modules/merge-class-definition-visibility.cpp
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-class-definition-visibility/modmap \
-// RUN:-I%S/Inputs/merge-class-definition-visibility \
+// RUN:-std=c++1z -I%S/Inputs/merge-class-definition-visibility \
 // RUN:-fmodules-cache-path=%t %s -verify \
 // RUN:-fmodules-local-submodule-visibility
 // expected-no-diagnostics
@@ -10,6 +10,9 @@
 typedef X XA;
 struct B;
 
+template int n;
+
+
 #include "e.h"
 // Ensure that this triggers the import of the second definition from e.h,
 // which is necessary to make the definition of A visible in the template
@@ -21,3 +24,5 @@
 // and that definition was merged into the canonical definition from b.h,
 // so that becomes visible, and we have a visible definition.
 B b;
+
+void f (int dflt = n) {}
Index: test/Modules/Inputs/merge-class-definition-visibility/e.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/e.h
+++ test/Modules/Inputs/merge-class-definition-visibility/e.h
@@ -1,3 +1,5 @@
 #include "a.h"
 
 struct B {};
+
+template int n;
Index: test/Modules/Inputs/merge-class-definition-visibility/d.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/d.h
+++ test/Modules/Inputs/merge-class-definition-visibility/d.h
@@ -1 +1,3 @@
 struct B {};
+
+template int n;
Index: test/Modules/Inputs/merge-class-definition-visibility/c.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/c.h
+++ test/Modules/Inputs/merge-class-definition-visibility/c.h
@@ -1 +1,3 @@
 struct A;
+
+inline int var_A;
Index: test/Modules/Inputs/merge-class-definition-visibility/b.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/b.h
+++ test/Modules/Inputs/merge-class-definition-visibility/b.h
@@ -2,3 +2,6 @@
 #include "a.h"
 
 struct B {};
+
+template int n;
+int k = n;
Index: test/Modules/Inputs/merge-class-definition-visibility/a.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/a.h
+++ test/Modules/Inputs/merge-class-definition-visibility/a.h
@@ -1 +1,3 @@
 struct A {};
+
+inline int var_A = 2;
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type 

Re: r283460 - [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252

2016-10-06 Thread Richard Smith via cfe-commits
LGTM

On 6 Oct 2016 8:58 am, "David Sheinkman via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: davidsh
> Date: Thu Oct  6 10:47:36 2016
> New Revision: 283460
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283460=rev
> Log:
> [OpenMP] Check if the template specialization is mappable instead of
> specialized template Differential Revision: https://reviews.llvm.org/
> D25252
>
> Modified:
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/target_map_messages.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaOpenMP.cpp?rev=283460=283459=283460=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Oct  6 10:47:36 2016
> @@ -10523,9 +10523,6 @@ static bool IsCXXRecordForMappable(Sema
>if (!RD || RD->isInvalidDecl())
>  return true;
>
> -  if (auto *CTSD = dyn_cast(RD))
> -if (auto *CTD = CTSD->getSpecializedTemplate())
> -  RD = CTD->getTemplatedDecl();
>auto QTy = SemaRef.Context.getRecordType(RD);
>if (RD->isDynamicClass()) {
>  SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy;
>
> Modified: cfe/trunk/test/OpenMP/target_map_messages.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> target_map_messages.cpp?rev=283460=283459=283460=diff
> 
> ==
> --- cfe/trunk/test/OpenMP/target_map_messages.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_map_messages.cpp Thu Oct  6 10:47:36 2016
> @@ -347,6 +347,15 @@ public:
>S5(int v):a(v) { }
>  };
>
> +template 
> +struct S6;
> +
> +template<>
> +struct S6  // expected-note {{mappable type cannot be polymorphic}}
> +{
> +   virtual void foo();
> +};
> +
>  S3 h;
>  #pragma omp threadprivate(h) // expected-note 2 {{defined as
> threadprivate or thread local}}
>
> @@ -451,6 +460,7 @@ int main(int argc, char **argv) {
>int i;
>int  = i;
>int *k = 
> +  S6 m;
>int x;
>int y;
>int to, tofrom, always;
> @@ -513,6 +523,8 @@ int main(int argc, char **argv) {
>{}
>  #pragma omp target firstprivate(j) map(j)  // expected-error
> {{firstprivate variable cannot be in a map clause in '#pragma omp target'
> directive}} expected-note {{defined as firstprivate}}
>{}
> +#pragma omp target map(m) // expected-error {{type 'S6' is not
> mappable to target}}
> +  {}
>return tmain(argc)+tmain(argc); // expected-note {{in
> instantiation of function template specialization 'tmain' requested
> here}} expected-note {{in instantiation of function template specialization
> 'tmain' requested here}}
>  }
>  #endif
>
>
> ___
> 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