Re: [PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression

2016-09-09 Thread Daniel Krupp via cfe-commits
dkrupp added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:83
@@ -78,1 +82,3 @@
+  // we can assume that the region starts at 0.
+  if (!state->isNull(extentVal).isConstrained()) {
 return UnknownVal();

NoQ wrote:
> Perhaps you could consider the memory space of the `region`, it would look a 
> bit less hacky to me.
> 
> In my dreams, i wish heap regions were no longer symbolic regions, and this 
> hack would go away then.
> 
> Also, i recall there is a bug in `isNull()`: in the `ConstraintManager` class 
> (this time i actually mean //the abstract base class// of 
> `RangeConstraintManager`) this function boils down to `assume()`, but in 
> `RangeConstraintManager` it is overridden to do a direct lookup into the 
> constraint map; which means that in fact this function does not simplify 
> symbolic expressions before answering. This code is probably unaffected 
> because extents are always either concrete or atomic symbols, but i think i'd 
> make a patch for that.
Good point!
region->getMemorySpace() does a very similar recursion as the while loop in 
this function. So I  guess the while loop can be refactored like this:

```
static SVal computeExtentBegin(SValBuilder &svalBuilder, 
const MemRegion *region) {
  const MemSpaceRegion *SR = region->getMemorySpace();
  if (SR->getKind() == MemRegion::UnknownSpaceRegionKind)
return UnknownVal();
  else
return svalBuilder.makeZeroArrayIndex();
 }
```
All test cases pass. Particularly it filters out this false positive from 
out-of-bounds.c :

```
// Don't warn when indexing below the start of a symbolic region's whose 
// base extent we don't know.
int *get_symbolic();
void test_index_below_symboloc() {
  int *buf = get_symbolic();
  buf[-1] = 0; // no-warning;
}
```



https://reviews.llvm.org/D24307



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


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

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


Comment at: change-namespace/ChangeNamespace.cpp:85
@@ +84,3 @@
+
+SourceLocation getStartOfNextLine(SourceLocation Loc, const SourceManager &SM,
+  const LangOptions &LangOpts) {

omtcyfz wrote:
> Wouldn't it be better of in some common interface?
> 
> A couple of useful cases for other refactorings come to my mind. I.e. 
> `getStartOfPreviousLine` would be nice to have there, too.
> 
> For this patch, though, I think `FIXME` would be enough.
Acked.


Comment at: change-namespace/ChangeNamespace.cpp:124
@@ +123,3 @@
+// Adds a replacement `R` into `Replaces` or merges it into `Replaces` by
+// applying all existing Replaces first if there is conflict.
+void addOrMergeReplacement(const tooling::Replacement &R,

omtcyfz wrote:
> (probably not very much related to the patch and more out of curiosity)
> 
> If there is a conflict, why does it get resolved by applying all existing 
> `Replaces` first?
It's a bit complicated to explain...Please see the comment for 
`tooling::Replacements`, specifically the `merge` function. Generally, the idea 
is that conflicting replacements will be merged into a single one so that the 
set of replacements never conflict.


Comment at: change-namespace/ChangeNamespace.cpp:139
@@ +138,3 @@
+  if (!Start.isValid() || !End.isValid()) {
+llvm::errs() << "start or end location were invalid\n";
+return tooling::Replacement();

omtcyfz wrote:
> Alex suggested using diagnostics instead of dumping stuff to `llvm::errs()` 
> in D24224 and I think it looks way better. Actually, you can output locations 
> with that, which makes error message more informative. It might be also 
> easier to track down bugs with that info, rather than with raw error messages.
> 
> That's just a nit, probably `FIXME` is enough.
> 
> Same comment applies to the other `llvm::errs()` usages in this function.
Acked.


Comment at: change-namespace/ChangeNamespace.cpp:231
@@ +230,3 @@
+
+// FIXME(ioeric): handle the following symbols:
+//   - Types in `UsingShadowDecl` (e.g. `using a::b::c;`) which are not matched

omtcyfz wrote:
> `FIXME` without handle here?
?


Comment at: change-namespace/ChangeNamespace.cpp:335
@@ +334,3 @@
+// into the old namespace after moving code from the old namespace to the new
+// namespace.
+void ChangeNamespaceTool::moveClassForwardDeclaration(

omtcyfz wrote:
> Slightly strange wording. I recall an offline discussion where you told about 
> it, so I can understand that, but probably an example would be cool to have.
There is an example in the comment for the class. Also copied it here :)


Comment at: change-namespace/ChangeNamespace.cpp:381
@@ +380,3 @@
+  llvm::StringRef Postfix = OldNs;
+  bool Consumed = Postfix.consume_front(OldNamespace);
+  assert(Consumed);

omtcyfz wrote:
> Also, if you only use this for an assert, why not just pass 
> `Postfix.consume_front(OldNamespace)` to `assert`?
I think it is not a good idea to put code with side-effect into `assert` since 
assertion can be disabled.


https://reviews.llvm.org/D24183



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


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-09 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 70793.
ioeric marked 16 inline comments as done.
ioeric added a comment.

- Addressed reviewer comments.


https://reviews.llvm.org/D24183

Files:
  CMakeLists.txt
  change-namespace/CMakeLists.txt
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/CMakeLists.txt
  change-namespace/tool/ClangChangeNamespace.cpp
  test/CMakeLists.txt
  test/change-namespace/simple-move.cpp
  unittests/CMakeLists.txt
  unittests/change-namespace/CMakeLists.txt
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- /dev/null
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -0,0 +1,234 @@
+//===-- ChangeNamespaceTests.cpp - Change namespace unit tests ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ChangeNamespace.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace change_namespace {
+namespace {
+
+class ChangeNamespaceTest : public ::testing::Test {
+public:
+  std::string runChangeNamespaceOnCode(llvm::StringRef Code) {
+clang::RewriterTestContext Context;
+clang::FileID ID = Context.createInMemoryFile(FileName, Code);
+
+std::map FileToReplacements;
+change_namespace::ChangeNamespaceTool NamespaceTool(
+OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+ast_matchers::MatchFinder Finder;
+NamespaceTool.registerMatchers(&Finder);
+std::unique_ptr Factory =
+tooling::newFrontendActionFactory(&Finder);
+tooling::runToolOnCodeWithArgs(Factory->create(), Code, {"-std=c++11"},
+   FileName);
+formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite);
+return format(Context.getRewrittenText(ID));
+  }
+
+  std::string format(llvm::StringRef Code) {
+tooling::Replacements Replaces = format::reformat(
+format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())});
+auto ChangedCode = tooling::applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(ChangedCode));
+if (!ChangedCode) {
+  llvm::errs() << llvm::toString(ChangedCode.takeError());
+  return "";
+}
+return *ChangedCode;
+  }
+
+protected:
+  std::string FileName = "input.cc";
+  std::string OldNamespace = "na::nb";
+  std::string NewNamespace = "x::y";
+  std::string FilePattern = "input.cc";
+};
+
+TEST_F(ChangeNamespaceTest, NoMatchingNamespace) {
+  std::string Code = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveWithoutTypeRefs) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "class A {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "} // na

Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-09 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: change-namespace/ChangeNamespace.cpp:232
@@ +231,3 @@
+}
+
+// FIXME(ioeric): handle the following symbols:

handle == "ioeric" here

s/FIXME(ioeric)/FIXME


Comment at: change-namespace/ChangeNamespace.cpp:336
@@ +335,3 @@
+// creates an `InsertForwardDeclaration` to insert the forward declaration back
+// into the old namespace after moving code from the old namespace to the new
+// namespace.

Ah, I see. Thank you!


https://reviews.llvm.org/D24183



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


Re: [PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-09-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 70797.
malcolm.parsons added a comment.

Improve comments
Improve doc
Add tests
Simplify implementation


https://reviews.llvm.org/D24339

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantMemberInitCheck.cpp
  clang-tidy/readability/RedundantMemberInitCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-member-init.rst
  test/clang-tidy/readability-redundant-member-init.cpp

Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s readability-redundant-member-init %t
+
+struct S {
+  S() = default;
+  S(int i) : i(i) {}
+  int i = 1;
+};
+
+struct T {
+  T(int i = 1) : i(i) {}
+  int i;
+};
+
+struct U {
+  int i;
+};
+
+// Initializer calls default constructor
+struct F1 {
+  F1() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  S f;
+};
+
+// Initializer calls default constructor with default argument
+struct F2 {
+  F2() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  T f;
+};
+
+// Multiple redundant initializers for same constructor
+struct F3 {
+  F3() : f(), g(1), h() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: initializer for 'h' is redundant [readability-redundant-member-init]
+  S f, g, h;
+};
+
+// Initializer not written
+struct NF1 {
+  NF1() {}
+  S f;
+};
+
+// Initializer doesn't call default constructor
+struct NF2 {
+  NF2() : f(1) {}
+  S f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF3 {
+  NF3() : f(1) {}
+  T f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF4 {
+  NF4() : f(2) {}
+  T f;
+};
+
+// Initializer is zero-initialization
+struct NF5 {
+  NF5() : i() {}
+  int i;
+};
+
+// Initializer is direct-initialization
+struct NF6 {
+  NF6() : i(1) {}
+  int i;
+};
+
+// Initializer is aggregate initialization of struct
+struct NF7 {
+  NF7() : f{} {}
+  U f;
+};
+
+// Initializer is aggregate initialization of array
+struct NF8 {
+  NF8() : f{} {}
+  int f[2];
+};
Index: docs/clang-tidy/checks/readability-redundant-member-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-member-init.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-redundant-member-init
+
+readability-redundant-member-init
+=
+
+Finds member initializations that are unnecessary because the same default
+constructor would be called if they were not present.
+
+Example:   
+
+.. code-block:: c++ 
+
+  // Explicitly initializing the member s is unnecessary.  
+  class Foo {
+  public:
+Foo() : s() {}
+
+  private:
+std::string s;
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -131,6 +131,7 @@
readability-named-parameter
readability-non-const-parameter
readability-redundant-control-flow
+   readability-redundant-member-init
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: clang-tidy/readability/RedundantMemberInitCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantMemberInitCheck.h
@@ -0,0 +1,36 @@
+//===--- RedundantMemberInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_MEMBER_INIT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABI

Re: [PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-09-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons marked 15 inline comments as done.


Comment at: clang-tidy/readability/RedundantMemberInitCheck.cpp:34
@@ +33,3 @@
+
+  if (Construct->getNumArgs() == 0 ||
+  Construct->getArg(0)->isDefaultArgument()) {

Other forms of initialization are not CXXConstructExprs.


https://reviews.llvm.org/D24339



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


Re: [PATCH] D24235: [OpenCL] Improve double literal handling

2016-09-09 Thread Neil Hickey via cfe-commits
neil.hickey updated this revision to Diff 70799.
neil.hickey added a comment.

Modifying formating to match LLVM style. Adding new test to confirm that the 
vararg for printf is cast up to a double is allowable.


https://reviews.llvm.org/D24235

Files:
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/fpmath.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
 
+#if __OPENCL_C_VERSION__ < 120
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
@@ -21,16 +24,22 @@
 #endif
 
   (void) 1.0;
+#ifdef FP64
+// expected-no-diagnostics
+#endif
+
 #ifdef NOFP64
-// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
+// expected-warning@-6{{double precision constant requires cl_khr_fp64, casting to single precision}}
 #endif
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
 #ifdef NOFP64
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#if __OPENCL_C_VERSION__ < 120
 void f3(void) {
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
 }
+#endif
Index: test/CodeGenOpenCL/fpmath.cl
===
--- test/CodeGenOpenCL/fpmath.cl
+++ test/CodeGenOpenCL/fpmath.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-DBL %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
@@ -21,14 +22,26 @@
   return a / b;
 }
 
+void printf(constant char* fmt, ...);
+
+#ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+void testdbllit(long *val) {
+  // CHECK-DBL: float 2.00e+01
+  // CHECK: double 2.00e+01
+  printf("%f", 20.0);
+}
 
+#ifndef NOFP64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
+#endif
 
 // CHECK: attributes #[[ATTR]] = {
 // NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1413,7 +1413,8 @@
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
+!((S.getLangOpts().OpenCLVersion >= 120 
+   && S.Context.getTargetInfo().getSupportedOpenCLOpts().cl_khr_fp64) ||
   S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -828,8 +828,18 @@
   // double.
   const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
-  BTy->getKind() == BuiltinType::Float))
-E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+  BTy->getKind() == BuiltinType::Float)) {
+if (getLangOpts().OpenCL &&
+!((getLangOpts().OpenCLVersion >= 120 &&
+   Context.getTargetInfo()
+   .getSupportedOpenCLOpts()
+   .cl_khr_fp64) ||
+  getOpenCLOptions().cl_khr_fp64)) {
+E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
+} else {
+  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+}
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
@@ -3406,8 +3416,14 @@
   if (getLangOpts().SinglePrecisionConstants) {
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_Floa

Re: [PATCH] D24235: [OpenCL] Improve double literal handling

2016-09-09 Thread Neil Hickey via cfe-commits
neil.hickey added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:837
@@ +836,3 @@
+   .getSupportedOpenCLOpts()
+   .cl_khr_fp64) ||
+  getOpenCLOptions().cl_khr_fp64)) {

Anastasia wrote:
> Could we merge this and two lines above into one?
This was the result when I ran this through clang-format so I'd rather keep it 
as it is.


https://reviews.llvm.org/D24235



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


Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor

2016-09-09 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 70802.
omtcyfz marked 2 inline comments as done.
omtcyfz added a comment.

Slightly improve the interface.

Patch is still not complete, though.


https://reviews.llvm.org/D24192

Files:
  CMakeLists.txt
  clang-refactor/CMakeLists.txt
  clang-refactor/driver/CMakeLists.txt
  clang-refactor/driver/Driver.cpp
  clang-refactor/driver/ModuleManager.cpp
  clang-refactor/driver/ModuleManager.h
  clang-refactor/modules/CMakeLists.txt
  clang-refactor/modules/core/CMakeLists.txt
  clang-refactor/modules/core/RefactoringModule.cpp
  clang-refactor/modules/core/RefactoringModule.h

Index: clang-refactor/modules/core/RefactoringModule.h
===
--- /dev/null
+++ clang-refactor/modules/core/RefactoringModule.h
@@ -0,0 +1,142 @@
+//===--- RefactoringModule.h - clang-refactor ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "clang/Basic/Diagnostic.h"
+#include "llvm/Support/Signals.h"
+#include 
+
+namespace clang {
+namespace refactor {
+
+class RefactoringModule {
+public:
+  RefactoringModule(const std::string &ModuleName,
+const std::string &ModuleMetaDescription)
+  : ModuleName(ModuleName), ModuleMetaDescription(ModuleMetaDescription) {}
+
+  //======//
+  // Refactoring cosists of 3 stages.
+  //
+  //======//
+  //
+  // Stage I: Plan execution.
+  //
+  // In this stage the submodule parses arguments, determines whether the
+  // refactoring invokation is correct and stores information neeeded to perform
+  // that refactoring in each affected translation unit.
+  //
+  // Input: Command line (?) arguments.
+  //
+  // Ouput: List of affected translation units, in which the refactoring would
+  // happen, and submodule-specific information needed for the execution.
+  //
+  // Has access to: AST  belongs to, cross-reference index.
+  //
+  //======//
+  //
+  // Stage II: Running on a single translation unit.
+  //
+  // Input: submodule-specific information needed for the execution from
+  // Stage I.
+  //
+  // Output: list of replacements and diagnostics.
+  //
+  // Has access to: AST of given translation unit.
+  //
+  //======//
+  //
+  // Stage III: Apply replacements and output diagnostics.
+  //
+  // This step is not submodule-specific. Therefore, it should be delegated to
+  // the common interface.
+  //
+  // Input: Replacements and diagnostics from stage II.
+  //
+  // Output: Applied replacements and issued diagnostics.
+  //
+  //======//
+
+  int run(int argc, const char **argv);
+
+  // Routine for registering common refactoring options.
+  //
+  // Common options reused by multiple tools like "-offset", "verbose" etc
+  // should go here.
+  void registerCommonOptions(llvm::cl::OptionCategory &Category);
+
+  // A way for each tool to provide additional options. Overriding this one is
+  // optional.
+  virtual void registerCustomOptions(llvm::cl::OptionCategory &Category) = 0;
+
+  //======//
+  // Stage I: Plan execution.
+
+  // This processes given translation unit of  and retrieves
+  // information needed for the refactoring.
+  //
+  // Input: ASTContext of translation unit  belongs to.
+  //
+  // Output: Serialized refactoring-specific information;
+  virtual std::string getExecutionInformation() = 0;
+
+  // Return translation units affected by certain refactoring. As a temporary
+  // solution it can return all translation units, regardless of them being
+  // affected by refactoring.
+  //
+  // Input: Serialized refactroing-specific information.
+  //
+  // Output: List of translation units.
+  virtual std::vector getAffectedTUs(tooling::CompilationDatabase,
+  std::string RefactoringInfo);
+  //======//
+
+  //===

[PATCH] D24383: Add addOrMerge interface to tooling::Replacements.

2016-09-09 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: klimek, djasper.
ioeric added subscribers: alexshap, hokein, omtcyfz, cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D24383

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -177,6 +177,23 @@
   llvm::consumeError(std::move(Err));
 }
 
+TEST_F(ReplacementTest, AddOrMerge) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 10, 0, "a"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement R("x.cc", 10, 0, "b");
+  Err = Replaces.add(R);
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+
+  Replaces.addOrMerge(R);
+
+  Replacements Expected(Replacement("x.cc", 10, 0, "ab"));
+  EXPECT_EQ(Expected, Replaces);
+}
+
 TEST_F(ReplacementTest, CanApplyReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -190,6 +190,27 @@
   llvm::inconvertibleErrorCode());
 }
 
+// Returns `R` with new range that refers to code after `Replaces` being
+// applied.
+Replacement
+Replacements::getReplacementInChangedCode(const Replacement &R) {
+  unsigned NewStart = getShiftedCodePosition(R.getOffset());
+  unsigned NewEnd = getShiftedCodePosition(R.getOffset() + R.getLength());
+  return Replacement(R.getFilePath(), NewStart, NewEnd - NewStart,
+ R.getReplacementText());
+}
+
+void Replacements::addOrMerge(const Replacement &R) {
+  auto Err = add(R);
+  if (!Err)
+return;
+  llvm::consumeError(std::move(Err));
+  // Failed to add R. Use `merge`.
+  Replacements NewReplaces =
+  merge(Replacements(getReplacementInChangedCode(R)));
+  Replaces = NewReplaces.Replaces;
+}
+
 namespace {
 
 // Represents a merged replacement, i.e. a replacement consisting of multiple
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -175,6 +175,12 @@
   /// refers to code after applying the current replacements.
   Replacements merge(const Replacements &Replaces) const;
 
+  /// \brief Adds `R` to the current set of replacements. If this fails,
+  /// calculates the range of R in the code after applying all existing
+  /// replacements and sets the the range of `R` to be the new range. `R` with
+  /// new range is then merged into the current replacements.
+  void addOrMerge(const Replacement &R);
+
   // Returns the affected ranges in the changed code.
   std::vector getAffectedRanges() const;
 
@@ -204,6 +210,8 @@
 
   Replacements mergeReplacements(const ReplacementsImpl &Second) const;
 
+  Replacement getReplacementInChangedCode(const Replacement &R);
+
   ReplacementsImpl Replaces;
 };
 


Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -177,6 +177,23 @@
   llvm::consumeError(std::move(Err));
 }
 
+TEST_F(ReplacementTest, AddOrMerge) {
+  Replacements Replaces;
+  auto Err = Replaces.add(Replacement("x.cc", 10, 0, "a"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+
+  Replacement R("x.cc", 10, 0, "b");
+  Err = Replaces.add(R);
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+
+  Replaces.addOrMerge(R);
+
+  Replacements Expected(Replacement("x.cc", 10, 0, "ab"));
+  EXPECT_EQ(Expected, Replaces);
+}
+
 TEST_F(ReplacementTest, CanApplyReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -190,6 +190,27 @@
   llvm::inconvertibleErrorCode());
 }
 
+// Returns `R` with new range that refers to code after `Replaces` being
+// applied.
+Replacement
+Replacements::getReplacementInChangedCode(const Replacement &R) {
+  unsigned NewStart = getShiftedCodePosition(R.getOffset());
+  unsigned NewEnd = getShiftedCodePosition(R.getOffset() + R.getLength());
+  return Replacement(R.getFilePath(), NewStart, NewEnd - NewStart,
+ R.getReplacementText());
+}
+
+void Replacements::addOrMerge(const Replacement &R) {
+  auto Err = add(R);
+  if (!Err)
+return;
+  llvm::consumeError(std::move(Err));
+  // Failed 

Re: [PATCH] D24349: [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()

2016-09-09 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for the patch!

In https://reviews.llvm.org/D24349#537500, @aaron.ballman wrote:

> In https://reviews.llvm.org/D24349#537350, @Eugene.Zelenko wrote:
>
> > Probably check should have options to extend list of containers and also to 
> > assume all classes with integer type size() const and bool empty() const as 
> > containers. It may be not trivial to find out all custom containers and 
> > last option will be helpful to assemble such list.
>
>
> I think this should actually have two options: one is a list of 
> default-checked containers (default is the list of 
>  STL containers we previously had), and the other is a Boolean option for 
> guessing at what might be a 
>  container based on function signature (default is true). This gives people a 
> way to silence the diagnostic 
>  while still being useful.


While I understand your concerns, I would suggest to wait for actual bug 
reports before introducing more options. The duck typing approach worked really 
well for readability-redundant-smartptr-get and I expect it to work equally 
well here. The constraints checked here are pretty strict and should make the 
check safe.

> I would document what function signatures we use as our heuristic, but note 
> that the function signatures we care about may change (for instance, we may 
> decide that const-qualification is unimportant, or that we want to require 
> begin()/end() functions, etc). I think ` size() const` 
> and `bool empty() const` are a reasonable heuristic for a first pass.


Yep, documentation should be updated accordingly.



Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:33
@@ +32,3 @@
+  const auto validContainer = namedDecl(
+  has(functionDecl(
+  isPublic(), hasName("size"), returns(isInteger()),

aaron.ballman wrote:
> omtcyfz wrote:
> > Thank you!
> > 
> > Blacklisted these types.
> > 
> > Actually, I believe if someone has `bool size()` in their codebase there's 
> > still a problem...
> > Blacklisted these types.
> 
> I'm still not certain this is correct. For instance, if someone wants to do 
> `uint8_t size() const;`, we shouldn't punish them because `uint8_t` happens 
> to be `unsigned char` for their platform. But you are correct that we don't 
> want this to work with char32_t, for instance.
> 
> I think the best approach is to make a local matcher for the type predicate. 
> We want isInteger() unless it's char (that's not explicitly qualified with 
> signed or unsigned), bool, wchar_t, char16_t, char32_t, or an enumeration 
> type.
> 
> > Actually, I believe if someone has bool size() in their codebase there's 
> > still a problem...
> 
> Agreed, though not as part of this check. ;-)
Same here, let's wait for a real user asking to support his real container 
class that defines `uint8_t size() const;`.


Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:145
@@ -144,3 +144,3 @@
   }
   diag(MemberCall->getLocStart(), "the 'empty' method should be used to check "
   "for emptiness instead of 'size'")

Since we're expanding the set of supported classes, it makes sense to include 
the name of the class to the diagnostic message.


Repository:
  rL LLVM

https://reviews.llvm.org/D24349



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


Re: [PATCH] D24349: [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()

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

In https://reviews.llvm.org/D24349#538098, @alexfh wrote:

> Thank you for the patch!
>
> In https://reviews.llvm.org/D24349#537500, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D24349#537350, @Eugene.Zelenko wrote:
> >
> > > Probably check should have options to extend list of containers and also 
> > > to assume all classes with integer type size() const and bool empty() 
> > > const as containers. It may be not trivial to find out all custom 
> > > containers and last option will be helpful to assemble such list.
> >
> >
> > I think this should actually have two options: one is a list of 
> > default-checked containers (default is the list of 
> >  STL containers we previously had), and the other is a Boolean option for 
> > guessing at what might be a 
> >  container based on function signature (default is true). This gives people 
> > a way to silence the diagnostic 
> >  while still being useful.
>
>
> While I understand your concerns, I would suggest to wait for actual bug 
> reports before introducing more options. The duck typing approach worked 
> really well for readability-redundant-smartptr-get and I expect it to work 
> equally well here. The constraints checked here are pretty strict and should 
> make the check safe.


That means there is no way to silence this check on false positives aside from 
disabling it entirely, which is not a particularly good user experience. 
However, I do agree that if we constrain the heuristic appropriately, the 
number of false positives should be low.



Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:33
@@ +32,3 @@
+  const auto validContainer = namedDecl(
+  has(functionDecl(
+  isPublic(), hasName("size"), returns(isInteger()),

alexfh wrote:
> aaron.ballman wrote:
> > omtcyfz wrote:
> > > Thank you!
> > > 
> > > Blacklisted these types.
> > > 
> > > Actually, I believe if someone has `bool size()` in their codebase 
> > > there's still a problem...
> > > Blacklisted these types.
> > 
> > I'm still not certain this is correct. For instance, if someone wants to do 
> > `uint8_t size() const;`, we shouldn't punish them because `uint8_t` happens 
> > to be `unsigned char` for their platform. But you are correct that we don't 
> > want this to work with char32_t, for instance.
> > 
> > I think the best approach is to make a local matcher for the type 
> > predicate. We want isInteger() unless it's char (that's not explicitly 
> > qualified with signed or unsigned), bool, wchar_t, char16_t, char32_t, or 
> > an enumeration type.
> > 
> > > Actually, I believe if someone has bool size() in their codebase there's 
> > > still a problem...
> > 
> > Agreed, though not as part of this check. ;-)
> Same here, let's wait for a real user asking to support his real container 
> class that defines `uint8_t size() const;`.
I'm not certain I agree with that (I don't like adding new functionality that 
is known to be imprecise, especially when dealing with heuristic-based 
checking), but I don't have that strong of feelings.


Repository:
  rL LLVM

https://reviews.llvm.org/D24349



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


r281018 - Update clang for D21514. NFC

2016-09-09 Thread Amaury Sechet via cfe-commits
Author: deadalnix
Date: Thu Sep  8 23:42:49 2016
New Revision: 281018

URL: http://llvm.org/viewvc/llvm-project?rev=281018&view=rev
Log:
Update clang for D21514. NFC

Summary: As per title.

Reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=281018&r1=281017&r2=281018&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Sep  8 23:42:49 2016
@@ -2758,10 +2758,11 @@ void CodeGenFunction::EmitTrapCheck(llvm
 llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
   llvm::CallInst *TrapCall = Builder.CreateCall(CGM.getIntrinsic(IntrID));
 
-  if (!CGM.getCodeGenOpts().TrapFuncName.empty())
-TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex,
-   "trap-func-name",
-   CGM.getCodeGenOpts().TrapFuncName);
+  if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
+auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",
+  CGM.getCodeGenOpts().TrapFuncName);
+TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex, A);
+  }
 
   return TrapCall;
 }


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


[PATCH] D24373: [Coroutines] Adding builtins for coroutine intrinsics and backendutil support.

2016-09-09 Thread Gor Nishanov via cfe-commits
GorNishanov created this revision.
GorNishanov added reviewers: rsmith, majnemer.
GorNishanov added a subscriber: cfe-commits.
Herald added subscribers: beanz, mehdi_amini.

With this commit simple coroutines can be created in plain C using coroutine 
builtins (see coro.c and coro.h for an example):


https://reviews.llvm.org/D24373

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CMakeLists.txt
  test/Coroutines/Inputs/coro.h
  test/Coroutines/coro.c

Index: test/Coroutines/coro.c
===
--- /dev/null
+++ test/Coroutines/coro.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines -emit-llvm %s -o - -O3 | FileCheck %s
+#include "Inputs/coro.h"
+void print(int);
+
+void* f() {
+  CORO_BEGIN(malloc);
+
+  for (int i = 0;; ++i) {
+print(i);
+CORO_SUSPEND();
+  }
+
+  CORO_END(free);
+}
+
+// CHECK-LABEL: @main
+int main() {
+  void* coro = f();
+  CORO_RESUME(coro);
+  CORO_RESUME(coro);
+  CORO_DESTROY(coro);
+// CHECK: call void @print(i32 0)
+// CHECK: call void @print(i32 1)
+// CHECK: call void @print(i32 2)
+}
Index: test/Coroutines/Inputs/coro.h
===
--- /dev/null
+++ test/Coroutines/Inputs/coro.h
@@ -0,0 +1,36 @@
+void free(void *ptr);
+void *malloc(unsigned int);
+
+#define CORO_SUSPEND_IMPL(IsFinal) \
+  switch (__builtin_coro_suspend(__builtin_coro_save(0), IsFinal)) {   \
+  case 0:  \
+if (IsFinal)   \
+  __builtin_trap();\
+break; \
+  case 1:  \
+goto coro_Cleanup; \
+  default: \
+goto coro_Suspend; \
+  }
+
+#define CORO_SUSPEND() CORO_SUSPEND_IMPL(0)
+#define CORO_FINAL_SUSPEND() CORO_SUSPEND_IMPL(1)
+
+#define CORO_BEGIN(AllocFunc)  \
+  void *coro_hdl = __builtin_coro_begin(__builtin_coro_id(0, 0, 0, 0), \
+AllocFunc(__builtin_coro_size()));
+
+#define CORO_END(FreeFunc) \
+  coro_Cleanup : { \
+void *coro_mem = __builtin_coro_free(coro_hdl);\
+if (coro_mem)  \
+  FreeFunc(coro_mem);  \
+  }\
+  coro_Suspend:\
+  __builtin_coro_end(0, 0);\
+  return coro_hdl;
+
+#define CORO_RESUME(hdl) __builtin_coro_resume(hdl)
+#define CORO_DESTROY(hdl) __builtin_coro_destroy(hdl)
+
+
Index: lib/CodeGen/CMakeLists.txt
===
--- lib/CodeGen/CMakeLists.txt
+++ lib/CodeGen/CMakeLists.txt
@@ -3,6 +3,7 @@
   BitReader
   BitWriter
   Core
+  Coroutines
   Coverage
   IPO
   IRReader
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -462,6 +462,25 @@
   return Builder.CreateCall(F, {EmitScalarExpr(E), CI});
 }
 
