Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2015-11-05 Thread David Blaikie via cfe-commits
On Wed, Nov 4, 2015 at 11:32 PM, Robinson, Paul <
paul_robin...@playstation.sony.com> wrote:

> Would citing PR20455 help?  It wasn't actually my primary motivation but
> it's not too far off.  Having the template parameters there lets you know
> what's going on in the DWARF, without having to fetch and parse the name
> string of every struct you come across.  Actually I'm not sure parsing the
> name string is unambiguous either; each parameter is either a typename, or
> an expression, but without the parameter DIEs you don't know which,
> a-priori.  (What does  mean? Depends on whether you think it should be
> a type name or a value; you can't tell, syntactically, you have to do some
> lookups.  Ah, but if you had the parameter DIEs, you would Just Know.)
>

For LLDB's needs, I'm not sure it's sufficient either - but I wouldn't mind
an answer before we use it as the basis for this change (it sounds like
maybe it's possible to remangle the template using just the string name,
rather than needing an explicit representation of the parameters)

What was your primary motivation?


>  Choosing to emit a forward/incomplete declaration in the first place
> fails source fidelity,
>

How so? You might have only a template declaration (template
struct foo; foo *f;) or you may've only instantiated the declaration
(the C++ language requires you to instantiate or avoid instantiating
certain things in certain places, so in some contexts you /only/ have an
instantiated declaration, not a definition)


> but it is a practical engineering tradeoff of compile/link performance
> against utility; and, after all, the source *could* have been written that
> way, with no semantic difference.  But, if we're going to emit a white-lie
> incomplete declaration, we should do so correctly.
>

Again, "correct" in DWARF is a fairly nebulous concept.


> --paulr
>
>
>
> P.S. We should talk about this forward-declaration tactic wrt LTO
> sometime.  I have a case where a nested class got forward-declared; it's
> entirely conceivable that the outer class with the inner forward-declared
> class would end up being picked by LTO, leaving the user with no debug info
> for the inner class contents.
>

I believe this Just Works(tm). The things that can vary per-insntance of a
type (implicit special members, member template implicit specializations,
and nested types*) are not added to the type's child list, but they
reference the child as their parent. So they continue to apply no matter
which instance of the type is picked for uniquing (because of the
name-based referencing, so the nested type definition just says "my parent
is _Zfoo" and whatever _Zfoo we end up picking in the LTO linking/metadata
deduplication will serve that role just fine)

* we could just do a better job of modelling nested types (& other
non-globally scoped types) in a way that more closely models the source by
emitting a declaration where they were declared, and a definition where
they are defined (with the usual DW_AT_specification to wire them up)


>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Wednesday, November 04, 2015 8:30 PM
> *To:* reviews+d14358+public+d3104135076f0...@reviews.llvm.org; Robinson,
> Paul
> *Subject:* Re: [PATCH] D14358: DWARF's forward decl of a template should
> have template parameters.
>
>
>
>
>
>
>
> On Wed, Nov 4, 2015 at 5:53 PM, Paul Robinson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> probinson added a comment.
>
> GCC 4.8.4 on Linux doesn't produce these, but DWARF 4 section 5.5.8 says a
> class template instantiation is just like the equivalent non-template class
> entry, with the exception of the template parameter entries.  I read that
> as meaning an incomplete description (i.e. with DW_AT_declaration) lets you
> omit all the other children, but not the template parameters.
>
>
>
> As usual, I think it's pretty hard to argue that DWARF /requires/ anything
> (permissive & all that). And I'm not sure that having these is particularly
> valuable/useful - what use do you have in mind for them?
>
> Wouldn't hurt to have some size info about the cost here, though I don't
> imagine it's massive, it does open us up to emitting a whole slew of new
> types (the types the template is instantiated with, and anything that
> depends on - breaking/avoiding type edges can, in my experience, be quite
> beneficial (I described an example of this in my lightning talk last week)).
>
>
>
>
> I don't think omitting the template DIEs was an intentional optimization,
> in the sense of being a decision separate from deciding to emit the
> incomplete/forward declaration in the first place.  They were just omitted
> because we were omitting everything, but everything turns out to be
> non-compliant.
>
>
>
> http://reviews.llvm.org/D14358
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>

Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-05 Thread Yury Gribov via cfe-commits
ygribov updated this revision to Diff 39345.
ygribov added a comment.

Moved to unix package (and thus enabled by default). I now also test for 
collaboration with security.InsecureAPI.vfork.


http://reviews.llvm.org/D14014

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  lib/StaticAnalyzer/Checkers/VforkChecker.cpp
  lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  test/Analysis/Inputs/system-header-simulator.h
  test/Analysis/vfork.c

Index: test/Analysis/vfork.c
===
--- /dev/null
+++ test/Analysis/vfork.c
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify -x c++ %s
+
+#include "Inputs/system-header-simulator.h"
+
+void foo();
+
+// Ensure that child process is properly checked.
+int f1(int x) {
+  pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is insecure}}
+  if (pid != 0)
+return 0;
+
+  switch (x) {
+  case 0:
+// Ensure that modifying pid is ok.
+pid = 1; // no-warning
+// Ensure that calling whitelisted routines is ok.
+execl("", "", 0); // no-warning
+_exit(1); // no-warning
+break;
+  case 1:
+// Ensure that writing variables is prohibited.
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+  case 2:
+// Ensure that calling functions is prohibited.
+foo(); // expected-warning{{This function call is prohibited after a successful vfork}}
+break;
+  default:
+// Ensure that returning from function is prohibited.
+return 0; // expected-warning{{Return is prohibited after a successful vfork; call _exit() instead}}
+  }
+
+  while(1);
+}
+
+// Same as previous but without explicit pid variable.
+int f2(int x) {
+  pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is insecure}}
+
+  switch (x) {
+  case 0:
+// Ensure that writing pid is ok.
+pid = 1; // no-warning
+// Ensure that calling whitelisted routines is ok.
+execl("", "", 0); // no-warning
+_exit(1); // no-warning
+break;
+  case 1:
+// Ensure that writing variables is prohibited.
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+  case 2:
+// Ensure that calling functions is prohibited.
+foo(); // expected-warning{{This function call is prohibited after a successful vfork}}
+break;
+  default:
+// Ensure that returning from function is prohibited.
+return 0; // expected-warning{{Return is prohibited after a successful vfork; call _exit() instead}}
+  }
+
+  while(1);
+}
+
+// Ensure that parent process isn't restricted.
+int f3(int x) {
+  if (vfork() == 0) // expected-warning{{Call to function 'vfork' is insecure}}
+_exit(1);
+  x = 0; // no-warning
+  foo(); // no-warning
+  return 0;
+} // no-warning
+
+// Unbound pids are special so test them separately.
+void f4(int x) {
+  switch (x) {
+  case 0:
+vfork(); // expected-warning{{Call to function 'vfork' is insecure}}
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+
+  case 1:
+{
+  char args[2];
+  switch (vfork()) { // expected-warning{{Call to function 'vfork' is insecure}}
+  case 0:
+args[0] = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+exit(1);
+  }
+  break;
+}
+
+  case 2:
+{
+  pid_t pid;
+  if ((pid = vfork()) == 0) // expected-warning{{Call to function 'vfork' is insecure}}
+while(1); // no-warning
+  break;
+}
+  }
+  while(1);
+} //no-warning
+
+
+void f5() {
+  // See "libxtables: move some code to avoid cautions in vfork man page"
+  // (http://lists.netfilter.org/pipermail/netfilter-buglog/2014-October/003280.html).
+  if (vfork() == 0) { // expected-warning{{Call to function 'vfork' is insecure}}
+execl("prog", "arg1", 0); // no-warning
+exit(1);  // expected-warning{{This function call is prohibited after a successful vfork}}
+  }
+}
+
Index: test/Analysis/Inputs/system-header-simulator.h
===
--- test/Analysis/Inputs/system-header-simulator.h
+++ test/Analysis/Inputs/system-header-simulator.h
@@ -92,3 +92,13 @@
   char * p;
 } SomeStruct;
 void fakeSystemHeaderCall(SomeStruct *);
+
+typedef int pid_t;
+pid_t fork(void);
+pid_t vfork(void);
+int execl(const char *path, const char *arg, ...);
+
+void exit(int status) __attribute__ ((__noreturn__));
+void _exit(int status) __attribute__ ((__noreturn__));
+void _Exit(int status) __attribute__ ((__noreturn__));
+
Index: lib/StaticAnalyzer/Core/CheckerHelpers.cpp

r252156 - [x86] Additional small fix for MCU psABI support

2015-11-05 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Thu Nov  5 06:43:09 2015
New Revision: 252156

URL: http://llvm.org/viewvc/llvm-project?rev=252156=rev
Log:
[x86] Additional small fix for MCU psABI support

This patch fixes one more thing in MCU psABI support: LongDoubleWidth should be 
set to 64.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=252156=252155=252156=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Nov  5 06:43:09 2015
@@ -2335,8 +2335,7 @@ class X86TargetInfo : public TargetInfo
 public:
   X86TargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? ::APFloat::IEEEdouble
-  : ::APFloat::x87DoubleExtended;
+LongDoubleFormat = ::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@ public:
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = ::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |

Modified: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c?rev=252156=252155=252156=diff
==
--- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Thu Nov  5 06:43:09 2015
@@ -57,6 +57,6 @@ st12_t retLargeStruct(int i1, st12_t r)
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 


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


Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-05 Thread Yury Gribov via cfe-commits
ygribov added a comment.

> I now also test for collaboration with security.InsecureAPI.vfork.


Should probably clarify: I've added checks to testcase to verify that new 
checker properly interacts with (existing) InsecureAPI.vfork checker,


http://reviews.llvm.org/D14014



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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-11-05 Thread Nicholas Allegra via cfe-commits
comex added a comment.

(Ping?  I verified yesterday that the patch still applies and passes regression 
tests.)


http://reviews.llvm.org/D12686



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


[PATCH] D14378: Fix another case where loop-convert wasn't handling correctly data members.

2015-11-05 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

If the container expression was obtained from the point where "size" (which 
usually is a const method) is invoked, then the topmost node in this expression 
may be an implicit cast to const.

When the container is a data member, the check was trying to obtain the member 
expression directly and was failing in the case mentioned above. This is solved 
by ignoring implicit casts.

http://reviews.llvm.org/D14378

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -240,6 +240,7 @@
 struct MemberNaming {
   const static int N = 10;
   int Ints[N], Ints_[N];
+  dependent DInts;
   void loops() {
 for (int I = 0; I < N; ++I) {
   printf("%d\n", Ints[I]);
@@ -254,8 +255,32 @@
 // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop 
instead
 // CHECK-FIXES: for (int Int : Ints_)
 // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < DInts.size(); ++I) {
+  printf("%d\n", DInts[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop 
instead
+// CHECK-FIXES: for (int DInt : DInts)
+// CHECK-FIXES-NEXT: printf("%d\n", DInt);
   }
+
+  void outOfLine();
 };
+void MemberNaming::outOfLine() {
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints_[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints_)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+}
 
 } // namespace NamingAlias
 
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -357,7 +357,7 @@
 static const ValueDecl *getReferencedVariable(const Expr *E) {
   if (const DeclRefExpr *DRE = getDeclRef(E))
 return dyn_cast(DRE->getDecl());
-  if (const auto *Mem = dyn_cast(E))
+  if (const auto *Mem = dyn_cast(E->IgnoreParenImpCasts()))
 return dyn_cast(Mem->getMemberDecl());
   return nullptr;
 }


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -240,6 +240,7 @@
 struct MemberNaming {
   const static int N = 10;
   int Ints[N], Ints_[N];
+  dependent DInts;
   void loops() {
 for (int I = 0; I < N; ++I) {
   printf("%d\n", Ints[I]);
@@ -254,8 +255,32 @@
 // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
 // CHECK-FIXES: for (int Int : Ints_)
 // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < DInts.size(); ++I) {
+  printf("%d\n", DInts[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int DInt : DInts)
+// CHECK-FIXES-NEXT: printf("%d\n", DInt);
   }
+
+  void outOfLine();
 };
+void MemberNaming::outOfLine() {
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints_[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints_)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+}
 
 } // namespace NamingAlias
 
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -357,7 +357,7 @@
 static const ValueDecl *getReferencedVariable(const Expr *E) {
   if (const DeclRefExpr *DRE = getDeclRef(E))
 return dyn_cast(DRE->getDecl());
-  if (const auto *Mem = dyn_cast(E))
+  if (const auto *Mem = dyn_cast(E->IgnoreParenImpCasts()))
 return dyn_cast(Mem->getMemberDecl());
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252175 - [ARM] Clang gives unintended warning message for 'mthumb' + M-profiles:

2015-11-05 Thread Alexandros Lamprineas via cfe-commits
Author: alelab01
Date: Thu Nov  5 11:11:55 2015
New Revision: 252175

URL: http://llvm.org/viewvc/llvm-project?rev=252175=rev
Log:
[ARM] Clang gives unintended warning message for 'mthumb' + M-profiles:

$ clang --target=armv7m-none-eabi -mthumb -march=armv7-m -c test.c
clang-3.8: warning: argument unused during compilation: '-mthumb'

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

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

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=252175=252174=252175=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Nov  5 11:11:55 2015
@@ -481,9 +481,8 @@ std::string ToolChain::ComputeLLVMTriple
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, 
ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


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


Re: [PATCH] D14384: [ARM] Clang gives unintended warning message for 'mthumb' + M-profiles

2015-11-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252175: [ARM] Clang gives unintended warning message for 
'mthumb' + M-profiles: (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D14384?vs=39370=39373#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14384

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

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, 
ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-05 Thread Saleem Abdulrasool via cfe-commits
On Wednesday, November 4, 2015, Tamas Berghammer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> tberghammer created this revision.
> tberghammer added a reviewer: echristo.
> tberghammer added a subscriber: cfe-commits.
>
> Add new compiler flag to enable the generation of dwarf accelerator tables
>
>
Is the additional information large enough to require a new flag?  They
wouldn't break split debug even though they don't work there yet, so if the
impact isn't large enough, might make sense to just enable them on -g.


> The dwarf accelerator tables already generated on darwin platforms. This
> CL ands a new flag to clang to make it possible to enable the generation of
> these tables on other platforms also.
>
> Note: Currently the accelerator table generation code isn't working when
> split dwarf is enabled for several reasons (accelerator tables aren't
> copied to dwo file, they contain relocation entries for the .debug_str.dwo
> sections). These issues should be addressed separately.
>
> http://reviews.llvm.org/D14354
>
> Files:
>   include/clang/Driver/Options.td
>   lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -3876,6 +3876,14 @@
>  CmdArgs.push_back("-split-dwarf=Enable");
>}
>
> +  // -gdwarf-accel-tables should turn on -g and enable the genereation of
> the
> +  // dwarf acceleration tables in the backend.
> +  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {
> +DebugInfoKind = CodeGenOptions::LimitedDebugInfo;
> +CmdArgs.push_back("-backend-option");
> +CmdArgs.push_back("-dwarf-accel-tables=Enable");
> +  }
> +
>// After we've dealt with all combinations of things that could
>// make DebugInfoKind be other than None or DebugLineTablesOnly,
>// figure out if we need to "upgrade" it to standalone debug info.
> Index: include/clang/Driver/Options.td
> ===
> --- include/clang/Driver/Options.td
> +++ include/clang/Driver/Options.td
> @@ -1161,6 +1161,7 @@
>  def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
>  def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
>  def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
> +def gdwarf_accel_tables : Flag<["-"], "gdwarf-accel-tables">,
> Group;
>  def gmodules : Flag <["-"], "gmodules">, Group,
>HelpText<"Generate debug info with external references to clang modules"
> " or precompiled headers">;
>
>
>

-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14384: [ARM] Clang gives unintended warning message for 'mthumb' + M-profiles

2015-11-05 Thread Alexandros Lamprineas via cfe-commits
labrinea created this revision.
labrinea added reviewers: cfe-commits, rengolin.
Herald added subscribers: rengolin, aemerson.

```
$ clang --target=armv7m-none-eabi -mthumb -march=armv7-m -c test.c
clang-3.8: warning: argument unused during compilation: '-mthumb'
```

http://reviews.llvm.org/D14384

Files:
  lib/Driver/ToolChain.cpp

Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, 
ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14384: [ARM] Clang gives unintended warning message for 'mthumb' + M-profiles

2015-11-05 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


http://reviews.llvm.org/D14384



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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 39376.
alexfh marked an inline comment as done.
alexfh added a comment.

Addressed review comments.


http://reviews.llvm.org/D14192

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  test/clang-tidy/custom-diagnostics.cpp

Index: test/clang-tidy/custom-diagnostics.cpp
===
--- /dev/null
+++ test/clang-tidy/custom-diagnostics.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' %s -- | count 0
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN:   -config='{ExtraArgs: ["-Wshadow","-Wno-unused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wfloat-conversion","-Wunused-variable"]}' %s -- \
+// RUN:   | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+void f(float x) {
+  int a;
+  { int a; }
+  // CHECK: :[[@LINE-1]]:9: warning: declaration shadows a local variable [clang-diagnostic-shadow]
+  int b = x;
+  // CHECK: :[[@LINE-1]]:11: warning: implicit conversion turns floating-point number into integer: 'float' to 'int' [clang-diagnostic-float-conversion]
+}
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -83,6 +83,14 @@
 
   /// \brief Key-value mapping used to store check-specific options.
   OptionMap CheckOptions;
+
+  typedef std::vector ArgList;
+
+  /// \brief Add extra compilation arguments to the end of the list.
+  llvm::Optional ExtraArgs;
+
+  /// \brief Add extra compilation arguments to the start of the list.
+  llvm::Optional ExtraArgsBefore;
 };
 
 /// \brief Abstract interface for retrieving various ClangTidy options.
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -27,6 +27,7 @@
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
 LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair)
+LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
 
 namespace llvm {
 namespace yaml {
@@ -88,6 +89,8 @@
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
+IO.mapOptional("ExtraArgs", Options.ExtraArgs);
+IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
   }
 };
 
@@ -129,6 +132,10 @@
 Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors;
   if (Other.User)
 Result.User = Other.User;
+  if (Other.ExtraArgs)
+Result.ExtraArgs = Other.ExtraArgs;
+  if (Other.ExtraArgsBefore)
+Result.ExtraArgsBefore = Other.ExtraArgsBefore;
 
   for (const auto  : Other.CheckOptions)
 Result.CheckOptions[KeyValue.first] = KeyValue.second;
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -36,6 +36,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
@@ -376,6 +377,20 @@
  std::vector *Errors, ProfileData *Profile) {
   ClangTool Tool(Compilations, InputFiles);
   clang::tidy::ClangTidyContext Context(std::move(OptionsProvider));
+  ArgumentsAdjuster PerFileExtraArgumentsInserter = [](
+  const CommandLineArguments , StringRef Filename) {
+Context.setCurrentFile(Filename);
+const ClangTidyOptions  = Context.getOptions();
+CommandLineArguments AdjustedArgs;
+if (Opts.ExtraArgsBefore)
+  AdjustedArgs = *Opts.ExtraArgsBefore;
+AdjustedArgs.insert(AdjustedArgs.begin(), Args.begin(), Args.end());
+if (Opts.ExtraArgs)
+  AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(),
+  Opts.ExtraArgs->end());
+return AdjustedArgs;
+  };
+  Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
   if (Profile)
 Context.setCheckProfileData(Profile);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14385: Correct atomic libcall support for __atomic_*_fetch builtins.

2015-11-05 Thread James Y Knight via cfe-commits
jyknight created this revision.
jyknight added a reviewer: rsmith.
jyknight added subscribers: majnemer, compnerd, cfe-commits, tstellarAMD.

In r244063, I had caused these builtins to call the same-named library
functions, __atomic_*_fetch_SIZE. However, this was incorrect: while
those functions are in fact supported by GCC's libatomic, they're not
documented by the spec (and gcc doesn't ever call them).

Instead, you're /supposed/ to call the __atomic_fetch_* builtins and
then redo the operation inline to return the final value.

http://reviews.llvm.org/D14385

Files:
  lib/CodeGen/CGAtomic.cpp
  test/CodeGen/atomic-ops-libcall.c

Index: test/CodeGen/atomic-ops-libcall.c
===
--- test/CodeGen/atomic-ops-libcall.c
+++ test/CodeGen/atomic-ops-libcall.c
@@ -74,36 +74,43 @@
 
 int test_atomic_add_fetch(int *p) {
   // CHECK: test_atomic_add_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_add_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: {{%[^ ]*}} = add i32 [[CALL]], 55
   return __atomic_add_fetch(p, 55, memory_order_seq_cst);
 }
 
 int test_atomic_sub_fetch(int *p) {
   // CHECK: test_atomic_sub_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_sub_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: {{%[^ ]*}} = add i32 [[CALL]], -55
   return __atomic_sub_fetch(p, 55, memory_order_seq_cst);
 }
 
 int test_atomic_and_fetch(int *p) {
   // CHECK: test_atomic_and_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_and_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_and_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: {{%[^ ]*}} = and i32 [[CALL]], 55
   return __atomic_and_fetch(p, 55, memory_order_seq_cst);
 }
 
 int test_atomic_or_fetch(int *p) {
   // CHECK: test_atomic_or_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_or_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_or_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: {{%[^ ]*}} = or i32 [[CALL]], 55
   return __atomic_or_fetch(p, 55, memory_order_seq_cst);
 }
 
 int test_atomic_xor_fetch(int *p) {
   // CHECK: test_atomic_xor_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_xor_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_xor_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: {{%[^ ]*}} = xor i32 [[CALL]], 55
   return __atomic_xor_fetch(p, 55, memory_order_seq_cst);
 }
 
 int test_atomic_nand_fetch(int *p) {
   // CHECK: test_atomic_nand_fetch
-  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_nand_fetch_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[CALL:%[^ ]*]] = tail call i32 @__atomic_fetch_nand_4(i8* {{%[0-9]+}}, i32 55, i32 5)
+  // CHECK: [[OR:%[^ ]*]] = or i32 [[CALL]], -56
+  // CHECK: {{%[^ ]*}} = xor i32 [[OR]], 55
   return __atomic_nand_fetch(p, 55, memory_order_seq_cst);
 }
Index: lib/CodeGen/CGAtomic.cpp
===
--- lib/CodeGen/CGAtomic.cpp
+++ lib/CodeGen/CGAtomic.cpp
@@ -609,8 +609,8 @@
 break;
 
   case AtomicExpr::AO__atomic_nand_fetch:
-PostOp = llvm::Instruction::And;
-// Fall through.
+PostOp = llvm::Instruction::And; // the NOT is special cased below
+  // Fall through.
   case AtomicExpr::AO__atomic_fetch_nand:
 Op = llvm::AtomicRMWInst::Nand;
 break;
@@ -840,6 +840,7 @@
   MemTy->isPointerType() ? getContext().getIntPtrType() : MemTy;
 QualType RetTy;
 bool HaveRetTy = false;
+llvm::Instruction::BinaryOps PostOp = (llvm::Instruction::BinaryOps)0;
 switch (E->getOp()) {
 case AtomicExpr::AO__c11_atomic_init:
   llvm_unreachable("Already handled!");
@@ -893,84 +894,71 @@
 case AtomicExpr::AO__atomic_load_n:
   LibCallName = "__atomic_load";
   break;
+// T __atomic_add_fetch_N(T *mem, T val, int order)
 // T __atomic_fetch_add_N(T *mem, T val, int order)
+case AtomicExpr::AO__atomic_add_fetch:
+  PostOp = llvm::Instruction::Add;
+// Fall through.
 case AtomicExpr::AO__c11_atomic_fetch_add:
 case AtomicExpr::AO__atomic_fetch_add:
   LibCallName = "__atomic_fetch_add";
   AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1.getPointer(),
 LoweredMemTy, E->getExprLoc(), sizeChars);
   break;
+// T __atomic_and_fetch_N(T *mem, T val, int order)
 // T __atomic_fetch_and_N(T *mem, T val, int order)
+case AtomicExpr::AO__atomic_and_fetch:
+  PostOp = llvm::Instruction::And;
+// Fall through.
 case AtomicExpr::AO__c11_atomic_fetch_and:
 case AtomicExpr::AO__atomic_fetch_and:
   LibCallName = "__atomic_fetch_and";
   AddDirectArgument(*this, Args, 

Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/ClangTidyOptions.h:89-93
@@ -86,1 +88,7 @@
+
+  /// \brief Add extra compilation arguments to the end of the list.
+  llvm::Optional ExtraArgs;
+
+  /// \brief Add extra compilation arguments to the start of the list.
+  llvm::Optional ExtraArgsBefore;
 };

djasper wrote:
> Are we sure we are going to need both? Maybe for now only add the one you are 
> actually using (and testing)?
Though it's a less frequently used option, but seems to be good for consistency 
(with the clang tools' -extra-arg/-extra-arg-before pair of options) and for 
completeness. I've extended the test to verify both options and their 
interaction.


http://reviews.llvm.org/D14192



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-05 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:3407
@@ +3406,3 @@
+ : ExpectedVariableOrFunction);
+D->dropAttr();
+  }

aaron.ballman wrote:
> Why is this dropping AlwaysInlineAttr instead of returning a nullptr?
A copy/paste error. Fixed.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-05 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 39389.
eugenis marked an inline comment as done.
eugenis added a comment.

Added the new warning to a -W group.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attribute_internal_linkage.cpp
  test/Sema/attr-coldhot.c
  test/Sema/internal_linkage.c
  test/SemaCXX/internal_linkage.cpp

Index: test/SemaCXX/internal_linkage.cpp
===
--- /dev/null
+++ test/SemaCXX/internal_linkage.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int f() __attribute__((internal_linkage));
+
+class A;
+class __attribute__((internal_linkage)) A {
+public:
+  int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  static int y __attribute__((internal_linkage));
+  void f1() __attribute__((internal_linkage));
+  void f2() __attribute__((internal_linkage)) {}
+  static void f3() __attribute__((internal_linkage)) {}
+  void f4(); // expected-note{{previous definition is here}}
+  static int zz; // expected-note{{previous definition is here}}
+  A() __attribute__((internal_linkage)) {}
+  ~A() __attribute__((internal_linkage)) {}
+  A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
+  struct {
+int z  __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  };
+};
+
+__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
+
+__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
+
+namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+}
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+[[clang::internal_linkage]] int h() {}
+
+enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  a = 1,
+  b = 2
+};
+
+int A::y;
+
+void A::f1() {
+}
+
+void g(int a [[clang::internal_linkage]]) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  int x [[clang::internal_linkage]]; // expected-warning{{'internal_linkage' attribute on a non-static local variable is ignored}}
+  static int y [[clang::internal_linkage]];
+}
Index: test/Sema/internal_linkage.c
===
--- /dev/null
+++ test/Sema/internal_linkage.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((internal_linkage));
+int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+int var3 __attribute__((common,internal_linkage)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+
+int var4 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+// expected-note{{previous definition is here}}
+int var4 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}} \
+// expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'var4'}}
+
+int var5 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}}
+int var5 __attribute__((common)); // expected-note{{conflicting attribute is here}}
+
+__attribute__((internal_linkage)) int f() {}
+struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables and functions}}
+};
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
Index: test/Sema/attr-coldhot.c
===
--- test/Sema/attr-coldhot.c
+++ test/Sema/attr-coldhot.c
@@ -6,5 +6,7 @@
 int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
 int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
 
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // 

[libcxx] r252195 - Implement P0092R1 for C++1z

2015-11-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Nov  5 13:33:59 2015
New Revision: 252195

URL: http://llvm.org/viewvc/llvm-project?rev=252195=rev
Log:
Implement P0092R1 for C++1z

Added:
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp
Modified:
libcxx/trunk/include/chrono
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/chrono
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=252195=252194=252195=diff
==
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Thu Nov  5 13:33:59 2015
@@ -194,6 +194,13 @@ template 
   ToDuration duration_cast(const duration& d);
 
+template 
+constexpr ToDuration floor(const duration& d);// C++17
+template 
+constexpr ToDuration ceil(const duration& d); // C++17
+template 
+constexpr ToDuration round(const duration& d);// C++17
+
 // time_point arithmetic (all constexpr in C++14)
 template 
   time_point>::type>
@@ -227,6 +234,20 @@ template 
   time_point time_point_cast(const time_point& t);
 
+template 
+constexpr time_point
+floor(const time_point& tp);  // C++17
+
+template 
+constexpr time_point
+ceil(const time_point& tp);   // C++17
+
+template 
+constexpr time_point
+round(const time_point& tp);  // C++17
+
+template 
+constexpr duration abs(duration d);  // C++17
 // Clocks
 
 class system_clock
@@ -401,6 +422,58 @@ public:
 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  {return 
numeric_limits<_Rep>::lowest();}
 };
 
+#if _LIBCPP_STD_VER > 14
+template 
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+__is_duration<_ToDuration>::value,
+_ToDuration
+>::type
+floor(const duration<_Rep, _Period>& __d)
+{
+_ToDuration __t = duration_cast<_ToDuration>(__d);
+if (__t > __d)
+__t = __t - _ToDuration{1};
+return __t;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+__is_duration<_ToDuration>::value,
+_ToDuration
+>::type
+ceil(const duration<_Rep, _Period>& __d)
+{
+_ToDuration __t = duration_cast<_ToDuration>(__d);
+if (__t < __d)
+__t = __t + _ToDuration{1};
+return __t;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+__is_duration<_ToDuration>::value,
+_ToDuration
+>::type
+round(const duration<_Rep, _Period>& __d)
+{
+_ToDuration __lower = floor<_ToDuration>(__d);
+_ToDuration __upper = __lower + _ToDuration{1};
+auto __lowerDiff = __d - __lower;
+auto __upperDiff = __upper - __d;
+if (__lowerDiff < __upperDiff)
+return __lower;
+if (__lowerDiff > __upperDiff)
+return __upper;
+return __lower.count() & 1 ? __upper : __lower;
+}
+#endif
+
 // duration
 
 template 
@@ -807,6 +880,56 @@ time_point_cast(const time_point<_Clock,
 return time_point<_Clock, 
_ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
 }
 
+#if _LIBCPP_STD_VER > 14
+template 
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+__is_duration<_ToDuration>::value,
+time_point<_Clock, _ToDuration>
+>::type
+floor(const time_point<_Clock, _Duration>& __t)
+{
+return time_point<_Clock, 
_ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
+}
+
+template 
+inline 

RE: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2015-11-05 Thread Robinson, Paul via cfe-commits
| What was your primary motivation?
A similar concern to PR20455 from our own debugger.  It much helps matching up 
the forward declaration and definition to have the parameters properly 
specified.

| maybe it's possible to remangle the template using just the string name
I have no idea what you're talking about here.
| | Choosing to emit a forward/incomplete declaration in the first place fails 
source fidelity,
| How so?
When the source has a full definition but Clang chooses to emit only the 
declaration, per CGDebugInfo.cpp/shouldOmitDefinition().
--paulr

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Thursday, November 05, 2015 12:10 AM
To: Robinson, Paul
Cc: reviews+d14358+public+d3104135076f0...@reviews.llvm.org; cfe-commits 
(cfe-commits@lists.llvm.org)
Subject: Re: [PATCH] D14358: DWARF's forward decl of a template should have 
template parameters.



On Wed, Nov 4, 2015 at 11:32 PM, Robinson, Paul 
> 
wrote:
Would citing PR20455 help?  It wasn't actually my primary motivation but it's 
not too far off.  Having the template parameters there lets you know what's 
going on in the DWARF, without having to fetch and parse the name string of 
every struct you come across.  Actually I'm not sure parsing the name string is 
unambiguous either; each parameter is either a typename, or an expression, but 
without the parameter DIEs you don't know which, a-priori.  (What does  
mean? Depends on whether you think it should be a type name or a value; you 
can't tell, syntactically, you have to do some lookups.  Ah, but if you had the 
parameter DIEs, you would Just Know.)

For LLDB's needs, I'm not sure it's sufficient either - but I wouldn't mind an 
answer before we use it as the basis for this change (it sounds like maybe it's 
possible to remangle the template using just the string name, rather than 
needing an explicit representation of the parameters)

What was your primary motivation?

 Choosing to emit a forward/incomplete declaration in the first place fails 
source fidelity,

How so? You might have only a template declaration (template struct 
foo; foo *f;) or you may've only instantiated the declaration (the C++ 
language requires you to instantiate or avoid instantiating certain things in 
certain places, so in some contexts you /only/ have an instantiated 
declaration, not a definition)

but it is a practical engineering tradeoff of compile/link performance against 
utility; and, after all, the source *could* have been written that way, with no 
semantic difference.  But, if we're going to emit a white-lie incomplete 
declaration, we should do so correctly.

Again, "correct" in DWARF is a fairly nebulous concept.

--paulr

P.S. We should talk about this forward-declaration tactic wrt LTO sometime.  I 
have a case where a nested class got forward-declared; it's entirely 
conceivable that the outer class with the inner forward-declared class would 
end up being picked by LTO, leaving the user with no debug info for the inner 
class contents.

I believe this Just Works(tm). The things that can vary per-insntance of a type 
(implicit special members, member template implicit specializations, and nested 
types*) are not added to the type's child list, but they reference the child as 
their parent. So they continue to apply no matter which instance of the type is 
picked for uniquing (because of the name-based referencing, so the nested type 
definition just says "my parent is _Zfoo" and whatever _Zfoo we end up picking 
in the LTO linking/metadata deduplication will serve that role just fine)

* we could just do a better job of modelling nested types (& other non-globally 
scoped types) in a way that more closely models the source by emitting a 
declaration where they were declared, and a definition where they are defined 
(with the usual DW_AT_specification to wire them up)


From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Wednesday, November 04, 2015 8:30 PM
To: 
reviews+d14358+public+d3104135076f0...@reviews.llvm.org;
 Robinson, Paul
Subject: Re: [PATCH] D14358: DWARF's forward decl of a template should have 
template parameters.



On Wed, Nov 4, 2015 at 5:53 PM, Paul Robinson via cfe-commits 
> wrote:
probinson added a comment.

GCC 4.8.4 on Linux doesn't produce these, but DWARF 4 section 5.5.8 says a 
class template instantiation is just like the equivalent non-template class 
entry, with the exception of the template parameter entries.  I read that as 
meaning an incomplete description (i.e. with DW_AT_declaration) lets you omit 
all the other children, but not the template parameters.

As usual, I think it's pretty hard to argue that DWARF /requires/ anything 
(permissive & all that). And I'm not sure that having these is particularly 

Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-05 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Ok. Thanks!
I'll commit shortly.


http://reviews.llvm.org/D14014



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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-05 Thread Tamas Berghammer via cfe-commits
Adding the dwarf accelerator tables is increasing the size of libclang.so
(ToT) by ~12% so I don't think we want to generate them by default. Also
these sections are not specified by any dwarf standard at the moment so
emitting them by default would be strange in my opinion.

On Thu, Nov 5, 2015 at 8:17 AM Saleem Abdulrasool 
wrote:

>
>
> On Wednesday, November 4, 2015, Tamas Berghammer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> tberghammer created this revision.
>> tberghammer added a reviewer: echristo.
>> tberghammer added a subscriber: cfe-commits.
>>
>> Add new compiler flag to enable the generation of dwarf accelerator tables
>>
>>
> Is the additional information large enough to require a new flag?  They
> wouldn't break split debug even though they don't work there yet, so if the
> impact isn't large enough, might make sense to just enable them on -g.
>
>
>> The dwarf accelerator tables already generated on darwin platforms. This
>> CL ands a new flag to clang to make it possible to enable the generation of
>> these tables on other platforms also.
>>
>> Note: Currently the accelerator table generation code isn't working when
>> split dwarf is enabled for several reasons (accelerator tables aren't
>> copied to dwo file, they contain relocation entries for the .debug_str.dwo
>> sections). These issues should be addressed separately.
>>
>> http://reviews.llvm.org/D14354
>>
>> Files:
>>   include/clang/Driver/Options.td
>>   lib/Driver/Tools.cpp
>>
>> Index: lib/Driver/Tools.cpp
>> ===
>> --- lib/Driver/Tools.cpp
>> +++ lib/Driver/Tools.cpp
>> @@ -3876,6 +3876,14 @@
>>  CmdArgs.push_back("-split-dwarf=Enable");
>>}
>>
>> +  // -gdwarf-accel-tables should turn on -g and enable the genereation
>> of the
>> +  // dwarf acceleration tables in the backend.
>> +  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {
>> +DebugInfoKind = CodeGenOptions::LimitedDebugInfo;
>> +CmdArgs.push_back("-backend-option");
>> +CmdArgs.push_back("-dwarf-accel-tables=Enable");
>> +  }
>> +
>>// After we've dealt with all combinations of things that could
>>// make DebugInfoKind be other than None or DebugLineTablesOnly,
>>// figure out if we need to "upgrade" it to standalone debug info.
>> Index: include/clang/Driver/Options.td
>> ===
>> --- include/clang/Driver/Options.td
>> +++ include/clang/Driver/Options.td
>> @@ -1161,6 +1161,7 @@
>>  def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
>>  def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
>>  def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
>> +def gdwarf_accel_tables : Flag<["-"], "gdwarf-accel-tables">,
>> Group;
>>  def gmodules : Flag <["-"], "gmodules">, Group,
>>HelpText<"Generate debug info with external references to clang
>> modules"
>> " or precompiled headers">;
>>
>>
>>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252201 - [WebAssembly] Update wasm builtin functions to match spec changes.