+// Emit intrinsic with all of the parameters as specified in the builtin.
+// We special case llvm.coro.free, as it takes a token parameter that has no
+// representation in the __builtin type system.
+static RValue emitSimpleIntrinsic(CodeGenFunction &CGF, const CallExpr *E,
+  Intrinsic::ID ID) {
+  SmallVector Args;
+  switch (ID) {
+  default:
+break;
+  case Intrinsic::coro_free:
+Args.push_back(llvm::ConstantTokenNone::get(CGF.getLLVMContext()));
+break;
+  }
+  for (auto &Arg : E->arguments())
+Args.push_back(CGF.EmitScalarExpr(Arg));
+  Value *F = CGF.CGM.getIntrinsic(ID);
+  return RValue::get(CGF.Builder.CreateCall(F, Args));
+}
+
 RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
 unsigned BuiltinID, const CallExpr *E,
 ReturnValueSlot ReturnValue) {
@@ -2057,6 +2076,41 @@
 break;
   }
 
+  case Builtin::BI__builtin_coro_size: {
+ASTContext &Context = getContext();
+auto SizeTy = Context.getSizeType();
+IntegerType *T = Builder.getIntNT

Re: [PATCH] D24349: [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()

2016-09-09 Thread Kirill Bobyrev via cfe-commits
omtcyfz removed rL LLVM as the repository for this revision.
omtcyfz updated this revision to Diff 70818.
omtcyfz added a comment.

Restricted `size()` and `empty()` functions a little bit more.


https://reviews.llvm.org/D24349

Files:
  clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  test/clang-tidy/clang-cl-driver.cpp
  test/clang-tidy/readability-container-size-empty.cpp

Index: test/clang-tidy/readability-container-size-empty.cpp
===
--- test/clang-tidy/readability-container-size-empty.cpp
+++ test/clang-tidy/readability-container-size-empty.cpp
@@ -24,9 +24,34 @@
 };
 }
 
-
 }
 