2015-11-05 Thread Dan Gohman via cfe-commits
Author: djg
Date: Thu Nov  5 14:16:37 2015
New Revision: 252201

URL: http://llvm.org/viewvc/llvm-project?rev=252201=rev
Log:
[WebAssembly] Update wasm builtin functions to match spec changes.

The page_size operator has been removed from the spec, and the resize_memory
operator has been changed to grow_memory.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=252201=252200=252201=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Thu Nov  5 14:16:37 
2015
@@ -16,8 +16,7 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
-BUILTIN(__builtin_wasm_page_size, "z", "nc")
 BUILTIN(__builtin_wasm_memory_size, "z", "nc")
-BUILTIN(__builtin_wasm_resize_memory, "vz", "n")
+BUILTIN(__builtin_wasm_grow_memory, "vz", "n")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=252201=252200=252201=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Nov  5 14:16:37 2015
@@ -7274,19 +7274,14 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
   switch (BuiltinID) {
-  case WebAssembly::BI__builtin_wasm_page_size: {
-llvm::Type *ResultType = ConvertType(E->getType());
-Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_page_size, ResultType);
-return Builder.CreateCall(Callee);
-  }
   case WebAssembly::BI__builtin_wasm_memory_size: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_size, ResultType);
 return Builder.CreateCall(Callee);
   }
-  case WebAssembly::BI__builtin_wasm_resize_memory: {
+  case WebAssembly::BI__builtin_wasm_grow_memory: {
 Value *X = EmitScalarExpr(E->getArg(0));
-Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_resize_memory, 
X->getType());
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_grow_memory, 
X->getType());
 return Builder.CreateCall(Callee, X);
   }
 

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=252201=252200=252201=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Thu Nov  5 14:16:37 2015
@@ -3,12 +3,6 @@
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -O3 -emit-llvm -o - %s \
 // RUN:   | FileCheck %s -check-prefix=WEBASSEMBLY64
 
-__SIZE_TYPE__ f0(void) {
-  return __builtin_wasm_page_size();
-// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.page.size.i32()
-// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.page.size.i64()
-}
-
 __SIZE_TYPE__ f1(void) {
   return __builtin_wasm_memory_size();
 // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32()
@@ -16,7 +10,7 @@ __SIZE_TYPE__ f1(void) {
 }
 
 void f2(long delta) {
-  __builtin_wasm_resize_memory(delta);
-// WEBASSEMBLY32: call void @llvm.wasm.resize.memory.i32(i32 %{{.*}})
-// WEBASSEMBLY64: call void @llvm.wasm.resize.memory.i64(i64 %{{.*}})
+  __builtin_wasm_grow_memory(delta);
+// WEBASSEMBLY32: call void @llvm.wasm.grow.memory.i32(i32 %{{.*}})
+// WEBASSEMBLY64: call void @llvm.wasm.grow.memory.i64(i64 %{{.*}})
 }


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


Re: [PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-05 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 39386.
nwilson added a comment.

- replace hyphen and apostrophe with equivalent ASCII characters


http://reviews.llvm.org/D14352

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-05 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D14352



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


[libcxx] r252199 - Mark LWG issue #2234. We already do this; no code change needed

2015-11-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Nov  5 13:57:50 2015
New Revision: 252199

URL: http://llvm.org/viewvc/llvm-project?rev=252199=rev
Log:
Mark LWG issue #2234. We already do this; no code change needed

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=252199=252198=252199=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Nov  5 13:57:50 2015
@@ -158,7 +158,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2218;>2218Unclear
 how containers use 
allocator_traits::construct()Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2219;>2219INVOKE-ing
 a pointer to member with a reference_wrapper as the object 
expressionKona
http://cplusplus.github.io/LWG/lwg-defects.html#2224;>2224Ambiguous
 status of access to non-live objectsKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2234;>2234assert()
 should allow usage in constant expressionsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2234;>2234assert()
 should allow usage in constant 
expressionsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2244;>2244Issue
 on basic_istream::seekgKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2250;>2250Follow-up
 On Library Issue 2207Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2259;>2259Issues
 in 17.6.5.5 rules for member functionsKonaComplete


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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-05 Thread Tamas Berghammer via cfe-commits
tberghammer updated this revision to Diff 39385.
tberghammer added a comment.

Add a test (I have no experience writing clang tests so please let me know if I 
approach is wrong)


http://reviews.llvm.org/D14354

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/dwarf-accel.c

Index: test/Driver/dwarf-accel.c
===
--- /dev/null
+++ test/Driver/dwarf-accel.c
@@ -0,0 +1,6 @@
+// Check that -gdwarf-accel-tables requests the emission of the accelerator 
tables
+//
+// RUN: %clang -target x86_64-unknown-linux-gnu -gdwarf-accel-tables -c -### 
%s 2> %t
+// RUN: FileCheck -check-prefix=CHECK < %t %s
+//
+// CHECK: -dwarf-accel-tables=Enable
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3876,6 +3876,14 @@
 CmdArgs.push_back("-split-dwarf=Enable");
   }
 
+  // -gdwarf-accel-tables should turn on -g and enable the genereation of the
+  // dwarf acceleration tables in the backend.
+  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {
+DebugInfoKind = CodeGenOptions::LimitedDebugInfo;
+CmdArgs.push_back("-backend-option");
+CmdArgs.push_back("-dwarf-accel-tables=Enable");
+  }
+
   // After we've dealt with all combinations of things that could
   // make DebugInfoKind be other than None or DebugLineTablesOnly,
   // figure out if we need to "upgrade" it to standalone debug info.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1161,6 +1161,7 @@
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
+def gdwarf_accel_tables : Flag<["-"], "gdwarf-accel-tables">, 
Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;


Index: test/Driver/dwarf-accel.c
===
--- /dev/null
+++ test/Driver/dwarf-accel.c
@@ -0,0 +1,6 @@
+// Check that -gdwarf-accel-tables requests the emission of the accelerator tables
+//
+// RUN: %clang -target x86_64-unknown-linux-gnu -gdwarf-accel-tables -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK < %t %s
+//
+// CHECK: -dwarf-accel-tables=Enable
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3876,6 +3876,14 @@
 CmdArgs.push_back("-split-dwarf=Enable");
   }
 
+  // -gdwarf-accel-tables should turn on -g and enable the genereation of the
+  // dwarf acceleration tables in the backend.
+  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {
+DebugInfoKind = CodeGenOptions::LimitedDebugInfo;
+CmdArgs.push_back("-backend-option");
+CmdArgs.push_back("-dwarf-accel-tables=Enable");
+  }
+
   // After we've dealt with all combinations of things that could
   // make DebugInfoKind be other than None or DebugLineTablesOnly,
   // figure out if we need to "upgrade" it to standalone debug info.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1161,6 +1161,7 @@
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
+def gdwarf_accel_tables : Flag<["-"], "gdwarf-accel-tables">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252187 - After some discussion, promote -fobjc-weak to a driver option.

2015-11-05 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Nov  5 13:19:56 2015
New Revision: 252187

URL: http://llvm.org/viewvc/llvm-project?rev=252187=rev
Log:
After some discussion, promote -fobjc-weak to a driver option.

rdar://problem/23415863

Added:
cfe/trunk/test/Driver/objc-weak.m
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=252187=252186=252187=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Nov  5 13:19:56 2015
@@ -518,8 +518,6 @@ def fobjc_runtime_has_weak : Flag<["-"],
   HelpText<"The target Objective-C runtime supports ARC weak operations">;
 def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">,
   HelpText<"Objective-C dispatch method to use">;
-def fobjc_weak : Flag<["-"], "fobjc-weak">, Group,
-  HelpText<"Enable ARC-style __weak references">;
 def disable_objc_default_synthesize_properties : Flag<["-"], 
"disable-objc-default-synthesize-properties">,
   HelpText<"disable the default synthesis of Objective-C properties">;
 def fencode_extended_block_signature : Flag<["-"], 
"fencode-extended-block-signature">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=252187=252186=252187=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Nov  5 13:19:56 2015
@@ -852,6 +852,7 @@ def fno_ms_compatibility : Flag<["-"], "
 def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
+def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;
 def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group;
 def fno_operator_names : Flag<["-"], "fno-operator-names">, Group,
   HelpText<"Do not treat C++ operator name keywords as synonyms for 
operators">,
@@ -921,6 +922,8 @@ def fno_objc_infer_related_result_type :
 "do not infer Objective-C related result type based on method family">,
   Flags<[CC1Option]>;
 def fobjc_link_runtime: Flag<["-"], "fobjc-link-runtime">, Group;
+def fobjc_weak : Flag<["-"], "fobjc-weak">, Group, Flags<[CC1Option]>,
+  HelpText<"Enable ARC-style weak references in Objective-C">;
 
 // Objective-C ABI options.
 def fobjc_runtime_EQ : Joined<["-"], "fobjc-runtime=">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=252187=252186=252187=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Nov  5 13:19:56 2015
@@ -4816,6 +4816,23 @@ void Clang::ConstructJob(Compilation ,
 }
   }
 
+  // Pass down -fobjc-weak or -fno-objc-weak if present.
+  if (types::isObjC(InputType)) {
+auto WeakArg = Args.getLastArg(options::OPT_fobjc_weak,
+   options::OPT_fno_objc_weak);
+if (!WeakArg) {
+  // nothing to do
+} else if (GCArg) {
+  if (WeakArg->getOption().matches(options::OPT_fobjc_weak))
+D.Diag(diag::err_objc_weak_with_gc);
+} else if (!objcRuntime.allowsWeak()) {
+  if (WeakArg->getOption().matches(options::OPT_fobjc_weak))
+D.Diag(diag::err_objc_weak_unsupported);
+} else {
+  WeakArg->render(Args, CmdArgs);
+}
+  }
+
   if (Args.hasFlag(options::OPT_fapplication_extension,
options::OPT_fno_application_extension, false))
 CmdArgs.push_back("-fapplication-extension");

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=252187=252186=252187=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Nov  5 13:19:56 2015
@@ -1483,16 +1483,19 @@ static void ParseLangArgs(LangOptions 
   Opts.ObjCWeakRuntime = Opts.ObjCRuntime.allowsWeak();
 
 // ObjCWeak determines whether __weak is actually enabled.
-if (Opts.ObjCAutoRefCount) {
-  Opts.ObjCWeak = Opts.ObjCWeakRuntime;
-} else if (Args.hasArg(OPT_fobjc_weak)) {
-  if (Opts.getGC() != LangOptions::NonGC) {
+// Note that we allow -fno-objc-weak to disable this even in ARC mode.
+if (auto 

Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

PTAL


http://reviews.llvm.org/D14192



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


Re: [PATCH] D10025: Refactor: Simplify boolean conditional return statements in clang-apply-replacements

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh closed this revision.
alexfh added a comment.

Committed revision 252207.


http://reviews.llvm.org/D10025



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


Re: [PATCH] D9556: [clang-tidy] Support for Static Analyzer plugins (clang part)

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

http://reviews.llvm.org/D9555 depends on this patch. Are these two patches 
still interesting to someone?


http://reviews.llvm.org/D9556



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


Re: [PATCH] D14266: CodeGen: Update for debug info API change.Depends on D14265.

2015-11-05 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252220: CodeGen: Update for debug info API change. (authored 
by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D14266?vs=39004=39414#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14266

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-block-decl.c
  cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
  cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp
  cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
  cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Index: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
===
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
@@ -10,14 +10,14 @@
 
 void Derived::VariadicFunction(...) { }
 
-// CHECK-LABEL: define void @_ZN7Derived16VariadicFunctionEz(
+// CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg ![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
 // CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
 //
 // CHECK: !llvm.dbg.cu = !{![[CU:[0-9]+]]}
 //
 // CHECK: ![[CU]] = distinct !DICompileUnit({{.*}} subprograms: ![[SPs:[0-9]+]]
-// CHECK: ![[SPs]] = !{![[SP:[0-9]+]]}
-// CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction",{{.*}} function: {{[^:]+}} @_ZN7Derived16VariadicFunctionEz
+// CHECK: ![[SPs]] = !{![[SP]]}
+// CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
Index: cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
@@ -7,7 +7,7 @@
 }
 
 // Verify that a is present and mangled.
-// CHECK: !DISubprogram(name: "a", linkageName: "_ZN1AL1aEi",
+// CHECK: define internal i32 @_ZN1AL1aEi({{.*}} !dbg [[DBG:![0-9]+]]
+// CHECK: [[DBG]] = distinct !DISubprogram(name: "a", linkageName: "_ZN1AL1aEi",
 // CHECK-SAME:  line: 4
 // CHECK-SAME:  isDefinition: true
-// CHECK-SAME:  function: i32 (i32)* @_ZN1AL1aEi
Index: cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp
===
--- cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp
+++ cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp
@@ -4,7 +4,7 @@
 // Verify that the global init helper function does not get associated
 // with any source location.
 //
-// CHECK: define internal {{.*}}void @_GLOBAL__sub_I_globalinit_loc.cpp
+// CHECK: define internal {{.*}}void @_GLOBAL__sub_I_globalinit_loc.cpp({{.*}} {
 // CHECK: !dbg ![[DBG:.*]]
 // CHECK: !DISubprogram(linkageName: "_GLOBAL__sub_I_globalinit_loc.cpp"
 // CHECK-NOT:   line:
Index: cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
@@ -14,9 +14,9 @@
 
 template struct AB;
 
-// CHECK-LABEL: define {{.*}}@"\01??_E?$AB@H@@W3AEPAXI@Z"
+// CHECK: define {{.*}}@"\01??_E?$AB@H@@W3AEPAXI@Z"({{.*}} !dbg [[THUNK_VEC_DEL_DTOR:![0-9]*]]
 // CHECK: call {{.*}}@"\01??_G?$AB@H@@UAEPAXI@Z"({{.*}}) #{{[0-9]*}}, !dbg [[THUNK_LOC:![0-9]*]]
-// CHECK-LABEL: define
+// CHECK: define
 
-// CHECK: [[THUNK_VEC_DEL_DTOR:![0-9]*]] = distinct !DISubprogram({{.*}}function: {{.*}}@"\01??_E?$AB@H@@W3AEPAXI@Z"
+// CHECK: [[THUNK_VEC_DEL_DTOR]] = distinct !DISubprogram
 // CHECK: [[THUNK_LOC]] = !DILocation(line: 15, scope: [[THUNK_VEC_DEL_DTOR]])
Index: cfe/trunk/test/CodeGenObjCXX/property-objects.mm
===
--- cfe/trunk/test/CodeGenObjCXX/property-objects.mm
+++ cfe/trunk/test/CodeGenObjCXX/property-objects.mm
@@ -37,7 +37,7 @@
 
 // Don't attach debug locations to the prologue instructions. These were
 // leaking over from the previous function emission by accident.
-// CHECK: define internal void @"\01-[I setBounds:]"
+// CHECK: define internal void @"\01-[I setBounds:]"({{.*}} {
 // CHECK-NOT: !dbg
 // CHECK: call void @llvm.dbg.declare
 - (void)setFrame:(CGRect)frameRect {}
Index: cfe/trunk/test/CodeGen/debug-info-block-decl.c
===
--- cfe/trunk/test/CodeGen/debug-info-block-decl.c
+++ cfe/trunk/test/CodeGen/debug-info-block-decl.c
@@ -5,7 +5,7 @@
 // CHECK: define{{.*}}@main()
 // CHECK: store{{.*}}bitcast{{.*}}, !dbg ![[ASSIGNMENT:[0-9]+]]
 // CHECK: define {{.*}} @__main_block_invoke
-// CHECK: dbg ![[BLOCK_ENTRY:[0-9]+]]
+// CHECK: , !dbg ![[BLOCK_ENTRY:[0-9]+]]
 
 int main()
 {
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

r252220 - CodeGen: Update for debug info API change.

2015-11-05 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Nov  5 16:04:14 2015
New Revision: 252220

URL: http://llvm.org/viewvc/llvm-project?rev=252220=rev
Log:
CodeGen: Update for debug info API change.

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info-block-decl.c
cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
cfe/trunk/test/CodeGenCXX/globalinit-loc.cpp
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=252220=252219=252220=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov  5 16:04:14 2015
@@ -1183,7 +1183,7 @@ llvm::DISubprogram *CGDebugInfo::CreateC
   RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
   MethodTy, /*isLocalToUnit=*/false,
   /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags,
-  CGM.getLangOpts().Optimize, nullptr, TParamsArray.get());
+  CGM.getLangOpts().Optimize, TParamsArray.get());
 
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
@@ -2486,7 +2486,7 @@ CGDebugInfo::getFunctionForwardDeclarati
   llvm::DISubprogram *SP = DBuilder.createTempFunctionFwdDecl(
   DContext, Name, LinkageName, Unit, Line,
   getOrCreateFunctionType(FD, FnType, Unit), !FD->isExternallyVisible(),
-  /* isDefinition = */ false, 0, Flags, CGM.getLangOpts().Optimize, 
nullptr,
+  /* isDefinition = */ false, 0, Flags, CGM.getLangOpts().Optimize,
   TParamsArray.get(), getFunctionDeclaration(FD));
   const FunctionDecl *CanonDecl = cast(FD->getCanonicalDecl());
   FwdDeclReplaceMap.emplace_back(std::piecewise_construct,
@@ -2699,8 +2699,9 @@ void CGDebugInfo::EmitFunctionStart(Glob
   llvm::DISubprogram *SP = DBuilder.createFunction(
   FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),
-  true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn,
+  true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
   TParamsArray.get(), getFunctionDeclaration(D));
+  Fn->setSubprogram(SP);
   // We might get here with a VarDecl in the case we're generating
   // code for the initialization of globals. Do not record these decls
   // as they will overwrite the actual VarDecl Decl in the cache.
@@ -2752,9 +2753,8 @@ void CGDebugInfo::EmitFunctionDecl(Globa
   DBuilder.createFunction(FDContext, Name, LinkageName, Unit, LineNo,
   getOrCreateFunctionType(D, FnType, Unit),
   false /*internalLinkage*/, true /*definition*/,
-  ScopeLine, Flags, CGM.getLangOpts().Optimize, 
nullptr,
-  TParamsArray.get(),
-  getFunctionDeclaration(D));
+  ScopeLine, Flags, CGM.getLangOpts().Optimize,
+  TParamsArray.get(), getFunctionDeclaration(D));
 }
 
 void CGDebugInfo::EmitLocation(CGBuilderTy , SourceLocation Loc) {

Modified: cfe/trunk/test/CodeGen/debug-info-block-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-block-decl.c?rev=252220=252219=252220=diff
==
--- cfe/trunk/test/CodeGen/debug-info-block-decl.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-block-decl.c Thu Nov  5 16:04:14 2015
@@ -5,7 +5,7 @@
 // CHECK: define{{.*}}@main()
 // CHECK: store{{.*}}bitcast{{.*}}, !dbg ![[ASSIGNMENT:[0-9]+]]
 // CHECK: define {{.*}} @__main_block_invoke
-// CHECK: dbg ![[BLOCK_ENTRY:[0-9]+]]
+// CHECK: , !dbg ![[BLOCK_ENTRY:[0-9]+]]
 
 int main()
 {

Modified: cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp?rev=252220=252219=252220=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-fns.cpp Thu Nov  5 16:04:14 2015
@@ -7,7 +7,7 @@ namespace A {
 }
 
 // Verify that a is present and mangled.
-// CHECK: !DISubprogram(name: "a", linkageName: "_ZN1AL1aEi",
+// CHECK: define internal i32 @_ZN1AL1aEi({{.*}} !dbg [[DBG:![0-9]+]]
+// CHECK: [[DBG]] = distinct !DISubprogram(name: "a", linkageName: 
"_ZN1AL1aEi",
 // CHECK-SAME:  line: 4
 // CHECK-SAME:  isDefinition: true
-// CHECK-SAME:  function: i32 (i32)* @_ZN1AL1aEi

Modified: cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
URL: 

Re: [PATCH] D9556: [clang-tidy] Support for Static Analyzer plugins (clang part)

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D9556#282718, @xazax.hun wrote:

> Unfortunately I had no time to work on this patch, and after I did not finish 
> this the team I was working in took a different approach: running static 
> analyzer checker through clang and tidy checkers through clang tidy. 
> Initially we wanted to avoid this approach, because they are invoked 
> differently. I have no interest finishing this patch at the moment, but I can 
> not tell for sure for the future. Should I abadon this?


If it's not needed, then probably yes.


http://reviews.llvm.org/D9556



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


r252229 - Fix crash in EmitDeclMetadata mode

2015-11-05 Thread Keno Fischer via cfe-commits
Author: kfischer
Date: Thu Nov  5 17:18:44 2015
New Revision: 252229

URL: http://llvm.org/viewvc/llvm-project?rev=252229=rev
Log:
Fix crash in EmitDeclMetadata mode

Summary: This fixes a bug that's easily encountered in LLDB
(https://llvm.org/bugs/show_bug.cgi?id=22875). The problem here is that we
mangle a name during debug info emission, but never actually emit the actual
Decl, so we run into problems in EmitDeclMetadata (which assumes such a Decl
exists). Fix that by just skipping metadata emissions for mangled names that
don't have associated Decls.

Reviewers: rjmccall

Subscribers: labath, cfe-commits

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

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=252229=252228=252229=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Nov  5 17:18:44 2015
@@ -3707,10 +3707,12 @@ bool CodeGenModule::lookupRepresentative
 void CodeGenModule::EmitDeclMetadata() {
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  // StaticLocalDeclMap
   for (auto  : MangledDeclNames) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+// Some mangled names don't necessarily have an associated GlobalValue
+// in this module, e.g. if we mangled it for DebugInfo.
+if (Addr)
+  EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
   }
 }
 


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


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-11-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252229: Fix crash in EmitDeclMetadata mode (authored by 
kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D13959?vs=38049=39426#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13959

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3707,10 +3707,12 @@
 void CodeGenModule::EmitDeclMetadata() {
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  // StaticLocalDeclMap
   for (auto  : MangledDeclNames) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+// Some mangled names don't necessarily have an associated GlobalValue
+// in this module, e.g. if we mangled it for DebugInfo.
+if (Addr)
+  EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
   }
 }
 


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3707,10 +3707,12 @@
 void CodeGenModule::EmitDeclMetadata() {
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  // StaticLocalDeclMap
   for (auto  : MangledDeclNames) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+// Some mangled names don't necessarily have an associated GlobalValue
+// in this module, e.g. if we mangled it for DebugInfo.
+if (Addr)
+  EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-05 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: www/analyzer/installation.html:103
@@ -102,3 +102,1 @@
 
-Currently these are not installed using make install, and
-are located in $(SRCDIR)/tools/clang/tools/scan-build and

@zaks.anna Do you know if there was a particular reason for this? It's kind of 
a shame to have to use them from the src dir.


http://reviews.llvm.org/D14403



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


[clang-tools-extra] r252248 - [clang-tidy] readability-named-parameter: don't complain about implicit parameters

2015-11-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Nov  5 18:19:21 2015
New Revision: 252248

URL: http://llvm.org/viewvc/llvm-project?rev=252248=rev
Log:
[clang-tidy] readability-named-parameter: don't complain about implicit 
parameters


Fixes http://llvm.org/PR24464.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-named-parameter.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.cpp?rev=252248=252247=252248=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.cpp Thu 
Nov  5 18:19:21 2015
@@ -45,6 +45,8 @@ void NamedParameterCheck::check(const Ma
   //   arguments in the same position.
   for (unsigned I = 0, E = Function->getNumParams(); I != E; ++I) {
 const ParmVarDecl *Parm = Function->getParamDecl(I);
+if (Parm->isImplicit())
+  continue;
 // Look for unnamed parameters.
 if (!Parm->getName().empty())
   continue;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-named-parameter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-named-parameter.cpp?rev=252248=252247=252248=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-named-parameter.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-named-parameter.cpp Thu 
Nov  5 18:19:21 2015
@@ -127,3 +127,7 @@ typedef decltype(nullptr) nullptr_t;
 }
 
 void f(std::nullptr_t) {}
+
+typedef void (F)(int);
+F f;
+void f(int x) {}


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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-05 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

So, currently you get accel tables by default for platforms that "tune" for 
LLDB, currently Darwin and FreeBSD.
Are you wanting to use LLDB on another platform, or did you want accel tables 
for a different debugger?

(Eventually I will have a chance to expose the "tuning" up through Clang, and 
if you're running LLDB on another platform, that will be the easier way to get 
what you want.)



Comment at: test/Driver/dwarf-accel.c:4
@@ +3,3 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -gdwarf-accel-tables -c -### 
%s 2> %t
+// RUN: FileCheck -check-prefix=CHECK < %t %s
+//

Normally you'd just pipe the output to FileCheck rather than write a temp file, 
because that's more efficient. There are lots of examples to crib from in other 
tests.


http://reviews.llvm.org/D14354



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


[clang-tools-extra] r252207 - Refactor: Simplify boolean conditional return statements in clang-apply-replacements

2015-11-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Nov  5 14:59:17 2015
New Revision: 252207

URL: http://llvm.org/viewvc/llvm-project?rev=252207=rev
Log:
Refactor: Simplify boolean conditional return statements in 
clang-apply-replacements

Differential revision: http://reviews.llvm.org/D10025

Patch by Richard Thomson!

Modified:

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=252207=252206=252207=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Thu Nov  5 14:59:17 2015
@@ -184,10 +184,7 @@ bool mergeAndDeduplicate(const TUReplace
   }
 
   // Ask clang to deduplicate and report conflicts.
-  if (deduplicateAndDetectConflicts(GroupedReplacements, SM))
-return false;
-
-  return true;
+  return !deduplicateAndDetectConflicts(GroupedReplacements, SM);
 }
 
 bool applyReplacements(const FileToReplacementsMap ,


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


Re: [PATCH] D9556: [clang-tidy] Support for Static Analyzer plugins (clang part)

2015-11-05 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Unfortunately I had no time to work on this patch, and after I did not finish 
this the team I was working in took a different approach: running static 
analyzer checker through clang and tidy checkers through clang tidy. Initially 
we wanted to avoid this approach, because they are invoked differently. I have 
no interest finishing this patch at the moment, but I can not tell for sure for 
the future. Should I abadon this?


http://reviews.llvm.org/D9556



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


r252223 - Better link for Library Fundamentals TS.

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 16:21:52 2015
New Revision: 252223

URL: http://llvm.org/viewvc/llvm-project?rev=252223=rev
Log:
Better link for Library Fundamentals TS.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=252223=25=252223=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov  5 16:21:52 2015
@@ -661,7 +661,7 @@ Clang version they became available:
 
 
   [TS] Library Fundamentals, Version 1 (invocation type traits)
-  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4335.html;>N4335
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html;>N4480
   No
 
 


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


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-05 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: lib/Driver/Tools.cpp:3415
@@ -3414,1 +3414,3 @@
 
+  CmdArgs.push_back("-meabi");
+  if (Arg *A = Args.getLastArg(options::OPT_meabi))

Shouldn't we only add the option if it was used in the command line?


Comment at: lib/Frontend/CompilerInvocation.cpp:459
@@ +458,3 @@
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+ .Case("default", true)

tinti wrote:
> This part of the code does not include TargetOptions.h (so EABI is an 
> undefined type). Can I add it here?
If you mean up there, at the beginning of the file, then I suspect you should. 
Though, I though some other header would get it by now. If they don't, then 
please add it.


Repository:
  rL LLVM

http://reviews.llvm.org/D14184



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


r252211 - PR25368: Replace workaround for build failure with modules enabled with a fix

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 15:16:22 2015
New Revision: 252211

URL: http://llvm.org/viewvc/llvm-project?rev=252211=rev
Log:
PR25368: Replace workaround for build failure with modules enabled with a fix
for the root cause. The 'using llvm::isa;' declaration in Basic/LLVM.h only
pulls the declarations of llvm::isa that were declared prior to it into
namespace clang. In a modules build, this is a hermetic set of just the
declarations from LLVM. In a non-modules build, we happened to also pull the
declaration from lib/CodeGen/Address.h into namespace clang, which made the
code in question accidentally compile.

Modified:
cfe/trunk/lib/CodeGen/Address.h
cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Modified: cfe/trunk/lib/CodeGen/Address.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Address.h?rev=252211=252210=252211=diff
==
--- cfe/trunk/lib/CodeGen/Address.h (original)
+++ cfe/trunk/lib/CodeGen/Address.h Thu Nov  5 15:16:22 2015
@@ -116,4 +116,11 @@ namespace llvm {
   }
 }
 
+namespace clang {
+  // Make our custom isa and cast available in namespace clang, to mirror
+  // what we do for LLVM's versions in Basic/LLVM.h.
+  using llvm::isa;
+  using llvm::cast;
+}
+
 #endif

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=252211=252210=252211=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Nov  5 15:16:22 2015
@@ -1038,7 +1038,7 @@ public:
   unsigned Type = cast(E)->getIdentType();
   if (CGF) {
 LValue Res = CGF->EmitPredefinedLValue(cast(E));
-return llvm::cast(Res.getAddress());
+return cast(Res.getAddress());
   } else if (Type == PredefinedExpr::PrettyFunction) {
 return CGM.GetAddrOfConstantCString("top level", ".tmp");
   }


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


Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-05 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Sounds good!


http://reviews.llvm.org/D14014



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


Re: [PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh added a comment.

A peanut gallery comment.



Comment at: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp:91
@@ +90,3 @@
+  diag_builder << FixItHint::CreateReplacement(ParenRange, CastText);
+} else
+  diag(

Please add braces around the `else` body.


http://reviews.llvm.org/D14096



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


r252206 - Improve macro dumping to preserve semantically-relevant spelling information.

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 14:55:14 2015
New Revision: 252206

URL: http://llvm.org/viewvc/llvm-project?rev=252206=rev
Log:
Improve macro dumping to preserve semantically-relevant spelling information.

Modified:
cfe/trunk/lib/Lex/MacroInfo.cpp

Modified: cfe/trunk/lib/Lex/MacroInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroInfo.cpp?rev=252206=252205=252206=diff
==
--- cfe/trunk/lib/Lex/MacroInfo.cpp (original)
+++ cfe/trunk/lib/Lex/MacroInfo.cpp Thu Nov  5 14:55:14 2015
@@ -154,16 +154,20 @@ void MacroInfo::dump() const {
 Out << ")";
   }
 
+  bool First = true;
   for (const Token  : ReplacementTokens) {
-Out << " ";
+// Leading space is semantically meaningful in a macro definition,
+// so preserve it in the dump output.
+if (First || Tok.hasLeadingSpace())
+  Out << " ";
+First = false;
+
 if (const char *Punc = tok::getPunctuatorSpelling(Tok.getKind()))
   Out << Punc;
-else if (const char *Kwd = tok::getKeywordSpelling(Tok.getKind()))
-  Out << Kwd;
-else if (Tok.is(tok::identifier))
-  Out << Tok.getIdentifierInfo()->getName();
 else if (Tok.isLiteral() && Tok.getLiteralData())
   Out << StringRef(Tok.getLiteralData(), Tok.getLength());
+else if (auto *II = Tok.getIdentifierInfo())
+  Out << II->getName();
 else
   Out << Tok.getName();
   }


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


Re: [PATCH] D9556: [clang-tidy] Support for Static Analyzer plugins (clang part)

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

What's the state here?


http://reviews.llvm.org/D9556



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


Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo removed a reviewer: majnemer.
lvoufo updated this revision to Diff 39411.
lvoufo added a comment.

Remove commented out line -- Offsets not needed on invariant_end calls after 
all.


http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -37,8 +37,8 @@
 #if defined(OBJ)
 struct A {
   int a;
-  int b;
-  A(int a) : a(a) {}
+  Const int b;
+  A(int a) : a(a), b(a) {}
 };
 
 // A with explicit destructor
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -260,9 +260,11 @@
   typedef std::vector CtorList;
 
   struct InvariantArgs {
-llvm::CallInst *StartInst;
-llvm::Value *Size;
+llvm::CallInst *StartInst;  // TODO: Is this necessary?
+llvm::Value *Size;  // TODO: Is this necessary?
 llvm::Value *Addr;
+llvm::SmallVector Offsets;
+
 InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
 InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
 : StartInst(C), Size(S), Addr(A) {}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1905,9 +1905,9 @@
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
   CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr);
-  void EmitInvariantEnd(llvm::CallInst *C, llvm::Value *Size,
-llvm::Value *Addr);
+  llvm::Value *Addr,
+  bool IsGlobalConstant = true);
+  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,15 +530,12 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-llvm::CallInst *StartInst;
-llvm::Value *Addr;
-llvm::Value *Size;  // TODO: Is this even necessary?
+CodeGenModule::InvariantArgs Args;
public:
-CallInvariantEnd(llvm::CallInst *C, llvm::Value *addr, llvm::Value *size)
-: StartInst(C), Addr(addr), Size(size) {}
+CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
-  CGF.EmitInvariantEnd(StartInst, Size, Addr);
+  CGF.EmitInvariantEnd(Args);
 }
   };
 }
@@ -881,16 +878,14 @@
   // If the address is writeonce, then emit @llvm.invariant.start() intrinsic.
   // Then, for non-global variables, push the emission of the
   // @llvm.invariant.end() intrinsic onto the cleanup stack.
-  if ((AI || !GV->isConstant()) && D->getType().isWriteOnce(CGF.getContext()))
-Args = CGF.EmitInvariantStart(*D, AddrPtr);
+  if (AI || !GV->isConstant())
+Args = CGF.EmitInvariantStart(*D, AddrPtr, /*IsGlobalConstant =*/false);
 }
 
 MarkWriteOnceWrittenRAII::~MarkWriteOnceWrittenRAII() {
-  if (AI && Args.StartInst) {
-assert(!GV && "Can't have it both ways!");
-CGF.EHStack.pushCleanup(NormalCleanup, Args.StartInst,
-  Args.Addr, Args.Size);
-  }
+  if (Args.Addr && dyn_cast(Args.Addr->stripPointerCasts()) &&
+  Args.StartInst)
+CGF.EHStack.pushCleanup(NormalCleanup, Args);
 }
 
 /// EmitAutoVarDecl - Emit code and set up an entry in LocalDeclMap for a
@@ -932,44 +927,84 @@
   C->setDoesNotThrow();
 }
 
+/// Collect offsets in bits.
+static bool getInvariantOffsets(const 

Re: r250577 - [modules] Allow the error when explicitly loading an incompatible module file

2015-11-05 Thread Richard Smith via cfe-commits
On Wed, Nov 4, 2015 at 7:14 PM, Sean Silva via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Wed, Nov 4, 2015 at 1:07 PM, Richard Smith 
> wrote:
>
>> On Sun, Nov 1, 2015 at 10:20 AM, Manuel Klimek  wrote:
>>
>>> On Fri, Oct 23, 2015 at 9:31 PM Sean Silva 
>>> wrote:
>>>
 On Tue, Oct 20, 2015 at 1:52 AM, Manuel Klimek 
 wrote:

> On Tue, Oct 20, 2015 at 10:41 AM Sean Silva 
> wrote:
>
>> On Tue, Oct 20, 2015 at 1:38 AM, Manuel Klimek 
>> wrote:
>>
>>> On Tue, Oct 20, 2015 at 5:52 AM Sean Silva 
>>> wrote:
>>>
 On Mon, Oct 19, 2015 at 2:10 AM, Manuel Klimek 
 wrote:

> On Sat, Oct 17, 2015 at 3:41 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Fri, Oct 16, 2015 at 6:30 PM, Sean Silva <
>> chisophu...@gmail.com> wrote:
>>
>>> On Fri, Oct 16, 2015 at 6:26 PM, Richard Smith <
>>> rich...@metafoo.co.uk> wrote:
>>>
 On Fri, Oct 16, 2015 at 6:25 PM, Sean Silva <
 chisophu...@gmail.com> wrote:

> On Fri, Oct 16, 2015 at 6:12 PM, Richard Smith <
> rich...@metafoo.co.uk> wrote:
>
>> On Fri, Oct 16, 2015 at 4:43 PM, Sean Silva <
>> chisophu...@gmail.com> wrote:
>>
>>> On Fri, Oct 16, 2015 at 4:20 PM, Richard Smith via
>>> cfe-commits  wrote:
>>>
 Author: rsmith
 Date: Fri Oct 16 18:20:19 2015
 New Revision: 250577

 URL:
 http://llvm.org/viewvc/llvm-project?rev=250577=rev
 Log:
 [modules] Allow the error when explicitly loading an
 incompatible module file
 via -fmodule-file= to be turned off; in that case, just
 include the relevant
 files textually. This allows module files to be
 unconditionally passed to all
 compile actions via CXXFLAGS, and to be ignored for rules
 that specify custom
 incompatible flags.

>>>
>>> What direction are you trying to go with this? Are you
>>> thinking something like having CMake build a bunch of modules 
>>> up front?
>>>
>>
>> That's certainly one thing you can do with this. Another is
>> that you can make cmake automatically and explicitly build a 
>> module for
>> each library, and then provide that for all the dependencies of 
>> that
>> library,
>>
>
> How does CMake know which headers are part of which library?
> Strategically named top-level modules in the module map?
>

 The idea would be for CMake to generate the module map itself
 based on the build rules.

>>>
>>> How would it know which headers to include? Do
>>> our ADDITIONAL_HEADER_DIRS things in our CMakeLists.txt have enough
>>> information for this?
>>>
>>
>> Some additional information may need to be added to the
>> CMakeLists to enable this. Some build systems already model the 
>> headers for
>> a library, and so already have the requisite information.
>>
>
> CMake supports specifying headers for libraries (mainly used for
> MS VS). If we need this for modules, we'll probably need to update our
> build rules (which will probably make sense anyway, for a better 
> experience
> for VS users ;)
>

 Nice.

 Brad, do you have any idea how hard it would be to get cmake to
 generate clang module map files and add explicit module build steps?
 Basically, the requirements (off the top of my head) are:
 - for each library, generate a module map which is essentially just
 a list of the headers in that library (it's not just a flat list, but
 that's the gist of it).
 - for each module map, add a build step that invokes clang on it to
 say "build the module corresponding to this module map" (it's basically
 `clang++ path/to/foo.modulemap -o foo.pcm` with a little bit of fluff
 around it). There is also a dependency from foo.pcm on each of the
 libraries that library "foo" depends on.
 - for each library $Dep that library $Lib depends on, add $Dep's
 .pcm file as a dependency of the .o build steps for $Lib. $Dep's .pcm 

Re: [PATCH] D7982: Add readability-duplicate-include check to clang-tidy

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

What's the state of this patch?


http://reviews.llvm.org/D7982



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


r252215 - Fix CSS style name.

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 15:42:07 2015
New Revision: 252215

URL: http://llvm.org/viewvc/llvm-project?rev=252215=rev
Log:
Fix CSS style name.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=252215=252214=252215=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov  5 15:42:07 2015
@@ -596,12 +596,12 @@ as the draft C++1z standard evolves.
 
   Remove deprecated register storage class
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0001r1.html;>P0001R1
-  No
+  No
 
 
   Remove deprecated bool increment
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0002r1.html;>P0002R1
-  No
+  No
 
 
   Make exception specifications part of the type system


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


r252216 - Fix incorrect status for P0012R1.

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 15:42:32 2015
New Revision: 252216

URL: http://llvm.org/viewvc/llvm-project?rev=252216=rev
Log:
Fix incorrect status for P0012R1.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=252216=252215=252216=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov  5 15:42:32 2015
@@ -606,7 +606,7 @@ as the draft C++1z standard evolves.
 
   Make exception specifications part of the type system
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html;>P0012R1
-  Clang 3.6
+  No
 
 
   __has_include


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


Re: [PATCH] D13746: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp:56
@@ +55,3 @@
+ArraySize = SizeArg.getAsIntegral();
+  }
+

We can go for a local setting for now, and if we introduce global or 
module-wide options, we can clean up these local settings in a single step.


Comment at: 
test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp:50
@@ +49,3 @@
+  a[10] = 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index 10 is past the end 
of the array (which contains 10 elements)
+  a[const_index(7)] = 3;

What's the difference between this warning and the -Warray-bounds compiler 
diagnostic that is turned on by default?
```
$ cat /tmp/q.cc 
void f() {
  int a[7];
  a[10];
}
$ clang_check /tmp/q.cc --
...
/tmp/q.cc:3:3: warning: array index 10 is past the end of the array (which 
contains 7 elements) [-Warray-bounds]
  a[10];
  ^ ~~
/tmp/q.cc:2:3: note: array 'a' declared here
  int a[7];
  ^
```


http://reviews.llvm.org/D13746



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2015-11-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Richard, what's the state of this patch?


http://reviews.llvm.org/D8149



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


r252214 - Update C++ status page to match motions from Kona.

2015-11-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  5 15:41:06 2015
New Revision: 252214

URL: http://llvm.org/viewvc/llvm-project?rev=252214=rev
Log:
Update C++ status page to match motions from Kona.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=252214=252213=252214=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov  5 15:41:06 2015
@@ -592,6 +592,27 @@ as the draft C++1z standard evolves.
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4268.html;>N4268
   Clang 3.6
 
+
+
+  Remove deprecated register storage class
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0001r1.html;>P0001R1
+  No
+
+
+  Remove deprecated bool increment
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0002r1.html;>P0002R1
+  No
+
+
+  Make exception specifications part of the type system
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html;>P0012R1
+  Clang 3.6
+
+
+  __has_include
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061.html;>P0061R1
+  Yes
+
 
 
 Technical specifications and standing documents
@@ -619,19 +640,38 @@ Clang version they became available:
 Clang 3.6 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4200;>N4200)
   
 
+
+
+
+  [TS] Concepts
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0121r0.pdf;>P0121R0
+  No
+
 
-  [DRAFT TS] Array extensions (arrays of runtime bound)
-  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3820.html;>N3820
+  [TS] Library Fundamentals, Version 1 (invocation type traits)
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4335.html;>N4335
   No
 
 
-  [DRAFT TS] Library fundamentals (invocation type traits)
-  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3908.html;>N3908
+  [DRAFT TS] Library Fundamentals, Version 2 
(source_location)
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4529.html;>N4529
   No
 
 
-  [DRAFT TS] Concepts
-  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4377.pdf;>N4377
+  [TS] Transactional Memory
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4302.pdf;>N4302
   No
 
 


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


[PATCH] D14419: [Extension --> Completeness] Relax rules for writeonce candidacy...

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo created this revision.
lvoufo added reviewers: chandlerc, majnemer, dberlin, nlewycky.
lvoufo added a subscriber: cfe-commits.

After D14418, Remove restriction for writeonce semantics to objects with no 
non-trivial methods... 

http://reviews.llvm.org/D14419

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -167,11 +167,11 @@
 // CHECK-NL-CO-OBJ: call void @_ZN1MC{{[0-9]+}}Ei({{.*}}* @_ZL3i_m, {{.*}})
 // CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_m to i8*),
 // CHECK-NL-CO-OBJ: call void @_ZN1FC{{[0-9]+}}Ei({{.*}}* @_ZL3i_f, {{.*}})
-// CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_f to i8*))
+// CHECK-NL-CO-OBJ-NOT: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_f to i8*))
 // CHECK-NL-CO-OBJ: call void @_ZN1IC{{[0-9]+}}Ei({{.*}}* @_ZL3i_i, {{.*}})
 // CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_i to i8*))
 // CHECK-NL-CO-OBJ: call void @_ZN2IVC{{[0-9]+}}Ei({{.*}}* @_ZL4i_iv, {{.*}})
-// CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL4i_iv to i8*))
+// CHECK-NL-CO-OBJ-NOT: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL4i_iv to i8*))
 // CHECK-NL-CO-OBJ: call void @_ZN3CIVC{{[0-9]+}}Ei({{.*}}* @_ZL5i_civ, {{.*}})
 // CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL5i_civ to i8*))
 
@@ -303,11 +303,11 @@
   // CHECK-L-CO-OBJ: %i_f = alloca {{.*}}
 
   // CHECK-L-CO-OBJ: call void @_ZN1FC{{[0-9]+}}Ei({{.*}}* %i_f,
-  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(
+  // CHECK-L-CO-OBJ-NOT: call {{.*}}@llvm.invariant.start(
   bar_f(i_f);
   foo_f(_f);  // May change i_f.
   bar_f(i_f);
-  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
+  // CHECK-L-CO-OBJ-NOT: call {{.*}}@llvm.invariant.end(
 }
 
 // Example 1 with type inheriting non-virtual base:
@@ -337,11 +337,11 @@
   // CHECK-L-CO-OBJ: %i_iv = alloca {{.*}}
 
   // CHECK-L-CO-OBJ: call void @_ZN2IVC{{[0-9]+}}Ei({{.*}}* %i_iv,
-  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(
+  // CHECK-L-CO-OBJ-NOT: call {{.*}}@llvm.invariant.start(
   bar_iv(i_iv);
   foo_iv(_iv);  // Does not change i_iv.
   bar_iv(i_iv);
-  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
+  // CHECK-L-CO-OBJ-NOT: call {{.*}}@llvm.invariant.end(
 }
 
 // Example 1 with type inheriting virtual writeonce base:
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1937,8 +1937,15 @@
 }
 
 bool QualType::isWriteOnce(ASTContext ) {
-  return (Context.getLangOpts().CPlusPlus && isConstant(Context) &&
-  !getTypePtr()->isReferenceType());
+  // TODO: Include C objects as well?
+  if (Context.getLangOpts().CPlusPlus && isConstant(Context) &&
+  !getTypePtr()->isReferenceType()) {
+if (const CXXRecordDecl *Record =
+Context.getBaseElementType(*this)->getAsCXXRecordDecl())
+  return Record->computeWriteOnceCandidacy();
+return true;
+  }
+  return false;
 }
 
 bool QualType::isPODType(ASTContext ) const {
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -58,6 +58,8 @@
   HasPrivateFields(false),
   HasProtectedFields(false),
   HasPublicFields(false),
+  IsWriteOnceChecked(false),
+  IsWriteOnceCandidate(false),
   HasMutableFields(false),
   HasVariantMembers(false),
   HasOnlyCMembers(true),
@@ -1348,6 +1350,73 @@
   return false;
 }
 