+template 
+class TemplatedContainer {
+public:
+  int size() const;
+  bool empty() const;
+};
+
+template 
+class PrivateEmpty {
+public:
+  int size() const;
+private:
+  bool empty() const;
+};
+
+struct BoolSize {
+  bool size() const;
+  bool empty() const;
+};
+
+struct EnumSize {
+  enum E { one };
+  enum E size() const;
+  bool empty() const;
+};
+
 int main() {
   std::set intSet;
   std::string str;
@@ -39,6 +64,7 @@
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
   // CHECK-FIXES: {{^  }}if (intSet.empty()){{$}}
+  // CHECK-MESSAGES: :23:8: note: method 'set'::empty() defined here
   if (str.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
@@ -127,6 +153,110 @@
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (vect4.empty()){{$}}
+
+  TemplatedContainer templated_container;
+  if (templated_container.size() == 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size() != 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (0 == templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (0 != templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() > 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (0 < templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() < 1)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (1 > templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size() >= 1)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (1 <= templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() > 1) // no warning
+;
+  if (1 < templated_container.size()) // no warning
+;
+  if (templated_container.size() <= 1) // no warning
+;
+  if (1 >= templated_container.size()) // no warning
+;
+  if (!templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+
+  if (templated_container.empty())
+;
+
+  // No warnings expected.
+  PrivateEmpty private_empty;
+  if (private_empty.size() == 0)
+;
+  if (private_empty.size() != 0)
+;
+  if (0 == private_empty.size())
+;
+  if (0 != private_empty.size())
+;
+  if (private_empty.size() > 0)
+;
+  if (0 < private_empty.size())
+;
+  if (private_empty.size() < 1)
+;
+  if (1 > private_empty.size())
+;
+  if (private_empty.size() >= 1)
+;
+  if (1 <= private_empty.size())
+;
+  if (private_empty.size() > 1)
+;
+  if (1 < private_empty.size())
+;
+  if (private_empty.size() <= 1)
+;
+  if (1 >= private_empty.size())
+;
+  if (!private_empty.size())
+;
+  if (private_empty.size())
+;
+
+  // Typ

Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h

2016-09-09 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

This seems related:
https://reviews.llvm.org/D20596

In that (stale) review, I switch away from unique_ptr in general for locale 
related operations.


https://reviews.llvm.org/D24374



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


Re: [PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression

2016-09-09 Thread Daniel Krupp via cfe-commits
dkrupp updated this revision to Diff 70821.
dkrupp added a comment.

I tried to address all your comments.

1. computeExtentBegin() is greatly simplified.
2. addExtendSize() is simplified (scaleValue() function inlined)
3. new testcases added a) allocation and indexing of non-array element (int *ip 
=new int;) b) allocation of array with run-time size


https://reviews.llvm.org/D24307

Files:
  lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/out-of-bounds-new.cpp

Index: test/Analysis/out-of-bounds-new.cpp
===
--- /dev/null
+++ test/Analysis/out-of-bounds-new.cpp
@@ -0,0 +1,150 @@
+// RUN: %clang_cc1 -std=c++11 -Wno-array-bounds -analyze -analyzer-checker=unix,core,alpha.security.ArrayBoundV2 -verify %s
+
+// Tests doing an out-of-bounds access after the end of an array using:
+// - constant integer index
+// - constant integer size for buffer
+void test1(int x) {
+  int *buf = new int[100];
+  buf[100] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ok(int x) {
+  int *buf = new int[100];
+  buf[99] = 1; // no-warning
+}
+
+// Tests doing an out-of-bounds access after the end of an array using:
+// - indirect pointer to buffer
+// - constant integer index
+// - constant integer size for buffer
+void test1_ptr(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p[101] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_ok(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p[99] = 1; // no-warning
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer, manipulated using simple pointer arithmetic
+// - constant integer index
+// - constant integer size for buffer
+void test1_ptr_arith(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p = p + 100;
+  p[0] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_arith_ok(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p = p + 99;
+  p[0] = 1; // no-warning
+}
+
+void test1_ptr_arith_bad(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p = p + 99;
+  p[1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_arith_ok2(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p = p + 99;
+  p[-1] = 1; // no-warning
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - constant integer index
+// - constant integer size for buffer
+void test2(int x) {
+  int *buf = new int[100];
+  buf[-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer
+// - constant integer index
+// - constant integer size for buffer
+void test2_ptr(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  p[-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer, manipulated using simple pointer arithmetic
+// - constant integer index
+// - constant integer size for buffer
+void test2_ptr_arith(int x) {
+  int *buf = new int[100];
+  int *p = buf;
+  --p;
+  p[0] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
+}
+
+// Tests under-indexing
+// of a multi-dimensional array
+void test2_multi(int x) {
+  auto buf = new int[100][100];
+  buf[0][-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests under-indexing
+// of a multi-dimensional array
+void test2_multi_b(int x) {
+  auto buf = new int[100][100];
+  buf[-1][0] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests over-indexing
+// of a multi-dimensional array
+void test2_multi_c(int x) {
+  auto buf = new int[100][100];
+  buf[100][0] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests over-indexing
+// of a multi-dimensional array
+void test2_multi_2(int x) {
+  auto buf = new int[100][100];
+  buf[99][100] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests normal access of
+// a multi-dimensional array
+void test2_multi_ok(int x) {
+  auto buf = new int[100][100];
+  buf[0][0] = 1; // no-warning
+}
+
+// Tests over-indexing using different types
+// array
+void test_diff_types(int x) {
+  int *buf = new int[10]; //10*sizeof(int) Bytes allocated
+  char *cptr = (char *)buf;
+  cptr[sizeof(int) * 9] = 1;  // no-warning
+  cptr[sizeof(int) * 10] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests over-indexing
+//if the allocated area is non-array
+void test_non_array(int x) {
+  int *ip = new int;
+  ip[0] = 1; // no-warning
+  ip[1] = 2; // expected-warning{{Out of bound memory access}}
+}
+
+//Tests over-indexing
+//if the allocated area size is a runtime parameter
+void test_dynamic_size(int s) {
+  int *buf = new int[s];
+  b

Re: [PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression

2016-09-09 Thread Daniel Krupp via cfe-commits
dkrupp added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1011
@@ +1010,3 @@
+// containing the elements.
+Region = (State->getSVal(NE, LCtx))
+ .getAsRegion()

MemRegion has now method called castAs<>, only getAs<>, so I stayed with it.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1020
@@ +1019,3 @@
+  }
+  assert(Region);
+

I changed the type of Region to SubRegion, hope this is clearer this way.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1043
@@ -988,3 +1042,3 @@
 void MallocChecker::checkPreStmt(const CXXDeleteExpr *DE,
  CheckerContext &C) const {
 

now inlined


https://reviews.llvm.org/D24307



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


Re: [PATCH] D24349: [clang-tidy] Extend readability-container-size-empty to arbitrary class with size() and empty()

2016-09-09 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 70822.
omtcyfz added a comment.

Allow inheritance for `size()` and `empty()`.


https://reviews.llvm.org/D24349

Files:
  clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  docs/clang-tidy/checks/readability-container-size-empty.rst
  test/clang-tidy/clang-cl-driver.cpp
  test/clang-tidy/readability-container-size-empty.cpp

Index: test/clang-tidy/readability-container-size-empty.cpp
===
--- test/clang-tidy/readability-container-size-empty.cpp
+++ test/clang-tidy/readability-container-size-empty.cpp
@@ -24,9 +24,44 @@
 };
 }
 
-
 }
 
+template 
+class TemplatedContainer {
+public:
+  int size() const;
+  bool empty() const;
+};
+
+template 
+class PrivateEmpty {
+public:
+  int size() const;
+private:
+  bool empty() const;
+};
+
+struct BoolSize {
+  bool size() const;
+  bool empty() const;
+};
+
+struct EnumSize {
+  enum E { one };
+  enum E size() const;
+  bool empty() const;
+};
+
+class Container {
+public:
+  int size() const;
+  bool empty() const;
+};
+
+class Derived : public Container {
+};
+
+
 int main() {
   std::set intSet;
   std::string str;
@@ -39,6 +74,7 @@
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
   // CHECK-FIXES: {{^  }}if (intSet.empty()){{$}}
+  // CHECK-MESSAGES: :23:8: note: method 'set'::empty() defined here
   if (str.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
@@ -127,6 +163,116 @@
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (vect4.empty()){{$}}
+
+  TemplatedContainer templated_container;
+  if (templated_container.size() == 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size() != 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (0 == templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (0 != templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() > 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (0 < templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() < 1)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (1 > templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size() >= 1)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (1 <= templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container.size() > 1) // no warning
+;
+  if (1 < templated_container.size()) // no warning
+;
+  if (templated_container.size() <= 1) // no warning
+;
+  if (1 >= templated_container.size()) // no warning
+;
+  if (!templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (templated_container.empty()){{$}}
+  if (templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+
+  if (templated_container.empty())
+;
+
+  // No warnings expected.
+  PrivateEmpty private_empty;
+  if (private_empty.size() == 0)
+;
+  if (private_empty.size() != 0)
+;
+  if (0 == private_empty.size())
+;
+  if (0 != private_empty.size())
+;
+  if (private_empty.size() > 0)
+;
+  if (0 < private_empty.size())
+;
+  if (private_empty.size() < 1)
+;
+  if (1 > private_empty.size())
+;
+  if (private_empty.size() >= 1)
+;
+  if (1 <= private_empty.size())
+;
+  if (private_empty.size() > 1)
+;
+  if (1 < private_empty.size())
+;
+  if (private_empty.size() <= 1)
+;
+  if (1 >= private

Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

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

Ping.



Comment at: clang-rename/USRFindingAction.cpp:169
@@ -160,2 +168,3 @@
<< SymbolOffset << ").\n";
+exit(1);
   } else {

alexfh wrote:
> I'd better not use `exit()` in library code and try to find a way to signal 
> the error to the caller (e.g. make the function return a bool so that 
> HandleTranslationUnit doesn't do useless work, and use 
> ASTContext::getDiagnostics() to report errors; or add a separate callback, if 
> this doesn't work for some reason).
Done.


https://reviews.llvm.org/D24224



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


[PATCH] D24395: Align declarations that are preceded by different number of commas.

2016-09-09 Thread Nikola Smiljanić via cfe-commits
nikola created this revision.
nikola added a reviewer: djasper.
nikola added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Having a template with more than one template argument breaks alignment of 
consecutive declarations. Something like this won't be correctly aligned:

int x;
std::pair y;

https://reviews.llvm.org/D24395

Files:
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9310,6 +9310,10 @@
   verifyFormat("int  oneTwoThree{0}; // comment\n"
"unsigned oneTwo; // comment",
Alignment);
+  verifyFormat("template  struct pair {};\n"
+   "inta;\n"
+   "pair b;",
+   Alignment);
   EXPECT_EQ("float const a = 5;\n"
 "\n"
 "int oneTwoThree = 123;",
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -197,7 +197,8 @@
 // finalize the previous sequence.
 template 
 static void AlignTokens(const FormatStyle &Style, F &&Matches,
-SmallVector &Changes) {
+SmallVector &Changes,
+bool AligningAssignments) {
   unsigned MinColumn = 0;
   unsigned MaxColumn = UINT_MAX;
 
@@ -214,9 +215,9 @@
   unsigned NestingLevelOfLastMatch = 0;
   unsigned NestingLevel = 0;
 
-  // Keep track of the number of commas before the matching tokens, we will 
only
-  // align a sequence of matching tokens if they are preceded by the same 
number
-  // of commas.
+  // Keep track of the number of commas before the matching tokens, when
+  // aligning assignments we will only align a sequence of matching tokens
+  // if they are preceded by the same number of commas.
   unsigned CommasBeforeLastMatch = 0;
   unsigned CommasBeforeMatch = 0;
 
@@ -271,10 +272,10 @@
   continue;
 
 // If there is more than one matching token per line, or if the number of
-// preceding commas, or the scope depth, do not match anymore, end the
-// sequence.
-if (FoundMatchOnLine || CommasBeforeMatch != CommasBeforeLastMatch ||
-NestingLevel != NestingLevelOfLastMatch)
+// preceding commas when aligning assignments, or the scope depth, do not
+// match anymore, end the sequence.
+if (FoundMatchOnLine || NestingLevel != NestingLevelOfLastMatch ||
+(AligningAssignments && CommasBeforeMatch != CommasBeforeLastMatch))
   AlignCurrentSequence();
 
 CommasBeforeLastMatch = CommasBeforeMatch;
@@ -321,7 +322,7 @@
 
 return C.Kind == tok::equal;
   },
-  Changes);
+  Changes, true);
 }
 
 void WhitespaceManager::alignConsecutiveDeclarations() {
@@ -336,7 +337,7 @@
   //   SomeVeryLongType const& v3;
 
   AlignTokens(Style, [](Change const &C) { return C.IsStartOfDeclName; },
-  Changes);
+  Changes, false);
 }
 
 void WhitespaceManager::alignTrailingComments() {


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9310,6 +9310,10 @@
   verifyFormat("int  oneTwoThree{0}; // comment\n"
"unsigned oneTwo; // comment",
Alignment);
+  verifyFormat("template  struct pair {};\n"
+   "inta;\n"
+   "pair b;",
+   Alignment);
   EXPECT_EQ("float const a = 5;\n"
 "\n"
 "int oneTwoThree = 123;",
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -197,7 +197,8 @@
 // finalize the previous sequence.
 template 
 static void AlignTokens(const FormatStyle &Style, F &&Matches,
-SmallVector &Changes) {
+SmallVector &Changes,
+bool AligningAssignments) {
   unsigned MinColumn = 0;
   unsigned MaxColumn = UINT_MAX;
 
@@ -214,9 +215,9 @@
   unsigned NestingLevelOfLastMatch = 0;
   unsigned NestingLevel = 0;
 
-  // Keep track of the number of commas before the matching tokens, we will only
-  // align a sequence of matching tokens if they are preceded by the same number
-  // of commas.
+  // Keep track of the number of commas before the matching tokens, when
+  // aligning assignments we will only align a sequence of matching tokens
+  // if they are preceded by the same number of commas.
   unsigned CommasBeforeLastMatch = 0;
   unsigned CommasBeforeMatch = 0;
 
@@ -271,10 +272,10 @@
   continue;
 
 // If there is more than one matching token per line, or if the numb

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

2016-09-09 Thread Nemanja Ivanovic via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: hfinkel, kbarton, wschmidt, amehsan, seurer.
nemanjai added subscribers: cfe-commits, echristo.
nemanjai set the repository for this revision to rL LLVM.
Herald added a subscriber: nemanjai.

This patch introduces the following builtins:
unsigned int vec_first_match_index (vector signed char, vector signed char);
unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
unsigned int vec_first_match_index (vector signed int, vector signed int);
unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
unsigned int vec_first_match_index (vector signed short, vector signed short);
unsigned int vec_first_match_index (vector unsigned short, vector unsigned 
short);
unsigned int vec_first_match_or_eos_index (vector signed char, vector signed 
char);
unsigned int vec_first_match_or_eos_index (vector unsigned char, vector 
unsigned char);
unsigned int vec_first_match_or_eos_index (vector signed int, vector signed 
int);
unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned 
int);
unsigned int vec_first_match_or_eos_index (vector signed short, vector signed 
short);
unsigned int vec_first_match_or_eos_index (vector unsigned short, vector 
unsigned short);
unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned 
char);
unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned 
int);
unsigned int vec_first_mismatch_index (vector signed short, vector signed 
short);
unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned 
short);
unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed 
char);
unsigned int vec_first_mismatch_or_eos_index (vector unsigned char, vector 
unsigned char);
unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed 
int);
unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector 
unsigned int);
unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector 
signed short);
unsigned int vec_first_mismatch_or_eos_index (vector unsigned short, vector 
unsigned short);
vector bool char vec_cmpne (vector bool char, vector bool char);
vector bool char vec_cmpne (vector signed char, vector signed char);
vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
vector bool int vec_cmpne (vector bool int, vector bool int);
vector bool int vec_cmpne (vector signed int, vector signed int);
vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
vector bool long long vec_cmpne (vector bool long long, vector bool long long);
vector bool long long vec_cmpne (vector signed long long, vector signed long 
long);
vector bool long long vec_cmpne (vector unsigned long long, vector unsigned 
long long);
vector bool short vec_cmpne (vector bool short, vector bool short);
vector bool short vec_cmpne (vector signed short, vector signed short);
vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
vector bool long long vec_cmpne (vector double, vector double);
vector bool int vec_cmpne (vector float, vector float);
vector signed char vec_cnttz (vector signed char);
vector unsigned char vec_cnttz (vector unsigned char);
vector signed int vec_cnttz (vector signed int);
vector unsigned int vec_cnttz (vector unsigned int);
vector signed long long vec_cnttz (vector signed long long);
vector unsigned long long vec_cnttz (vector unsigned long long);
vector signed short vec_cnttz (vector signed short);
vector unsigned short vec_cnttz (vector unsigned short);
vector unsigned char vec_popcnt (vector signed char);
vector unsigned char vec_popcnt (vector unsigned char);
vector unsigned int vec_popcnt (vector signed int);
vector unsigned int vec_popcnt (vector unsigned int);
vector unsigned long long vec_popcnt (vector signed long long);
vector unsigned long long vec_popcnt (vector unsigned long long);
vector unsigned short vec_popcnt (vector signed short);
vector unsigned short vec_popcnt (vector unsigned short);

Repository:
  rL LLVM

https://reviews.llvm.org/D24397

Files:
  include/clang/Basic/BuiltinsPPC.def
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-p9vector.c

Index: test/CodeGen/builtins-ppc-p9vector.c
===
--- test/CodeGen/builtins-ppc-p9vector.c
+++ test/CodeGen/builtins-ppc-p9vector.c
@@ -0,0 +1,748 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -faltivec -target-feature +power9-vector \
+// RUN:   -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -O2 -o - | FileCheck %s -check-prefix=CHECK-BE
+
+// RUN: %clang_cc1 -faltivec -target-feature +power9-vector \
+// RUN:   -triple p

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

2016-09-09 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

Looking over the patch, I realized that I forgot to add a test case for the 
__POWER9_VECTOR__ macro and the builtins that target the record forms of the 
instructions. I'll add those on the next revision along with addressing any 
review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D24378



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


[PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D24400

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   Ranges = std::vector(1, tooling::Range(17, 0));
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1119,19 +1119,28 @@
   template 
   void cleanupPair(FormatToken *Start, LeftKind LK, RightKind RK,
bool DeleteLeft) {
-auto NextNotDeleted = [this](const FormatToken &Tok) -> FormatToken * {
-  for (auto *Res = Tok.Next; Res; Res = Res->Next)
-if (!Res->is(tok::comment) &&
-DeletedTokens.find(Res) == DeletedTokens.end())
+auto NextNotDeleted = [this](
+const FormatToken &Tok,
+llvm::SmallVectorImpl &Comments) -> FormatToken * {
+  for (auto *Res = Tok.Next; Res; Res = Res->Next) {
+if (Res->is(tok::comment))
+  Comments.push_back(Res);
+else if (DeletedTokens.find(Res) == DeletedTokens.end())
   return Res;
+  }
   return nullptr;
 };
+llvm::SmallVector Comments;
 for (auto *Left = Start; Left;) {
-  auto *Right = NextNotDeleted(*Left);
+  Comments.clear();
+  auto *Right = NextNotDeleted(*Left, Comments);
   if (!Right)
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+// Delete all comments between `Left` and `Right`.
+for (auto *Comment : Comments)
+  deleteToken(Comment);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA()

[PATCH] D24401: clang-format: Add Java detection to git-clang-format.

2016-09-09 Thread Luis Héctor Chávez via cfe-commits
lhchavez created this revision.
lhchavez added a reviewer: djasper.
lhchavez added subscribers: cfe-commits, srhines.
lhchavez set the repository for this revision to rL LLVM.

This change adds "java" to the list of known extensions that clang-format 
supports.

Repository:
  rL LLVM

https://reviews.llvm.org/D24401

Files:
  cfe/trunk/tools/clang-format/git-clang-format

Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -77,6 +77,7 @@
   'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
   'js',  # JavaScript
   'ts',  # TypeScript
   ])


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -77,6 +77,7 @@
   'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
   'js',  # JavaScript
   'ts',  # TypeScript
   ])
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-09-09 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 70840.
rmaprath added a comment.
Herald added a subscriber: beanz.

Final patch incorporating all the changes from @EricWF and @compnerd.

Will commit tomorrow (@mclow.lists gave approval earlier)

/ Asiri


https://reviews.llvm.org/D21968

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  include/thread
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  
test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,10 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#define _LIBCPP_BUILDING_EXTERNAL_THREADS
+#include <__threading_support>
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -26,6 +26,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
+config.libcxx_external_thread_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
===
--- test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
+++ test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
+++ test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
+++ test/libcxx/thread/thread.condition/thread.cond

r281053 - [codeview] Extend the heuristic for detecting classes imported from DLLs

2016-09-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep  9 11:27:04 2016
New Revision: 281053

URL: http://llvm.org/viewvc/llvm-project?rev=281053&view=rev
Log:
[codeview] Extend the heuristic for detecting classes imported from DLLs

If a dynamic class contains a dllimport method, then assume the class
may not be constructed in this DLL, and therefore the vtable will live
in a different PDB.

This heuristic is still incomplete, and will miss things like abstract
base classes that are only constructed on one side of the DLL interface.
That said, this heuristic does detect some cases that are currently
problematic, and may be useful to other projects that don't use many
DLLs.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=281053&r1=281052&r2=281053&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep  9 11:27:04 2016
@@ -1707,6 +1707,16 @@ static bool isDefinedInClangModule(const
   return true;
 }
 
+/// Return true if the class or any of its methods are marked dllimport.
+static bool isClassOrMethodDLLImport(const CXXRecordDecl *RD) {
+  if (RD->hasAttr())
+return true;
+  for (const CXXMethodDecl *MD : RD->methods())
+if (MD->hasAttr())
+  return true;
+  return false;
+}
+
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
  bool DebugTypeExtRefs, const RecordDecl *RD,
  const LangOptions &LangOpts) {
@@ -1729,10 +1739,12 @@ static bool shouldOmitDefinition(codegen
 
   // Only emit complete debug info for a dynamic class when its vtable is
   // emitted.  However, Microsoft debuggers don't resolve type information
-  // across DLL boundaries, so skip this optimization if the class is marked
-  // dllimport.
+  // across DLL boundaries, so skip this optimization if the class or any of 
its
+  // methods are marked dllimport. This isn't a complete solution, since 
objects
+  // without any dllimport methods can be used in one DLL and constructed in
+  // another, but it is the current behavior of LimitedDebugInfo.
   if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
-  !CXXDecl->hasAttr())
+  !isClassOrMethodDLLImport(CXXDecl))
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;

Modified: cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp?rev=281053&r1=281052&r2=281053&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp Fri Sep  9 
11:27:04 2016
@@ -4,10 +4,23 @@
 // be imported from a DLL.  Otherwise, the debugger wouldn't be able to show 
the
 // members.
 
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OutOfLineCtor",
+// CHECK-SAME: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
 // CHECK-NOT:  DIFlagFwdDecl
 // CHECK-SAME: ){{$}}
 
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedMethod",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct OutOfLineCtor {
+  OutOfLineCtor();
+  virtual void Foo();
+};
+
 struct __declspec(dllimport) ImportedBase {
   ImportedBase();
   virtual void Foo();
@@ -15,6 +28,14 @@ struct __declspec(dllimport) ImportedBas
 
 struct DerivedFromImported : public ImportedBase {};
 
+struct ImportedMethod {
+  ImportedMethod();
+  virtual void Foo();
+  static void __declspec(dllimport) create();
+};
+
 int main() {
+  OutOfLineCtor o;
   DerivedFromImported d;
+  ImportedMethod m;
 }


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


r281056 - Make -fstandalone-debug and -flimit-debug-info available in clang-cl

2016-09-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep  9 11:42:50 2016
New Revision: 281056

URL: http://llvm.org/viewvc/llvm-project?rev=281056&view=rev
Log:
Make -fstandalone-debug and -flimit-debug-info available in clang-cl

Our limited debug info optimizations are breaking down at DLL
boundaries, so we're going to evaluate the size impact of these
settings, and possibly change the default.

Users should be able to override our settings, though.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=281056&r1=281055&r2=281056&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Sep  9 11:42:50 2016
@@ -1138,12 +1138,12 @@ def fstack_protector_strong : Flag<["-"]
   HelpText<"Use a strong heuristic to apply stack protectors to functions">;
 def fstack_protector : Flag<["-"], "fstack-protector">, Group,
   HelpText<"Enable stack protectors for functions potentially vulnerable to 
stack smashing">;
-def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group,
+def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, 
Flags<[CoreOption]>,
   HelpText<"Emit full debug info for all types used by the program">;
-def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, Group,
+def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, 
Group, Flags<[CoreOption]>,
   HelpText<"Limit debug information produced to reduce size of debug binary">;
-def flimit_debug_info : Flag<["-"], "flimit-debug-info">, 
Alias;
-def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, 
Alias;
+def flimit_debug_info : Flag<["-"], "flimit-debug-info">, Flags<[CoreOption]>, 
Alias;
+def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, 
Flags<[CoreOption]>, Alias;
 def fstrict_aliasing : Flag<["-"], "fstrict-aliasing">, Group,
   Flags<[DriverOption, CoreOption]>;
 def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=281056&r1=281055&r2=281056&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Sep  9 11:42:50 2016
@@ -518,6 +518,8 @@
 // RUN: -resource-dir \
 // RUN: -Wunused-variable \
 // RUN: -fmacro-backtrace-limit=0 \
+// RUN: -fstandalone-debug \
+// RUN: -flimit-debug-info \
 // RUN: -Werror /Zs -- %s 2>&1
 
 


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


[PATCH] D24407: [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.

2016-09-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

This fixes a bug where we were unable to compile the following CUDA
file with libstdc++ (didn't try libc++):

  #include 
  void foo() { std::shared_future x; }

The problem is that  only defines std::shared_future if
__GCC_ATOMIC_INT_LOCK_FREE > 1.  When we compiled this file for device,
the macro was set to 1, and then the class didn't exist at all.

https://reviews.llvm.org/D24407

Files:
  clang/lib/Basic/Targets.cpp
  clang/test/Preprocessor/cuda-types.cu

Index: clang/test/Preprocessor/cuda-types.cu
===
--- clang/test/Preprocessor/cuda-types.cu
+++ clang/test/Preprocessor/cuda-types.cu
@@ -1,21 +1,30 @@
-// Check that types, widths, etc. match on the host and device sides of CUDA
-// compilations.  Note that we filter out long double, as this is intentionally
-// different on host and device.
+// Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
+// device sides of CUDA compilations.  Note that we filter out long double, as
+// this is intentionally different on host and device.
+//
+// FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
+// host and device, but architecturally this is difficult at the moment.
 
-// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/i386-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > %T/i386-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' %T/i386-host-defines  
 | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' 
%T/i386-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/i386-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-device-defines-filtered
 // RUN: diff %T/i386-host-defines-filtered %T/i386-device-defines-filtered
 
-// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/x86_64-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > 
%T/x86_64-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-device-defines-filtered
 // RUN: diff %T/x86_64-host-defines-filtered %T/x86_64-device-defines-filtered
 
-// RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null > %T/powerpc64-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > 
%T/powerpc64-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-device-defines-filtered
 // RUN: diff %T/

r281057 - [DebugInfo] Ensure complete type is emitted with -fstandalone-debug

2016-09-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep  9 12:03:53 2016
New Revision: 281057

URL: http://llvm.org/viewvc/llvm-project?rev=281057&view=rev
Log:
[DebugInfo] Ensure complete type is emitted with -fstandalone-debug

The logic for upgrading a class from a forward decl to a complete type
was not checking the debug info emission level before applying the
vtable optimization. This meant we ended up without debug info for a
class which was required to be complete. I noticed it because it
triggered an assertion during CodeView emission, but that's a separate
issue.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=281057&r1=281056&r2=281057&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep  9 12:03:53 2016
@@ -1648,9 +1648,13 @@ void CGDebugInfo::completeRequiredType(c
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
 
-  if (const auto *CXXDecl = dyn_cast(RD))
-if (CXXDecl->isDynamicClass())
-  return;
+  // If this is a dynamic class and we're emitting limited debug info, wait
+  // until the vtable is emitted to complete the class debug info.
+  if (DebugKind <= codegenoptions::LimitedDebugInfo) {
+if (const auto *CXXDecl = dyn_cast(RD))
+  if (CXXDecl->isDynamicClass())
+return;
+  }
 
   if (DebugTypeExtRefs && RD->isFromASTFile())
 return;

Modified: cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp?rev=281057&r1=281056&r2=281057&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-class-nolimit.cpp Fri Sep  9 12:03:53 
2016
@@ -1,8 +1,29 @@
-// RUN: %clang_cc1 -triple x86_64-unk-unk -debug-info-kind=standalone -o - 
-emit-llvm %s | FileCheck %s
-// On Darwin, "full" debug info is the default, so really these tests are
-// identical, as cc1 no longer chooses the effective value of DebugInfoKind.
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -debug-info-kind=standalone -o 
- -emit-llvm %s | FileCheck %s
 
+// We had a bug in -fstandalone-debug where UnicodeString would not be 
completed
+// when it was required to be complete. This orginally manifested as an
+// assertion in CodeView emission on Windows with some dllexport stuff, but 
it's
+// more general than that.
+
+struct UnicodeString;
+struct GetFwdDecl {
+  static UnicodeString format;
+};
+GetFwdDecl force_fwd_decl;
+struct UnicodeString {
+private:
+  virtual ~UnicodeString();
+};
+struct UseCompleteType {
+  UseCompleteType();
+  ~UseCompleteType();
+  UnicodeString currencySpcAfterSym[1];
+};
+UseCompleteType require_complete;
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "UnicodeString"
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
 namespace rdar14101097_1 { // see also PR16214
 // Check that we emit debug info for the definition of a struct if the
 // definition is available, even if it's used via a pointer wrapped in a


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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Eli Friedman via cfe-commits
efriedma added a comment.

This is probably going to lead to someone complaining about clang realigning 
the stack on 32-bit Windows; are your sure we're choosing the right alignment 
there?


https://reviews.llvm.org/D24378



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


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

2016-09-09 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

I think will be good idea to await clang-refactor and merge code there.

Please run Include What You Use. Code use a lot of containers and will be good 
to include them explicitly.



Comment at: migrate-tool/HeaderBuild.cpp:28
@@ +27,3 @@
+}
+class Namespace {
+public:

Please separate with empty line.


https://reviews.llvm.org/D24380



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


Re: [PATCH] D24407: [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.

2016-09-09 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D24407



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


Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

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


Comment at: lib/Format/Format.cpp:1141
@@ -1134,1 +1140,3 @@
 deleteToken(DeleteLeft ? Left : Right);
+// Delete all comments between `Left` and `Right`.
+for (auto *Comment : Comments)

Couldn't you just do:

  for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
if (Tok->is(tok::comment))
  deleteToken(Comment);

That way you wouldn't have to store the comments in a vector.


https://reviews.llvm.org/D24400



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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Richard Smith via cfe-commits
There's an (unconvincing to me) explanation for why gcc does this here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19131

On 9 Sep 2016 10:14 am, "Eli Friedman"  wrote:

> efriedma added a comment.
>
> This is probably going to lead to someone complaining about clang
> realigning the stack on 32-bit Windows; are your sure we're choosing the
> right alignment there?
>
>
> https://reviews.llvm.org/D24378
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Friedman, Eli via cfe-commits
It probably makes sense to say that alloca should have the same 
alignment as the default stack alignment, simply because it's hard to do 
anything useful with completely unaligned memory.  That said, the 
default stack alignment is 4 bytes on 32-bit Windows, not 16.


-Eli

On 9/9/2016 10:29 AM, Richard Smith wrote:
There's an (unconvincing to me) explanation for why gcc does this 
here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19131


On 9 Sep 2016 10:14 am, "Eli Friedman" > wrote:


efriedma added a comment.

This is probably going to lead to someone complaining about clang
realigning the stack on 32-bit Windows; are your sure we're
choosing the right alignment there?


https://reviews.llvm.org/D24378 




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

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


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

2016-09-09 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

This all looks good to me - but with a couple nits.



Comment at: include/memory:2137
@@ -2132,3 +2136,3 @@
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
 __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)

Have you tested this on C++11?
I suspect that some of these need to be `_LIBCPP_CONSTEXPR_AFTER_CXX11`


Comment at: 
test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/constinit.pass.cpp:16
@@ +15,3 @@
+#ifndef _LIBCPP_SAFE_STATIC
+#define _LIBCPP_SAFE_STATIC
+#endif

Shouldn't this test be in the `libcxx` hierarchy, since it uses internal libcxx 
features (i.e, `_LIBCPP_SAFE_STATIC`)?


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 70863.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24400

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   Ranges = std::vector(1, tooling::Range(17, 0));
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1132,6 +1132,9 @@
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  if (Tok->is(tok::comment))
+deleteToken(Tok);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Ran

Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

One remark, otherwise looks good.



Comment at: lib/Format/Format.cpp:1136
@@ +1135,3 @@
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  if (Tok->is(tok::comment))
+deleteToken(Tok);

Hm. I think this "if" actually doesn't change behavior. If we remove it, we'd 
just add already deleted tokens to the set again, which shouldn't hurt (and we 
do it for comments at the moment). I'd just remove this line.


https://reviews.llvm.org/D24400



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


Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h

2016-09-09 Thread Shoaib Meenai via cfe-commits
smeenai planned changes to this revision.
smeenai added a comment.

@bcraig thanks for pointing me to that diff; there's a lot of nice cleanup 
going on there. Were you planning on updating and following up on it?

I also realized I forgot to adjust `locale_win32.cpp` for this diff. Will 
re-upload with that fixed.


https://reviews.llvm.org/D24374



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


Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

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


Comment at: lib/Format/Format.cpp:1136
@@ +1135,3 @@
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  if (Tok->is(tok::comment))
+deleteToken(Tok);

djasper wrote:
> Hm. I think this "if" actually doesn't change behavior. If we remove it, we'd 
> just add already deleted tokens to the set again, which shouldn't hurt (and 
> we do it for comments at the moment). I'd just remove this line.
Wow, from 20 LOC to 2 LOC! Thanks!


https://reviews.llvm.org/D24400



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


Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 70865.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24400

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   Ranges = std::vector(1, tooling::Range(17, 0));
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1132,6 +1132,8 @@
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  deleteToken(Tok);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ra

r281064 - Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Sep  9 12:50:49 2016
New Revision: 281064

URL: http://llvm.org/viewvc/llvm-project?rev=281064&view=rev
Log:
Also cleanup comments around redundant colons/commas in format::cleanup.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=281064&r1=281063&r2=281064&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Sep  9 12:50:49 2016
@@ -1132,6 +1132,8 @@ private:
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  deleteToken(Tok);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=281064&r1=281063&r2=281064&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Fri Sep  9 12:50:49 2016
@@ -188,39 +188,34 @@ TEST_F(CleanupTest, RedundantCommaNotInA
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   Ranges = std::vector(1, tooling::Range(17, 0));


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


Re: [PATCH] D24400: Also cleanup comments around redundant colons/commas in format::cleanup.

2016-09-09 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281064: Also cleanup comments around redundant colons/commas 
in format::cleanup. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D24400?vs=70865&id=70867#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24400

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1132,6 +1132,8 @@
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  deleteToken(Tok);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\n {} };";
+  Expected = "class A {\nA() : x({1})\n {} };";
   Ranges = std::vector(1, tooling::Range(25, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
-  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Expected = "class A {\nA() : x({1}),  y(1){} };";
   Ranges = std::vector(1, tooling::Range(38, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
-  Expected = "class A {\nA() : x({1}), \n/* comment */ y(1){} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
   Ranges = std::vector(1, tooling::Range(40, 0));
   Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   Ranges = std::vector(1, tooling::Range(17, 0));


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1132,6 +1132,8 @@
 break;
   if (Left->is(LK) && Right->is(RK)) {
 deleteToken(DeleteLeft ? Left : Right);
+for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
+  deleteToken(Tok);
 // If the right token is deleted, we should keep the left token
 // unchanged and pair it with the new right token.
 if (!DeleteLeft)
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -188,39 +188,34 @@
   EXPECT_EQ(Expected, Result);
 }
 
-// FIXME: delete comments too.
-TEST_F(CleanupTest, CtorInitializationCommentAroundCommas) {
-  // Remove redundant commas around comment.
-  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
-  std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };";
+TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, /* comment */ {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
   std::vector Ranges;
   Ranges.push_back(tooling::Range(25, 0));
   Ranges.push_back(tooling::Range(40, 0));
   std::string Result = cleanup(Code, Ranges);
   EXPECT_EQ(Expected, Result);
 
-  // Remove trailing comma and ignore comment.
-  Code = "class A {\nA() : x({1}), // comment\n{} };";
-  Expected = "class A {\nA() : x({1}) // comment\n{} };";
+  Code = "class A {\nA() : x({1}), // comment\

Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h

2016-09-09 Thread Ben Craig via cfe-commits
bcraig added a comment.

In https://reviews.llvm.org/D24374#538521, @smeenai wrote:

> @bcraig thanks for pointing me to that diff; there's a lot of nice cleanup 
> going on there. Were you planning on updating and following up on it?
>
> I also realized I forgot to adjust `locale_win32.cpp` for this diff. Will 
> re-upload with that fixed.


I'm still in favor of that change, but I don't expect to have the time, 
resources, or permission to submit or test that change in the near future.  I'm 
about to change jobs, and the new position doesn't involve working on the llvm 
projects.


https://reviews.llvm.org/D24374



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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D24378#538430, @efriedma wrote:

> This is probably going to lead to someone complaining about clang realigning 
> the stack on 32-bit Windows; are your sure we're choosing the right alignment 
> there?


I checked, and MSVC emits a call to __alloca_probe_16 for this code:

  extern "C" void *_alloca(size_t);
  #pragma intrinsic (_alloca)
  void g(void*);
  void f(int n) {
void *p = _alloca(n);
g(p);
  }

So, they do realign the stack. We don't really need to realign the whole stack 
frame for highly aligned dynamic allocas, though. There's no reason we can't 
overallocate from the stack and realign the returned pointer. I'm not sure if 
we do that, though...


https://reviews.llvm.org/D24378



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


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

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

In https://reviews.llvm.org/D24380#538434, @Eugene.Zelenko wrote:

> I think will be good idea to await clang-refactor and merge code there.


This tool is not exactly a clang-tool; it is a framework that invokes multiple 
clang refactoring tool and also manipulates build rules. Also, I don't think 
two on-going projects should await on one another. If this tool fits into 
clang-refactor when it's actually there, I'd be happy to merge it into 
clang-refactor.

> Please run Include What You Use. Code use a lot of containers and will be 
> good to include them explicitly.


Thanks for the tip!


https://reviews.llvm.org/D24380



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


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-09 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

This definitely seems to be useful. However, this patch is pretty big. Some of 
its parts are not directly related with the feature being introduced (for 
example, changes for copypaste/sub-sequences.cpp). Is it possible to split this 
patch? Moreover, as I understand, you may not even need a review for 
refactoring-only changes. Or you can make a review for them which will be done 
much faster.
There is a temporary dump of some stylish comments after brief look.



Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3449
@@ +3448,3 @@
+// we may optionally convert those to path notes.
+for (auto I = exampleReport->getExtraNotes().rbegin(),
+  E = exampleReport->getExtraNotes().rend(); I != E; ++I) {

Reverse iteration on array and push the corresponding element to the front 
(always O(n)) seems a bit strange to me. I suggest using a combination of 
resize + move existing elements to the end + copy/transform from start. What do 
you think? Or am I missing something?


Comment at: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:230
@@ +229,3 @@
+unsigned NumExtraPieces = 0;
+for (auto I = path.begin(), E = path.end(); I != E; ++I) {
+  if (const auto *P = dyn_cast(I->get())) {

const auto &Piece : path?


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:117
@@ +116,3 @@
+  // First, add extra notes, even if paths should not be included.
+  for (PathPieces::const_iterator PI = PD->path.begin(),
+  PE = PD->path.end(); PI != PE; ++PI) {

Range-for loop may look nicer here. What do you think?


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:119
@@ +118,3 @@
+  PE = PD->path.end(); PI != PE; ++PI) {
+if (!isa(PI->get()))
+  continue;

if (isa<...>()) {
  ...
  ...
}
?


https://reviews.llvm.org/D24278



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


Re: [PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

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

I agree that it is weird that region store modifies the value it was asked to 
bind and over all this seems like the right approach.

My big concern with this patch is that the logic that looks whether an lval is 
being stored into a non-reference location and dereferences it seems overly 
broad. I'm worried that this could paper over other issues by "fixing up" 
mismatches that are really the result of some other bug. Is there a way to make 
that logic more targeted? For example, if it only applies to initializing char 
arrays with string literals, that is a much more precise check for when to load 
from the lvalue.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:536
@@ -535,3 +535,3 @@
   } else {
 // We bound the temp obj region to the CXXConstructExpr. Now recover
 // the lazy compound value when the variable is not a reference.

It seems like this comment ("We bound the temp obj region to the 
CXXConstructorExpr...") is incomplete/misleading (and has been for a while) 
because this code is executed when there is no constructor. Can it be updated 
to something more helpful?


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:665
@@ +664,3 @@
+// type, as any expression. We need to read this type and make the
+// necessary conversions.
+if (const RecordType *RT =

I am surprised Sema wouldn't have already added an implicit cast with an lvalue 
to rvalue conversion when needed. It seems in many cases it already does. Can 
you be more explicit in your comments about why this is needed and under what 
situations Sema doesn't handle this logic? Is initializing an array with a 
string literal the only time this is needed? If so, can the check be more 
targeted? I'll note that `InitListExpr` has an `isStringLiteralInit()` method 
and that CodeGen has a special case for it.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:669
@@ +668,3 @@
+  // For structures, check if the respective field is a reference.
+  // FIXME: What if fields mismatch?
+  const RecordDecl *RD = RT->getDecl();

NoQ wrote:
> Whoops, was a note to myself, didn't mean to leave it here, sorry. Will 
> actually have a look and update.
It is probably also worth looking into what it would take to support unions 
here.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:673
@@ +672,3 @@
+  auto FieldI = RD->field_begin(), FieldE = RD->field_end();
+  for (auto InitI = IE->rbegin(), InitE = IE->rend();
+   InitI != InitE; ++InitI) {

If you are going to iterate through the initializer expressions in reverse, you 
also have to iterate through the field decls in reverse. Also, I think it is 
worth commenting why you iterate in reverse order here.


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:679
@@ +678,3 @@
+SVal V = state->getSVal(E, LCtx);
+if (E->isLValue() && !V.isUnknownOrUndef() &&
+!FieldI->getType()->isReferenceType())

This logic for checking with an expression is an lvalue and whether the type of 
the storage location is reference and loading from the lvalue if not is 
duplicated 3 times in this patch. Can you factor it out and give an meaningful 
name?


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:696
@@ +695,3 @@
+  V = state->getSVal(V.castAs(), ET);
+vals = getBasicVals().consVals(V, vals);
+  }

I think it would good to add a test with array fillers if we don't already have 
them. For example:

```
int a[2000] = {1, 2, 3};
clang_analyzer_eval(a[0] == 1);
clang_analyzer_eval(a[1999] == 0);
```


Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:699
@@ +698,3 @@
+} else {
+  // Vector values, complex numbers, etc: No lvalues to expect.
+  for (auto InitI = IE->rbegin(), InitE = IE->rend();

Should there be an assert here to make sure we have enumerated all the cases? 
I'm worried about the 'etc'. How will we know if we have not considered a case?


https://reviews.llvm.org/D23963



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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Eli Friedman via cfe-commits
efriedma added a comment.

Huh... then I guess this is fine.


https://reviews.llvm.org/D24378



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


Re: [PATCH] D24378: [CodeGen] Provide an appropriate alignment for dynamic allocas

2016-09-09 Thread Richard Smith via cfe-commits
On Fri, Sep 9, 2016 at 10:45 AM, Friedman, Eli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> It probably makes sense to say that alloca should have the same alignment
> as the default stack alignment, simply because it's hard to do anything
> useful with completely unaligned memory.  That said, the default stack
> alignment is 4 bytes on 32-bit Windows, not 16.
>

Well, if the allocated size is dynamic, it would seem preferable to provide
a pointer that's suitably-aligned for anything that can fit within it, and
even on 32-bit x86 that means 16 byte alignment if we want to support SSE.
But if the size is known, there doesn't seem to be any need to provide an
alignment greater than the allocated size.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281071 - Myriad: nominally "support" ASAN.

2016-09-09 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Fri Sep  9 13:20:49 2016
New Revision: 281071

URL: http://llvm.org/viewvc/llvm-project?rev=281071&view=rev
Log:
Myriad: nominally "support" ASAN.

Doesn't work, but needs to be enabled in order to get there.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=281071&r1=281070&r2=281071&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep  9 13:20:49 2016
@@ -5042,6 +5042,10 @@ Tool *MyriadToolChain::buildLinker() con
   return new tools::Myriad::Linker(*this);
 }
 
+SanitizerMask MyriadToolChain::getSupportedSanitizers() const {
+  return SanitizerKind::Address;
+}
+
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
  const llvm::opt::ArgList &Args)
   : ToolChain(D, Triple, Args) {

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=281071&r1=281070&r2=281071&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep  9 13:20:49 2016
@@ -1147,6 +1147,7 @@ public:
   llvm::opt::ArgStringList &CC1Args) const override;
   Tool *SelectTool(const JobAction &JA) const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
+  SanitizerMask getSupportedSanitizers() const override;
 
 protected:
   Tool *buildLinker() const override;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=281071&r1=281070&r2=281071&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep  9 13:20:49 2016
@@ -3081,11 +3081,15 @@ static void linkSanitizerRuntimeDeps(con
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  CmdArgs.push_back("-lpthread");
-  CmdArgs.push_back("-lrt");
+  // There's no libpthread or librt on RTEMS.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+CmdArgs.push_back("-lpthread");
+CmdArgs.push_back("-lrt");
+  }
   CmdArgs.push_back("-lm");
-  // There's no libdl on FreeBSD.
-  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+  // There's no libdl on FreeBSD or RTEMS.
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
+  TC.getTriple().getOS() != llvm::Triple::RTEMS)
 CmdArgs.push_back("-ldl");
 }
 
@@ -11055,9 +11059,12 @@ void tools::Myriad::Linker::ConstructJob
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(TC, Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
   if (UseDefaultLibs) {
+if (NeedsSanitizerDeps)
+  linkSanitizerRuntimeDeps(TC, CmdArgs);
 if (C.getDriver().CCCIsCXX())
   CmdArgs.push_back("-lstdc++");
 if (T.getOS() == llvm::Triple::RTEMS) {

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=281071&r1=281070&r2=281071&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Fri Sep  9 13:20:49 2016
@@ -151,6 +151,15 @@
 // CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
 // CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target sparcel-myriad-rtems-elf -fsanitize=address \
+// RUN: --sysroot=%S/Inputs/basic_myriad_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-MYRIAD %s
+//
+// CHECK-ASAN-MYRIAD: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-MYRIAD-NOT: "-lc"
+// CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=thread \


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


Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith  wrote:

> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren  wrote:
>
>> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
>> wrote:
>>
>>> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: mren
 Date: Tue Sep  6 13:16:54 2016
 New Revision: 280728

 URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
 Log:
 Modules: Fix an assertion in DeclContext::buildLookup.

 When calling getMostRecentDecl, we can pull in more definitions from
 a module. We call getPrimaryContext afterwards to make sure that
 we buildLookup on a primary context.

 rdar://27926200

 Added:
 cfe/trunk/test/Modules/Inputs/lookup-assert/
 cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
 cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
 cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
 cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
 cfe/trunk/test/Modules/lookup-assert.m
 Modified:
 cfe/trunk/lib/AST/DeclBase.cpp

 Modified: cfe/trunk/lib/AST/DeclBase.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
 se.cpp?rev=280728&r1=280727&r2=280728&view=diff
 
 ==
 --- cfe/trunk/lib/AST/DeclBase.cpp (original)
 +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
 @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
assert(DeclKind != Decl::LinkageSpec &&
   "Should not perform lookups into linkage specs!");

 -  const DeclContext *PrimaryContext = getPrimaryContext();
 -  if (PrimaryContext != this)
 -return PrimaryContext->lookup(Name);
 -
// If we have an external source, ensure that any later
 redeclarations of this
// context have been loaded, since they may add names to the result
 of this
// lookup (or add external visible storage).
 @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
if (Source)
  (void)cast(this)->getMostRecentDecl();

 +  // getMostRecentDecl can change the result of getPrimaryContext. Call
 +  // getPrimaryContext afterwards.
 +  const DeclContext *PrimaryContext = getPrimaryContext();
 +  if (PrimaryContext != this)
 +return PrimaryContext->lookup(Name);

>>>
>>> This seems like a bug in getPrimaryContext() -- if there is a
>>> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
>>> return that instead of returning a non-defining declaration. Why is
>>> ObjCInterfaceDecl::hasDefinition (indirectly called by
>>> getPrimaryContext) not loading the definition in this case?
>>>
>>
>> In the testing case, we have a definition of the ObjC interface from
>> textually including a header file, but the definition is also in a module.
>> getPrimaryContext for ObjCInterface currently does not  pull from the
>> external source.
>>
>
> As far as I can see, it does. For ObjCInterface, getPrimaryContext calls
> ObjCInterface::getDefinition:
>
>   ObjCInterfaceDecl *getDefinition() {
> return hasDefinition()? Data.getPointer()->Definition : nullptr;
>   }
>
> hasDefinition() pulls from the external source to find a definition, if it
> believes the definition is out of date:
>
>   bool hasDefinition() const {
> // If the name of this class is out-of-date, bring it up-to-date, which
> // might bring in a definition.
> // Note: a null value indicates that we don't have a definition and
> that
> // modules are enabled.
> if (!Data.getOpaqueValue())
>   getMostRecentDecl();
>
> return Data.getPointer();
>   }
>
--> You are right, this is the backtrace when calling getPrimaryContext.
  * frame #0: 0x000102e6c1b0
clang`clang::ObjCInterfaceDecl::hasDefinition(this=0x00010f079a38)
const + 16 at DeclObjC.h:1445
frame #1: 0x000105d09009
clang`clang::ObjCInterfaceDecl::getDefinition(this=0x00010f079a38) + 25
at DeclObjC.h:1455
frame #2: 0x000105d08b2b
clang`clang::DeclContext::getPrimaryContext(this=0x00010f079a60) + 171
at DeclBase.cpp:1013
frame #3: 0x000105d08a75
clang`clang::DeclContext::getPrimaryContext(this=0x00010f079a60) const
+ 21 at DeclBase.h:1360
frame #4: 0x000105d0cda4
clang`clang::DeclContext::lookup(this=0x00010f079a60, Name=(Ptr =
4547240953)) const + 164 at DeclBase.cpp:1416
frame #5: 0x000105d30804
clang`clang::ObjCContainerDecl::getMethod(this=0x00010f079a38,
Sel=(InfoPtr = 4547240953), isInstance=true, AllowHidden=false) const + 212
at DeclObjC.cpp:86
frame #6: 0x000105d347bd
clang`clang::ObjCInterfaceDecl::lookupMethod(this=0x00010f079c88,
Sel=(InfoPtr = 4547240953), isInstance=true, shallowCategoryLookup=false,
followSuper=true, C=0x) const + 221 at Dec

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Richard Smith via cfe-commits
On Fri, Sep 9, 2016 at 11:29 AM, Manman Ren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith 
> wrote:
>
>> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren  wrote:
>>
>>> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
>>> wrote:
>>>
 On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: mren
> Date: Tue Sep  6 13:16:54 2016
> New Revision: 280728
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
> Log:
> Modules: Fix an assertion in DeclContext::buildLookup.
>
> When calling getMostRecentDecl, we can pull in more definitions from
> a module. We call getPrimaryContext afterwards to make sure that
> we buildLookup on a primary context.
>
> rdar://27926200
>
> Added:
> cfe/trunk/test/Modules/Inputs/lookup-assert/
> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
> cfe/trunk/test/Modules/lookup-assert.m
> Modified:
> cfe/trunk/lib/AST/DeclBase.cpp
>
> Modified: cfe/trunk/lib/AST/DeclBase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>assert(DeclKind != Decl::LinkageSpec &&
>   "Should not perform lookups into linkage specs!");
>
> -  const DeclContext *PrimaryContext = getPrimaryContext();
> -  if (PrimaryContext != this)
> -return PrimaryContext->lookup(Name);
> -
>// If we have an external source, ensure that any later
> redeclarations of this
>// context have been loaded, since they may add names to the result
> of this
>// lookup (or add external visible storage).
> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>if (Source)
>  (void)cast(this)->getMostRecentDecl();
>
> +  // getMostRecentDecl can change the result of getPrimaryContext.
> Call
> +  // getPrimaryContext afterwards.
> +  const DeclContext *PrimaryContext = getPrimaryContext();
> +  if (PrimaryContext != this)
> +return PrimaryContext->lookup(Name);
>

 This seems like a bug in getPrimaryContext() -- if there is a
 not-yet-loaded definition of the DeclContext, getPrimaryContext() should
 return that instead of returning a non-defining declaration. Why is
 ObjCInterfaceDecl::hasDefinition (indirectly called by
 getPrimaryContext) not loading the definition in this case?

>>>
>>> In the testing case, we have a definition of the ObjC interface from
>>> textually including a header file, but the definition is also in a module.
>>> getPrimaryContext for ObjCInterface currently does not  pull from the
>>> external source.
>>>
>>
>> As far as I can see, it does. For ObjCInterface, getPrimaryContext calls
>> ObjCInterface::getDefinition:
>>
>>   ObjCInterfaceDecl *getDefinition() {
>> return hasDefinition()? Data.getPointer()->Definition : nullptr;
>>   }
>>
>> hasDefinition() pulls from the external source to find a definition, if
>> it believes the definition is out of date:
>>
>>   bool hasDefinition() const {
>> // If the name of this class is out-of-date, bring it up-to-date,
>> which
>> // might bring in a definition.
>> // Note: a null value indicates that we don't have a definition and
>> that
>> // modules are enabled.
>> if (!Data.getOpaqueValue())
>>   getMostRecentDecl();
>>
>> return Data.getPointer();
>>   }
>>
> --> You are right, this is the backtrace when calling getPrimaryContext.
>   * frame #0: 0x000102e6c1b0 clang`clang::ObjCInterfaceDecl::
> hasDefinition(this=0x00010f079a38) const + 16 at DeclObjC.h:1445
> frame #1: 0x000105d09009 clang`clang::ObjCInterfaceDecl::
> getDefinition(this=0x00010f079a38) + 25 at DeclObjC.h:1455
> frame #2: 0x000105d08b2b clang`clang::DeclContext::
> getPrimaryContext(this=0x00010f079a60) + 171 at DeclBase.cpp:1013
> frame #3: 0x000105d08a75 clang`clang::DeclContext::
> getPrimaryContext(this=0x00010f079a60) const + 21 at DeclBase.h:1360
> frame #4: 0x000105d0cda4 
> clang`clang::DeclContext::lookup(this=0x00010f079a60,
> Name=(Ptr = 4547240953)) const + 164 at DeclBase.cpp:1416
> frame #5: 0x000105d30804 clang`clang::
> ObjCContainerDecl::getMethod(this=0x00010f079a38, Sel=(InfoPtr =
> 4547240953), isInstance=true, AllowHidden=false) const + 212 at
> Dec

Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

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

Thanks!

I could have split this up into three patches (one for the core and two patches 
for the checkers), however that'd mean that the first patch comes without 
tests; so i thought that the patch should be self-contained. Was it a bad idea 
after all?



Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3449
@@ +3448,3 @@
+// we may optionally convert those to path notes.
+for (auto I = exampleReport->getExtraNotes().rbegin(),
+  E = exampleReport->getExtraNotes().rend(); I != E; ++I) {

a.sidorin wrote:
> Reverse iteration on array and push the corresponding element to the front 
> (always O(n)) seems a bit strange to me. I suggest using a combination of 
> resize + move existing elements to the end + copy/transform from start. What 
> do you think? Or am I missing something?
`PathPieces` is an `std::list`, so each push is O(1).


https://reviews.llvm.org/D24278



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


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

2016-09-09 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: 
test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/constinit.pass.cpp:19-23
@@ +18,6 @@
+
+_LIBCPP_SAFE_STATIC static std::unique_ptr a;
+
+int main() {
+assert(a == nullptr);
+}

This is a bit painful to test without _LIBCPP_SAFE_STATIC, because the contents 
of `a` will be all 0 bits on program startup regardless of whether static or 
dynamic initialization is performed. Something like this might work though:

  extern std::unique_ptr a;
  void *trample = std::memset(&a, 0xab, sizeof(a));
  _LIBCPP_SAFE_STATIC std::unique_ptr a;

  int main() {
// Check that the initialization of 'a' was performed before the 
initialization of 'trample'.
for (size_t n = 0; n != sizeof(a); ++n)
  assert(reinterpret_cast(trample)[n] == 0xab);
// Put a unique_ptr object back so that the global dtor is valid.
new (&a) std::unique_ptr;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


Re: [PATCH] D24235: [OpenCL] Improve double literal handling

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

LGTM! Thanks!


https://reviews.llvm.org/D24235



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


Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
On Fri, Sep 9, 2016 at 11:33 AM, Richard Smith 
wrote:

> On Fri, Sep 9, 2016 at 11:29 AM, Manman Ren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith 
>> wrote:
>>
>>> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren 
>>> wrote:
>>>
 On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
 wrote:

> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: mren
>> Date: Tue Sep  6 13:16:54 2016
>> New Revision: 280728
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>> Log:
>> Modules: Fix an assertion in DeclContext::buildLookup.
>>
>> When calling getMostRecentDecl, we can pull in more definitions from
>> a module. We call getPrimaryContext afterwards to make sure that
>> we buildLookup on a primary context.
>>
>> rdar://27926200
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>> cfe/trunk/test/Modules/lookup-assert.m
>> Modified:
>> cfe/trunk/lib/AST/DeclBase.cpp
>>
>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>assert(DeclKind != Decl::LinkageSpec &&
>>   "Should not perform lookups into linkage specs!");
>>
>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>> -  if (PrimaryContext != this)
>> -return PrimaryContext->lookup(Name);
>> -
>>// If we have an external source, ensure that any later
>> redeclarations of this
>>// context have been loaded, since they may add names to the
>> result of this
>>// lookup (or add external visible storage).
>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>if (Source)
>>  (void)cast(this)->getMostRecentDecl();
>>
>> +  // getMostRecentDecl can change the result of getPrimaryContext.
>> Call
>> +  // getPrimaryContext afterwards.
>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>> +  if (PrimaryContext != this)
>> +return PrimaryContext->lookup(Name);
>>
>
> This seems like a bug in getPrimaryContext() -- if there is a
> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
> return that instead of returning a non-defining declaration. Why is
> ObjCInterfaceDecl::hasDefinition (indirectly called by
> getPrimaryContext) not loading the definition in this case?
>

 In the testing case, we have a definition of the ObjC interface from
 textually including a header file, but the definition is also in a module.
 getPrimaryContext for ObjCInterface currently does not  pull from the
 external source.

>>>
>>> As far as I can see, it does. For ObjCInterface, getPrimaryContext calls
>>> ObjCInterface::getDefinition:
>>>
>>>   ObjCInterfaceDecl *getDefinition() {
>>> return hasDefinition()? Data.getPointer()->Definition : nullptr;
>>>   }
>>>
>>> hasDefinition() pulls from the external source to find a definition, if
>>> it believes the definition is out of date:
>>>
>>>   bool hasDefinition() const {
>>> // If the name of this class is out-of-date, bring it up-to-date,
>>> which
>>> // might bring in a definition.
>>> // Note: a null value indicates that we don't have a definition and
>>> that
>>> // modules are enabled.
>>> if (!Data.getOpaqueValue())
>>>   getMostRecentDecl();
>>>
>>> return Data.getPointer();
>>>   }
>>>
>> --> You are right, this is the backtrace when calling getPrimaryContext.
>>   * frame #0: 0x000102e6c1b0 clang`clang::ObjCInterfaceDecl
>> ::hasDefinition(this=0x00010f079a38) const + 16 at DeclObjC.h:1445
>> frame #1: 0x000105d09009 clang`clang::ObjCInterfaceDecl
>> ::getDefinition(this=0x00010f079a38) + 25 at DeclObjC.h:1455
>> frame #2: 0x000105d08b2b clang`clang::DeclContext::getP
>> rimaryContext(this=0x00010f079a60) + 171 at DeclBase.cpp:1013
>> frame #3: 0x000105d08a75 clang`clang::DeclContext::getP
>> rimaryContext(this=0x00010f079a60) const + 21 at DeclBase.h:1360
>> frame #4: 0x000105d0cda4 
>> clang`clang::DeclContext::lookup(this=0x00010f079a60,
>> Name=(Ptr = 4547240953)) const + 164 at DeclBase.cpp:1416
>> fram

r281078 - Modules: revert r280728.

2016-09-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Sep  9 14:03:07 2016
New Revision: 281078

URL: http://llvm.org/viewvc/llvm-project?rev=281078&view=rev
Log:
Modules: revert r280728.

In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

Removed:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/lookup-assert.m
Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=281078&r1=281077&r2=281078&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Sep  9 14:03:07 2016
@@ -1413,6 +1413,10 @@ DeclContext::lookup(DeclarationName Name
   assert(DeclKind != Decl::LinkageSpec && DeclKind != Decl::Export &&
  "should not perform lookups into transparent contexts");
 
+  const DeclContext *PrimaryContext = getPrimaryContext();
+  if (PrimaryContext != this)
+return PrimaryContext->lookup(Name);
+
   // If we have an external source, ensure that any later redeclarations of 
this
   // context have been loaded, since they may add names to the result of this
   // lookup (or add external visible storage).
@@ -1420,12 +1424,6 @@ DeclContext::lookup(DeclarationName Name
   if (Source)
 (void)cast(this)->getMostRecentDecl();
 
-  // getMostRecentDecl can change the result of getPrimaryContext. Call
-  // getPrimaryContext afterwards.
-  const DeclContext *PrimaryContext = getPrimaryContext();
-  if (PrimaryContext != this)
-return PrimaryContext->lookup(Name);
-
   if (hasExternalVisibleStorage()) {
 assert(Source && "external visible storage but no external source?");
 

Removed: cfe/trunk/test/Modules/lookup-assert.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert.m?rev=281077&view=auto
==
--- cfe/trunk/test/Modules/lookup-assert.m (original)
+++ cfe/trunk/test/Modules/lookup-assert.m (removed)
@@ -1,10 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert %s -verify
-// expected-no-diagnostics
-
-#include "Derive.h"
-#import 
-@implementation DerivedInterface
-- (void)test {
-}
-@end


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


Re: [PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

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

Hi Doug,

Can you take a look at the updated version?

Thanks,
Manman


https://reviews.llvm.org/D23079



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


Re: [PATCH] D24238: StaticAnalyzer CastToStruct : No memory corruption when casting array to struct

2016-09-09 Thread Artem Dergachev via cfe-commits
NoQ added a subscriber: cfe-commits.
NoQ added a comment.

Adding cfe-commits as per developer policy.

Yeah, it doesn't probably cause the same kind of memory corruption, however i 
wouldn't call this code safe: it still violates the //strict aliasing rule//, 
unless the array is of `char`s. I think this warning is worth keeping for 
non-`char` arrays. Even with `-fno-strict-aliasing` of some sort, the 
programmer might run into endianness or alignment issues.


https://reviews.llvm.org/D24238



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


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-09 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

Neat!  I would have liked to have had this for the Excess Padding Checker.  
Currently, the padding checker has a very long diagnostic that recommends a new 
order for data members.  I think a note (or fixit) would be more appropriate, 
but that support didn't exist previously.


https://reviews.llvm.org/D24278



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


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

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

In https://reviews.llvm.org/D24380#538556, @ioeric wrote:

> In https://reviews.llvm.org/D24380#538434, @Eugene.Zelenko wrote:
>
> > I think will be good idea to await clang-refactor and merge code there.
>
>
> This tool is not exactly a clang-tool; it is a framework that invokes 
> multiple clang refactoring tool and also manipulates build rules. Also, I 
> don't think two on-going projects should await on one another. If this tool 
> fits into clang-refactor when it's actually there, I'd be happy to merge it 
> into clang-refactor.


+1 on that. It's fine to push standalone tools first.


https://reviews.llvm.org/D24380



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


Re: [PATCH] D24371: Add diagnostics to require_constant_initialization

2016-09-09 Thread Richard Smith via cfe-commits
rsmith added a comment.

There's no way for `-verify` to test for a diagnostic with an invalid location 
at the moment. Maybe add a FIXME and disable that portion of the test for C++11?



Comment at: lib/Sema/SemaDecl.cpp:10535-10538
@@ -10534,1 +10534,6 @@
   << attr->getRange();
+APValue Value;
+SmallVector Notes;
+cast(var->ensureEvaluatedStmt()->Value)->EvaluateAsInitializer(
+  Value, getASTContext(), var, Notes);
+for (auto &it : Notes)

Can you capture the diagnostics from `checkInitIsICE` instead of recomputing 
them here? (It looks straightforward to add an overload that takes a vector of 
notes.) In the non-C++11 case, you can produce a note pointing to 
`CacheCulprit` instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D24371



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


Re: [PATCH] D24371: Add diagnostics to require_constant_initialization

2016-09-09 Thread Keno Fischer via cfe-commits
loladiro added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10535-10538
@@ -10534,1 +10534,6 @@
   << attr->getRange();
+APValue Value;
+SmallVector Notes;
+cast(var->ensureEvaluatedStmt()->Value)->EvaluateAsInitializer(
+  Value, getASTContext(), var, Notes);
+for (auto &it : Notes)

rsmith wrote:
> Can you capture the diagnostics from `checkInitIsICE` instead of recomputing 
> them here? (It looks straightforward to add an overload that takes a vector 
> of notes.) In the non-C++11 case, you can produce a note pointing to 
> `CacheCulprit` instead.
The problem is that the result of checking is cached internally and the 
diagnostics are only produced the first time. I don't think it's necessarily 
guaranteed that the above `checkInitIsICE` is the first such call (unless you 
can see such a reason). 


Repository:
  rL LLVM

https://reviews.llvm.org/D24371



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


Re: [PATCH] D24371: Add diagnostics to require_constant_initialization

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


Comment at: lib/Sema/SemaDecl.cpp:10535-10538
@@ -10534,1 +10534,6 @@
   << attr->getRange();
+APValue Value;
+SmallVector Notes;
+cast(var->ensureEvaluatedStmt()->Value)->EvaluateAsInitializer(
+  Value, getASTContext(), var, Notes);
+for (auto &it : Notes)

loladiro wrote:
> rsmith wrote:
> > Can you capture the diagnostics from `checkInitIsICE` instead of 
> > recomputing them here? (It looks straightforward to add an overload that 
> > takes a vector of notes.) In the non-C++11 case, you can produce a note 
> > pointing to `CacheCulprit` instead.
> The problem is that the result of checking is cached internally and the 
> diagnostics are only produced the first time. I don't think it's necessarily 
> guaranteed that the above `checkInitIsICE` is the first such call (unless you 
> can see such a reason). 
That's unfortunate, but yeah, it's not reasonable to rely on that. Please just 
use `Init` instead of `cast(var->ensureEvaluatedStmt()->Value)` here 
(`ensureEvaluatedStmt()` really ought to be a private member of `VarDecl`...).


Repository:
  rL LLVM

https://reviews.llvm.org/D24371



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


Re: [PATCH] D24312: [CodeGen] Fix an assert in EmitNullConstant

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

LGTM.


https://reviews.llvm.org/D24312



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


r281089 - [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.

2016-09-09 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep  9 15:35:43 2016
New Revision: 281089

URL: http://llvm.org/viewvc/llvm-project?rev=281089&view=rev
Log:
[CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.

Summary:
This fixes a bug where we were unable to compile the following CUDA
file with libstdc++ (didn't try libc++):

  #include 
  void foo() { std::shared_future x; }

The problem is that  only defines std::shared_future if
__GCC_ATOMIC_INT_LOCK_FREE > 1.  When we compiled this file for device,
the macro was set to 1, and then the class didn't exist at all.

Reviewers: tra

Subscribers: cfe-commits, jhen

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/cuda-types.cu

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=281089&r1=281088&r2=281089&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Sep  9 15:35:43 2016
@@ -1768,6 +1768,12 @@ public:
 UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
 ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
 
+// This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and
+// we need those macros to be identical on host and device, because (among
+// other things) they affect which standard library classes are defined, 
and
+// we need all classes to be defined on both the host and device.
+MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
+
 // Properties intentionally not copied from host:
 // - LargeArrayMinWidth, LargeArrayAlign: Not visible across the
 //   host/device boundary.

Modified: cfe/trunk/test/Preprocessor/cuda-types.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cuda-types.cu?rev=281089&r1=281088&r2=281089&view=diff
==
--- cfe/trunk/test/Preprocessor/cuda-types.cu (original)
+++ cfe/trunk/test/Preprocessor/cuda-types.cu Fri Sep  9 15:35:43 2016
@@ -1,21 +1,30 @@
-// Check that types, widths, etc. match on the host and device sides of CUDA
-// compilations.  Note that we filter out long double, as this is intentionally
-// different on host and device.
+// Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
+// device sides of CUDA compilations.  Note that we filter out long double, as
+// this is intentionally different on host and device.
+//
+// FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
+// host and device, but architecturally this is difficult at the moment.
 
-// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/i386-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > %T/i386-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' %T/i386-host-defines  
 | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' 
%T/i386-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/i386-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-device-defines-filtered
 // RUN: diff %T/i386-host-defines-filtered %T/i386-device-defines-filtered
 
-// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/x86_64-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > 
%T/x86_64-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/nul

Re: [PATCH] D24407: [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.

2016-09-09 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281089: [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the 
same on host/device. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24407?vs=70857&id=70895#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24407

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/cuda-types.cu

Index: cfe/trunk/test/Preprocessor/cuda-types.cu
===
--- cfe/trunk/test/Preprocessor/cuda-types.cu
+++ cfe/trunk/test/Preprocessor/cuda-types.cu
@@ -1,21 +1,30 @@
-// Check that types, widths, etc. match on the host and device sides of CUDA
-// compilations.  Note that we filter out long double, as this is intentionally
-// different on host and device.
+// Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
+// device sides of CUDA compilations.  Note that we filter out long double, as
+// this is intentionally different on host and device.
+//
+// FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
+// host and device, but architecturally this is difficult at the moment.
 
-// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/i386-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > %T/i386-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' %T/i386-host-defines  
 | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)' 
%T/i386-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/i386-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-device-defines-filtered
 // RUN: diff %T/i386-host-defines-filtered %T/i386-device-defines-filtered
 
-// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null > %T/x86_64-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > 
%T/x86_64-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/x86_64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/x86_64-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-device-defines-filtered
 // RUN: diff %T/x86_64-host-defines-filtered %T/x86_64-device-defines-filtered
 
-// RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null > %T/powerpc64-host-defines
-// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null > 
%T/powerpc64-device-defines
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-host-defines   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-host-defines-filtered
-// RUN: grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF\|WIDTH\)' 
%T/powerpc64-device-defines | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-device-defines-filtered
+// RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
__GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > 
%T/powerpc64-device-defines-filtered
 // RUN: diff %T/powerpc64-host-defines-filtered 
%T/powerpc64-device-defines-filtered
Index: cfe/trunk/lib/Basic/Targets.cpp
===

Re: [PATCH] D24411: [Analyzer] Suppress false positives on the clang static analyzer

2016-09-09 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

IIRC, I was the primary author of this code, I'd really appreciate if you could 
attribute the code to the authors. Thanks


https://reviews.llvm.org/D24411



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


[PATCH] D24426: DebugInfo: use llvm::DINode::FlagAlignment to mark forcibly aligned data

2016-09-09 Thread Victor Leschuk via cfe-commits
vleschuk created this revision.
vleschuk added reviewers: echristo, aprantl, dblaikie, mehdi_amini.
vleschuk added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

Add llvm::DINode::FlagAlignment to entities marked with C++11 'alignas', C11 
'_Alignas' keywords or ObjC clang attribute((aligned (N))).

https://reviews.llvm.org/D24426

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -232,10 +232,17 @@
   CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS,
llvm::DIFile *F);
 
-  llvm::DIType *createFieldType(StringRef name, QualType type,
-SourceLocation loc, AccessSpecifier AS,
-uint64_t offsetInBits, llvm::DIFile *tunit,
-llvm::DIScope *scope,
+  llvm::DIType *createFieldType(StringRef Name, QualType Type,
+SourceLocation Loc, AccessSpecifier AS,
+uint64_t OffsetInBits,
+llvm::DIFile *TUnit, llvm::DIScope *Scope,
+const RecordDecl *RD = nullptr);
+
+  llvm::DIType *createFieldType(StringRef Name, QualType Type,
+SourceLocation Loc, uint64_t AlignInBits,
+uint64_t OffsetInBits,
+llvm::DINode::DIFlags Flags,
+llvm::DIFile *TUnit, llvm::DIScope *Scope,
 const RecordDecl *RD = nullptr);
 
   /// Create new bit field member.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -976,27 +976,49 @@
 }
 
 llvm::DIType *
-CGDebugInfo::createFieldType(StringRef name, QualType type, SourceLocation loc,
- AccessSpecifier AS, uint64_t offsetInBits,
- llvm::DIFile *tunit, llvm::DIScope *scope,
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ AccessSpecifier AS, uint64_t OffsetInBits,
+ llvm::DIFile *TUnit, llvm::DIScope *Scope,
  const RecordDecl *RD) {
-  llvm::DIType *debugType = getOrCreateType(type, tunit);
+  llvm::DIType *DebugType = getOrCreateType(Type, TUnit);
 
   // Get the location for the field.
-  llvm::DIFile *file = getOrCreateFile(loc);
-  unsigned line = getLineNumber(loc);
+  llvm::DIFile *File = getOrCreateFile(Loc);
+  unsigned Line = getLineNumber(Loc);
 
   uint64_t SizeInBits = 0;
-  unsigned AlignInBits = 0;
-  if (!type->isIncompleteArrayType()) {
-TypeInfo TI = CGM.getContext().getTypeInfo(type);
+  uint64_t AlignInBits = 0;
+  if (!Type->isIncompleteArrayType()) {
+TypeInfo TI = CGM.getContext().getTypeInfo(Type);
 SizeInBits = TI.Width;
 AlignInBits = TI.Align;
   }
+  llvm::DINode::DIFlags Flags = getAccessFlag(AS, RD);
 
-  llvm::DINode::DIFlags flags = getAccessFlag(AS, RD);
-  return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
-   AlignInBits, offsetInBits, flags, debugType);
+  return DBuilder.createMemberType(Scope, Name, File, Line, SizeInBits,
+   AlignInBits, OffsetInBits, Flags, DebugType);
+}
+
+llvm::DIType *
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ uint64_t AlignInBits, uint64_t OffsetInBits,
+ llvm::DINode::DIFlags Flags,
+ llvm::DIFile *TUnit, llvm::DIScope *Scope,
+ const RecordDecl *RD) {
+  llvm::DIType *DebugType = getOrCreateType(Type, TUnit);
+
+  // Get the location for the field.
+  llvm::DIFile *File = getOrCreateFile(Loc);
+  unsigned Line = getLineNumber(Loc);
+
+  uint64_t SizeInBits = 0;
+  if (!Type->isIncompleteArrayType()) {
+TypeInfo TI = CGM.getContext().getTypeInfo(Type);
+SizeInBits = TI.Width;
+  }
+
+  return DBuilder.createMemberType(Scope, Name, File, Line, SizeInBits,
+   AlignInBits, OffsetInBits, Flags, DebugType);
 }
 
 void CGDebugInfo::CollectRecordLambdaFields(
@@ -1012,15 +1034,21 @@
  E = CXXDecl->captures_end();
I != E; ++I, ++Field, ++fieldno) {
 const LambdaCapture &C = *I;
+uint64_t AlignInBits = 0;
+llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
 if (C.capturesVariable()) {
   SourceLocation Loc = C.getLocation();
   assert(!Field->isBitField() && "lambdas don't have bitfield members!");
   VarDecl *V = C.getCapturedVar();
   StringRef VName = V->getName();
+

Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h

2016-09-09 Thread Shoaib Meenai via cfe-commits
smeenai updated this revision to Diff 70899.
smeenai added a comment.

Correcting support_win32.cpp


https://reviews.llvm.org/D24374

Files:
  include/support/win32/locale_win32.h
  src/support/win32/locale_win32.cpp

Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -10,6 +10,11 @@
 
 #include 
 #include  // va_start, va_end
+#include 
+#include 
+
+typedef _VSTD::remove_pointer::type __locale_struct;
+typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
 
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -17,7 +17,6 @@
 #include "support/win32/support.h"
 #include "support/win32/locale_mgmt_win32.h"
 #include 
-#include 
 
 lconv *localeconv_l( locale_t loc );
 size_t mbrlen_l( const char *__restrict s, size_t n,
@@ -34,13 +33,10 @@
  size_t nwc, size_t len, mbstate_t *__restrict ps, 
locale_t loc);
 wint_t btowc_l( int c, locale_t loc );
 int wctob_l( wint_t c, locale_t loc );
-typedef _VSTD::remove_pointer::type __locale_struct;
-typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
 inline _LIBCPP_ALWAYS_INLINE
 decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
 {
-  __locale_raii __current( uselocale(__l), uselocale );
-  return MB_CUR_MAX;
+  return ___mb_cur_max_l_func(__l);
 }
 
 // the *_l functions are prefixed on Windows, only available for msvcr80+, 
VS2005+


Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -10,6 +10,11 @@
 
 #include 
 #include  // va_start, va_end
+#include 
+#include 
+
+typedef _VSTD::remove_pointer::type __locale_struct;
+typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
 
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -17,7 +17,6 @@
 #include "support/win32/support.h"
 #include "support/win32/locale_mgmt_win32.h"
 #include 
-#include 
 
 lconv *localeconv_l( locale_t loc );
 size_t mbrlen_l( const char *__restrict s, size_t n,
@@ -34,13 +33,10 @@
  size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);
 wint_t btowc_l( int c, locale_t loc );
 int wctob_l( wint_t c, locale_t loc );
-typedef _VSTD::remove_pointer::type __locale_struct;
-typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
 inline _LIBCPP_ALWAYS_INLINE
 decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
 {
-  __locale_raii __current( uselocale(__l), uselocale );
-  return MB_CUR_MAX;
+  return ___mb_cur_max_l_func(__l);
 }
 
 // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h

2016-09-09 Thread Shoaib Meenai via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D24374#538534, @bcraig wrote:

> In https://reviews.llvm.org/D24374#538521, @smeenai wrote:
>
> > @bcraig thanks for pointing me to that diff; there's a lot of nice cleanup 
> > going on there. Were you planning on updating and following up on it?
> >
> > I also realized I forgot to adjust `locale_win32.cpp` for this diff. Will 
> > re-upload with that fixed.
>
>
> I'm still in favor of that change, but I don't expect to have the time, 
> resources, or permission to submit or test that change in the near future.  
> I'm about to change jobs, and the new position doesn't involve working on the 
> llvm projects.


Ah, that's unfortunate.


https://reviews.llvm.org/D24374



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


r281094 - Debug info: Bump the default DWARF version on Darwin to 4.

2016-09-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep  9 16:10:35 2016
New Revision: 281094

URL: http://llvm.org/viewvc/llvm-project?rev=281094&view=rev
Log:
Debug info: Bump the default DWARF version on Darwin to 4.

This is a spiritual re-commit of r201375 with only a brief delay
for upgrading the green dragon builders.

Modified:
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/CodeGen/dwarf-version.c
cfe/trunk/test/Driver/clang-g-opts.c
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=281094&r1=281093&r2=281094&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep  9 16:10:35 2016
@@ -585,7 +585,7 @@ public:
   void AddLinkARCArgs(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 2; }
+  unsigned GetDefaultDwarfVersion() const override { return 4; }
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // Darwin defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }

Modified: cfe/trunk/test/CodeGen/dwarf-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dwarf-version.c?rev=281094&r1=281093&r2=281094&view=diff
==
--- cfe/trunk/test/CodeGen/dwarf-version.c (original)
+++ cfe/trunk/test/CodeGen/dwarf-version.c Fri Sep  9 16:10:35 2016
@@ -4,7 +4,7 @@
 // RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
 // RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck 
%s --check-prefix=VER4
 // RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
-// RUN: %clang -target x86_64-apple-darwin -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
+// RUN: %clang -target x86_64-apple-darwin -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VER2

Modified: cfe/trunk/test/Driver/clang-g-opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-g-opts.c?rev=281094&r1=281093&r2=281094&view=diff
==
--- cfe/trunk/test/Driver/clang-g-opts.c (original)
+++ cfe/trunk/test/Driver/clang-g-opts.c Fri Sep  9 16:10:35 2016
@@ -4,7 +4,7 @@
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
 // RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target x86_64-pc-freebsd10.0 2>&1 \
@@ -22,7 +22,7 @@
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 // RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g0 -g -target x86_64-pc-freebsd10.0 2>&1 \
@@ -34,3 +34,6 @@
 // CHECK-WITH-G: "-debug-info-kind=limited"
 // CHECK-WITH-G: "-dwarf-version=4"
 // CHECK-WITH-G-DWARF2: "-dwarf-version=2"
+
+// CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone"
+// CHECK-WITH-G-STANDALONE: "-dwarf-version=4"

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=281094&r1=281093&r2=281094&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Fri Sep  9 16:10:35 2016
@@ -27,7 +27,7 @@
 // RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_GDB %s
 // RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
 // RUN: %clang 

Re: [PATCH] D24426: DebugInfo: use llvm::DINode::FlagAlignment to mark forcibly aligned data

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


Comment at: lib/CodeGen/CGDebugInfo.cpp:979
@@ -978,4 +978,3 @@
 llvm::DIType *
-CGDebugInfo::createFieldType(StringRef name, QualType type, SourceLocation loc,
- AccessSpecifier AS, uint64_t offsetInBits,
- llvm::DIFile *tunit, llvm::DIScope *scope,
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ AccessSpecifier AS, uint64_t OffsetInBits,

Could you please do the re-formatting as a separate NFC commit? No need to for 
a separate review.
This makes reviewing, cherry-picking, and bisection much easier.


https://reviews.llvm.org/D24426



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


Re: [PATCH] D22296: [wip] CodeGen: New vtable group representation: struct of vtable arrays.

2016-09-09 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 70908.
pcc added a comment.

Refresh and split out the inrange changes into a separate patch


https://reviews.llvm.org/D22296

Files:
  include/clang/AST/VTableBuilder.h
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/PR26569.cpp
  test/CodeGenCXX/apple-kext-indirect-call-2.cpp
  test/CodeGenCXX/apple-kext-indirect-call.cpp
  test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/constructor-init.cpp
  test/CodeGenCXX/copy-constructor-synthesis-2.cpp
  test/CodeGenCXX/copy-constructor-synthesis.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport-rtti.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/invariant.group-for-vptrs.cpp
  test/CodeGenCXX/key-function-vtable.cpp
  test/CodeGenCXX/microsoft-abi-constexpr-vs-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-extern-template.cpp
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/microsoft-abi-vftables.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp
  test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
  test/CodeGenCXX/microsoft-interface.cpp
  test/CodeGenCXX/microsoft-no-rtti-data.cpp
  test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp
  test/CodeGenCXX/vtable-align.cpp
  test/CodeGenCXX/vtable-assume-load.cpp
  test/CodeGenCXX/vtable-pointer-initialization.cpp
  test/CodeGenCXX/vtt-layout.cpp

Index: test/CodeGenCXX/vtt-layout.cpp
===
--- test/CodeGenCXX/vtt-layout.cpp
+++ test/CodeGenCXX/vtt-layout.cpp
@@ -78,11 +78,12 @@
   }
 }
 
-// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5Test11BE, i32 0, i32 3) to i8*)]
-// CHECK: @_ZTVN5Test51AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test51AE to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%"struct.Test5::A"*)* @_ZN5Test51A6anchorEv to i8*)]
-// CHECK: @_ZTVN5Test61AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test61AE to i8*), i8* bitcast (void ()* @__cxa_deleted_virtual to i8*), i8* bitcast (void (%"struct.Test6::A"*)* @_ZN5Test61A6anchorEv to i8*)]
-// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5Test21CE, i32 0, i32 4) to i8*)] 
-// CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i32 0, i32 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i32 0, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*], [14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i32 0, i32 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i32 0, i32 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i32 0, i32 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*], [19 x i8*]* @_ZTVN5Test31DE, i64 1, i32 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i32 0, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i32 0, i32 6) to i8*)] 
-// CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @_ZTVN5Test41DE, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i32 0, i32 7) to i8*), i8* bitcas

[PATCH] D24431: CodeGen: Start using inrange annotations on vtable getelementptr.

2016-09-09 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: rsmith, eugenis.
pcc added subscribers: cfe-commits, krasin.
pcc added a dependency: D22296: CodeGen: New vtable group representation: 
struct of vtable arrays..

This annotation allows the optimizer to split vtable groups, as permitted by
a change to the Itanium ABI that prevents compilers from adjusting virtual
table pointers between virtual tables.

Depends on D22296

https://reviews.llvm.org/D24431

Files:
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/constructor-init.cpp
  test/CodeGenCXX/copy-constructor-synthesis-2.cpp
  test/CodeGenCXX/copy-constructor-synthesis.cpp
  test/CodeGenCXX/microsoft-interface.cpp
  test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp
  test/CodeGenCXX/vtable-assume-load.cpp
  test/CodeGenCXX/vtable-pointer-initialization.cpp
  test/CodeGenCXX/vtt-layout.cpp

Index: test/CodeGenCXX/vtt-layout.cpp
===
--- test/CodeGenCXX/vtt-layout.cpp
+++ test/CodeGenCXX/vtt-layout.cpp
@@ -78,12 +78,12 @@
   }
 }
 
-// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTVN5Test11BE, i32 0, i32 0, i32 3) to i8*)]
+// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTVN5Test11BE, i32 0, inrange i32 0, i32 3) to i8*)]
 // CHECK: @_ZTVN5Test51AE = unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test51AE to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%"struct.Test5::A"*)* @_ZN5Test51A6anchorEv to i8*)] }
 // CHECK: @_ZTVN5Test61AE = unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test61AE to i8*), i8* bitcast (void ()* @__cxa_deleted_virtual to i8*), i8* bitcast (void (%"struct.Test6::A"*)* @_ZN5Test61A6anchorEv to i8*)] }
-// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, i32 0, i32 4) to i8*)]
-// CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, i32 0, i32 5) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE0_NS_2C1E, i32 0, i32 0, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE0_NS_2C1E, i32 0, i32 1, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 1, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, i32 2, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, i32 2, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, i32 1, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, i32 1, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, i32 3, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE64_NS_2V2E, i32 0, i32 0, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE64_NS_2V2E, i32 0, i32 1, i32 3) to i8*)]
+// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, inrange i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, inrange i32 0, i3

Re: [PATCH] D22296: CodeGen: New vtable group representation: struct of vtable arrays.

2016-09-09 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

This should now be ready for review and unblocked by other changes (I split out 
the inrange annotation to https://reviews.llvm.org/D24431).


https://reviews.llvm.org/D22296



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


Re: [PATCH] D24371: Add diagnostics to require_constant_initialization

2016-09-09 Thread Keno Fischer via cfe-commits
loladiro updated this revision to Diff 70915.
loladiro added a comment.

Address review comments:

- Disable C++11 test that lacks source locations
- Use CacheCulprit to give diagnostics for < C++11


Repository:
  rL LLVM

https://reviews.llvm.org/D24371

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- test/SemaCXX/attr-require-constant-initialization.cpp
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -7,9 +7,9 @@
 
 #define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
 
-int ReturnInt();
+int ReturnInt(); // expected-note 0+ {{declared here}}
 
-struct PODType {
+struct PODType { // expected-note 0+ {{declared here}}
   int value;
   int value2;
 };
@@ -20,20 +20,20 @@
 struct LitType {
   constexpr LitType() : value(0) {}
   constexpr LitType(int x) : value(x) {}
-  LitType(void *) : value(-1) {}
+  LitType(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   int value;
 };
 #endif
 
-struct NonLit {
+struct NonLit { // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201402L
   constexpr NonLit() : value(0) {}
   constexpr NonLit(int x) : value(x) {}
 #else
-  NonLit() : value(0) {}
+  NonLit() : value(0) {} // expected-note 0+ {{declared here}}
   NonLit(int x) : value(x) {}
 #endif
-  NonLit(void *) : value(-1) {}
+  NonLit(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   ~NonLit() {}
   int value;
 };
@@ -82,23 +82,44 @@
   const int non_global = 42;
   ATTR static const int &local_init = non_global; // expected-error {{variable does not have a constant initializer}}
   // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{reference to 'non_global' is not a constant expression}}
+// expected-note@-5 {{declared here}}
+#else
+// expected-note@-6 {{subexpression not valid in a constant expression}}
+#endif
   ATTR static const int &global_init = glvalue_int;
   ATTR static const int &temp_init = 42;
 }
 
 ATTR const int &temp_ref = 42;
 ATTR const int &temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 ATTR const NonLit &nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-literal type 'const NonLit' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 #if __cplusplus >= 201103L
 ATTR const LitType &lit_temp_ref = 42;
 ATTR const int &subobj_ref = LitType{}.value;
 #endif
 
 ATTR const int &nl_subobj_ref = NonLit().value; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note-re@-3 {{non-literal type '{{.*}}' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 struct TT1 {
   ATTR static const int &no_init;
@@ -116,6 +137,8 @@
 #if __cplusplus >= 201103L
 thread_local const int &TT1::tl_glvalue_init = glvalue_int;
 thread_local const int &TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{reference to temporary is not a constant expression}}
+// expected-note@-2 {{temporary created here}}
 #endif
 
 // [basic.start.static]p2.2
@@ -129,17 +152,25 @@
 #else
   ATTR static PODType pod; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+// expected-note@-2 {{non-constexpr constructor 'PODType' cannot be used in a constant expression}}
 #endif
   ATTR static PODType pot2 = {ReturnInt()}; // expected-error {{variable does not have a constant initializer}}
-// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 #if __cplusplus >= 201103L
   constexpr LitType l;
   ATTR static LitType static_lit = l;
   ATTR static LitType static_lit

Buildbot numbers for the last week of 8/28/2016 - 9/03/2016

2016-09-09 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 8/28/2016 - 9/03/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

 buildername|  was_red
+---
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 130:54:02
 clang-ppc64le-linux-lnt| 112:46:03
 clang-x86_64-linux-selfhost-modules| 107:38:13
 sanitizer-windows  | 73:28:02
 lldb-x86_64-ubuntu-14.04-android   | 62:50:55
 clang-ppc64le-linux-multistage | 54:52:07
 sanitizer-x86_64-linux-fuzzer  | 52:23:42
 llvm-sphinx-docs   | 48:48:34
 sanitizer-x86_64-linux-fast| 48:03:09
 sanitizer-x86_64-linux-bootstrap   | 47:31:29
 libcxx-libcxxabi-x86_64-linux-debian   | 43:44:40
 clang-with-lto-ubuntu  | 33:25:09
 clang-x86-win2008-selfhost | 32:00:39
 llvm-clang-lld-x86_64-debian-fast  | 31:02:57
 clang-x64-ninja-win7   | 30:18:11
 lldb-windows7-android  | 25:04:54
 clang-x86_64-debian-fast   | 20:20:17
 sanitizer-x86_64-linux | 18:25:59
 lld-x86_64-darwin13| 18:15:28
 lldb-x86_64-darwin-13.4| 17:37:07
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 17:26:16
 lldb-x86_64-ubuntu-14.04-buildserver   | 16:15:00
 lldb-x86_64-ubuntu-14.04-cmake | 15:27:14
 clang-3stage-ubuntu| 15:23:00
 clang-x86-windows-msvc2015 | 14:51:59
 clang-ppc64be-linux-lnt| 14:32:11
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 12:16:18
 sanitizer-ppc64be-linux| 08:14:52
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 07:25:28
 clang-cmake-thumbv7-a15-full-sh| 07:23:33
 clang-cmake-armv7-a15-selfhost | 07:00:29
 clang-ppc64be-linux| 06:27:45
 clang-cmake-aarch64-full   | 06:06:27
 clang-cmake-mips   | 05:57:52
 perf-x86_64-penryn-O3-polly| 05:56:17
 perf-x86_64-penryn-O3-polly-fast   | 05:48:46
 sanitizer-ppc64le-linux| 05:30:50
 clang-sphinx-docs  | 05:10:16
 clang-cmake-aarch64-42vma  | 05:07:34
 clang-cuda-build   | 04:20:15
 clang-native-arm-lnt   | 04:01:20
 clang-ppc64le-linux| 03:59:01
 perf-x86_64-penryn-O3  | 03:45:14
 clang-cmake-armv7-a15-full | 03:34:32
 clang-cmake-aarch64-quick  | 03:20:05
 perf-x86_64-penryn-O3-polly-unprofitable   | 03:09:50
 clang-ppc64be-linux-multistage | 02:58:03
 sanitizer-x86_64-linux-autoconf| 02:51:04
 perf-x86_64-penryn-O3-polly-parallel-fast  | 02:51:01
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 02:43:55
 llvm-hexagon-elf   | 02:38:20
 clang-cmake-thumbv7-a15| 02:14:05
 clang-cmake-armv7-a15  | 02:13:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 02:06:05
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 01:46:30
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 01:33:22
 libcxx-libcxxabi-x86_64-linux-ubuntu-unstable-abi  | 01:23:22
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 01:15:55
 clang-hexagon-elf  | 01:14:18
 clang-s390x-linux   

Re: [PATCH] D24330: Add some MS aliases for existing intrinsics

2016-09-09 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 70923.
agutowski added a comment.

Changed way of handling Intel intrinsics
Removed constant folding


https://reviews.llvm.org/D24330

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/BuiltinsX86.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/emmintrin.h
  lib/Headers/ia32intrin.h
  lib/Headers/intrin.h
  lib/Headers/xmmintrin.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/builtins-x86.c
  test/Sema/implicit-ms-builtin-decl.c

Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -60,12 +60,6 @@
   return __builtin_ia32_rdpmc(__A);
 }
 
-/* __rdtsc */
-static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
-__rdtsc(void) {
-  return __builtin_ia32_rdtsc();
-}
-
 /* __rdtscp */
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
 __rdtscp(unsigned int *__A) {
Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -2457,11 +2457,7 @@
 /// \param __p
 ///A pointer to the memory location used to identify the cache line to be
 ///flushed.
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_clflush(void const *__p)
-{
-  __builtin_ia32_clflush(__p);
-}
+void _mm_clflush(void const *);
 
 /// \brief Forces strong memory ordering (serialization) between load
 ///instructions preceding this instruction and load instructions following
@@ -2472,11 +2468,7 @@
 ///
 /// This intrinsic corresponds to the \c LFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_lfence(void)
-{
-  __builtin_ia32_lfence();
-}
+void _mm_lfence(void);
 
 /// \brief Forces strong memory ordering (serialization) between load and store
 ///instructions preceding this instruction and load and store instructions
@@ -2487,11 +2479,7 @@
 ///
 /// This intrinsic corresponds to the \c MFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_mfence(void)
-{
-  __builtin_ia32_mfence();
-}
+void _mm_mfence(void);
 
 /// \brief Converts 16-bit signed integers from both 128-bit integer vector
 ///operands into 8-bit signed integers, and packs the results into the
@@ -3213,11 +3201,7 @@
 ///
 /// This intrinsic corresponds to the \c PAUSE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_pause(void)
-{
-  __builtin_ia32_pause();
-}
+void _mm_pause(void);
 
 #undef __DEFAULT_FN_ATTRS
 
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -518,14 +518,6 @@
   *_Index = 31 - __builtin_clzl(_Mask);
   return 1;
 }
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
-__popcnt16(unsigned short _Value) {
-  return __builtin_popcount((int)_Value);
-}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-__popcnt(unsigned int _Value) {
-  return __builtin_popcount(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
@@ -568,11 +560,6 @@
   *_Index = 63 - __builtin_clzll(_Mask);
   return 1;
 }
-static __inline__
-unsigned __int64 __DEFAULT_FN_ATTRS
-__popcnt64(unsigned __int64 _Value) {
-  return __builtin_popcountll(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2094,11 +2094,7 @@
 ///
 /// This intrinsic corresponds to the \c SFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_sfence(void)
-{
-  __builtin_ia32_sfence();
-}
+void _mm_sfence(void);
 
 /// \brief Extracts 16-bit element from a 64-bit vector of [4 x i16] and
 ///returns it, as specified by the immediate integer operand.
@@ -2408,11 +2404,7 @@
 ///
 /// \returns A 32-bit unsigned integer containing the contents of the MXCSR
 ///register.
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_mm_getcsr(void)
-{
-  return __builtin_ia32_stmxcsr();
-}
+unsigned int _mm_getcsr(void);
 
 /// \brief Sets the MXCSR register with the 32-bit unsigned integer value. There
 ///are several groups of macros associated with this intrinsic, including:
@@ -2450,11 +2442,7 @@
 ///
 /// \param __i
 ///A 32-bit unsigned integer value to be written to the MXCSR register.
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_setcsr(unsigned int __i)
-{
-  __builtin_ia32_ldmxcsr(__i);
-}
+void _mm_setcsr(unsigned int);
 
 /// \brief Selects 4 float values from the 128-bit operands of [4 x float], as
 ///specified by the immediate value operand.
Index: lib/CodeGen/CGBuiltin.cpp
==

Re: [PATCH] D24330: Add some MS aliases for existing intrinsics

2016-09-09 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 70926.
agutowski added a comment.

Separated Intel intrinsics tests


https://reviews.llvm.org/D24330

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/BuiltinsX86.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/emmintrin.h
  lib/Headers/ia32intrin.h
  lib/Headers/intrin.h
  lib/Headers/xmmintrin.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/builtins-x86.c
  test/Sema/implicit-intel-builtin-decl.c
  test/Sema/implicit-ms-builtin-decl.c

Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -60,12 +60,6 @@
   return __builtin_ia32_rdpmc(__A);
 }
 
-/* __rdtsc */
-static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
-__rdtsc(void) {
-  return __builtin_ia32_rdtsc();
-}
-
 /* __rdtscp */
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
 __rdtscp(unsigned int *__A) {
Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -2457,11 +2457,7 @@
 /// \param __p
 ///A pointer to the memory location used to identify the cache line to be
 ///flushed.
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_clflush(void const *__p)
-{
-  __builtin_ia32_clflush(__p);
-}
+void _mm_clflush(void const *);
 
 /// \brief Forces strong memory ordering (serialization) between load
 ///instructions preceding this instruction and load instructions following
@@ -2472,11 +2468,7 @@
 ///
 /// This intrinsic corresponds to the \c LFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_lfence(void)
-{
-  __builtin_ia32_lfence();
-}
+void _mm_lfence(void);
 
 /// \brief Forces strong memory ordering (serialization) between load and store
 ///instructions preceding this instruction and load and store instructions
@@ -2487,11 +2479,7 @@
 ///
 /// This intrinsic corresponds to the \c MFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_mfence(void)
-{
-  __builtin_ia32_mfence();
-}
+void _mm_mfence(void);
 
 /// \brief Converts 16-bit signed integers from both 128-bit integer vector
 ///operands into 8-bit signed integers, and packs the results into the
@@ -3213,11 +3201,7 @@
 ///
 /// This intrinsic corresponds to the \c PAUSE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_pause(void)
-{
-  __builtin_ia32_pause();
-}
+void _mm_pause(void);
 
 #undef __DEFAULT_FN_ATTRS
 
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -518,14 +518,6 @@
   *_Index = 31 - __builtin_clzl(_Mask);
   return 1;
 }
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
-__popcnt16(unsigned short _Value) {
-  return __builtin_popcount((int)_Value);
-}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-__popcnt(unsigned int _Value) {
-  return __builtin_popcount(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
@@ -568,11 +560,6 @@
   *_Index = 63 - __builtin_clzll(_Mask);
   return 1;
 }
-static __inline__
-unsigned __int64 __DEFAULT_FN_ATTRS
-__popcnt64(unsigned __int64 _Value) {
-  return __builtin_popcountll(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2094,11 +2094,7 @@
 ///
 /// This intrinsic corresponds to the \c SFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_sfence(void)
-{
-  __builtin_ia32_sfence();
-}
+void _mm_sfence(void);
 
 /// \brief Extracts 16-bit element from a 64-bit vector of [4 x i16] and
 ///returns it, as specified by the immediate integer operand.
@@ -2408,11 +2404,7 @@
 ///
 /// \returns A 32-bit unsigned integer containing the contents of the MXCSR
 ///register.
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_mm_getcsr(void)
-{
-  return __builtin_ia32_stmxcsr();
-}
+unsigned int _mm_getcsr(void);
 
 /// \brief Sets the MXCSR register with the 32-bit unsigned integer value. There
 ///are several groups of macros associated with this intrinsic, including:
@@ -2450,11 +2442,7 @@
 ///
 /// \param __i
 ///A 32-bit unsigned integer value to be written to the MXCSR register.
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_setcsr(unsigned int __i)
-{
-  __builtin_ia32_ldmxcsr(__i);
-}
+void _mm_setcsr(unsigned int);
 
 /// \brief Selects 4 float values from the 128-bit operands of [4 x float], as
 ///specified by the immediate value operand.
Index: lib/CodeGen/CGBuiltin.cpp
=

r281119 - Modules: for ObjectiveC try to keep the definition invariant.

2016-09-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Sep  9 18:48:27 2016
New Revision: 281119

URL: http://llvm.org/viewvc/llvm-project?rev=281119&view=rev
Log:
Modules: for ObjectiveC try to keep the definition invariant.

When deserializing ObjCInterfaceDecl with definition data, if we already have
a definition, try to keep the definition invariant; also pull in the
categories even if it is not what getDefinition returns (this effectively
combines categories).

rdar://27926200
rdar://26708823

Added:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
cfe/trunk/test/Modules/Inputs/objc-category/
cfe/trunk/test/Modules/Inputs/objc-category-2/
cfe/trunk/test/Modules/Inputs/objc-category-2/Base.h
cfe/trunk/test/Modules/Inputs/objc-category-2/Category.h
cfe/trunk/test/Modules/Inputs/objc-category-2/H3.h
cfe/trunk/test/Modules/Inputs/objc-category-2/module.map
cfe/trunk/test/Modules/Inputs/objc-category-3/
cfe/trunk/test/Modules/Inputs/objc-category-3/Base.h
cfe/trunk/test/Modules/Inputs/objc-category-3/Category.h
cfe/trunk/test/Modules/Inputs/objc-category-3/Category_B.h
cfe/trunk/test/Modules/Inputs/objc-category-3/H3.h
cfe/trunk/test/Modules/Inputs/objc-category-3/module.map
cfe/trunk/test/Modules/Inputs/objc-category/Base.h
cfe/trunk/test/Modules/Inputs/objc-category/Category.h
cfe/trunk/test/Modules/Inputs/objc-category/H3.h
cfe/trunk/test/Modules/Inputs/objc-category/module.map
cfe/trunk/test/Modules/lookup-assert.m
cfe/trunk/test/Modules/objc-category-2.m
cfe/trunk/test/Modules/objc-category-3.m
cfe/trunk/test/Modules/objc-category.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=281119&r1=281118&r2=281119&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Sep  9 18:48:27 2016
@@ -133,6 +133,10 @@ namespace clang {
const RecordData &R, unsigned &I);
 void MergeDefinitionData(CXXRecordDecl *D,
  struct CXXRecordDecl::DefinitionData &&NewDD);
+void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data,
+const RecordData &R, unsigned &I);
+void MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD);
 
 static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
  DeclContext *DC,
@@ -981,6 +985,43 @@ ObjCTypeParamList *ASTDeclReader::ReadOb
typeParams, rAngleLoc);
 }
 
+void ASTDeclReader::ReadObjCDefinitionData(
+ struct ObjCInterfaceDecl::DefinitionData &Data,
+ const RecordData &R, unsigned &I) {
+  // Read the superclass.
+  Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx);
+
+  Data.EndLoc = ReadSourceLocation(Record, Idx);
+  Data.HasDesignatedInitializers = Record[Idx++];
+   
+  // Read the directly referenced protocols and their SourceLocations.
+  unsigned NumProtocols = Record[Idx++];
+  SmallVector Protocols;
+  Protocols.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+Protocols.push_back(ReadDeclAs(Record, Idx));
+  SmallVector ProtoLocs;
+  ProtoLocs.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
+  Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, 
ProtoLocs.data(),
+   Reader.getContext());
+ 
+  // Read the transitive closure of protocols referenced by this class.
+  NumProtocols = Record[Idx++];
+  Protocols.clear();
+  Protocols.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+Protocols.push_back(ReadDeclAs(Record, Idx));
+  Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
+  Reader.getContext());
+}
+
+void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
+  // FIXME: odr checking?
+}
+
 void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
   RedeclarableResult Redecl = VisitRedeclarable(ID);
   VisitObjCContainerDecl(ID);
@@ -991,43 +1032,22 @@ void ASTDeclReader::VisitObjCInterfaceDe
   if (Record[Idx++]) {
 // Read the definition.
 ID->allocateDefinitionData();
-
-// Set the definition data of the canonical declaration, so other
-// redeclarations will see it.
-ID->getCanonicalDecl()->D

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
Committed r281119. Let me know if you see any problem.

Cheers,
Manman

On Fri, Sep 9, 2016 at 12:07 PM, Manman Ren  wrote:

>
>
> On Fri, Sep 9, 2016 at 11:33 AM, Richard Smith 
> wrote:
>
>> On Fri, Sep 9, 2016 at 11:29 AM, Manman Ren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith 
>>> wrote:
>>>
 On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren 
 wrote:

> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
> wrote:
>
>> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: mren
>>> Date: Tue Sep  6 13:16:54 2016
>>> New Revision: 280728
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>>> Log:
>>> Modules: Fix an assertion in DeclContext::buildLookup.
>>>
>>> When calling getMostRecentDecl, we can pull in more definitions from
>>> a module. We call getPrimaryContext afterwards to make sure that
>>> we buildLookup on a primary context.
>>>
>>> rdar://27926200
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>>> cfe/trunk/test/Modules/lookup-assert.m
>>> Modified:
>>> cfe/trunk/lib/AST/DeclBase.cpp
>>>
>>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>>assert(DeclKind != Decl::LinkageSpec &&
>>>   "Should not perform lookups into linkage specs!");
>>>
>>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>>> -  if (PrimaryContext != this)
>>> -return PrimaryContext->lookup(Name);
>>> -
>>>// If we have an external source, ensure that any later
>>> redeclarations of this
>>>// context have been loaded, since they may add names to the
>>> result of this
>>>// lookup (or add external visible storage).
>>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>>if (Source)
>>>  (void)cast(this)->getMostRecentDecl();
>>>
>>> +  // getMostRecentDecl can change the result of getPrimaryContext.
>>> Call
>>> +  // getPrimaryContext afterwards.
>>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>>> +  if (PrimaryContext != this)
>>> +return PrimaryContext->lookup(Name);
>>>
>>
>> This seems like a bug in getPrimaryContext() -- if there is a
>> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
>> return that instead of returning a non-defining declaration. Why is
>> ObjCInterfaceDecl::hasDefinition (indirectly called by
>> getPrimaryContext) not loading the definition in this case?
>>
>
> In the testing case, we have a definition of the ObjC interface from
> textually including a header file, but the definition is also in a module.
> getPrimaryContext for ObjCInterface currently does not  pull from the
> external source.
>

 As far as I can see, it does. For ObjCInterface, getPrimaryContext
 calls ObjCInterface::getDefinition:

   ObjCInterfaceDecl *getDefinition() {
 return hasDefinition()? Data.getPointer()->Definition : nullptr;
   }

 hasDefinition() pulls from the external source to find a definition, if
 it believes the definition is out of date:

   bool hasDefinition() const {
 // If the name of this class is out-of-date, bring it up-to-date,
 which
 // might bring in a definition.
 // Note: a null value indicates that we don't have a definition and
 that
 // modules are enabled.
 if (!Data.getOpaqueValue())
   getMostRecentDecl();

 return Data.getPointer();
   }

>>> --> You are right, this is the backtrace when calling getPrimaryContext.
>>>   * frame #0: 0x000102e6c1b0 clang`clang::ObjCInterfaceDecl
>>> ::hasDefinition(this=0x00010f079a38) const + 16 at DeclObjC.h:1445
>>> frame #1: 0x000105d09009 clang`clang::ObjCInterfaceDecl
>>> ::getDefinition(this=0x00010f079a38) + 25 at DeclObjC.h:1455
>>> frame #2: 0x000105d08b2b clang`clang::DeclContext::getP
>>> rimaryContext(this=0x00010f079a60) + 171 at DeclBase.cpp:1013
>>> frame #3: 0x000105d08a75 clang`clang::DeclContext

Re: [PATCH] D21113: Add support for case-insensitive header lookup

2016-09-09 Thread John Sheu via cfe-commits
sheu added a subscriber: sheu.
sheu added a comment.

I'd be very interested in seeing this patch happen.  What's the current status 
here?

Also, w.r.t. the cache invalidation problem -- would it be feasible / a good 
idea to move users of the FileSystem API to VirtualFileSystem, in general?  
This would have the nice effect of putting filesystem things all in once place. 
 Then invalidation tracking etc. will be easier.


https://reviews.llvm.org/D21113



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


[PATCH] D24439: [Clang] Fix some Clang-tidy modernize-use-bool-literals and Include What You Use warnings; other minor fixes

2016-09-09 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: mehdi_amini, compnerd.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Repository:
  rL LLVM

https://reviews.llvm.org/D24439

Files:
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/Diagnostic.cpp
  lib/Basic/SourceManager.cpp
  lib/Index/IndexDecl.cpp
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Lex/PTHLexer.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Rewrite/DeltaTree.cpp
  lib/Rewrite/HTMLRewrite.cpp

Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -13,10 +13,27 @@
 
 #include "clang/Parse/Parser.h"
 #include "RAIIObjectsForParser.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/Ownership.h"
 #include "clang/Sema/Scope.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
+#include 
+
 using namespace clang;
 
 /// ParseCXXInlineMethodDef - We parsed and verified that the specified
@@ -672,7 +689,7 @@
   // We always want this function to consume at least one token if the first
   // token isn't T and if not at EOF.
   bool isFirstTokenConsumed = true;
-  while (1) {
+  while (true) {
 // If we found one of the tokens, stop and return true.
 if (Tok.is(T1) || Tok.is(T2)) {
   if (ConsumeFinalToken) {
@@ -1012,7 +1029,7 @@
   unsigned AngleCount = 0;
   unsigned KnownTemplateCount = 0;
 
-  while (1) {
+  while (true) {
 switch (Tok.getKind()) {
 case tok::comma:
   // If we might be in a template, perform a tentative parse to check.
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -23,13 +23,39 @@
 
 #include "RAIIObjectsForParser.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/OperatorPrecedence.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Basic/TypeTraits.h"
+#include "clang/Basic/VersionTuple.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/Parser.h"
+#include "clang/Sema/AttributeList.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
+#include "clang/Sema/Ownership.h"
 #include "clang/Sema/Scope.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/TypoCorrection.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
+#include 
+
 using namespace clang;
 
 /// \brief Simple precedence-based parser for binary/ternary operators.
@@ -251,7 +277,7 @@
getLangOpts().CPlusPlus11);
   SourceLocation ColonLoc;
 
-  while (1) {
+  while (true) {
 // If this token has a lower precedence than we are allowed to parse (e.g.
 // because we are called recursively, or because the token is not a binop),
 // then we are done!
@@ -485,8 +511,9 @@
 }
 
 namespace {
+
 class CastExpressionIdValidator : public CorrectionCandidateCallback {
- public:
+public:
   CastExpressionIdValidator(Token Next, bool AllowTypes, bool AllowNonTypes)
   : NextToken(Next), AllowNonTypes(AllowNonTypes) {
 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
@@ -514,11 +541,12 @@
 return false;
   }
 
- private:
+private:
   Token NextToken;
   bool AllowNonTypes;
 };
-}
+
+} // end anonymous namespace
 
 /// \brief Parse a cast-expression, or, if \pisUnaryExpression is true, parse
 /// a unary-expression.
@@ -1407,7 +1435,7 @@
   // Now that the primary-expression piece of the postfix-expression has been
   // parsed, see if there are any postfix-expression pieces here.
   SourceLocation Loc;
-  while (1) {
+  while (true) {
 switch (Tok.getKind()) {
 case tok::code_completion:
   if (InMessageExpression)
@@ -1810,7 +1838,6 @@
   return Operand;
 }
 
-
 /// \brief Parse a siz

Re: [PATCH] D24426: DebugInfo: use llvm::DINode::FlagAlignment to mark forcibly aligned data

2016-09-09 Thread Victor Leschuk via cfe-commits
vleschuk added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:979
@@ -978,4 +978,3 @@
 llvm::DIType *
-CGDebugInfo::createFieldType(StringRef name, QualType type, SourceLocation loc,
- AccessSpecifier AS, uint64_t offsetInBits,
- llvm::DIFile *tunit, llvm::DIScope *scope,
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ AccessSpecifier AS, uint64_t OffsetInBits,

aprantl wrote:
> Could you please do the re-formatting as a separate NFC commit? No need to 
> for a separate review.
> This makes reviewing, cherry-picking, and bisection much easier.
Sure, sorry for that. Will revert.


https://reviews.llvm.org/D24426



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


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

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

Thanks!

Looks good overall. Several comments below.



Comment at: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:160
@@ +159,3 @@
+[](const IntrusiveRefCntPtr &p) {
+  return isa(p.get());
+});

What do you think about calling these PathDiagnosticNotePiece, specifically, 
looks like "Extra" does not add anything.

You'll probably need to change quite a few names to remove the "Extra", so up 
to you.


Comment at: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:170
@@ +169,3 @@
+  // Will also make a second pass through those later below,
+  // when the header text is ready.
+  HandlePiece(R, FID, **I, NumExtraPieces, TotalExtraPieces);

Why we need the second path? Please, add a comment as it's not obvious.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:119
@@ +118,3 @@
+  PE = PD->path.end(); PI != PE; ++PI) {
+if (!isa(PI->get()))
+  continue;

a.sidorin wrote:
> if (isa<...>()) {
>   ...
>   ...
> }
> ?
@a.sidorin, LLVM coding guidelines prefer early exits 
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code.


Comment at: test/Analysis/copypaste/plist-diagnostics.cpp:4
@@ +3,3 @@
+
+void log();
+

We should call out that this is not working as expected right now. As far as I 
understand, this file is a test case for a FIXME, correct?


Comment at: test/Analysis/copypaste/text-diagnostics.cpp:5
@@ +4,3 @@
+
+int max(int a, int b) { // expected-warning{{Detected code clone}} // 
expected-note{{Detected code clone}}
+  log();

It's better to use full sentences for the warning messages: "Clone of this code 
is detected" (or "Clones of this code are detected" when there are more than 
one).



Comment at: test/Analysis/copypaste/text-diagnostics.cpp:12
@@ +11,3 @@
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here}}
+  log();

I would just say: "Code clone here". When I think about it, I assume the very 
first one is not a clone, but the ones we highlight with notes are clones.


https://reviews.llvm.org/D24278



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


r281132 - [tablegen] Check that an optional IdentifierArgument of an attribute is

2016-09-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Sep  9 22:29:43 2016
New Revision: 281132

URL: http://llvm.org/viewvc/llvm-project?rev=281132&view=rev
Log:
[tablegen] Check that an optional IdentifierArgument of an attribute is
provided before trying to print it.

This fixes a segfault that occurs when function printPretty generated by
tablegen tries to print an optional argument of attribute
objc_bridge_related.

rdar://problem/28155469

Modified:
cfe/trunk/test/Misc/ast-print-objectivec.m
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=281132&r1=281131&r2=281132&view=diff
==
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Fri Sep  9 22:29:43 2016
@@ -39,3 +39,9 @@
 // CHECK: }
 
 // CHECK: @end
+
+@class C1;
+struct __attribute__((objc_bridge_related(C1,,))) S1;
+
+// CHECK: @class C1;
+// CHECK: struct __attribute__((objc_bridge_related(C1, , ))) S1;

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=281132&r1=281131&r2=281132&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Sep  9 22:29:43 2016
@@ -299,7 +299,13 @@ namespace {
 OS << "\" << get" << getUpperName()
<< "()->getNameInfo().getAsString() << \"";
   } else if (type == "IdentifierInfo *") {
-OS << "\" << get" << getUpperName() << "()->getName() << \"";
+OS << "\";\n";
+if (isOptional())
+  OS << "if (get" << getUpperName() << "()) ";
+else
+  OS << "";
+OS << "OS << get" << getUpperName() << "()->getName();\n";
+OS << "OS << \"";
   } else if (type == "TypeSourceInfo *") {
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   } else {


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


Re: [PATCH] D24426: DebugInfo: use llvm::DINode::FlagAlignment to mark forcibly aligned data

2016-09-09 Thread Victor Leschuk via cfe-commits
vleschuk updated this revision to Diff 70949.
vleschuk added a comment.

Reverted formatting changes.


https://reviews.llvm.org/D24426

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -238,6 +238,13 @@
 llvm::DIScope *scope,
 const RecordDecl *RD = nullptr);
 
+  llvm::DIType *createFieldType(StringRef Name, QualType Type,
+SourceLocation Loc, uint64_t AlignInBits,
+uint64_t OffsetInBits,
+llvm::DINode::DIFlags Flags,
+llvm::DIFile *TUnit, llvm::DIScope *Scope,
+const RecordDecl *RD = nullptr);
+
   /// Create new bit field member.
   llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl,
llvm::DIScope *RecordTy,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -999,6 +999,28 @@
AlignInBits, offsetInBits, flags, debugType);
 }
 
+llvm::DIType *
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ uint64_t AlignInBits, uint64_t OffsetInBits,
+ llvm::DINode::DIFlags Flags,
+ llvm::DIFile *TUnit, llvm::DIScope *Scope,
+ const RecordDecl *RD) {
+  llvm::DIType *DebugType = getOrCreateType(Type, TUnit);
+
+  // Get the location for the field.
+  llvm::DIFile *File = getOrCreateFile(Loc);
+  unsigned Line = getLineNumber(Loc);
+
+  uint64_t SizeInBits = 0;
+  if (!Type->isIncompleteArrayType()) {
+TypeInfo TI = CGM.getContext().getTypeInfo(Type);
+SizeInBits = TI.Width;
+  }
+
+  return DBuilder.createMemberType(Scope, Name, File, Line, SizeInBits,
+   AlignInBits, OffsetInBits, Flags, DebugType);
+}
+
 void CGDebugInfo::CollectRecordLambdaFields(
 const CXXRecordDecl *CXXDecl, SmallVectorImpl &elements,
 llvm::DIType *RecordTy) {
@@ -1012,15 +1034,21 @@
  E = CXXDecl->captures_end();
I != E; ++I, ++Field, ++fieldno) {
 const LambdaCapture &C = *I;
+uint64_t AlignInBits = 0;
+llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
 if (C.capturesVariable()) {
   SourceLocation Loc = C.getLocation();
   assert(!Field->isBitField() && "lambdas don't have bitfield members!");
   VarDecl *V = C.getCapturedVar();
   StringRef VName = V->getName();
+  AlignInBits = V->getMaxAlignment();
+  Flags |= getAccessFlag(Field->getAccess(), CXXDecl);
+  if (V->hasAttr())
+Flags |= llvm::DINode::FlagAlignment;
   llvm::DIFile *VUnit = getOrCreateFile(Loc);
   llvm::DIType *FieldType = createFieldType(
-  VName, Field->getType(), Loc, Field->getAccess(),
-  layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
+  VName, Field->getType(), Loc, AlignInBits,
+  layout.getFieldOffset(fieldno), Flags, VUnit, RecordTy, CXXDecl);
   elements.push_back(FieldType);
 } else if (C.capturesThis()) {
   // TODO: Need to handle 'this' in some way by probably renaming the
@@ -1061,9 +1089,14 @@
 }
   }
 
+  uint64_t AlignInBits = 0;
   llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
+  if (Var->hasAttr()) {
+Flags |= llvm::DINode::FlagAlignment;
+AlignInBits = Var->getMaxAlignment();
+  }
   llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
-  RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
+  RecordTy, VName, VUnit, LineNumber, VTy, AlignInBits, Flags, C);
   StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
   return GV;
 }
@@ -1074,6 +1107,14 @@
 const RecordDecl *RD) {
   StringRef name = field->getName();
   QualType type = field->getType();
+  uint64_t AlignInBits = 0;
+  llvm::DINode::DIFlags Flags = getAccessFlag(field->getAccess(), RD);
+  if (field->hasAttr()) {
+Flags |= llvm::DINode::FlagAlignment;
+AlignInBits = field->getMaxAlignment();
+  } else if (!type->isIncompleteArrayType()) {
+AlignInBits = CGM.getContext().getTypeInfo(type).Align;
+  }
 
   // Ignore unnamed fields unless they're anonymous structs/unions.
   if (name.empty() && !type->isRecordType())
@@ -1084,8 +1125,8 @@
 FieldType = createBitFieldType(field, RecordTy, RD);
   } else {
 FieldType =
-createFieldType(name, type, field->getLocation(), field->getAccess(),
-OffsetInBits, tunit, RecordTy, RD);
+createFieldType(name, type, field->getLocation(), AlignInBits,
+OffsetInBits, Fla

Re: [PATCH] D24426: DebugInfo: use llvm::DINode::FlagAlignment to mark forcibly aligned data

2016-09-09 Thread Victor Leschuk via cfe-commits
vleschuk marked 2 inline comments as done.
vleschuk added a comment.

https://reviews.llvm.org/D24426



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