+/// \brief A class is a candidate for 'writeonce' semantics if
+/// none of its methods writes to memory.
+bool CXXRecordDecl::computeWriteOnceCandidacy() const {
+  // The class must be defined and concrete.
+  if (!isCompleteDefinition() || isDependentType()) return false;
+
+  // If this has already been checked, then return the stored value.
+  if (data().IsWriteOnceChecked) return data().IsWriteOnceCandidate;
+
+  // Otherwise, mark that this is checked.
+  data().IsWriteOnceChecked = true;
+  assert(!data().IsWriteOnceCandidate &&
+ "The candidacy should not have been set yet.");
+
+  // Check each method, excluding constructors and destructors.
+  // NOTE: The invariant intrinsic calls are generated right after the
+  //   construction of a given const object (which must be initialized)
+  //   and right before its destruction at the end of its lifetime.
+  //   Both constructors and destructors modify the allocated memory and
+  //   and will not be called in the middle of an invariant_start/end
+  //   pair, 

Re: [PATCH] D14385: Correct atomic libcall support for __atomic_*_fetch builtins.

2015-11-05 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

Unfortunate that they have this crazy behavior.



Comment at: lib/CodeGen/CGAtomic.cpp:901
@@ -897,1 +900,3 @@
+  PostOp = llvm::Instruction::Add;
+// Fall through.
 case AtomicExpr::AO__c11_atomic_fetch_add:

I think we should use `[[clang::fallthrough]]` instead.  It annotates as well 
as the comment, aids the static analyzer, and should be ignored by compilers 
that don't support it.


Comment at: lib/CodeGen/CGAtomic.cpp:985
@@ -996,1 +984,3 @@
 
+assert(UseOptimizedLibcall || !PostOp);
+

Can you add an explanatory message in the assert?  (Yes, thats had to come up 
with since its obvious if you are familiar with this path).


Comment at: lib/CodeGen/CGAtomic.cpp:998
@@ -1007,1 +997,3 @@
   llvm::Value *ResVal = Res.getScalarVal();
+  llvm::Value *LoadVal1 = Args[1].RV.getScalarVal();
+  if (PostOp)

Am I mistaken, but, we don't need this unless we have an operation to perform?  
Cant we sink this into the PostOp condition?


http://reviews.llvm.org/D14385



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


[libcxx] r252274 - Cleanup foo.h headers and __config to work in C

2015-11-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Nov  6 00:30:12 2015
New Revision: 252274

URL: http://llvm.org/viewvc/llvm-project?rev=252274=rev
Log:
Cleanup foo.h headers and __config to work in C

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/errno.h
libcxx/trunk/include/float.h
libcxx/trunk/include/inttypes.h
libcxx/trunk/include/setjmp.h
libcxx/trunk/include/stdlib.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Nov  6 00:30:12 2015
@@ -11,10 +11,16 @@
 #ifndef _LIBCPP_CONFIG
 #define _LIBCPP_CONFIG
 
-#if !defined(_MSC_VER) || defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
+#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#endif
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header
 #endif
 
+#ifdef __cplusplus
+
 #ifdef __GNUC__
 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
 #else
@@ -526,7 +532,6 @@ using namespace _LIBCPP_NAMESPACE __attr
 #elif defined(_LIBCPP_MSVC)
 
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
-#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@@ -811,4 +816,6 @@ extern "C" void __sanitizer_annotate_con
 #define _LIBCPP_HAS_NO_ATOMIC_HEADER
 #endif
 
+#endif // __cplusplus
+
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/errno.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/errno.h?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/errno.h (original)
+++ libcxx/trunk/include/errno.h Fri Nov  6 00:30:12 2015
@@ -31,6 +31,8 @@ Macros:
 
 #include_next 
 
+#ifdef __cplusplus
+
 #if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 #ifdef ELAST
@@ -391,4 +393,6 @@ static const int __elast2 = 105;
 #define EMLINK 9979
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_ERRNO_H

Modified: libcxx/trunk/include/float.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/float.h?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/float.h (original)
+++ libcxx/trunk/include/float.h Fri Nov  6 00:30:12 2015
@@ -68,6 +68,8 @@ Macros:
 
 #include_next 
 
+#ifdef __cplusplus
+
 #ifndef FLT_EVAL_METHOD
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
 #endif
@@ -76,4 +78,6 @@ Macros:
 #define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_FLOAT_H

Modified: libcxx/trunk/include/inttypes.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/inttypes.h?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/inttypes.h (original)
+++ libcxx/trunk/include/inttypes.h Fri Nov  6 00:30:12 2015
@@ -246,6 +246,6 @@ uintmax_t wcstoumax(const wchar_t* restr
 #undef imaxabs
 #undef imaxdiv
 
-#endif
+#endif // __cplusplus
 
 #endif  // _LIBCPP_INTTYPES_H

Modified: libcxx/trunk/include/setjmp.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/setjmp.h?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/setjmp.h (original)
+++ libcxx/trunk/include/setjmp.h Fri Nov  6 00:30:12 2015
@@ -34,8 +34,12 @@ void longjmp(jmp_buf env, int val);
 
 #include_next 
 
+#ifdef __cplusplus
+
 #ifndef setjmp
 #define setjmp(env) setjmp(env)
 #endif
 
+#endif // __cplusplus
+
 #endif  // _LIBCPP_SETJMP_H

Modified: libcxx/trunk/include/stdlib.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdlib.h?rev=252274=252273=252274=diff
==
--- libcxx/trunk/include/stdlib.h (original)
+++ libcxx/trunk/include/stdlib.h Fri Nov  6 00:30:12 2015
@@ -94,6 +94,7 @@ void *aligned_alloc(size_t alignment, si
 #include_next 
 
 #ifdef __cplusplus
+
 extern "C++" {
 
 #ifdef _LIBCPP_MSVCRT
@@ -123,6 +124,7 @@ inline _LIBCPP_INLINE_VISIBILITY lldiv_t
 #endif // _LIBCPP_MSVCRT / __sun__ / _AIX
 
 }  // extern "C++"
+
 #endif  // __cplusplus
 
 #endif  // _LIBCPP_STDLIB_H


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


[PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2015-11-05 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: EricWF, mclow.lists.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

Use __attribute__((internal_linkage)) instead of always_inline and 
visibility("hidden") when it is available.

Repository:
  rL LLVM

http://reviews.llvm.org/D14411

Files:
  include/__config

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -233,15 +233,23 @@
 #endif
 
 #ifndef _LIBCPP_INLINE_VISIBILITY
+#if __has_attribute(internal_linkage)
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((internal_linkage))
+#else
 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), 
__always_inline__))
 #endif
+#endif
 
 #ifndef _LIBCPP_EXCEPTION_ABI
 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
 #endif
 
 #ifndef _LIBCPP_ALWAYS_INLINE
-#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), 
__always_inline__))
+#if __has_attribute(internal_linkage)
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((internal_linkage))
+#else
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), 
__always_inline__))
+#endif
 #endif
 
 #if defined(__clang__)


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -233,15 +233,23 @@
 #endif
 
 #ifndef _LIBCPP_INLINE_VISIBILITY
+#if __has_attribute(internal_linkage)
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((internal_linkage))
+#else
 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
 #endif
+#endif
 
 #ifndef _LIBCPP_EXCEPTION_ABI
 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
 #endif
 
 #ifndef _LIBCPP_ALWAYS_INLINE
-#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
+#if __has_attribute(internal_linkage)
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((internal_linkage))
+#else
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
+#endif
 #endif
 
 #if defined(__clang__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo updated this revision to Diff 39464.

http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1904,10 +1904,41 @@
 
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
-  CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr,
-  bool IsGlobalConstant = true);
-  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
+
+  /// \brief Specifes arguments to invariant_start/end intrinsic calls.
+  struct InvariantArgs {
+llvm::CallInst *StartInst;  // Contains invariant offsets.
+llvm::Value *Size;  // TODO: Is this necessary?
+llvm::Value *Addr;
+
+InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
+InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
+: StartInst(C), Size(S), Addr(A) {}
+  };
+
+  /// \brief Specifies type of invariant offsets in a given record.
+  typedef llvm::SmallVector OffsetsType;
+
+private:
+
+  /// \brief Specifies offsets and whether they have already been computed.
+  /// Note: empty offsets may or may not have been computed.
+  struct OffsetsInfoType {
+bool Computed;
+OffsetsType Offsets;
+OffsetsInfoType() : Computed(false) { }
+  };
+
+  /// \brief A collection of invariant offsets per given record.
+  llvm::DenseMap InvariantOffsets;
+
+  /// \brief Compute the invariant offsets of a given Record.
+  OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
+
+public:
+  InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
+   bool IsGlobalConstant = true);
+  void EmitInvariantEnd(InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
@@ -3226,7 +3257,7 @@
   CodeGenFunction 
   llvm::GlobalVariable *GV;
   llvm::AllocaInst *AI;
-  CodeGenModule::InvariantArgs Args;
+  CodeGenFunction::InvariantArgs Args;
 
  public:
   MarkWriteOnceWrittenRAII(CodeGenFunction , const VarDecl *D,
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,9 +530,9 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-CodeGenModule::InvariantArgs Args;
+CodeGenFunction::InvariantArgs Args;
public:
-CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
+CallInvariantEnd(CodeGenFunction::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitInvariantEnd(Args);
@@ -927,74 +927,93 @@
   C->setDoesNotThrow();
 }
 
-/// Collect offsets in bits.
-static bool getInvariantOffsets(const CodeGenFunction , QualType Ty,
-llvm::SmallVectorImpl ) {
-  ASTContext  = CGF.getContext();
-  bool FoundWriteOnce = false;
-  if (const CXXRecordDecl *Record =
-  Ctx.getBaseElementType(Ty)->getAsCXXRecordDecl()) {
-for (const auto *Field : Record->fields()) {
-  assert(dyn_cast(Field) && "Field decls only.");
-  if (Field->getType().isWriteOnce(Ctx)) {
-FoundWriteOnce = true;
-CharUnits WidthChars = Ctx.getTypeSizeInChars(Ty);
-uint64_t Width = WidthChars.getQuantity();
-Args.push_back(llvm::ConstantInt::get(CGF.Int64Ty, Width));  // Size
-
-uint64_t Offset = Ctx.getFieldOffset(Field);
-Args.push_back(llvm::ConstantInt::get(CGF.Int64Ty, Offset));  // Offset
-  } else {
-FoundWriteOnce |= getInvariantOffsets(CGF, 

[PATCH] D14418: [Extension] Optimizing const objects with mutable fields.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo created this revision.
lvoufo added reviewers: dberlin, chandlerc, nlewycky, majnemer.
lvoufo added a subscriber: cfe-commits.

Adapting solution from const members of non-const objects (D13618)

http://reviews.llvm.org/D14418

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -165,7 +165,7 @@
 // CHECK-NL-CO-OBJ: call void @_ZN1DC{{[0-9]+}}Ei({{.*}}* @_ZL3i_d, {{.*}})
 // CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_d to i8*))
 // CHECK-NL-CO-OBJ: call void @_ZN1MC{{[0-9]+}}Ei({{.*}}* @_ZL3i_m, {{.*}})
-// CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_m to i8*))
+// CHECK-NL-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_m to i8*),
 // CHECK-NL-CO-OBJ: call void @_ZN1FC{{[0-9]+}}Ei({{.*}}* @_ZL3i_f, {{.*}})
 // CHECK-NL-CO-OBJ-NOT: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* bitcast ({{.*}} @_ZL3i_f to i8*))
 // CHECK-NL-CO-OBJ: call void @_ZN1IC{{[0-9]+}}Ei({{.*}}* @_ZL3i_i, {{.*}})
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1929,12 +1929,20 @@
 OffsetsInfoType() : Computed(false) { }
   };
 
-  /// \brief A collection of invariant offsets per given record.
+  /// \brief A collection of invariant offsets per given record,
+  /// for non-const objects.
   llvm::DenseMap InvariantOffsets;
 
+  /// \brief A collection of non-mutable offsets per given record,
+  /// for const objects.
+  llvm::DenseMap NonMutableOffsets;
+
   /// \brief Compute the invariant offsets of a given Record.
   OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
 
+  /// \brief Compute the non-mutable offsets of a given Record.
+  OffsetsType& ComputeNonMutableOffsets(const CXXRecordDecl *Record);
+
 public:
   InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
bool IsGlobalConstant = true);
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -927,6 +927,8 @@
   C->setDoesNotThrow();
 }
 
+/// This assumes that the fields of the given Record are assumed to be
+/// non-writeonce by default.
 CodeGenFunction::OffsetsType&
 CodeGenFunction::ComputeInvariantOffsets(const CXXRecordDecl *Record) {
   ASTContext  = getContext();
@@ -951,11 +953,69 @@
 
   uint64_t Offset = Ctx.getFieldOffset(Field);
   Args.push_back(llvm::ConstantInt::get(Int64Ty, Offset));  // Offset
+
+  // If this writeonce type happens to be a record holding mutable
+  // fields, make sure to collect the offsets.
+  if (const CXXRecordDecl *RecField =
+  Ctx.getBaseElementType(FieldType)->getAsCXXRecordDecl()) {
+if (RecField->hasMutableFields()) {
+  auto  = ComputeNonMutableOffsets(RecField);
+  Args.insert(Args.end(), FieldArgs.begin(), FieldArgs.end());
+}
+  }
 } else if (const CXXRecordDecl *RecField =
Ctx.getBaseElementType(FieldType)->getAsCXXRecordDecl()) {
   auto  = ComputeInvariantOffsets(RecField);
   Args.insert(Args.end(), FieldArgs.begin(), FieldArgs.end());
 }
+
+// Ignore non-writeonce non-record fields.
+  }
+
+  return Args;
+}
+
+/// This is similar to ComputeInvariantOffsets() but collect offsets of
+/// non-mutable fields instead of those of writeonce fields.
+/// It is meant to be used when the given Record is writeonce and its
+/// fields are assumed to be writeonce by default.
+CodeGenFunction::OffsetsType&
+CodeGenFunction::ComputeNonMutableOffsets(const CXXRecordDecl *Record) {
+  ASTContext  = getContext();
+  auto  = NonMutableOffsets.FindAndConstruct(Record).second;
+  OffsetsType  = OffsetsInfo.Offsets;
+
+  // If this has already been computed, then return the stored value.
+  if (OffsetsInfo.Computed) return Args;
+
+  // Otherwise, mark that this is computed.
+  OffsetsInfo.Computed = true;
+  assert(Args.empty() && "There should be no offset specified yet.");
+
+  // Trace through fields collecting offsets of writeonce candidates.
+  for (const auto *Field : Record->fields()) {
+assert(dyn_cast(Field) && "Field decls only.");
+QualType FieldType = Field->getType();
+
+if (Field->isMutable()) {
+  // Ignore mutable fields.
+  continue;
+} else if (const CXXRecordDecl *RecField =
+   Ctx.getBaseElementType(FieldType)->getAsCXXRecordDecl()) {
+  if (RecField->hasMutableFields()) {
+auto  = ComputeNonMutableOffsets(RecField);
+Args.insert(Args.end(), FieldArgs.begin(), FieldArgs.end());

Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-05 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Thank you so much! I was procrastination taking this on.


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


[PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-05 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: EricWF, mclow.lists.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

This change moves visibility attributes from out-of-class method definitions to 
in-class declaration.
This is needed for a switch to __attribute__((internal_linkage)) (see 
http://reviews.llvm.org/D13925) which can only appear on the first declaration.

This change does not touch istream/ostream/streambuf, which are handled 
separately in http://reviews.llvm.org/D14409.



Repository:
  rL LLVM

http://reviews.llvm.org/D14410

Files:
  include/__hash_table
  include/__mutex_base
  include/__split_buffer
  include/bitset
  include/condition_variable
  include/deque
  include/future
  include/locale
  include/memory
  include/random
  include/regex
  include/string
  include/thread
  include/valarray
  include/vector

Index: include/vector
===
--- include/vector
+++ include/vector
@@ -685,9 +685,11 @@
 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template 
+_LIBCPP_INLINE_VISIBILITY
 void emplace_back(_Args&&... __args);
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 void pop_back();
 
 iterator insert(const_iterator __position, const_reference __x);
@@ -766,6 +768,7 @@
 void deallocate() _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
 void __construct_at_end(size_type __n);
+_LIBCPP_INLINE_VISIBILITY
 void __construct_at_end(size_type __n, const_reference __x);
 template 
 typename enable_if
@@ -990,7 +993,7 @@
 //  Postcondition:  size() == old size() + __n
 //  Postcondition:  [i] == __x for all i in [size() - __n, __n)
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
 {
@@ -1627,7 +1630,7 @@
 
 template 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 {
@@ -1648,7 +1651,7 @@
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 vector<_Tp, _Allocator>::pop_back()
 {
Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -802,11 +802,14 @@
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
 valarray() : __begin_(0), __end_(0) {}
+_LIBCPP_INLINE_VISIBILITY
 explicit valarray(size_t __n);
+_LIBCPP_INLINE_VISIBILITY
 valarray(const value_type& __x, size_t __n);
 valarray(const value_type* __p, size_t __n);
 valarray(const valarray& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 valarray(valarray&& __v) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -816,22 +819,31 @@
 valarray(const gslice_array& __ga);
 valarray(const mask_array& __ma);
 valarray(const indirect_array& __ia);
+_LIBCPP_INLINE_VISIBILITY
 ~valarray();
 
 // assignment:
 valarray& operator=(const valarray& __v);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(valarray&& __v) _NOEXCEPT;
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(initializer_list);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const value_type& __x);
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const slice_array& __sa);
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const gslice_array& __ga);
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const mask_array& __ma);
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const indirect_array& __ia);
 template 
+_LIBCPP_INLINE_VISIBILITY
 valarray& operator=(const __val_expr<_ValExpr>& __v);
 
 // element access:
@@ -842,24 +854,38 @@
 value_type&   operator[](size_t __i)   {return __begin_[__i];}
 
 // subset operations:
+_LIBCPP_INLINE_VISIBILITY
 __val_expr<__slice_expr >operator[](slice __s) const;
+_LIBCPP_INLINE_VISIBILITY
 slice_array   operator[](slice __s);
+_LIBCPP_INLINE_VISIBILITY
 __val_expr<__indirect_expr > operator[](const gslice& __gs) const;
+_LIBCPP_INLINE_VISIBILITY
 gslice_array   operator[](const gslice& __gs);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 __val_expr<__indirect_expr > operator[](gslice&& __gs) const;
+_LIBCPP_INLINE_VISIBILITY
 gslice_array  operator[](gslice&& __gs);
 #endif  // 

Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2015-11-05 Thread Richard Smith via cfe-commits
Ping.

On Thu, Oct 29, 2015 at 5:21 PM, Richard Smith 
wrote:

> Hi,
>
> The attached patch undoes the revert of r249929, and adds an extension to
> allow  (and ) to work properly even in environments such
> as iOS where the underlying libc does not provide C++'s const-correct
> overloads of strchr and friends.
>
> This works as follows:
>
>  * The macro _LIBCPP_PREFERRED_OVERLOAD is, where possible, defined by
> <__config> to an attribute that provides the following semantics:
>- A function declaration with the attribute declares a different
> function from a function declaration without the attribute.
>- Overload resolution prefers a function with the attribute over a
> function without.
>  * For each of the functions that has a "broken" signature in C, if we
> don't believe that the C library provided the C++ signatures, and we have a
> _LIBCPP_PREFERRED_OVERLOAD, then we add the C++ declarations and mark them
> as preferred over the C overloads.
>  * The overloads provided in namespace std always exactly match those in
> ::.
>
>
> This results in the following changes in cases where the underlying libc
> provides the C signature not the C++ one, compared to the status quo:
>
>
> :
>
>   char *strchr(const char*, int) // #1
>   char *strchr(char*, int) // #2
>   const char *strchr(const char*, int) // #3
>
> We used to provide #1 and #2 in namespace std (in ) and only #1
> in global namespace (in ).
>
> For a very old clang or non-clang compiler, we now have only #1 in both
> places (note that #2 is essentially useless). This is unlikely to be a
> visible change in real code, but it's slightly broken either way and we
> can't fix it.
>
> For newer clang (3.6 onwards?), we now have correct signatures (#2 and #3)
> in :: and std (depending on header). Taking address of strchr requires
> ~trunk clang (but it didn't work before either, so this is not really a
> regression).
>
>
> :
>
>   wchar_t *wcschr(const wchar_t *, wchar_t) // #1
>   const wchar_t *wcschr(const wchar_t *, wchar_t) // #2
>   wchar_t *wcschr(wchar_t *, wchar_t) // #3
>
> We used to provide #1 in global namespace, and #2 and #3 in namespace std.
> This broke code that uses 'using namespace std;'.
>
> For a very old clang or non-clang compiler, we now have #1 in global
> namespace and namespace std. This fixes the ambiguity errors, but decreases
> const-correctness in this case. On the whole, this seems like an
> improvement to me.
>
> For newer clang, we now have correct signatures (#2 and #3) in :: and std
> (depending on header). As above, taking address doesn't work unless you're
> using very recent Clang (this is not a regression in ::, but is a
> regression in namespace std).
>
>
> To summarize, we previously had ad-hoc, inconsistent, slightly broken
> rules for  and , and with this patch we fix the overload
> set to give the exact C++ semantics where possible (for all recent versions
> of Clang), and otherwise leave the C signatures alone.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo updated this revision to Diff 39466.

http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -37,7 +37,7 @@
 #if defined(OBJ)
 struct A {
   int a;
-  int b;
+  Const int b;
   A(int a) : a(a), b(a) {}
 };
 
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -259,17 +259,6 @@
 
   typedef std::vector CtorList;
 
-  struct InvariantArgs {
-llvm::CallInst *StartInst;  // TODO: Is this necessary?
-llvm::Value *Size;  // TODO: Is this necessary?
-llvm::Value *Addr;
-llvm::SmallVector Offsets;
-
-InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
-InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
-: StartInst(C), Size(S), Addr(A) {}
-  };
-
 private:
   ASTContext 
   const LangOptions 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1904,10 +1904,41 @@
 
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
-  CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr,
-  bool IsGlobalConstant = true);
-  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
+
+  /// \brief Specifes arguments to invariant_start/end intrinsic calls.
+  struct InvariantArgs {
+llvm::CallInst *StartInst;  // Contains invariant offsets.
+llvm::Value *Size;  // TODO: Is this necessary?
+llvm::Value *Addr;
+
+InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
+InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
+: StartInst(C), Size(S), Addr(A) {}
+  };
+
+  /// \brief Specifies type of invariant offsets in a given record.
+  typedef llvm::SmallVector OffsetsType;
+
+private:
+
+  /// \brief Specifies offsets and whether they have already been computed.
+  /// Note: empty offsets may or may not have been computed.
+  struct OffsetsInfoType {
+bool Computed;
+OffsetsType Offsets;
+OffsetsInfoType() : Computed(false) { }
+  };
+
+  /// \brief A collection of invariant offsets per given record.
+  llvm::DenseMap InvariantOffsets;
+
+  /// \brief Compute the invariant offsets of a given Record.
+  OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
+
+public:
+  InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
+   bool IsGlobalConstant = true);
+  void EmitInvariantEnd(InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
@@ -3226,7 +3257,7 @@
   CodeGenFunction 
   llvm::GlobalVariable *GV;
   llvm::AllocaInst *AI;
-  CodeGenModule::InvariantArgs Args;
+  CodeGenFunction::InvariantArgs Args;
 
  public:
   MarkWriteOnceWrittenRAII(CodeGenFunction , const VarDecl *D,
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,9 +530,9 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-CodeGenModule::InvariantArgs Args;
+CodeGenFunction::InvariantArgs Args;
public:
-CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
+CallInvariantEnd(CodeGenFunction::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitInvariantEnd(Args);
@@ -927,74 +927,93 @@
   C->setDoesNotThrow();
 }
 
-/// Collect offsets in bits.
-static bool getInvariantOffsets(const CodeGenFunction , QualType 

Re: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-11-05 Thread Richard Smith via cfe-commits
rsmith added a comment.

As discussed off-line:

1. Can we avoid tracking the `pass_object_size` attributes in the canonical 
function type? As the only permitted use of a function with this attribute is 
as a direct callee in a function call, it seems like we'll always have the 
parameters to hand when we need to know how they affect the calling convention.

2. In order to pass non-frontend-constant object sizes (those computed in the 
middle-end by @llvm.objectsize) into `pass_object_size` parameters, we need to 
keep functions viable even if the object size is not known to be a constant.



Comment at: include/clang/AST/Expr.h:631-634
@@ -630,1 +630,6 @@
 
+  /// tryEvaluateObjectSize - If the current Expr is a pointer, this will try 
to
+  /// statically determine how many bytes remain in the object this pointer is
+  /// pointing to.
+  bool tryEvaluateObjectSize(llvm::APSInt , ASTContext ,
+ unsigned Type) const;

... and what if the current expression isn't a pointer? Is that a precondition 
(function might assert / crash) or does it result in 'return false'?

Also, don't use `"/// FunctionName - [...]"` in new code, use `"/// \brief 
[...]"` instead.


Comment at: include/clang/AST/Type.h:3110-3112
@@ -3106,2 +3109,5 @@
 
+  /// Whether this function has pass_object_size attribute(s) on its parameters
+  unsigned HasPassObjectSizeParams : 1;
+
   // ParamInfo - There is an variable size array after the class in memory that

Seems nicer to put this right after `HasAnyConsumedParams`. (I'm also surprised 
to find that we have a spare bit here...)


Comment at: include/clang/AST/Type.h:3131-3134
@@ -3124,3 +3130,6 @@
 
-  friend class ASTContext;  // ASTContext creates these.
+  // PassObjectSizeParams - A variable size array, following ConsumedParameters
+  // and of length NumParams, holding flags indicating which parameters have 
the
+  // pass_object_size attribute. This only appears if HasPassObjectSizeParams 
is
+  // true.
 

Do we really want just flags here rather than the `type` value? Should `int 
(void * __attribute__((pass_object_size(1` and `int (void 
*__attribute((pass_object_size(2` be the same type?


Comment at: include/clang/Basic/AttrDocs.td:269-270
@@ +268,4 @@
+  let Content = [{
+.. Note:: The mangling of functions with parameters that are annotated with
+  ``pass_object_size`` is not yet standardized.
+

Rather than "not yet standardized", perhaps "subject to change" is more useful 
for user-facing documentation. Might be worth noting that `asm("blah")` can be 
used to avoid ABI changes if we do change the mangling.


Comment at: include/clang/Basic/AttrDocs.td:351
@@ +350,3 @@
+
+* It is an error to apply the ``pass_object_size`` attribute on parameters that
+  are not const pointers

This should only apply to the function definition; the top-level `const` has no 
effect on a non-defining declaration.


Comment at: include/clang/Basic/AttrDocs.td:352
@@ +351,3 @@
+* It is an error to apply the ``pass_object_size`` attribute on parameters that
+  are not const pointers
+

Missing period.


Comment at: include/clang/Basic/AttrDocs.td:354-365
@@ +353,14 @@
+
+* Because the size is passed at runtime, ``CallFoo`` below will always call
+  A:
+
+  .. code-block:: c++
+
+int Foo(int n) __attribute__((enable_if(n > 0, ""))); // function A
+int Foo(int n) __attribute__((enable_if(n <= 0, ""))); // function B
+int CallFoo(const void *p __attribute__((pass_object_size(0
+__attribute__((noinline)) {
+  return Foo(__builtin_object_size(p, 0));
+}
+  }];
+}

I would expect this to result in an error: neither A nor B is viable because 
their conditions are non-constant.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5101
@@ -5089,1 +5100,3 @@
+def err_address_of_function_with_pass_object_size_params: Error<
+  "functions with pass_object_size params cannot have their address taken">;
 def err_parens_pointer_member_function : Error<

params -> parameters

or better, something like:

  cannot take address of function %0 because parameter %1 uses pass_object_size 
attribute


Comment at: include/clang/Sema/TemplateDeduction.h:261
@@ -256,2 +260,3 @@
 public:
-  TemplateSpecCandidateSet(SourceLocation Loc) : Loc(Loc) {}
+  TemplateSpecCandidateSet(SourceLocation Loc, bool ForTakingAddress=false)
+  : Loc(Loc), ForTakingAddress(ForTakingAddress) {}

Spaces around `=`.


Comment at: lib/AST/ExprConstant.cpp:6390-6391
@@ +6389,4 @@
+
+  // These are here more for readability than out of laziness -- yes, this was
+  // ripped from IntExprEvaluator :)
+  auto Error = [](const Expr *E) {

Comment doesn't 

Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo updated this revision to Diff 39465.

http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -259,17 +259,6 @@
 
   typedef std::vector CtorList;
 
-  struct InvariantArgs {
-llvm::CallInst *StartInst;  // TODO: Is this necessary?
-llvm::Value *Size;  // TODO: Is this necessary?
-llvm::Value *Addr;
-llvm::SmallVector Offsets;
-
-InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
-InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
-: StartInst(C), Size(S), Addr(A) {}
-  };
-
 private:
   ASTContext 
   const LangOptions 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1904,10 +1904,41 @@
 
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
-  CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr,
-  bool IsGlobalConstant = true);
-  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
+
+  /// \brief Specifes arguments to invariant_start/end intrinsic calls.
+  struct InvariantArgs {
+llvm::CallInst *StartInst;  // Contains invariant offsets.
+llvm::Value *Size;  // TODO: Is this necessary?
+llvm::Value *Addr;
+
+InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
+InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
+: StartInst(C), Size(S), Addr(A) {}
+  };
+
+  /// \brief Specifies type of invariant offsets in a given record.
+  typedef llvm::SmallVector OffsetsType;
+
+private:
+
+  /// \brief Specifies offsets and whether they have already been computed.
+  /// Note: empty offsets may or may not have been computed.
+  struct OffsetsInfoType {
+bool Computed;
+OffsetsType Offsets;
+OffsetsInfoType() : Computed(false) { }
+  };
+
+  /// \brief A collection of invariant offsets per given record.
+  llvm::DenseMap InvariantOffsets;
+
+  /// \brief Compute the invariant offsets of a given Record.
+  OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
+
+public:
+  InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
+   bool IsGlobalConstant = true);
+  void EmitInvariantEnd(InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
@@ -3226,7 +3257,7 @@
   CodeGenFunction 
   llvm::GlobalVariable *GV;
   llvm::AllocaInst *AI;
-  CodeGenModule::InvariantArgs Args;
+  CodeGenFunction::InvariantArgs Args;
 
  public:
   MarkWriteOnceWrittenRAII(CodeGenFunction , const VarDecl *D,
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,9 +530,9 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-CodeGenModule::InvariantArgs Args;
+CodeGenFunction::InvariantArgs Args;
public:
-CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
+CallInvariantEnd(CodeGenFunction::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitInvariantEnd(Args);
@@ -927,74 +927,93 @@
   C->setDoesNotThrow();
 }
 
-/// Collect offsets in bits.
-static bool getInvariantOffsets(const CodeGenFunction , QualType Ty,
-llvm::SmallVectorImpl ) {
-  ASTContext  = CGF.getContext();
-  bool FoundWriteOnce 

r252256 - Refactor: simplify boolean conditional return statements in lib/Analysis

2015-11-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Nov  5 19:08:38 2015
New Revision: 252256

URL: http://llvm.org/viewvc/llvm-project?rev=252256=rev
Log:
Refactor: simplify boolean conditional return statements in lib/Analysis

Patch by Richard Thomson!

Differential revision: http://reviews.llvm.org/D10008

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=252256=252255=252256=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Thu Nov  5 19:08:38 2015
@@ -36,10 +36,7 @@ static bool isDispatchBlock(QualType Ty)
   // returns void.
   const FunctionProtoType *FT =
   BPT->getPointeeType()->getAs();
-  if (!FT || !FT->getReturnType()->isVoidType() || FT->getNumParams() != 0)
-return false;
-
-  return true;
+  return FT && FT->getReturnType()->isVoidType() && FT->getNumParams() == 0;
 }
 
 namespace {


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


Re: [PATCH] D10008: Refactor: simplify boolean conditional return statements in lib/Analysis

2015-11-05 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252256: Refactor: simplify boolean conditional return 
statements in lib/Analysis (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D10008?vs=26486=39448#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D10008

Files:
  cfe/trunk/lib/Analysis/BodyFarm.cpp

Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -36,10 +36,7 @@
   // returns void.
   const FunctionProtoType *FT =
   BPT->getPointeeType()->getAs();
-  if (!FT || !FT->getReturnType()->isVoidType() || FT->getNumParams() != 0)
-return false;
-
-  return true;
+  return FT && FT->getReturnType()->isVoidType() && FT->getNumParams() == 0;
 }
 
 namespace {


Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -36,10 +36,7 @@
   // returns void.
   const FunctionProtoType *FT =
   BPT->getPointeeType()->getAs();
-  if (!FT || !FT->getReturnType()->isVoidType() || FT->getNumParams() != 0)
-return false;
-
-  return true;
+  return FT && FT->getReturnType()->isVoidType() && FT->getNumParams() == 0;
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-05 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: www/analyzer/installation.html:103
@@ -102,3 +102,1 @@
 
-Currently these are not installed using make install, and
-are located in $(SRCDIR)/tools/clang/tools/scan-build and

jroelofs wrote:
> @zaks.anna Do you know if there was a particular reason for this? It's kind 
> of a shame to have to use them from the src dir.
I do not know. Ted might know.


http://reviews.llvm.org/D14403



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


r252261 - Refactor: Simplify boolean conditional return statements in lib/ARCMigrate

2015-11-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Nov  5 19:26:37 2015
New Revision: 252261

URL: http://llvm.org/viewvc/llvm-project?rev=252261=rev
Log:
Refactor: Simplify boolean conditional return statements in lib/ARCMigrate

Patch by Richard Thomson! (+a couple of modifications to address comments)

Differential revision: http://reviews.llvm.org/D10009

Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=252261=252260=252261=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Nov  5 19:26:37 2015
@@ -214,25 +214,15 @@ namespace {
   // FIXME. This duplicates one in RewriteObjCFoundationAPI.cpp
   bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
 const Expr* Expr = FullExpr->IgnoreImpCasts();
-if (isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(FullExpr) ||
-isa(Expr) ||
-isa(Expr))
-  return false;
-
-return true;
+return !(isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) ||
+ isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(FullExpr) ||
+ isa(Expr) || isa(Expr));
   }
   
   /// \brief - Rewrite message expression for Objective-C setter and getters 
into
@@ -665,9 +655,7 @@ ClassImplementsAllMethodsAndProperties(A
 return false;
 }
   }
-  if (HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod)
-return true;
-  return false;
+  return HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod;
 }
 
 static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,

Modified: cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp?rev=252261=252260=252261=diff
==
--- cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp Thu Nov  5 
19:26:37 2015
@@ -104,9 +104,7 @@ public:
   return false;
 if (!S->getThen() || !Visit(S->getThen()))
   return false;
-if (S->getElse() && !Visit(S->getElse()))
-  return false;
-return true;
+return !S->getElse() || Visit(S->getElse());
   }
   bool VisitWhileStmt(WhileStmt *S) {
 if (S->getConditionVariable())

Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=252261=252260=252261=diff
==
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Thu Nov  5 19:26:37 2015
@@ -152,9 +152,7 @@ public:
 return ID->getImplementation() != nullptr;
   if (ObjCCategoryDecl *CD = dyn_cast(ContD))
 return CD->getImplementation() != nullptr;
-  if (isa(ContD))
-return true;
-  return false;
+  return isa(ContD);
 }
 return false;
   }

Modified: cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=252261=252260=252261=diff
==
--- cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp Thu Nov  5 19:26:37 
2015
@@ -150,11 +150,8 @@ public:
   return true;
 }
 
-if (!hasSideEffects(rec, Pass.Ctx)) {
-  if (tryRemoving(RecContainer))
-return true;
-}
-Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
+if (hasSideEffects(rec, Pass.Ctx) || !tryRemoving(RecContainer))
+  Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
 
 return true;
   }
@@ -174,11 +171,8 @@ private:
   ///   return var;
   ///
   bool isCommonUnusedAutorelease(ObjCMessageExpr *E) {
-if (isPlusOneAssignBeforeOrAfterAutorelease(E))
-  return true;
-if (isReturnedAfterAutorelease(E))
-  return true;
-return false;
+return isPlusOneAssignBeforeOrAfterAutorelease(E) ||
+   isReturnedAfterAutorelease(E);
   }
 
   

Re: [PATCH] D10009: Refactor: Simplify boolean conditional return statements in lib/ARCMigrate

2015-11-05 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252261: Refactor: Simplify boolean conditional return 
statements in lib/ARCMigrate (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D10009?vs=26475=39450#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D10009

Files:
  cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
  cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
  cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
  cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  cfe/trunk/lib/ARCMigrate/Transforms.cpp

Index: cfe/trunk/lib/ARCMigrate/Transforms.cpp
===
--- cfe/trunk/lib/ARCMigrate/Transforms.cpp
+++ cfe/trunk/lib/ARCMigrate/Transforms.cpp
@@ -113,10 +113,7 @@
   while (implCE && implCE->getCastKind() ==  CK_BitCast)
 implCE = dyn_cast(implCE->getSubExpr());
 
-  if (implCE && implCE->getCastKind() == CK_ARCConsumeObject)
-return true;
-
-  return false;
+  return implCE && implCE->getCastKind() == CK_ARCConsumeObject;
 }
 
 /// \brief 'Loc' is the end of a statement range. This returns the location
Index: cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
===
--- cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
+++ cfe/trunk/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
@@ -104,9 +104,7 @@
   return false;
 if (!S->getThen() || !Visit(S->getThen()))
   return false;
-if (S->getElse() && !Visit(S->getElse()))
-  return false;
-return true;
+return !S->getElse() || Visit(S->getElse());
   }
   bool VisitWhileStmt(WhileStmt *S) {
 if (S->getConditionVariable())
Index: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
===
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
@@ -152,9 +152,7 @@
 return ID->getImplementation() != nullptr;
   if (ObjCCategoryDecl *CD = dyn_cast(ContD))
 return CD->getImplementation() != nullptr;
-  if (isa(ContD))
-return true;
-  return false;
+  return isa(ContD);
 }
 return false;
   }
Index: cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
===
--- cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -150,11 +150,8 @@
   return true;
 }
 
-if (!hasSideEffects(rec, Pass.Ctx)) {
-  if (tryRemoving(RecContainer))
-return true;
-}
-Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
+if (hasSideEffects(rec, Pass.Ctx) || !tryRemoving(RecContainer))
+  Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
 
 return true;
   }
@@ -174,11 +171,8 @@
   ///   return var;
   ///
   bool isCommonUnusedAutorelease(ObjCMessageExpr *E) {
-if (isPlusOneAssignBeforeOrAfterAutorelease(E))
-  return true;
-if (isReturnedAfterAutorelease(E))
-  return true;
-return false;
+return isPlusOneAssignBeforeOrAfterAutorelease(E) ||
+   isReturnedAfterAutorelease(E);
   }
 
   bool isReturnedAfterAutorelease(ObjCMessageExpr *E) {
@@ -225,11 +219,7 @@
 // Check for "RefD = [+1 retained object];".
 
 if (BinaryOperator *Bop = dyn_cast(S)) {
-  if (RefD != getReferencedDecl(Bop->getLHS()))
-return false;
-  if (isPlusOneAssign(Bop))
-return true;
-  return false;
+  return (RefD == getReferencedDecl(Bop->getLHS())) && isPlusOneAssign(Bop);
 }
 
 if (DeclStmt *DS = dyn_cast(S)) {
Index: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
===
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
@@ -214,25 +214,15 @@
   // FIXME. This duplicates one in RewriteObjCFoundationAPI.cpp
   bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
 const Expr* Expr = FullExpr->IgnoreImpCasts();
-if (isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(Expr) ||
-isa(FullExpr) ||
-isa(Expr) ||
-isa(Expr))
-  return false;
-
-return true;
+return !(isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) ||
+ isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(Expr) ||
+ isa(Expr) || isa(FullExpr) ||
+ isa(Expr) || isa(Expr));
   }
   
   /// \brief - Rewrite message expression for Objective-C setter and getters into
@@ -665,9 +655,7 @@
 return false;
 }
   }
-  if 

Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-05 Thread Tamas Berghammer via cfe-commits
tberghammer added a comment.

In http://reviews.llvm.org/D14354#282870, @probinson wrote:

> So, currently you get accel tables by default for platforms that "tune" for 
> LLDB, currently Darwin and FreeBSD.
>  Are you wanting to use LLDB on another platform, or did you want accel 
> tables for a different debugger?
>
> (Eventually I will have a chance to expose the "tuning" up through Clang, and 
> if you're running LLDB on another platform, that will be the easier way to 
> get what you want.)


We are using LLDB for Android (as part of Android Studio) and some of us also 
use if for Linux (I hope we can get higher adaptation soon).



Comment at: test/Driver/dwarf-accel.c:4
@@ +3,3 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -gdwarf-accel-tables -c -### 
%s 2> %t
+// RUN: FileCheck -check-prefix=CHECK < %t %s
+//

probinson wrote:
> Normally you'd just pipe the output to FileCheck rather than write a temp 
> file, because that's more efficient. There are lots of examples to crib from 
> in other tests.
I copied this pattern from split-dwarf.c but will check out how can I do it 
with piping


http://reviews.llvm.org/D14354



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


[PATCH] D14409: Remove visibility attributes from out-of-class method definitions in iostreams.

2015-11-05 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: mclow.lists, EricWF.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

No point in pretending that these methods are hidden - they are
actually exported from libc++.so. Extern template declarations make
them part of libc++ ABI.

This patch does not change libc++.so export list (at least on Linux).


Repository:
  rL LLVM

http://reviews.llvm.org/D14409

Files:
  include/istream
  include/ostream
  include/streambuf

Index: include/streambuf
===
--- include/streambuf
+++ include/streambuf
@@ -220,7 +220,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 locale
 basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc)
 {
@@ -231,23 +231,23 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 locale
 basic_streambuf<_CharT, _Traits>::getloc() const
 {
 return __loc_;
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_streambuf<_CharT, _Traits>*
 basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n)
 {
 return setbuf(__s, __n);
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::pos_type
 basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off,
  ios_base::seekdir __way,
@@ -257,24 +257,24 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::pos_type
 basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp,
  ios_base::openmode __which)
 {
 return seekpos(__sp, __which);
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 int
 basic_streambuf<_CharT, _Traits>::pubsync()
 {
 return sync();
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 streamsize
 basic_streambuf<_CharT, _Traits>::in_avail()
 {
@@ -284,7 +284,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::snextc()
 {
@@ -294,7 +294,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::sbumpc()
 {
@@ -304,7 +304,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::sgetc()
 {
@@ -314,15 +314,15 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 streamsize
 basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n)
 {
 return xsgetn(__s, __n);
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c)
 {
@@ -332,7 +332,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::sungetc()
 {
@@ -342,7 +342,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::sputc(char_type __c)
 {
@@ -353,7 +353,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 streamsize
 basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n)
 {
@@ -411,15 +411,15 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_streambuf<_CharT, _Traits>::gbump(int __n)
 {
 __ninp_ += __n;
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext,
   char_type* __gend)
@@ -430,15 +430,15 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_streambuf<_CharT, _Traits>::pbump(int __n)
 {
 __nout_ += __n;
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend)
 {
Index: include/ostream
===
--- include/ostream
+++ include/ostream
@@ -275,23 +275,23 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf* __sb)
 {
 this->init(__sb);
 }
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
 {
 this->move(__rhs);
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 basic_ostream<_CharT, _Traits>&
 basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
 {
@@ -307,23 +307,23 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs)
 {
 basic_ios

Re: r250577 - [modules] Allow the error when explicitly loading an incompatible module file

2015-11-05 Thread Sean Silva via cfe-commits
On Thu, Nov 5, 2015 at 1:12 PM, Richard Smith  wrote:

> On Wed, Nov 4, 2015 at 7:14 PM, Sean Silva via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Wed, Nov 4, 2015 at 1:07 PM, Richard Smith 
>> wrote:
>>
>>> On Sun, Nov 1, 2015 at 10:20 AM, Manuel Klimek 
>>> wrote:
>>>
 On Fri, Oct 23, 2015 at 9:31 PM Sean Silva 
 wrote:

> On Tue, Oct 20, 2015 at 1:52 AM, Manuel Klimek 
> wrote:
>
>> On Tue, Oct 20, 2015 at 10:41 AM Sean Silva 
>> wrote:
>>
>>> On Tue, Oct 20, 2015 at 1:38 AM, Manuel Klimek 
>>> wrote:
>>>
 On Tue, Oct 20, 2015 at 5:52 AM Sean Silva 
 wrote:

> On Mon, Oct 19, 2015 at 2:10 AM, Manuel Klimek 
> wrote:
>
>> On Sat, Oct 17, 2015 at 3:41 AM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Fri, Oct 16, 2015 at 6:30 PM, Sean Silva <
>>> chisophu...@gmail.com> wrote:
>>>
 On Fri, Oct 16, 2015 at 6:26 PM, Richard Smith <
 rich...@metafoo.co.uk> wrote:

> On Fri, Oct 16, 2015 at 6:25 PM, Sean Silva <
> chisophu...@gmail.com> wrote:
>
>> On Fri, Oct 16, 2015 at 6:12 PM, Richard Smith <
>> rich...@metafoo.co.uk> wrote:
>>
>>> On Fri, Oct 16, 2015 at 4:43 PM, Sean Silva <
>>> chisophu...@gmail.com> wrote:
>>>
 On Fri, Oct 16, 2015 at 4:20 PM, Richard Smith via
 cfe-commits  wrote:

> Author: rsmith
> Date: Fri Oct 16 18:20:19 2015
> New Revision: 250577
>
> URL:
> http://llvm.org/viewvc/llvm-project?rev=250577=rev
> Log:
> [modules] Allow the error when explicitly loading an
> incompatible module file
> via -fmodule-file= to be turned off; in that case, just
> include the relevant
> files textually. This allows module files to be
> unconditionally passed to all
> compile actions via CXXFLAGS, and to be ignored for rules
> that specify custom
> incompatible flags.
>

 What direction are you trying to go with this? Are you
 thinking something like having CMake build a bunch of modules 
 up front?

>>>
>>> That's certainly one thing you can do with this. Another is
>>> that you can make cmake automatically and explicitly build a 
>>> module for
>>> each library, and then provide that for all the dependencies of 
>>> that
>>> library,
>>>
>>
>> How does CMake know which headers are part of which library?
>> Strategically named top-level modules in the module map?
>>
>
> The idea would be for CMake to generate the module map itself
> based on the build rules.
>

 How would it know which headers to include? Do
 our ADDITIONAL_HEADER_DIRS things in our CMakeLists.txt have enough
 information for this?

>>>
>>> Some additional information may need to be added to the
>>> CMakeLists to enable this. Some build systems already model the 
>>> headers for
>>> a library, and so already have the requisite information.
>>>
>>
>> CMake supports specifying headers for libraries (mainly used for
>> MS VS). If we need this for modules, we'll probably need to update 
>> our
>> build rules (which will probably make sense anyway, for a better 
>> experience
>> for VS users ;)
>>
>
> Nice.
>
> Brad, do you have any idea how hard it would be to get cmake to
> generate clang module map files and add explicit module build steps?
> Basically, the requirements (off the top of my head) are:
> - for each library, generate a module map which is essentially
> just a list of the headers in that library (it's not just a flat 
> list, but
> that's the gist of it).
> - for each module map, add a build step that invokes clang on it
> to say "build the module corresponding to this module map" (it's 
> basically
> `clang++ path/to/foo.modulemap -o foo.pcm` with a little bit of fluff
> around it). There is also a dependency from 

Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo updated this revision to Diff 39463.

http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1904,10 +1904,41 @@
 
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
-  CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr,
-  bool IsGlobalConstant = true);
-  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
+
+  /// \brief Specifes arguments to invariant_start/end intrinsic calls.
+  struct InvariantArgs {
+llvm::CallInst *StartInst;  // Contains invariant offsets.
+llvm::Value *Size;  // TODO: Is this necessary?
+llvm::Value *Addr;
+
+InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
+InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
+: StartInst(C), Size(S), Addr(A) {}
+  };
+
+  /// \brief Specifies type of invariant offsets in a given record.
+  typedef llvm::SmallVector OffsetsType;
+
+private:
+
+  /// \brief Specifies offsets and whether they have already been computed.
+  /// Note: empty offsets may or may not have been computed.
+  struct OffsetsInfoType {
+bool Computed;
+OffsetsType Offsets;
+OffsetsInfoType() : Computed(false) { }
+  };
+
+  /// \brief A collection of invariant offsets per given record.
+  llvm::DenseMap InvariantOffsets;
+
+  /// \brief Compute the invariant offsets of a given Record.
+  OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
+
+public:
+  InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
+   bool IsGlobalConstant = true);
+  void EmitInvariantEnd(InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
@@ -3226,7 +3257,7 @@
   CodeGenFunction 
   llvm::GlobalVariable *GV;
   llvm::AllocaInst *AI;
-  CodeGenModule::InvariantArgs Args;
+  CodeGenFunction::InvariantArgs Args;
 
  public:
   MarkWriteOnceWrittenRAII(CodeGenFunction , const VarDecl *D,
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,9 +530,9 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-CodeGenModule::InvariantArgs Args;
+CodeGenFunction::InvariantArgs Args;
public:
-CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
+CallInvariantEnd(CodeGenFunction::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitInvariantEnd(Args);
@@ -927,74 +927,93 @@
   C->setDoesNotThrow();
 }
 
-/// Collect offsets in bits.
-static bool getInvariantOffsets(const CodeGenFunction , QualType Ty,
-llvm::SmallVectorImpl ) {
-  ASTContext  = CGF.getContext();
-  bool FoundWriteOnce = false;
-  if (const CXXRecordDecl *Record =
-  Ctx.getBaseElementType(Ty)->getAsCXXRecordDecl()) {
-for (const auto *Field : Record->fields()) {
-  assert(dyn_cast(Field) && "Field decls only.");
-  if (Field->getType().isWriteOnce(Ctx)) {
-FoundWriteOnce = true;
-CharUnits WidthChars = Ctx.getTypeSizeInChars(Ty);
-uint64_t Width = WidthChars.getQuantity();
-Args.push_back(llvm::ConstantInt::get(CGF.Int64Ty, Width));  // Size
-
-uint64_t Offset = Ctx.getFieldOffset(Field);
-Args.push_back(llvm::ConstantInt::get(CGF.Int64Ty, Offset));  // Offset
-  } else {
-FoundWriteOnce |= getInvariantOffsets(CGF, 

Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-11-05 Thread Larisse Voufo via cfe-commits
lvoufo updated this revision to Diff 39467.

http://reviews.llvm.org/D13618

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/const-invariant.cpp

Index: test/CodeGenCXX/const-invariant.cpp
===
--- test/CodeGenCXX/const-invariant.cpp
+++ test/CodeGenCXX/const-invariant.cpp
@@ -37,8 +37,8 @@
 #if defined(OBJ)
 struct A {
   int a;
-  int b;
-  A(int a) : a(a) {}
+  Const int b;
+  A(int a) : a(a), b(a) {}
 };
 
 // A with explicit destructor
@@ -177,6 +177,8 @@
 
 void foo(const Type* const);
 void bar(Type);
+void foo(const int* const);
+void bar(int);
 #if defined(OBJ)
 void foo_d(const D* const);
 void bar_d(D);
@@ -359,6 +361,22 @@
   // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end(
 }
 
+// Example 1 with const member of non-const object:
+// collects offsets in invariant_start call.
+void ex1_cm() {
+// CHECK: @_Z6ex1_cmv(
+#ifdef LOCAL
+  Type i(one());
+#endif
+
+  // CHECK-L-CO-OBJ: call void @_ZN1AC{{[0-9]+}}Ei({{.*}}* %i,
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.start(i64 {{[0-9]+}}, i8* {{.*}},
+  bar(i.b);
+  foo();  // Does not change i.b.
+  bar(i.b);
+  // CHECK-L-CO-OBJ: call {{.*}}@llvm.invariant.end({{.*}}, i64 {{[0-9]+}}, i8*
+}
+
 #endif  // #if defined(OBJ)
 
 // Example 1 with references and pointers:
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -259,17 +259,6 @@
 
   typedef std::vector CtorList;
 
-  struct InvariantArgs {
-llvm::CallInst *StartInst;  // TODO: Is this necessary?
-llvm::Value *Size;  // TODO: Is this necessary?
-llvm::Value *Addr;
-llvm::SmallVector Offsets;
-
-InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
-InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
-: StartInst(C), Size(S), Addr(A) {}
-  };
-
 private:
   ASTContext 
   const LangOptions 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1904,10 +1904,41 @@
 
   llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
-  CodeGenModule::InvariantArgs EmitInvariantStart(const VarDecl ,
-  llvm::Value *Addr,
-  bool IsGlobalConstant = true);
-  void EmitInvariantEnd(CodeGenModule::InvariantArgs );
+
+  /// \brief Specifes arguments to invariant_start/end intrinsic calls.
+  struct InvariantArgs {
+llvm::CallInst *StartInst;  // Contains invariant offsets.
+llvm::Value *Size;  // TODO: Is this necessary?
+llvm::Value *Addr;
+
+InvariantArgs() : StartInst(nullptr), Size(nullptr), Addr(nullptr) {}
+InvariantArgs(llvm::CallInst *C, llvm::Value *S, llvm::Value *A)
+: StartInst(C), Size(S), Addr(A) {}
+  };
+
+  /// \brief Specifies type of invariant offsets in a given record.
+  typedef llvm::SmallVector OffsetsType;
+
+private:
+
+  /// \brief Specifies offsets and whether they have already been computed.
+  /// Note: empty offsets may or may not have been computed.
+  struct OffsetsInfoType {
+bool Computed;
+OffsetsType Offsets;
+OffsetsInfoType() : Computed(false) { }
+  };
+
+  /// \brief A collection of invariant offsets per given record.
+  llvm::DenseMap InvariantOffsets;
+
+  /// \brief Compute the invariant offsets of a given Record.
+  OffsetsType& ComputeInvariantOffsets(const CXXRecordDecl *Record);
+
+public:
+  InvariantArgs EmitInvariantStart(const VarDecl , llvm::Value *Addr,
+   bool IsGlobalConstant = true);
+  void EmitInvariantEnd(InvariantArgs );
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
   void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
@@ -3226,7 +3257,7 @@
   CodeGenFunction 
   llvm::GlobalVariable *GV;
   llvm::AllocaInst *AI;
-  CodeGenModule::InvariantArgs Args;
+  CodeGenFunction::InvariantArgs Args;
 
  public:
   MarkWriteOnceWrittenRAII(CodeGenFunction , const VarDecl *D,
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -530,9 +530,9 @@
 
   /// A cleanup to call @llvm.invariant.end.
   class CallInvariantEnd final : public EHScopeStack::Cleanup {
-CodeGenModule::InvariantArgs Args;
+CodeGenFunction::InvariantArgs Args;
public:
-CallInvariantEnd(CodeGenModule::InvariantArgs ) : Args(args) {}
+CallInvariantEnd(CodeGenFunction::InvariantArgs ) : Args(args) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitInvariantEnd(Args);
@@ -927,74 +927,93 @@
   C->setDoesNotThrow();
 }
 
-/// Collect offsets in bits.
-static bool 

r252170 - Allow use of private headers in different sub-modules.

2015-11-05 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Nov  5 09:24:47 2015
New Revision: 252170

URL: http://llvm.org/viewvc/llvm-project?rev=252170=rev
Log:
Allow use of private headers in different sub-modules.

Added:
cfe/trunk/test/Modules/Inputs/private3/
cfe/trunk/test/Modules/Inputs/private3/private.h
cfe/trunk/test/Modules/Inputs/private3/public.h
cfe/trunk/test/Modules/private.modulemap
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=252170=252169=252170=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Nov  5 09:24:47 2015
@@ -231,11 +231,9 @@ static bool violatesPrivateInclude(Modul
 assert((!IsPrivateRole || IsPrivate) && "inconsistent headers and roles");
   }
 #endif
-  return IsPrivateRole &&
- // FIXME: Should we map RequestingModule to its top-level module here
- //too? This check is redundant with the isSubModuleOf check in
- //diagnoseHeaderInclusion.
- RequestedModule->getTopLevelModule() != RequestingModule;
+  return IsPrivateRole && (!RequestingModule ||
+   RequestedModule->getTopLevelModule() !=
+   RequestingModule->getTopLevelModule());
 }
 
 static Module *getTopLevelOrNull(Module *M) {
@@ -261,11 +259,6 @@ void ModuleMap::diagnoseHeaderInclusion(
   HeadersMap::iterator Known = findKnownHeader(File);
   if (Known != Headers.end()) {
 for (const KnownHeader  : Known->second) {
-  // If 'File' is part of 'RequestingModule' we can definitely include it.
-  if (Header.getModule() &&
-  Header.getModule()->isSubModuleOf(RequestingModule))
-return;
-
   // Remember private headers for later printing of a diagnostic.
   if (violatesPrivateInclude(RequestingModule, File, Header.getRole(),
  Header.getModule())) {

Added: cfe/trunk/test/Modules/Inputs/private3/private.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/private3/private.h?rev=252170=auto
==
--- cfe/trunk/test/Modules/Inputs/private3/private.h (added)
+++ cfe/trunk/test/Modules/Inputs/private3/private.h Thu Nov  5 09:24:47 2015
@@ -0,0 +1,7 @@
+#ifndef PRIVATE_H
+#define PRIVATE_H
+
+void priv();
+
+#endif
+

Added: cfe/trunk/test/Modules/Inputs/private3/public.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/private3/public.h?rev=252170=auto
==
--- cfe/trunk/test/Modules/Inputs/private3/public.h (added)
+++ cfe/trunk/test/Modules/Inputs/private3/public.h Thu Nov  5 09:24:47 2015
@@ -0,0 +1,11 @@
+#ifndef PUBLIC_H
+#define PUBLIC_H
+
+#include "private.h"
+
+void pub() {
+  priv();
+}
+
+#endif
+

Added: cfe/trunk/test/Modules/private.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/private.modulemap?rev=252170=auto
==
--- cfe/trunk/test/Modules/private.modulemap (added)
+++ cfe/trunk/test/Modules/private.modulemap Thu Nov  5 09:24:47 2015
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: cd %S
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fmodules-cache-path=%t \
+// RUN:   -I%S/Inputs/private3 -emit-module -fmodule-name=A -o %t/m.pcm %s
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fmodules-cache-path=%t \
+// RUN:   -I%S/Inputs/private3 -emit-module -fmodule-name=B -o %t/m.pcm %s
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fmodules-cache-path=%t \
+// RUN:   -I%S/Inputs/private3 -emit-module -fmodule-name=C -o %t/m.pcm %s
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fmodules-cache-path=%t \
+// RUN:   -I%S/Inputs/private3 -emit-module -fmodule-name=D -o %t/m.pcm %s
+
+module A {
+  header "Inputs/private3/public.h"
+  private header "Inputs/private3/private.h"
+}
+module B {
+  header "Inputs/private3/public.h"
+  module "private.h" {
+private header "Inputs/private3/private.h"
+  }
+}
+module C {
+  module "public.h" {
+header "Inputs/private3/public.h"
+  }
+  private header "Inputs/private3/private.h"
+}
+module D {
+  module "public.h" {
+header "Inputs/private3/public.h"
+  }
+  module "private.h" {
+private header "Inputs/private3/private.h"
+  }
+}


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


Re: [PATCH] D14378: Fix another case where loop-convert wasn't handling correctly data members.

2015-11-05 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 39350.
angelgarcia added a comment.

Update the method comment.


http://reviews.llvm.org/D14378

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -240,6 +240,7 @@
 struct MemberNaming {
   const static int N = 10;
   int Ints[N], Ints_[N];
+  dependent DInts;
   void loops() {
 for (int I = 0; I < N; ++I) {
   printf("%d\n", Ints[I]);
@@ -254,8 +255,32 @@
 // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop 
instead
 // CHECK-FIXES: for (int Int : Ints_)
 // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < DInts.size(); ++I) {
+  printf("%d\n", DInts[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop 
instead
+// CHECK-FIXES: for (int DInt : DInts)
+// CHECK-FIXES-NEXT: printf("%d\n", DInt);
   }
+
+  void outOfLine();
 };
+void MemberNaming::outOfLine() {
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints_[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints_)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+}
 
 } // namespace NamingAlias
 
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -352,12 +352,12 @@
   LangOpts);
 }
 
-/// \brief If the given expression is actually a DeclRefExpr, find and return
-/// the underlying ValueDecl; otherwise, return NULL.
+/// \brief If the given expression is actually a DeclRefExpr or a MemberExpr,
+/// find and return the underlying ValueDecl; otherwise, return NULL.
 static const ValueDecl *getReferencedVariable(const Expr *E) {
   if (const DeclRefExpr *DRE = getDeclRef(E))
 return dyn_cast(DRE->getDecl());
-  if (const auto *Mem = dyn_cast(E))
+  if (const auto *Mem = dyn_cast(E->IgnoreParenImpCasts()))
 return dyn_cast(Mem->getMemberDecl());
   return nullptr;
 }


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -240,6 +240,7 @@
 struct MemberNaming {
   const static int N = 10;
   int Ints[N], Ints_[N];
+  dependent DInts;
   void loops() {
 for (int I = 0; I < N; ++I) {
   printf("%d\n", Ints[I]);
@@ -254,8 +255,32 @@
 // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
 // CHECK-FIXES: for (int Int : Ints_)
 // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < DInts.size(); ++I) {
+  printf("%d\n", DInts[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int DInt : DInts)
+// CHECK-FIXES-NEXT: printf("%d\n", DInt);
   }
+
+  void outOfLine();
 };
+void MemberNaming::outOfLine() {
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+  for (int I = 0; I < N; ++I) {
+printf("%d\n", Ints_[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Int : Ints_)
+  // CHECK-FIXES-NEXT: printf("%d\n", Int);
+}
 
 } // namespace NamingAlias
 
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -352,12 +352,12 @@
   LangOpts);
 }
 
-/// \brief If the given expression is actually a DeclRefExpr, find and return
-/// the underlying ValueDecl; otherwise, return NULL.
+/// \brief If the given expression is actually a DeclRefExpr or a MemberExpr,
+/// find and return the underlying ValueDecl; otherwise, return NULL.
 static const ValueDecl *getReferencedVariable(const Expr *E) {
   if (const DeclRefExpr *DRE = getDeclRef(E))
 return dyn_cast(DRE->getDecl());
-  if (const auto *Mem = dyn_cast(E))
+  if (const auto *Mem = dyn_cast(E->IgnoreParenImpCasts()))
 return dyn_cast(Mem->getMemberDecl());
   return nullptr;
 }
___
cfe-commits mailing list

Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-05 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:6609
@@ +6608,3 @@
+
+  if (NewVD->hasLocalStorage() && NewVD->hasAttr()) {
+Diag(NewVD->getLocation(), diag::warn_internal_linkage_local_storage);

Is there a reason this change cannot go into SemaDeclAttr.cpp instead? That way 
we don't bother to attach the attribute in the first place.


Comment at: lib/Sema/SemaDeclAttr.cpp:3407
@@ +3406,3 @@
+ : ExpectedVariableOrFunction);
+D->dropAttr();
+  }

Why is this dropping AlwaysInlineAttr instead of returning a nullptr?


Repository:
  rL LLVM

http://reviews.llvm.org/D13925



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