Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with one comment.



Comment at: clang-rename/USRLocFinder.cpp:73-76
@@ -73,3 +72,6 @@
   SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Location), 
Context.getSourceManager(), Context.getLangOpts());
+  StringRef TokenName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Location),
+  Context.getSourceManager(), Context.getLangOpts());
   if (TokenName == PrevName) {
+// The token of the source location we find actually has the old

Fair enough. I didn't get the intent of the code then.


Comment at: clang-rename/USRLocFinder.h:33
@@ -35,1 +32,3 @@
+std::vector
+getLocationsOfUSR(llvm::StringRef usr, llvm::StringRef PrevName, Decl *decl);
 }

Use llvm style for names: USR, Decl.


http://reviews.llvm.org/D22091



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


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63931.

http://reviews.llvm.org/D22091

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- /dev/null
+++ test/clang-rename/NoNewName.cpp
@@ -0,0 +1,20 @@
+// This test is a copy of ConstCastExpr.cpp with a single change:
+// -new-name hasn't been passed to clang-rename, so this test should give an
+// error.
+// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename: no new name provided.
+
+class Cla {
+public:
+  int getValue() {
+return 0;
+  }
+};
+
+int main() {
+  const Cla *C = new Cla();
+  const_cast(C)->getValue();
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -36,7 +36,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
-#include 
 #include 
 
 using namespace llvm;
@@ -83,7 +82,7 @@
 #define CLANG_RENAME_VERSION "0.0.1"
 
 static void PrintVersion() {
-  outs() << "clang-rename version " << CLANG_RENAME_VERSION << "\n";
+  outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n';
 }
 
 using namespace clang;
@@ -101,7 +100,6 @@
 
   if (NewName.empty()) {
 errs() << "clang-rename: no new name provided.\n\n";
-cl::PrintHelpMessage();
 exit(1);
   }
 
@@ -115,12 +113,14 @@
   const auto &USRs = USRAction.getUSRs();
   const auto &PrevName = USRAction.getUSRSpelling();
 
-  if (PrevName.empty())
+  if (PrevName.empty()) {
 // An error should have already been printed.
 exit(1);
+  }
 
-  if (PrintName)
-errs() << "clang-rename: found name: " << PrevName << "\n";
+  if (PrintName) {
+errs() << "clang-rename: found name: " << PrevName << '\n';
+  }
 
   // Perform the renaming.
   rename::RenamingAction RenameAction(NewName, PrevName, USRs,
Index: clang-rename/USRLocFinder.h
===
--- clang-rename/USRLocFinder.h
+++ clang-rename/USRLocFinder.h
@@ -16,23 +16,19 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H
 
+#include "clang/AST/AST.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 
-#include "llvm/ADT/StringRef.h"
-
 namespace clang {
-
-class Decl;
-class SourceLocation;
-
 namespace rename {
 
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
-std::vector getLocationsOfUSR(llvm::StringRef usr,
-  llvm::StringRef PrevName,
-  Decl *decl);
-}
-}
+std::vector
+getLocationsOfUSR(llvm::StringRef USR, llvm::StringRef PrevName, Decl *Decl);
+
+} // namespace rename
+} // namespace clang
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -34,8 +34,8 @@
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) {
-  }
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName)
+  : USR(USR), PrevName(PrevName) {}
 
   // Declaration visitors:
 
@@ -60,8 +60,7 @@
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
 const ASTContext &Context = ConstructorDecl->getASTContext();
-for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
-  const clang::CXXCtorInitializer* Initializer = *it;
+for (auto &Initializer : ConstructorDecl->inits()) {
   if (Initializer->getSourceOrder() == -1) {
 // Ignore implicit initializers.
 continue;
@@ -71,9 +70,12 @@
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
   SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts());
+  StringRef TokenName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Location),
+  Context.getSourceManager(), Context.getLangOpts());
   if (TokenName == PrevName) {
-// The token of the source location we find actually has the old name.
+// The token of the source location we find actually has the old
+ 

Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 marked an inline comment as done.
omtcyf0 added a comment.

Thanks, @alexfh!

Can you please land it?


http://reviews.llvm.org/D22091



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: test/clang-rename/TemplateTypename.cpp:4
@@ +3,3 @@
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+// XFAIL: *
+

Here, too?


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63934.

http://reviews.llvm.org/D22102

Files:
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/UserDefinedConversion.cpp
  test/clang-rename/VariableMacro.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,13 @@
+// Currently unsupported test.
+// FIXME: clang-rename should be able to rename virtual function and all the
+// functions which override it.
+
+class A {
+public:
+  virtual void foo();
+};
+
+class B : public A {
+public:
+  void foo();
+};
Index: test/clang-rename/VariableMacro.cpp
===
--- /dev/null
+++ test/clang-rename/VariableMacro.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define Y X // CHECK: #define Y Z
+
+void foo(int value) {}
+
+void macro() {
+  int X;// CHECK: int Z;
+  X = 42;   // CHECK: Z = 42;
+  Y -= 0;
+  foo(X);   // CHECK: foo(Z);
+  foo(Y);
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/UserDefinedConversion.cpp
===
--- /dev/null
+++ test/clang-rename/UserDefinedConversion.cpp
@@ -0,0 +1,12 @@
+// Currently unsupported test.
+// FIXME: clang-rename should handle conversions from a class type to another
+// type.
+
+class Foo {};
+
+class Boo {
+  operator Foo() const {
+Foo foo;
+return foo;
+  }
+};
Index: test/clang-rename/TemplateTypename.cpp
===
--- /dev/null
+++ test/clang-rename/TemplateTypename.cpp
@@ -0,0 +1,11 @@
+// Currently unsupported test.
+// FIXME: clang-rename should be able to rename template parameters correctly.
+
+template 
+T foo(T arg, T& ref, T* ptr) {
+  T value;
+  int number = 42;
+  value = (T)number;
+  value = static_cast(number);
+  return value;
+}
Index: test/clang-rename/Namespace.cpp
===
--- /dev/null
+++ test/clang-rename/Namespace.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace foo { // CHECK: namespace llvm {
+  int x;
+}
+
+void boo() {
+  foo::x = 42;  // CHECK: llvm::x = 42;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/FunctionMacro.cpp
===
--- /dev/null
+++ test/clang-rename/FunctionMacro.cpp
@@ -0,0 +1,21 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define moo foo // CHECK: #define moo macro_function
+
+int foo() { // CHECK: int macro_function() {
+  return 42;
+}
+
+void boo(int value) {}
+
+void qoo() {
+  foo();// CHECK: macro_function();
+  boo(foo());   // CHECK: boo(macro_function());
+  moo();
+  boo(moo());
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 marked an inline comment as done.
omtcyf0 added a comment.

Oops, sorry. Fixed it.

+1 currently unsupported test.


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

Thanks, Manuel!

Can you please land it?


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

Can you please avoid adding VirtualFunction.cpp? http://reviews.llvm.org/D22237 
would add it as well, but without the FIXME. Thanks! :-)


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63939.

http://reviews.llvm.org/D22102

Files:
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/UserDefinedConversion.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- /dev/null
+++ test/clang-rename/VariableMacro.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define Y X // CHECK: #define Y Z
+
+void foo(int value) {}
+
+void macro() {
+  int X;// CHECK: int Z;
+  X = 42;   // CHECK: Z = 42;
+  Y -= 0;
+  foo(X);   // CHECK: foo(Z);
+  foo(Y);
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/UserDefinedConversion.cpp
===
--- /dev/null
+++ test/clang-rename/UserDefinedConversion.cpp
@@ -0,0 +1,12 @@
+// Currently unsupported test.
+// FIXME: clang-rename should handle conversions from a class type to another
+// type.
+
+class Foo {};
+
+class Boo {
+  operator Foo() const {
+Foo foo;
+return foo;
+  }
+};
Index: test/clang-rename/TemplateTypename.cpp
===
--- /dev/null
+++ test/clang-rename/TemplateTypename.cpp
@@ -0,0 +1,11 @@
+// Currently unsupported test.
+// FIXME: clang-rename should be able to rename template parameters correctly.
+
+template 
+T foo(T arg, T& ref, T* ptr) {
+  T value;
+  int number = 42;
+  value = (T)number;
+  value = static_cast(number);
+  return value;
+}
Index: test/clang-rename/Namespace.cpp
===
--- /dev/null
+++ test/clang-rename/Namespace.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace foo { // CHECK: namespace llvm {
+  int x;
+}
+
+void boo() {
+  foo::x = 42;  // CHECK: llvm::x = 42;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/FunctionMacro.cpp
===
--- /dev/null
+++ test/clang-rename/FunctionMacro.cpp
@@ -0,0 +1,21 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define moo foo // CHECK: #define moo macro_function
+
+int foo() { // CHECK: int macro_function() {
+  return 42;
+}
+
+void boo(int value) {}
+
+void qoo() {
+  foo();// CHECK: macro_function();
+  boo(foo());   // CHECK: boo(macro_function());
+  moo();
+  boo(moo());
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@vmiklos sure thing.

Thanks for noticing!


http://reviews.llvm.org/D22102



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


r275384 - [X86][AVX512F] minor fix of the parameter names

2016-07-14 Thread Asaf Badouh via cfe-commits
Author: abadouh
Date: Thu Jul 14 03:40:30 2016
New Revision: 275384

URL: http://llvm.org/viewvc/llvm-project?rev=275384&view=rev
Log:
[X86][AVX512F] minor fix of the parameter names
add "__" prefix

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=275384&r1=275383&r2=275384&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jul 14 03:40:30 2016
@@ -9323,21 +9323,21 @@ _mm512_mask_compressstoreu_epi32 (void *
  (__mmask8)(U), (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_mask_cvtsd_ss (__m128 W, __mmask8 U, __m128 A, __m128d B)
+_mm_mask_cvtsd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128d __B)
 {
-  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(A),
- (__v2df)(B),
- (__v4sf)(W), 
- (__mmask8)(U), 
_MM_FROUND_CUR_DIRECTION);
+  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(__A),
+ (__v2df)(__B),
+ (__v4sf)(__W), 
+ (__mmask8)(__U), 
_MM_FROUND_CUR_DIRECTION);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_maskz_cvtsd_ss (__mmask8 U, __m128 A, __m128d B)
+_mm_maskz_cvtsd_ss (__mmask8 __U, __m128 __A, __m128d __B)
 {
-  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(A),
- (__v2df)(B),
+  return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)(__A),
+ (__v2df)(__B),
  (__v4sf)_mm_setzero_ps(), 
- (__mmask8)(U), 
_MM_FROUND_CUR_DIRECTION);
+ (__mmask8)(__U), 
_MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_cvtss_i32 _mm_cvtss_si32
@@ -9390,21 +9390,21 @@ _mm_maskz_cvtsd_ss (__mmask8 U, __m128 A
   (__mmask8)(U), (int)(R)); })
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_mask_cvtss_sd (__m128d W, __mmask8 U, __m128d A, __m128 B)
+_mm_mask_cvtss_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128 __B)
 {
-  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(A),
-  (__v4sf)(B),
-  (__v2df)(W),
-  (__mmask8)(U), 
_MM_FROUND_CUR_DIRECTION); 
+  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(__A),
+  (__v4sf)(__B),
+  (__v2df)(__W),
+  (__mmask8)(__U), 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_maskz_cvtss_sd (__mmask8 U, __m128d A, __m128 B)
+_mm_maskz_cvtss_sd (__mmask8 __U, __m128d __A, __m128 __B)
 {
-  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(A),
-  (__v4sf)(B),
+  return __builtin_ia32_cvtss2sd_round_mask((__v2df)(__A),
+  (__v4sf)(__B),
   (__v2df)_mm_setzero_pd(), 
-  (__mmask8)(U), 
_MM_FROUND_CUR_DIRECTION); 
+  (__mmask8)(__U), 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS


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


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a subscriber: omtcyf0.
omtcyf0 added a comment.

This one doesn't fix it though.

It only deals with declarations of overridden functions.

This is the test that still fails:

  / RUN: cat %s > %t.cpp
  // RUN: clang-rename -offset=161 -new-name=boo %t.cpp -i --
  // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
  // XFAIL: *
  
  class A {
  public:
virtual void foo() {}
  };
  
  class B : public A {
  public:
void foo() override {}  // OK: B::foo overrides A::foo
  };
  
  int main() {
A a;
a.foo();
  
B b;
b.foo();
  
return 0;
  }
  
  // Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
  // this file.


http://reviews.llvm.org/D22237



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


Re: [PATCH] D22129: [clang-rename] add documentation

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D22129



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


[PATCH] D22343: [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

The judgement that checks whether the fully-qualified name has scoped qualifiers
prefix is incorrect. Should always check whether the first matched postion is 
the
beginning position.

http://reviews.llvm.org/D22343

Files:
  include-fixer/IncludeFixerContext.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -42,9 +42,12 @@
   }
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
-  auto pos = FullyQualifiedName.find(SymbolScopedQualifiers);
-  return FullyQualifiedName.substr(
-  pos == std::string::npos ? 0 : SymbolScopedQualifiers.size());
+  bool HasScopedQualifiersPrefix =
+  FullyQualifiedName.find(SymbolScopedQualifiers) == 0;
+  if (!HasScopedQualifiersPrefix)
+return FullyQualifiedName;
+  // Skips symbol scoped qualifiers.
+  return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
 }
 
 } // anonymous namespace


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===

Re: r275368 - Add C++ dependencies to xray runtime

2016-07-14 Thread Mikael Holmén via cfe-commits

Hi,

Your commit

Add C++ dependencies to xray runtime

Doesn't compile with gcc. At least 5.3 and 4.8.4 complains about this 
change:


+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+ 
options::OPT_fxray_instruction_threshold_EQ)) {

+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+

../tools/clang/lib/Driver/Tools.cpp:4613:57: error: converting to 
'llvm::opt::OptSpecifier' from initializer list would use explicit 
constructor 'llvm::opt::OptSpecifier::OptSpecifier(bool)'

   options::OPT_fnoxray_instrument, false)) {
 ^
In file included from ../include/llvm/Option/OptTable.h:15:0,
 from ../include/llvm/Option/Option.h:15,
 from ../tools/clang/lib/Driver/Tools.h:19,
 from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error: 
'llvm::opt::OptSpecifier::OptSpecifier(bool)' is private

 explicit OptSpecifier(bool) = delete;
  ^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: within this context
   options::OPT_fnoxray_instrument, false)) {
 ^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: use of deleted 
function 'llvm::opt::OptSpecifier::OptSpecifier(bool)'

In file included from ../include/llvm/Option/OptTable.h:15:0,
 from ../include/llvm/Option/Option.h:15,
 from ../tools/clang/lib/Driver/Tools.h:19,
 from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error: declared here
 explicit OptSpecifier(bool) = delete;
  ^
In file included from 
../tools/clang/include/clang/Driver/SanitizerArgs.h:15:0,

 from ../tools/clang/lib/Driver/Tools.cpp:24:
../include/llvm/Option/ArgList.h:191:8: error:   initializing argument 3 
of 'bool llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier, 
llvm::opt::OptSpecifier, llvm::opt::OptSpecifier) const'
   bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) 
const {

^
ninja: build stopped: subcommand failed.
system(/proj/flexasic/app/ninja/1.4/SLED11-64/bin/ninja -j1 -C 
build-all-gcc53 llc llvm-stress opt clang all) failed: child exited with 
value 1

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


Re: [PATCH] D22343: [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/IncludeFixerContext.cpp:46
@@ +45,3 @@
+  bool HasScopedQualifiersPrefix =
+  FullyQualifiedName.find(SymbolScopedQualifiers) == 0;
+  if (!HasScopedQualifiersPrefix)

StringRef(FullyQualifiedName).startswith


http://reviews.llvm.org/D22343



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


Re: [PATCH] D22343: [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/IncludeFixerContext.cpp:46
@@ +45,3 @@
+  bool HasScopedQualifiersPrefix =
+  FullyQualifiedName.find(SymbolScopedQualifiers) == 0;
+  if (!HasScopedQualifiersPrefix)

bkramer wrote:
> StringRef(FullyQualifiedName).startswith
+1, more clear than std::string methods.


http://reviews.llvm.org/D22343



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


Re: [PATCH] D22343: [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 63941.
hokein marked an inline comment as done.
hokein added a comment.

Use StringRef::startwith.


http://reviews.llvm.org/D22343

Files:
  include-fixer/IncludeFixerContext.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -42,9 +42,12 @@
   }
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
-  auto pos = FullyQualifiedName.find(SymbolScopedQualifiers);
-  return FullyQualifiedName.substr(
-  pos == std::string::npos ? 0 : SymbolScopedQualifiers.size());
+
+  // Skips symbol scoped qualifiers prefix.
+  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
+return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
+
+  return FullyQualifiedName;
 }
 
 } // anonymous namespace


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -42,9 +42,12 @@
   }
   // Append the missing stripped qua

Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

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

In http://reviews.llvm.org/D22091#483834, @omtcyf0 wrote:

> Thanks, @alexfh!
>
> Can you please land it?


It's not easy to do from the phone ;) Please ask someone else (Ben?).


http://reviews.llvm.org/D22091



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


Re: [PATCH] D22343: [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275386: [include-fixer] Correct an incorrecst judgement 
about prefix scoped qualifiers. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D22343?vs=63941&id=63942#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22343

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
@@ -42,9 +42,12 @@
   }
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
-  auto pos = FullyQualifiedName.find(SymbolScopedQualifiers);
-  return FullyQualifiedName.substr(
-  pos == std::string::npos ? 0 : SymbolScopedQualifiers.size());
+
+  // Skips symbol scoped qualifiers prefix.
+  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
+return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
+
+  return FullyQualifiedName;
 }
 
 } // anonymous namespace


Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -63,6 +63,9 @@
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncl

[clang-tools-extra] r275386 - [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

2016-07-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jul 14 04:39:12 2016
New Revision: 275386

URL: http://llvm.org/viewvc/llvm-project?rev=275386&view=rev
Log:
[include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.

Summary:
The judgement that checks whether the fully-qualified name has scoped qualifiers
prefix is incorrect. Should always check whether the first matched postion is 
the
beginning position.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=275386&r1=275385&r2=275386&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Thu Jul 14 
04:39:12 2016
@@ -42,9 +42,12 @@ std::string createQualifiedNameForReplac
   }
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
-  auto pos = FullyQualifiedName.find(SymbolScopedQualifiers);
-  return FullyQualifiedName.substr(
-  pos == std::string::npos ? 0 : SymbolScopedQualifiers.size());
+
+  // Skips symbol scoped qualifiers prefix.
+  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
+return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
+
+  return FullyQualifiedName;
 }
 
 } // anonymous namespace

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=275386&r1=275385&r2=275386&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Thu 
Jul 14 04:39:12 2016
@@ -63,6 +63,9 @@ static std::string runIncludeFixer(
   SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar.h\"", 1,
  {{SymbolInfo::ContextType::Namespace, "b"},
   {SymbolInfo::ContextType::Namespace, "a"}}),
+  SymbolInfo("bar", SymbolInfo::SymbolKind::Class, "\"bar2.h\"", 1,
+ {{SymbolInfo::ContextType::Namespace, "c"},
+  {SymbolInfo::ContextType::Namespace, "a"}}),
   SymbolInfo("Green", SymbolInfo::SymbolKind::Class, "\"color.h\"", 1,
  {{SymbolInfo::ContextType::EnumDecl, "Color"},
   {SymbolInfo::ContextType::Namespace, "b"},
@@ -237,11 +240,15 @@ TEST(IncludeFixer, FixNamespaceQualifier
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace d {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test nested classes.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar::t b;\n}\n",
 runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));


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


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

on it ...


http://reviews.llvm.org/D22091



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


[clang-tools-extra] r275388 - [clang-rename] add documentation

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 04:46:07 2016
New Revision: 275388

URL: http://llvm.org/viewvc/llvm-project?rev=275388&view=rev
Log:
[clang-rename] add documentation

clang-rename needs at least to have a minimum documentation to provide a
small introduction for new users

Patch by Kirill Bobyrev!

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

Added:
clang-tools-extra/trunk/docs/clang-rename.rst
Modified:
clang-tools-extra/trunk/docs/index.rst

Added: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=275388&view=auto
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (added)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Thu Jul 14 04:46:07 2016
@@ -0,0 +1,99 @@
+
+Clang-Rename
+
+
+.. contents::
+
+See also:
+
+.. toctree::
+   :maxdepth: 1
+
+
+:program:`clang-rename` is a clang-based C++ "linter" tool. Its purpose is to
+perform efficient renaming actions in large-scale projects such as renaming
+classes, functions, variables, arguments, namespaces etc.
+
+The tool is in a very early development stage, so you might encounter bugs and
+crashes. Submitting reports with information about how to reproduce the issue
+to `the LLVM bugtracker `_ will definitely help the
+project. If you have any ideas or suggestions, you might want to put a feature
+request there.
+
+Using clang-rename
+==
+
+:program:`clang-rename` is a `LibTooling
+`_-based tool, and it's easier to
+work with if you set up a compile command database for your project (for an
+example of how to do this see `How To Setup Tooling For LLVM
+`_). You can also
+specify compilation options on the command line after ``--``:
+
+.. code-block:: console
+
+  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include 
-DMY_DEFINES ...
+
+
+To get an offset of a symbol in a file run
+
+.. code-block:: console
+
+  $ grep -FUbo 'foo' file.cpp
+
+
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
+.. code-block:: console
+
+  $ clang-rename -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol found at  in
+  . If -i is specified, the edited files are overwritten to disk.
+  Otherwise, the results are written to stdout.
+
+  USAGE: clang-rename [subcommand] [options]  [... ]
+
+  OPTIONS:
+
+  Clang-rename options:
+
+-export-fixes=   - YAML file to store suggested fixes in.
+-extra-arg=- Additional argument to append to the compiler 
command line
+-extra-arg-before= - Additional argument to prepend to the 
compiler command line
+-i - Overwrite edited s.
+-new-name= - The new name to change the symbol to.
+-offset= - Locates the symbol by offset as opposed to 
:.
+-old-name= - The fully qualified name of the symbol, if 
-offset is not used.
+-p=- Build path
+-pl- Print the locations affected by renaming to 
stderr.
+-pn- Print the found symbol's name prior to 
renaming to stderr.
+
+  Generic Options:
+
+-help  - Display available options (-help-hidden for 
more)
+-help-list - Display list of available options 
(-help-list-hidden for more)
+-version   - Display the version of this program
+
+
+clang-rename Vim integration
+
+
+You can call :program:`clang-rename` directly from Vim! To set up
+:program:`clang-rename` integration for Vim see
+`clang-rename/tool/clang-rename.py
+`_.
+
+Once installed, you can point your cursor to the symbols you want to rename,
+press `,cr` and print new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.

Modified: clang-tools-extra/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/index.rst?rev=275388&r1=275387&r2=275388&view=diff
==
--- clang-tools-extra/trunk/docs/index.rst (original)
+++ clang-tools-extra/trunk/docs/index.rst Thu Jul 14 04:46:07 2016
@@ -24,6 +

Re: [PATCH] D22129: [clang-rename] add documentation

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275388: [clang-rename] add documentation (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D22129?vs=63646&id=63944#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22129

Files:
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/docs/index.rst

Index: clang-tools-extra/trunk/docs/index.rst
===
--- clang-tools-extra/trunk/docs/index.rst
+++ clang-tools-extra/trunk/docs/index.rst
@@ -24,6 +24,7 @@
include-fixer
modularize
pp-trace
+   clang-rename
 
 
 Doxygen Documentation
Index: clang-tools-extra/trunk/docs/clang-rename.rst
===
--- clang-tools-extra/trunk/docs/clang-rename.rst
+++ clang-tools-extra/trunk/docs/clang-rename.rst
@@ -0,0 +1,99 @@
+
+Clang-Rename
+
+
+.. contents::
+
+See also:
+
+.. toctree::
+   :maxdepth: 1
+
+
+:program:`clang-rename` is a clang-based C++ "linter" tool. Its purpose is to
+perform efficient renaming actions in large-scale projects such as renaming
+classes, functions, variables, arguments, namespaces etc.
+
+The tool is in a very early development stage, so you might encounter bugs and
+crashes. Submitting reports with information about how to reproduce the issue
+to `the LLVM bugtracker `_ will definitely help the
+project. If you have any ideas or suggestions, you might want to put a feature
+request there.
+
+Using clang-rename
+==
+
+:program:`clang-rename` is a `LibTooling
+`_-based tool, and it's easier to
+work with if you set up a compile command database for your project (for an
+example of how to do this see `How To Setup Tooling For LLVM
+`_). You can also
+specify compilation options on the command line after ``--``:
+
+.. code-block:: console
+
+  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+
+
+To get an offset of a symbol in a file run
+
+.. code-block:: console
+
+  $ grep -FUbo 'foo' file.cpp
+
+
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
+.. code-block:: console
+
+  $ clang-rename -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol found at  in
+  . If -i is specified, the edited files are overwritten to disk.
+  Otherwise, the results are written to stdout.
+
+  USAGE: clang-rename [subcommand] [options]  [... ]
+
+  OPTIONS:
+
+  Clang-rename options:
+
+-export-fixes=   - YAML file to store suggested fixes in.
+-extra-arg=- Additional argument to append to the compiler command line
+-extra-arg-before= - Additional argument to prepend to the compiler command line
+-i - Overwrite edited s.
+-new-name= - The new name to change the symbol to.
+-offset= - Locates the symbol by offset as opposed to :.
+-old-name= - The fully qualified name of the symbol, if -offset is not used.
+-p=- Build path
+-pl- Print the locations affected by renaming to stderr.
+-pn- Print the found symbol's name prior to renaming to stderr.
+
+  Generic Options:
+
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
+
+
+clang-rename Vim integration
+
+
+You can call :program:`clang-rename` directly from Vim! To set up
+:program:`clang-rename` integration for Vim see
+`clang-rename/tool/clang-rename.py
+`_.
+
+Once installed, you can point your cursor to the symbols you want to rename,
+press `,cr` and print new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275387: [clang-rename] exit code-related bugfix and code 
cleanup (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D22091?vs=63931&id=63943#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22091

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.h
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Index: clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
@@ -0,0 +1,20 @@
+// This test is a copy of ConstCastExpr.cpp with a single change:
+// -new-name hasn't been passed to clang-rename, so this test should give an
+// error.
+// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename: no new name provided.
+
+class Cla {
+public:
+  int getValue() {
+return 0;
+  }
+};
+
+int main() {
+  const Cla *C = new Cla();
+  const_cast(C)->getValue();
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -34,8 +34,8 @@
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) {
-  }
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName)
+  : USR(USR), PrevName(PrevName) {}
 
   // Declaration visitors:
 
@@ -60,8 +60,7 @@
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
 const ASTContext &Context = ConstructorDecl->getASTContext();
-for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
-  const clang::CXXCtorInitializer* Initializer = *it;
+for (auto &Initializer : ConstructorDecl->inits()) {
   if (Initializer->getSourceOrder() == -1) {
 // Ignore implicit initializers.
 continue;
@@ -71,9 +70,12 @@
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
   SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts());
+  StringRef TokenName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Location),
+  Context.getSourceManager(), Context.getLangOpts());
   if (TokenName == PrevName) {
-// The token of the source location we find actually has the old name.
+// The token of the source location we find actually has the old
+// name.
 LocationsFound.push_back(Initializer->getSourceLocation());
   }
 }
@@ -183,14 +185,15 @@
   bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {
 clang::QualType Type = Expr->getType();
 // See if this a cast of a pointer.
-const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+const RecordDecl *Decl = Type->getPointeeCXXRecordDecl();
 if (!Decl) {
   // See if this is a cast of a reference.
   Decl = Type->getAsCXXRecordDecl();
 }
 
 if (Decl && getUSRForDecl(Decl) == USR) {
-  SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
+  SourceLocation Location =
+  Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
   LocationsFound.push_back(Location);
 }
 
@@ -205,8 +208,7 @@
 };
 } // namespace
 
-std::vector getLocationsOfUSR(StringRef USR,
-  StringRef PrevName,
+std::vector getLocationsOfUSR(StringRef USR, StringRef PrevName,
   Decl *Decl) {
   USRLocFindingASTVisitor visitor(USR, PrevName);
 
Index: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
@@ -49,7 +49,8 @@
 std::vector NewCandidates;
 
 for (const auto &USR : USRs) {
-  NewCandidates = getLocationsOfUSR(USR, PrevName, Context.getTranslationUnitDecl());
+  NewCandidates = getLocationsOfUSR(USR, PrevName,
+Context.getTranslationUnitDecl());
   RenamingCandidates.insert(

[clang-tools-extra] r275387 - [clang-rename] exit code-related bugfix and code cleanup

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 04:46:03 2016
New Revision: 275387

URL: http://llvm.org/viewvc/llvm-project?rev=275387&view=rev
Log:
[clang-rename] exit code-related bugfix and code cleanup

This patch does the following:

* enforces proper formatting for few files (i.e. deals with 80 linewidth 
violations and few other things)
* ensures '\n' chars are passed to the output streams instead of "\n" strings
* fixes a bug caused by calling cl::PrintHelpMessage(), which occasionally 
calls exit(0), so that exit(1) (which is right after cl::PrintHelpMessage line) 
becomes dead code

Patch by Kirill Bobyrev!

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

Added:
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=275387&r1=275386&r2=275387&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Thu Jul 14 04:46:03 
2016
@@ -49,7 +49,8 @@ public:
 std::vector NewCandidates;
 
 for (const auto &USR : USRs) {
-  NewCandidates = getLocationsOfUSR(USR, PrevName, 
Context.getTranslationUnitDecl());
+  NewCandidates = getLocationsOfUSR(USR, PrevName,
+Context.getTranslationUnitDecl());
   RenamingCandidates.insert(RenamingCandidates.end(), 
NewCandidates.begin(),
 NewCandidates.end());
   NewCandidates.clear();

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=275387&r1=275386&r2=275387&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Thu Jul 14 04:46:03 
2016
@@ -34,8 +34,8 @@ namespace {
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : 
USR(USR), PrevName(PrevName) {
-  }
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName)
+  : USR(USR), PrevName(PrevName) {}
 
   // Declaration visitors:
 
@@ -60,8 +60,7 @@ public:
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
 const ASTContext &Context = ConstructorDecl->getASTContext();
-for (clang::CXXConstructorDecl::init_const_iterator it = 
ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
-  const clang::CXXCtorInitializer* Initializer = *it;
+for (auto &Initializer : ConstructorDecl->inits()) {
   if (Initializer->getSourceOrder() == -1) {
 // Ignore implicit initializers.
 continue;
@@ -71,9 +70,12 @@ public:
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
   SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = 
Lexer::getSourceText(CharSourceRange::getTokenRange(Location), 
Context.getSourceManager(), Context.getLangOpts());
+  StringRef TokenName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Location),
+  Context.getSourceManager(), Context.getLangOpts());
   if (TokenName == PrevName) {
-// The token of the source location we find actually has the old 
name.
+// The token of the source location we find actually has the old
+// name.
 LocationsFound.push_back(Initializer->getSourceLocation());
   }
 }
@@ -183,14 +185,15 @@ private:
   bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {
 clang::QualType Type = Expr->getType();
 // See if this a cast of a pointer.
-const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+const RecordDecl *Decl = Type->getPointeeCXXRecordDecl();
 if (!Decl) {
   // See if this is a cast of a reference.
   Decl = Type->getAsCXXRecordDecl();
 }
 
 if (Decl && getUSRForDecl(Decl) == USR) {
-  SourceLocation Location = 
Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
+  SourceLocation Location =
+  Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
   LocationsFound.push_back(Location);
 }
 
@@ -205,8 +208,7 @@ private:
 };
 } // namespace
 
-std::vector getLocationsOfUSR(StringRef USR,
-  StringRef PrevName,
+std:

Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-14 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

In http://reviews.llvm.org/D22034#482925, @majnemer wrote:

> A flag on CXXRecordDecl which is sensitive to the most recent expression 
> evaluation might not be the best way to go.
>  Perhaps we should be able to use the VFTableBuilder to build imported and 
> local vftables for the same vftable? Not entirely sure though...


The flag can be only set to true, there is no way to reset it false. So by the 
end of translation unit it should have proper value and many things are 
deferred until the end of translation unit (like 
CodeGenModule::EmitDeferredVTables). But your example shows that normal var 
generation is not deferred, I missed it. Deferring var generation in 
CodeGenModule::MayBeEmittedEagerly seems to work fine.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-14 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 63950.
DmitryPolukhin marked 2 inline comments as done.
DmitryPolukhin added a comment.

- defer var generation if their type is class with dllimport.


http://reviews.llvm.org/D22034

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllimport-rtti.cpp
  test/CodeGenCXX/dllimport.cpp

Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -620,9 +620,31 @@
 struct __declspec(dllimport) W { virtual void foo() {} };
 USECLASS(W)
 // vftable:
-// MO1-DAG: @"\01??_SW@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
+// MO1-DAG: @"\01??_7W@@6B@" = external dllimport unnamed_addr constant [1 x i8*]
 // GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)]
 
+struct __declspec(dllimport) W2 {
+  virtual ~W2();
+  virtual void foo() {}
+};
+USECLASS(W2)
+// vftable:
+// MO1-DAG: @"\01??_SW2@@6B@" = linkonce_odr unnamed_addr constant [2 x i8*]
+// GO1-DAG: @_ZTV2W2 = external dllimport unnamed_addr constant [5 x i8*]
+
+struct __declspec(dllimport) W3 {
+  virtual void fn() const {
+  }
+  constexpr W3() = default;
+};
+
+W3 w3;
+W3& w3r = w3;
+
+constexpr W3 cw3;
+const W3 &cw3r = cw3;
+// MO1-DAG: @"\01??_SW3@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*]
+
 struct __declspec(dllimport) KeyFuncClass {
   constexpr KeyFuncClass() {}
   virtual void foo();
Index: test/CodeGenCXX/dllimport-rtti.cpp
===
--- test/CodeGenCXX/dllimport-rtti.cpp
+++ test/CodeGenCXX/dllimport-rtti.cpp
@@ -4,16 +4,25 @@
 struct __declspec(dllimport) S {
   virtual void f() {}
 } s;
-// MSVC: [[VF_S:.*]] = private unnamed_addr constant [2 x i8*]
-// MSVC-DAG: @"\01??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* [[VF_S]], i32 0, i32 1)
+// MSVC-DAG: @"\01??_7S@@6B@" = external dllimport unnamed_addr constant [2 x i8*]
 // MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R2S@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R3S@@8" = linkonce_odr
 
 // GNU-DAG: @_ZTV1S = available_externally dllimport
 // GNU-DAG: @_ZTI1S = external dllimport
 
+struct __declspec(dllimport) S2 {
+  virtual void f() {}
+  virtual ~S2() {}
+} s2;
+// MSVC-DAG: [[VF_S2:.*]] = private unnamed_addr constant [3 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4S2@@6B@" to i8*)
+// MSVC-DAG: @"\01??_SS2@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([3 x i8*], [3 x i8*]* [[VF_S2]], i32 0, i32 1)
+// MSVC-DAG: @"\01??_R0?AUS2@@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_R1A@?0A@EA@S2@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_R2S2@@8" = linkonce_odr
+
 struct U : S {
 } u;
 
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -4809,6 +4809,17 @@
 }
   }
 
+  if (!ClassExported) {
+if (Class->getTemplateSpecializationKind() != TSK_Undeclared)
+  Class->setNeedLocalVFTable();
+if (const CXXDestructorDecl *Destructor = Class->getDestructor()) {
+  // Classes with dllimport attribute needs local vftable if they have
+  // virtual d-tor.
+  if (Destructor->isVirtual())
+Class->setNeedLocalVFTable();
+}
+  }
+
   if (ClassExported)
 DelayedDllExportClasses.push_back(Class);
 }
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1670,9 +1670,13 @@
   //
   // Because of this unique behavior, we maintain this logic here instead of
   // getVTableLinkage.
-  llvm::GlobalValue::LinkageTypes VFTableLinkage =
-  RD->hasAttr() ? llvm::GlobalValue::LinkOnceODRLinkage
-   : CGM.getVTableLinkage(RD);
+  llvm::GlobalValue::LinkageTypes VFTableLinkage = CGM.getVTableLinkage(RD);
+  if (RD->hasAttr()) {
+if (RD->getNeedLocalVFTable())
+  VFTableLinkage = llvm::GlobalValue::LinkOnceODRLinkage;
+else
+  VFTableLinkage = llvm::GlobalValue::ExternalLinkage;
+  }
   bool VFTableComesFromAnotherTU =
   llvm::GlobalValue::isAvailableExternallyLinkage(VFTableLinkage) ||
   llvm::GlobalValue::isExternalLinkage(VFTableLinkage);
@@ -1745,7 +1749,9 @@
   if (C)
 VTable->setComdat(C);
 
-  if (RD->hasAttr())
+  if (RD->hasAttr() && !RD->getNeedLocalVFTable())
+VFTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+  else if (

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-14 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:160
@@ +159,3 @@
+  /// This returns true if the replacement is successfully inserted; otherwise,
+  /// it returns an llvm::Error, i.e. there is conflict between R and the
+  /// existing replacements or R's file path is different from the filepath of

a conflict


Comment at: include/clang/Tooling/Core/Replacement.h:163
@@ +162,3 @@
+  /// existing replacements. Callers must explicitly check the Error returned.
+  /// This disable users to add order-dependent replacements. To control the
+  /// order in which order-dependent replacements are applied, use merge({R})

This prevents users from adding order-dependent replacements.


Comment at: include/clang/Tooling/Core/Replacement.h:172-173
@@ +171,4 @@
+
+  // Merge \p Replaces with the current replacements with \p Replaces
+  // referring to code after applying the current replacements.
+  Replacements merge(const Replacements &Replaces) const;

That sentence doesn't parse...


Comment at: include/clang/Tooling/Core/Replacement.h:176
@@ +175,3 @@
+
+  // This is the same as the merge above except this merge a single 
replacement.
+  Replacements merge(const Replacement &R) const;

merges


Comment at: include/clang/Tooling/Core/Replacement.h:179
@@ +178,3 @@
+
+  // This returns the affected ranges in the changed code.
+  std::vector getAffectedRanges() const;

Here, above and below:
Don't start function comments with "This" or the function name - just leave it 
out, like this:
"Returns the affected ranges ..."


Comment at: lib/Tooling/Core/Replacement.cpp:300
@@ +299,3 @@
+Replacements Replacements::merge(const Replacement &R) const {
+  Replacements Rs;
+  llvm::consumeError(Rs.add(R));

I'd probably add a single-replacement constructor for convenience.


Comment at: lib/Tooling/Core/Replacement.cpp:306
@@ +305,3 @@
+// Merge and sort overlapping ranges in \p Ranges.
+static std::vector mergeAndSortRanges(std::vector Ranges) {
+  std::sort(Ranges.begin(), Ranges.end(),

So, this doesn't do the same as Replacements::merge, right? I think we're 
getting into a bit confusing terminology - perhaps we can find a better name 
for this?


Comment at: lib/Tooling/Core/Replacement.cpp:332
@@ +331,3 @@
+ const std::vector &Ranges) {
+  auto MergedRanges = mergeAndSortRanges(Ranges);
+  tooling::Replacements FakeReplaces;

This function could need a comment on how it actually works - I don't remember, 
and the function names called don't really give us a good explanation. I know 
this is just code you're moving, but I think we can make it a bit easier to 
understand while we're at it :)


http://reviews.llvm.org/D21748



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


Re: r275368 - Add C++ dependencies to xray runtime

2016-07-14 Thread Dean Michael Berris via cfe-commits
Thanks Mikael -- this has been fixed in r275377 (
http://reviews.llvm.org/rL275377).

On Thu, Jul 14, 2016 at 7:30 PM Mikael Holmén 
wrote:

> Hi,
>
> Your commit
>
>  Add C++ dependencies to xray runtime
>
> Doesn't compile with gcc. At least 5.3 and 4.8.4 complains about this
> change:
>
> +  if (Args.hasArg(options::OPT_fxray_instrument,
> +  options::OPT_fnoxray_instrument, false)) {
> +CmdArgs.push_back("-fxray-instrument");
> +if (Arg *A =
> Args.getLastArg(options::OPT_fxray_instruction_threshold_,
> +
> options::OPT_fxray_instruction_threshold_EQ)) {
> +  CmdArgs.push_back("-fxray-instruction-threshold");
> +  CmdArgs.push_back(A->getValue());
> +}
> +  }
> +
>
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: converting to
> 'llvm::opt::OptSpecifier' from initializer list would use explicit
> constructor 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
> options::OPT_fnoxray_instrument, false)) {
>   ^
> In file included from ../include/llvm/Option/OptTable.h:15:0,
>   from ../include/llvm/Option/Option.h:15,
>   from ../tools/clang/lib/Driver/Tools.h:19,
>   from ../tools/clang/lib/Driver/Tools.cpp:10:
> ../include/llvm/Option/OptSpecifier.h:24:14: error:
> 'llvm::opt::OptSpecifier::OptSpecifier(bool)' is private
>   explicit OptSpecifier(bool) = delete;
>^
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: within this context
> options::OPT_fnoxray_instrument, false)) {
>   ^
> ../tools/clang/lib/Driver/Tools.cpp:4613:57: error: use of deleted
> function 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
> In file included from ../include/llvm/Option/OptTable.h:15:0,
>   from ../include/llvm/Option/Option.h:15,
>   from ../tools/clang/lib/Driver/Tools.h:19,
>   from ../tools/clang/lib/Driver/Tools.cpp:10:
> ../include/llvm/Option/OptSpecifier.h:24:14: error: declared here
>   explicit OptSpecifier(bool) = delete;
>^
> In file included from
> ../tools/clang/include/clang/Driver/SanitizerArgs.h:15:0,
>   from ../tools/clang/lib/Driver/Tools.cpp:24:
> ../include/llvm/Option/ArgList.h:191:8: error:   initializing argument 3
> of 'bool llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,
> llvm::opt::OptSpecifier, llvm::opt::OptSpecifier) const'
> bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2)
> const {
>  ^
> ninja: build stopped: subcommand failed.
> system(/proj/flexasic/app/ninja/1.4/SLED11-64/bin/ninja -j1 -C
> build-all-gcc53 llc llvm-stress opt clang all) failed: child exited with
> value 1
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] Add missing documentation for some feature checks

2016-07-14 Thread Nathan Ridge via cfe-commits
Hello,

Comparing the list of feature checks documented here [1], and the list of 
checks actually implemented here [2], I found that a few are undocumented. 
Below is a patch that adds documentation for them.

Thank you,
Nate

[1] http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
[2] http://clang.llvm.org/doxygen/PPMacroExpansion_8cpp_source.html#l01049

Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst    (revision 275316)
+++ docs/LanguageExtensions.rst    (working copy)
@@ -573,6 +573,12 @@
 Use ``__has_feature(cxx_alignof)`` or ``__has_extension(cxx_alignof)`` to
 determine if support for the ``alignof`` keyword is enabled.
 
+C++11 atomics
+^
+
+Use ``__has_feature(cxx_atomics)`` or ``__has_extension(cxx_atomics)`` to
+determine if support for C++11 atomics is enabled.
+
 C++11 attributes
 
 
@@ -1002,6 +1008,7 @@
 * ``__is_pod`` (GNU, Microsoft)
 * ``__is_polymorphic`` (GNU, Microsoft)
 * ``__is_union`` (GNU, Microsoft)
+* ``__is_trivial`` (GNU, Microsoft)
 * ``__is_literal(type)``: Determines whether the given type is a literal type
 * ``__is_final``: Determines whether the given type is declared with a
   ``final`` class-virt-specifier.
@@ -1017,6 +1024,12 @@
   ``argtypes...`` such that no non-trivial functions are called as part of
   that initialization.  This trait is required to implement the C++11 standard
   library.
+* ``__is_trivially_copyable(type)``: Determines whether a value of type 
+  ``type`` is trivially copyable. This trait is required to implement the C++11
+  standard library.
+* ``__is_standard_layout(type)``: Determines whether ``type`` is a 
+  standard-layout type. This trait is required to implement the C++11 standard
+  library.
 * ``__is_destructible`` (MSVC 2013)
 * ``__is_nothrow_destructible`` (MSVC 2013)
 * ``__is_nothrow_assignable`` (MSVC 2013, clang)

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


Re: [PATCH] D19586: Misleading Indentation check

2016-07-14 Thread Pauer Gergely via cfe-commits
Pajesz updated this revision to Diff 63925.
Pajesz added a comment.

Minor changes in tests and doc and diff should be full now.


http://reviews.llvm.org/D19586

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-misleading-indentation.rst
  test/clang-tidy/readability-misleading-indentation.cpp

Index: test/clang-tidy/readability-misleading-indentation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-misleading-indentation.cpp
@@ -0,0 +1,130 @@
+// RUN: %check_clang_tidy %s readability-misleading-indentation %t
+
+void foo1() {}
+void foo2() {}
+
+int main() {
+  bool cond1 = true;
+  bool cond2 = true;
+
+  if (cond1)
+if (cond2)
+  foo1();
+else
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: wrong indentation, 'else' belongs to 'if(cond2)' statement
+  // CHECK-FIXES: {{^}}  // comment1
+
+  if (cond1) {
+if (cond2)
+  foo1();
+  } else
+foo2(); // ok, 'else' belongs to 'if(cond1)' statement
+
+  if (cond1)
+if (cond2)
+  foo1();
+else
+  foo2(); // ok, indentation matches to syntactical structure
+
+  if (cond1)
+foo1();
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of 'if(cond1)'
+  // CHECK-FIXES: {{^}}  // comment2
+
+  if (cond2)
+foo1();
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of 'if(cond2)'
+  // CHECK-FIXES: {{^}}  // comment3
+
+  if (cond1) {
+foo1();
+  }
+  foo2(); // ok
+
+  if (cond1)
+foo1();
+  foo2(); // ok
+
+  if (cond1)
+foo1();
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of 'if(cond1)'
+  // CHECK-FIXES: {{^}}  // comment4
+  foo2(); // no need for redundant warning
+
+  if (cond1) { // ok
+foo1();
+  } else {
+foo2();
+  }
+
+  if (cond1)
+foo1();
+  else
+foo2(); // ok
+
+  if (cond1) { // ok
+foo1();
+  } else {
+foo2();
+  }
+
+  if (cond1) // ok
+  {
+foo1();
+  } else {
+foo2();
+  }
+
+  if (cond1) // ok
+  {
+foo1();
+  } else {
+foo2();
+  }
+
+  while (cond1) {
+foo1();
+  }
+  foo2(); // ok
+
+  while (cond1)
+foo1();
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of 'while(cond1)'
+  // CHECK-FIXES: {{^}}  // comment5
+
+  while (cond1) {
+foo1();
+  }
+  foo2(); // ok
+
+  while (cond1)
+foo1();
+  foo2(); // ok
+
+  for (;;) {
+foo1();
+  }
+  foo2(); // ok
+
+  for (;;)
+foo1();
+  foo2(); // comment
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of 'for(;;)'
+  // CHECK-FIXES: {{^}}  // comment6
+
+  for (;;) {
+foo1();
+  }
+  foo2(); // ok
+
+  for (;;)
+foo1();
+  foo2(); // ok
+
+  return 0;
+}
Index: docs/clang-tidy/checks/readability-misleading-indentation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-misleading-indentation.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - readability-misleading-indentation
+
+readability-misleading-indentation
+==
+
+Description
+
+Correct indentation helps to understand code. Mismatch of the syntactical
+structure and the indentation of the code may reveal serious problems.
+Missing braces can also cause some problems in analyzing the code,
+therefore it is important to use braces. 
+
+The way to avoid dangling else is to always check that an ``else`` belongs
+to the ``if`` that begins in the same column.
+
+You can omit braces when your inner part of e.g. an ``if`` statement has only
+one statement in it. Although in that case you should begin the next statement
+in the same column with the ``if``.
+
+Examples:
+
+.. code-block:: c++
+
+  // Dangling else:
+
+  if (cond1)
+if (cond2)
+  foo1();
+  else
+foo2();  // wrong indentation: else belongs to if(cond2) statement
+
+  // Missing braces
+
+  if (cond1)
+foo1();
+foo2();  // not part of if(cond1)
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -93,6 +93,7 @@
readability-identifier-naming
readability-implicit-bool-cast
readability-inconsistent-declaration-parameter-name
+   readability-misleading-indentation
readability-named-parameter
readability-redundant-control-flow
readability-redundant-smartptr-get
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readabili

Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme added a subscriber: mboehme.
mboehme added a comment.

The test cfe/trunk/test/Frontend/opencl.cl that was added here appears to
fail.

Running "ninja check-clang" doesn't pick this up because
cfe/trunk/test/Frontend/lit.local.cfg doesn't contain '.cl' as a file
suffix:

config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']

As soon as I add the suffix:

config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']

the test fails. The failure seems to happen because of the new
"CHECK_INVALID_OPENCL_VERSION" checks. For OpenCL versions 1.1 and 1.2,
compilation fails for these checks because of the expected error "blocks
support disabled".

A solution seems to be to add "-fblocks" to the command line for these two
checks.

I'll be sending a patch with this fix out for review shortly.


Repository:
  rL LLVM

https://reviews.llvm.org/D22170



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


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-14 Thread Martin Böhme via cfe-commits
The test cfe/trunk/test/Frontend/opencl.cl that was added here appears to
fail.

Running "ninja check-clang" doesn't pick this up because
cfe/trunk/test/Frontend/lit.local.cfg doesn't contain '.cl' as a file
suffix:

config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']

As soon as I add the suffix:

config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']

the test fails. The failure seems to happen because of the new
"CHECK_INVALID_OPENCL_VERSION" checks. For OpenCL versions 1.1 and 1.2,
compilation fails for these checks because of the expected error "blocks
support disabled".

A solution seems to be to add "-fblocks" to the command line for these two
checks.

I'll be sending a patch with this fix out for review shortly.


On 13 July 2016 at 23:28, Yaxun Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL275318: [OpenCL] Fixes failures in test/Driver/
> opencl.cl. (authored by yaxunl).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D22170?vs=63722&id=63862#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D22170
>
> Files:
>   cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>   cfe/trunk/test/Driver/opencl.cl
>   cfe/trunk/test/Frontend/opencl-blocks.cl
>   cfe/trunk/test/Frontend/opencl.cl
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


-- 

Martin Böhme

Software Engineer

mboe...@google.com
+49 176 64059273

Google Germany GmbH
Maria-Goeppert-Str. 3
23562 Lübeck

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und
löschen Sie die E-Mail und alle Anhänge. Vielen Dank.



This e-mail is confidential. If you are not the right addressee please do
not forward it, please inform the sender, and please erase this e-mail
including any attachments. Thanks.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275404 - Correct the attribute documentation for the new XRay attributes. Fixes the documentation build.

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 07:35:00 2016
New Revision: 275404

URL: http://llvm.org/viewvc/llvm-project?rev=275404&view=rev
Log:
Correct the attribute documentation for the new XRay attributes. Fixes the 
documentation build.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=275404&r1=275403&r2=275404&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jul 14 07:35:00 2016
@@ -2453,10 +2453,11 @@ See the RenderScript_ documentation for
 
 def XRayDocs : Documentation {
   let Category = DocCatFunction;
+  let Heading = "xray_always_instrument (clang::xray_always_instrument), 
xray_never_instrument (clang::xray_never_instrument)";
   let Content = [{
-``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+``__attribute__((xray_always_instrument))`` or 
``[[clang::xray_always_instrument]]`` is used to mark member functions (in 
C++), methods (in Objective C), and free functions (in C, C++, and Objective C) 
to be instrumented with XRay. This will cause the function to always have space 
at the beginning and exit points to allow for runtime patching.
 
-Conversely, ``__attribute__((xray_never_instrument))`` or 
``[[clang:xray_never_instrument]]`` will inhibit the insertion of these 
instrumentation points.
+Conversely, ``__attribute__((xray_never_instrument))`` or 
``[[clang::xray_never_instrument]]`` will inhibit the insertion of these 
instrumentation points.
 
 If a function has neither of these attributes, they become subject to the XRay 
heuristics used to determine whether a function should be instrumented or 
otherwise.
   }];


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


[PATCH] D22349: [OpenCL] Actually activate Frontend/opencl.cl test and fix test bugs

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: bkramer.
mboehme added subscribers: cfe-commits, ashi1.

rL275318 added the test Frontend/opencl.cl test, but that test was never 
actually run because Frontend/lit.local.cfg doesn't contain the '.cl' file 
suffix.

Once the test is activated, it fails with (unintended) compile errors in the 
newly added CHECK_INVALID_OPENCL_VERSION checks.

This patch adds the '.cl' file suffix to Frontend/lit.local.cfg to activate the 
test and fixes the test bug by adding '-fblocks' to the relevant command lines.

https://reviews.llvm.org/D22349

Files:
  test/Frontend/lit.local.cfg
  test/Frontend/opencl.cl

Index: test/Frontend/opencl.cl
===
--- test/Frontend/opencl.cl
+++ test/Frontend/opencl.cl
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
-// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
@@ -24,4 +24,4 @@
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not 
support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not 
support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'
\ No newline at end of file
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'
Index: test/Frontend/lit.local.cfg
===
--- test/Frontend/lit.local.cfg
+++ test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']


Index: test/Frontend/opencl.cl
===
--- test/Frontend/opencl.cl
+++ test/Frontend/opencl.cl
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
-// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
@@ -24,4 +24,4 @@
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
\ No newline at end of file
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
Index: test/Frontend/lit.local.cfg
===
--- test/Frontend/lit.local.cfg
+++ test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme added a comment.

Fix in review at https://reviews.llvm.org/D22349


Repository:
  rL LLVM

https://reviews.llvm.org/D22170



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


r275405 - [OpenCL] Actually activate Frontend/opencl.cl test and fix test bugs

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 07:56:21 2016
New Revision: 275405

URL: http://llvm.org/viewvc/llvm-project?rev=275405&view=rev
Log:
[OpenCL] Actually activate Frontend/opencl.cl test and fix test bugs

rL275318 added the test Frontend/opencl.cl test, but that test was never 
actually run because Frontend/lit.local.cfg doesn't contain the '.cl' file 
suffix.

Once the test is activated, it fails with (unintended) compile errors in the 
newly added CHECK_INVALID_OPENCL_VERSION checks.

This patch adds the '.cl' file suffix to Frontend/lit.local.cfg to activate the 
test and fixes the test bug by adding '-fblocks' to the relevant command lines.

Patch by Martin Böhme!

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

Modified:
cfe/trunk/test/Frontend/lit.local.cfg
cfe/trunk/test/Frontend/opencl.cl

Modified: cfe/trunk/test/Frontend/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/lit.local.cfg?rev=275405&r1=275404&r2=275405&view=diff
==
--- cfe/trunk/test/Frontend/lit.local.cfg (original)
+++ cfe/trunk/test/Frontend/lit.local.cfg Thu Jul 14 07:56:21 2016
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']

Modified: cfe/trunk/test/Frontend/opencl.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/opencl.cl?rev=275405&r1=275404&r2=275405&view=diff
==
--- cfe/trunk/test/Frontend/opencl.cl (original)
+++ cfe/trunk/test/Frontend/opencl.cl Thu Jul 14 07:56:21 2016
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
-// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
@@ -24,4 +24,4 @@ void f(void (^g)(void)) {
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not 
support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not 
support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'
\ No newline at end of file
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'


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


Re: [PATCH] D22349: [OpenCL] Actually activate Frontend/opencl.cl test and fix test bugs

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275405: [OpenCL] Actually activate Frontend/opencl.cl test 
and fix test bugs (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D22349?vs=63959&id=63961#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22349

Files:
  cfe/trunk/test/Frontend/lit.local.cfg
  cfe/trunk/test/Frontend/opencl.cl

Index: cfe/trunk/test/Frontend/opencl.cl
===
--- cfe/trunk/test/Frontend/opencl.cl
+++ cfe/trunk/test/Frontend/opencl.cl
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
-// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | 
FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
@@ -24,4 +24,4 @@
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not 
support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not 
support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'
\ No newline at end of file
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not 
support the option '-cl-strict-aliasing'
Index: cfe/trunk/test/Frontend/lit.local.cfg
===
--- cfe/trunk/test/Frontend/lit.local.cfg
+++ cfe/trunk/test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']


Index: cfe/trunk/test/Frontend/opencl.cl
===
--- cfe/trunk/test/Frontend/opencl.cl
+++ cfe/trunk/test/Frontend/opencl.cl
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
-// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
@@ -24,4 +24,4 @@
 
 // CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
 // CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
\ No newline at end of file
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
Index: cfe/trunk/test/Frontend/lit.local.cfg
===
--- cfe/trunk/test/Frontend/lit.local.cfg
+++ cfe/trunk/test/Frontend/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.cl']
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme added a comment.

Fix submitted


Repository:
  rL LLVM

https://reviews.llvm.org/D22170



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


r275407 - This is a malformed :option: tag -- we don't have an option directive that matches it, so turning it actual text instead of a markup tag. This will hopefully fix the clang docs build (http:/

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 08:01:00 2016
New Revision: 275407

URL: http://llvm.org/viewvc/llvm-project?rev=275407&view=rev
Log:
This is a malformed :option: tag -- we don't have an option directive that 
matches it, so turning it actual text instead of a markup tag. This will 
hopefully fix the clang docs build 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15194/steps/docs-clang-html/logs/stdio)

Modified:
cfe/trunk/docs/ClangFormat.rst

Modified: cfe/trunk/docs/ClangFormat.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormat.rst?rev=275407&r1=275406&r2=275407&view=diff
==
--- cfe/trunk/docs/ClangFormat.rst (original)
+++ cfe/trunk/docs/ClangFormat.rst Thu Jul 14 08:01:00 2016
@@ -192,5 +192,5 @@ In an SVN client, you can do:
 
   svn diff --diff-cmd=diff -x -U0 | clang-format-diff.py -i
 
-The :option:`-U0` will create a diff without context lines (the script would 
format
+The option `-U0` will create a diff without context lines (the script would 
format
 those as well).


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


Re: [PATCH] D22310: Make the test for fno-pch-timestamp compatible with read-only checkouts.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer added a subscriber: bkramer.
bkramer accepted this revision.
bkramer added a reviewer: bkramer.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D22310



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


Re: [PATCH] D22196: Fix Bug "28480 - cppcoreguidelines-pro-bounds-array-to-pointer-decay handling __PRETTY_FUNCTION__"

2016-07-14 Thread Eric Lemanissier via cfe-commits
ericLemanissier added a comment.

After searching deeper into the C++ Core Guidelines, they are Ok with passing C 
strings to function without passing there size, but the types gsl::zstring and 
gsl::czstring have to be used : 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#i13-do-not-pass-an-array-as-a-single-pointer


https://reviews.llvm.org/D22196



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


Re: [PATCH] D22196: Fix Bug "28480 - cppcoreguidelines-pro-bounds-array-to-pointer-decay handling __PRETTY_FUNCTION__"

2016-07-14 Thread Eric Lemanissier via cfe-commits
ericLemanissier added a comment.

having studied cpp core guidelines in more depth, I completely understand that 
the problem in the case I described is that the function receiving 
PRETTY_FUNCTION takes a const char* parameter, whereas it should take a 
czstring or szstring_span. As a consequence this patch is not a good thing.

> In case it is not possible to change this function, I guess the only solution 
> is static_cast(__PRETTY_FUNCTION)


The function I refer to in this sentence is not 
ProBoundsArrayToPointerDecayCheck::registerMatchers, it is the function in user 
code receiving PRETTY_FUNCTION.


https://reviews.llvm.org/D22196



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


r275409 - Upgrade all the .arcconfigs to https.

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 08:15:37 2016
New Revision: 275409

URL: http://llvm.org/viewvc/llvm-project?rev=275409&view=rev
Log:
Upgrade all the .arcconfigs to https.

Modified:
cfe/trunk/.arcconfig

Modified: cfe/trunk/.arcconfig
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.arcconfig?rev=275409&r1=275408&r2=275409&view=diff
==
--- cfe/trunk/.arcconfig (original)
+++ cfe/trunk/.arcconfig Thu Jul 14 08:15:37 2016
@@ -1,4 +1,4 @@
 {
   "project_id" : "clang",
-  "conduit_uri" : "http://reviews.llvm.org/";
+  "conduit_uri" : "https://reviews.llvm.org/";
 }


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


[clang-tools-extra] r275409 - Upgrade all the .arcconfigs to https.

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 08:15:37 2016
New Revision: 275409

URL: http://llvm.org/viewvc/llvm-project?rev=275409&view=rev
Log:
Upgrade all the .arcconfigs to https.

Modified:
clang-tools-extra/trunk/.arcconfig

Modified: clang-tools-extra/trunk/.arcconfig
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/.arcconfig?rev=275409&r1=275408&r2=275409&view=diff
==
--- clang-tools-extra/trunk/.arcconfig (original)
+++ clang-tools-extra/trunk/.arcconfig Thu Jul 14 08:15:37 2016
@@ -1,4 +1,4 @@
 {
   "project_id" : "clang-tools-extra",
-  "conduit_uri" : "http://reviews.llvm.org/";
+  "conduit_uri" : "https://reviews.llvm.org/";
 }


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


[PATCH] D22351: [include-fixer] Move curosr to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

A small improvement: for only one suggested header, user don't have to
type ENTER manually after running the python script.

https://reviews.llvm.org/D22351

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -84,12 +84,18 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+# Set cursor to the #include line.
+include_header = "#include " + header["HeaderInfos"][0]["Header"]
+line_num = lines.index(include_header) + 1
+vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -135,15 +141,16 @@
 print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
-return
-
+  message = "Added #include for {0}".format(symbol)
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print message
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +160,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": selected_header_infos}, text)
-print "Added #include {0} for {1}.\n".format(selected, symbol)
+print message
   except Exception as error:
 print >> sys.stderr, error.message
   return


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -84,12 +84,18 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+# Set cursor to the #include line.
+include_header = "#include " + header["HeaderInfos"][0]["Header"]
+line_num = lines.index(include_header) + 1
+vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -135,15 +141,16 @@
 print "Couldn't find a header for {0}.\n".format(symbol)
 return
 
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
-return
-
+  message = "Added #include for {0}".format(symbol)
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print message
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +160,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": sel

Re: r275368 - Add C++ dependencies to xray runtime

2016-07-14 Thread Mikael Holmén via cfe-commits



On 07/14/2016 02:10 PM, Dean Michael Berris wrote:

Thanks Mikael -- this has been fixed in r275377
(http://reviews.llvm.org/rL275377).


Yes, now it compiled. Thank you!
/Mikael



On Thu, Jul 14, 2016 at 7:30 PM Mikael Holmén
mailto:mikael.hol...@ericsson.com>> wrote:

Hi,

Your commit

  Add C++ dependencies to xray runtime

Doesn't compile with gcc. At least 5.3 and 4.8.4 complains about this
change:

+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-fxray-instrument");
+if (Arg *A =
Args.getLastArg(options::OPT_fxray_instruction_threshold_,
+
options::OPT_fxray_instruction_threshold_EQ)) {
+  CmdArgs.push_back("-fxray-instruction-threshold");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+

../tools/clang/lib/Driver/Tools.cpp:4613:57: error: converting to
'llvm::opt::OptSpecifier' from initializer list would use explicit
constructor 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
 options::OPT_fnoxray_instrument, false)) {
   ^
In file included from ../include/llvm/Option/OptTable.h:15:0,
   from ../include/llvm/Option/Option.h:15,
   from ../tools/clang/lib/Driver/Tools.h:19,
   from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error:
'llvm::opt::OptSpecifier::OptSpecifier(bool)' is private
   explicit OptSpecifier(bool) = delete;
^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: within this context
 options::OPT_fnoxray_instrument, false)) {
   ^
../tools/clang/lib/Driver/Tools.cpp:4613:57: error: use of deleted
function 'llvm::opt::OptSpecifier::OptSpecifier(bool)'
In file included from ../include/llvm/Option/OptTable.h:15:0,
   from ../include/llvm/Option/Option.h:15,
   from ../tools/clang/lib/Driver/Tools.h:19,
   from ../tools/clang/lib/Driver/Tools.cpp:10:
../include/llvm/Option/OptSpecifier.h:24:14: error: declared here
   explicit OptSpecifier(bool) = delete;
^
In file included from
../tools/clang/include/clang/Driver/SanitizerArgs.h:15:0,
   from ../tools/clang/lib/Driver/Tools.cpp:24:
../include/llvm/Option/ArgList.h:191:8: error:   initializing argument 3
of 'bool llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,
llvm::opt::OptSpecifier, llvm::opt::OptSpecifier) const'
 bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2)
const {
  ^
ninja: build stopped: subcommand failed.
system(/proj/flexasic/app/ninja/1.4/SLED11-64/bin/ninja -j1 -C
build-all-gcc53 llc llvm-stress opt clang all) failed: child exited with
value 1



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


r275415 - The test added in r275267 does not work on read-only checkouts because of the use of touch -m -t.

2016-07-14 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Thu Jul 14 08:58:27 2016
New Revision: 275415

URL: http://llvm.org/viewvc/llvm-project?rev=275415&view=rev
Log:
The test added in r275267 does not work on read-only checkouts because of the 
use of touch -m -t.
Following Tom Rybka suggestion, the test files are now copied to a temporary 
directory first.

Modified:
cfe/trunk/test/PCH/include-timestamp.cpp

Modified: cfe/trunk/test/PCH/include-timestamp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/include-timestamp.cpp?rev=275415&r1=275414&r2=275415&view=diff
==
--- cfe/trunk/test/PCH/include-timestamp.cpp (original)
+++ cfe/trunk/test/PCH/include-timestamp.cpp Thu Jul 14 08:58:27 2016
@@ -1,23 +1,28 @@
 // Test that the timestamp is not included in the produced pch file with
 // -fno-pch-timestamp.
 
+// Copying files allow for read-only checkouts to run this test.
+// RUN: cp %S/Inputs/pragma-once2-pch.h %T
+// RUN: cp %S/Inputs/pragma-once2.h %T
+// RUN: cp %s %t1.cpp
+
 // Check timestamp is included by default.
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h
-// RUN: touch -m -a -t 201008011501 %S/Inputs/pragma-once2.h
-// RUN: not %clang_cc1 -include-pch %t %s 2>&1 | FileCheck 
-check-prefix=CHECK-TIMESTAMP %s
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h
+// RUN: touch -m -a -t 201008011501 %T/pragma-once2.h
+// RUN: not %clang_cc1 -include-pch %t %t1.cpp 2>&1 | FileCheck 
-check-prefix=CHECK-TIMESTAMP %s
 
 // Check bitcode output as well.
 // RUN: llvm-bcanalyzer -dump %t | FileCheck 
-check-prefix=CHECK-BITCODE-TIMESTAMP-ON %s
 
 // Check timestamp inclusion is disabled by -fno-pch-timestamp.
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/pragma-once2-pch.h 
-fno-pch-timestamp
-// RUN: touch -m -a -t 201008011502 %S/Inputs/pragma-once2.h
-// RUN: %clang_cc1 -include-pch %t %s 2>&1
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %T/pragma-once2-pch.h 
-fno-pch-timestamp
+// RUN: touch -m -a -t 201008011502 %T/pragma-once2.h
+// RUN: %clang_cc1 -include-pch %t %t1.cpp 2>&1
 
 // Check bitcode output as well.
 // RUN: llvm-bcanalyzer -dump %t | FileCheck 
-check-prefix=CHECK-BITCODE-TIMESTAMP-OFF %s
 
-#include "Inputs/pragma-once2.h"
+#include "pragma-once2.h"
 
 void g() { f(); }
 


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


Re: [PATCH] D22310: Make the test for fno-pch-timestamp compatible with read-only checkouts.

2016-07-14 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In https://reviews.llvm.org/D22310#484017, @bkramer wrote:

> lg


Thanks for the review!


https://reviews.llvm.org/D22310



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


r275416 - Removing more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/1

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 09:07:37 2016
New Revision: 275416

URL: http://llvm.org/viewvc/llvm-project?rev=275416&view=rev
Log:
Removing more :option: tags that we do not have corresponding .. option 
directives for; these are causing the sphinx bot to fail 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15195/steps/docs-clang-html/logs/stdio).

Modified:
cfe/trunk/docs/ClangPlugins.rst

Modified: cfe/trunk/docs/ClangPlugins.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangPlugins.rst?rev=275416&r1=275415&r2=275416&view=diff
==
--- cfe/trunk/docs/ClangPlugins.rst (original)
+++ cfe/trunk/docs/ClangPlugins.rst Thu Jul 14 09:07:37 2016
@@ -79,20 +79,20 @@ Using the cc1 command line
 --
 
 To run a plugin, the dynamic library containing the plugin registry must be
-loaded via the :option:`-load` command line option. This will load all plugins
+loaded via the `-load` command line option. This will load all plugins
 that are registered, and you can select the plugins to run by specifying the
-:option:`-plugin` option. Additional parameters for the plugins can be passed 
with
-:option:`-plugin-arg-`.
+`-plugin` option. Additional parameters for the plugins can be passed with
+`-plugin-arg-`.
 
 Note that those options must reach clang's cc1 process. There are two
 ways to do so:
 
-* Directly call the parsing process by using the :option:`-cc1` option; this
+* Directly call the parsing process by using the `-cc1` option; this
   has the downside of not configuring the default header search paths, so
   you'll need to specify the full system path configuration on the command
   line.
 * Use clang as usual, but prefix all arguments to the cc1 process with
-  :option:`-Xclang`.
+  `-Xclang`.
 
 For example, to run the ``print-function-names`` plugin over a source file in
 clang, first build the plugin, and then call clang with the plugin from the
@@ -116,11 +116,11 @@ Also see the print-function-name plugin
 Using the clang command line
 
 
-Using :option:`-fplugin=plugin` on the clang command line passes the plugin
-through as an argument to :option:`-load` on the cc1 command line. If the 
plugin
+Using `-fplugin=plugin` on the clang command line passes the plugin
+through as an argument to `-load` on the cc1 command line. If the plugin
 class implements the ``getActionType`` method then the plugin is run
 automatically. For example, to run the plugin automatically after the main AST
-action (i.e. the same as using :option:`-add-plugin`):
+action (i.e. the same as using `-add-plugin`):
 
 .. code-block:: c++
 


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


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

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275417: Diagnose taking address and reference binding of 
packed members (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D20561?vs=61089&id=63970#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20561

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/Sema/address-packed-member-memops.c
  cfe/trunk/test/Sema/address-packed.c
  cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
  cfe/trunk/test/SemaCXX/address-packed.cpp

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -6001,7 +6001,9 @@
   CheckTollFreeBridgeCast(castType, CastExpr);
   
   CheckObjCBridgeRelatedCast(castType, CastExpr);
-  
+
+  DiscardMisalignedMemberAddress(castType.getTypePtr(), CastExpr);
+
   return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
 }
 
@@ -10534,6 +10536,8 @@
   if (op->getType()->isObjCObjectType())
 return Context.getObjCObjectPointerType(op->getType());
 
+  CheckAddressOfPackedMember(op);
+
   return Context.getPointerType(op->getType());
 }
 
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8302,6 +8302,8 @@
 
   DiagnoseNullConversion(S, E, T, CC);
 
+  S.DiscardMisalignedMemberAddress(Target, E);
+
   if (!Source->isIntegerType() || !Target->isIntegerType())
 return;
 
@@ -9371,6 +9373,7 @@
   CheckUnsequencedOperations(E);
   if (!IsConstexpr && !E->isValueDependent())
 CheckForIntOverflow(E);
+  DiagnoseMisalignedMembers();
 }
 
 void Sema::CheckBitFieldInitialization(SourceLocation InitLoc,
@@ -10916,3 +10919,67 @@
 << ArgumentExpr->getSourceRange()
 << TypeTagExpr->getSourceRange();
 }
+
+void Sema::AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment) {
+  MisalignedMembers.emplace_back(E, RD, MD, Alignment);
+}
+
+void Sema::DiagnoseMisalignedMembers() {
+  for (MisalignedMember &m : MisalignedMembers) {
+Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
+<< m.MD << m.RD << m.E->getSourceRange();
+  }
+  MisalignedMembers.clear();
+}
+
+void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
+  if (!T->isPointerType())
+return;
+  if (isa(E) &&
+  cast(E)->getOpcode() == UO_AddrOf) {
+auto *Op = cast(E)->getSubExpr()->IgnoreParens();
+if (isa(Op)) {
+  auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
+  MisalignedMember(Op));
+  if (MA != MisalignedMembers.end() &&
+  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+MisalignedMembers.erase(MA);
+}
+  }
+}
+
+void Sema::RefersToMemberWithReducedAlignment(
+Expr *E,
+std::function Action) {
+  const auto *ME = dyn_cast(E);
+  while (ME && isa(ME->getMemberDecl())) {
+QualType BaseType = ME->getBase()->getType();
+if (ME->isArrow())
+  BaseType = BaseType->getPointeeType();
+RecordDecl *RD = BaseType->getAs()->getDecl();
+
+ValueDecl *MD = ME->getMemberDecl();
+bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
+if (ByteAligned) // Attribute packed does not have any effect.
+  break;
+
+if (!ByteAligned &&
+(RD->hasAttr() || (MD->hasAttr( {
+  CharUnits Alignment = std::min(Context.getTypeAlignInChars(MD->getType()),
+ Context.getTypeAlignInChars(BaseType));
+  // Notify that this expression designates a member with reduced alignment
+  Action(E, RD, MD, Alignment);
+  break;
+}
+ME = dyn_cast(ME->getBase());
+  }
+}
+
+void Sema::CheckAddressOfPackedMember(Expr *rhs) {
+  using namespace std::placeholders;
+  RefersToMemberWithReducedAlignment(
+  rhs, std::bind(&Sema::AddPotentialMisalignedMembers, std::ref(*this), _1,
+ _2, _3, _4));
+}
+
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -6457,6 +6457,15 @@
   ExtendingEntity->getDecl());
 
   CheckForNullPointerDereference(S, CurInit.get());
+
+  S.RefersToMemberWithReducedAlignment(CurInit.get(), [&](Expr *E,
+  RecordDecl *RD,
+  ValueDecl *MD,
+

r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Jul 14 09:10:43 2016
New Revision: 275417

URL: http://llvm.org/viewvc/llvm-project?rev=275417&view=rev
Log:
Diagnose taking address and reference binding of packed members

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
silence the warning.

This change also adds a new error diagnostic when the user attempts to
bind a reference to a packed member, regardless of the alignment.

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



Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417&r1=275416&r2=275417&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 09:10:43 
2016
@@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;
+def err_binding_reference_to_packed_member : Error<
+  "binding reference to packed member %0 of class or structure %q1">;
 
 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417&r1=275416&r2=275417&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
@@ -9518,6 +9518,10 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);
 
+  /// \brief Check if we are taking the address of a packed field
+  /// as this may be a problem if the pointer value is dereferenced.
+  void CheckAddressOfPackedMember(Expr *rhs);
+
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9596,6 +9600,51 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
+
+private:
+  /// \brief Helper class that collects misaligned member designations and
+  /// their location info for delayed diagnostics.
+  struct MisalignedMember {
+Expr *E;
+RecordDecl *RD;
+ValueDecl *MD;
+CharUnits Alignment;
+
+MisalignedMember() : E(), RD(), MD(), Alignment() {}
+MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment)
+: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
+explicit MisalignedMember(Expr *E)
+: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
+
+bool operator==(const MisalignedMember &m) { return this->E == m.E; }
+  };
+  /// \brief Small set of gathered accesses to potentially misaligned members
+  /// due to the packed attribute.
+  SmallVector MisalignedMembers;
+
+  /// \brief Adds an expression to the set of gathered misaligned members.
+  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment);
+
+public:
+  /// \brief Diagnoses the current set of gathered accesses. This typically
+  /// happens at full expression level. The set is cleared after emitting the
+  /// diagnostics.
+  void DiagnoseMisalignedMembers();
+
+  /// \brief This function checks if the expression is in the sef of 
potentially
+  /// misaligned members and it is converted to some pointer type T with lower
+  /// or equal alignment requirements.

Re: [PATCH] D22310: Make the test for fno-pch-timestamp compatible with read-only checkouts.

2016-07-14 Thread pierre gousseau via cfe-commits
pgousseau closed this revision.
pgousseau added a comment.

Committed in https://reviews.llvm.org/rL275415


https://reviews.llvm.org/D22310



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


[PATCH] D22359: [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: bkramer.
mboehme added a subscriber: cfe-commits.

The test currently fails if the name of the Clang binary doesn't contain 
"clang".

This patch removes that requirement, as some environments may choose to run the 
test with a differently named binary. This shouldn't make the test any less 
strict -- the only place where the flags we're searching for can really occur 
is the Clang command line.

https://reviews.llvm.org/D22359

Files:
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-m

r275428 - [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Jul 14 10:06:57 2016
New Revision: 275428

URL: http://llvm.org/viewvc/llvm-project?rev=275428&view=rev
Log:
[OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to 
contain "clang"

The test currently fails if the name of the Clang binary doesn't contain 
"clang".

This patch removes that requirement, as some environments may choose to run the 
test with a differently named binary. This shouldn't make the test any less 
strict -- the only place where the flags we're searching for can really occur 
is the Clang command line.

Patch by Martin Böhme!

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

Modified:
cfe/trunk/test/Driver/opencl.cl

Modified: cfe/trunk/test/Driver/opencl.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opencl.cl?rev=275428&r1=275427&r2=275428&view=diff
==
--- cfe/trunk/test/Driver/opencl.cl (original)
+++ cfe/trunk/test/Driver/opencl.cl Thu Jul 14 10:06:57 2016
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


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


Re: [PATCH] D22359: [OpenCL] In test/Driver/opencl.cl, don't require name of Clang binary to contain "clang"

2016-07-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275428: [OpenCL] In test/Driver/opencl.cl, don't require 
name of Clang binary to… (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D22359?vs=63976&id=63981#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22359

Files:
  cfe/trunk/test/Driver/opencl.cl

Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} 
"-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 


Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -15,20 +15,20 @@
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL"
-// CHECK-CL11: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.1"
-// CHECK-CL12: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL1.2"
-// CHECK-CL20: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-std=CL2.0"
-// CHECK-OPT-DISABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-opt-disable"
-// CHECK-STRICT-ALIASING: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-strict-aliasing"
-// CHECK-SINGLE-PRECISION-CONST: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-single-precision-constant"
-// CHECK-FINITE-MATH-ONLY: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-finite-math-only"
-// CHECK-KERNEL-ARG-INFO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-mad-enable"
-// CHECK-NO-SIGNED-ZEROS: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-no-signed-zeros"
-// CHECK-DENORMS-ARE-ZERO: {{.*}}clang{{.*}} "-cc1" {{.*}} "-cl-denorms-are-zero"
+// CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
+// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
+// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: "-cc1" {{.*}} "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: "-cc1" {{.*}} "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: "-cc1" {{.*}} "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: "-cc1" {{.*}} "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: "-cc1" {{.*}} "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: "-cc1" {{.*}} "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: "

Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I'm not entirely sure if jumping cursors are a good user interface. It will 
completely throw the user out of context, which is exactly what we want to 
avoid with include-fixer.


https://reviews.llvm.org/D22351



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

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

+1 to not throwing users around by default. Can we make it configurable if 
folks want it?


https://reviews.llvm.org/D22351



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


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Teresa Johnson via cfe-commits
tejohnson added a comment.

Note that this will have the side effect of enabling linkonce/weak resolution 
and internalization for the distributed backends.

I had just sent a separate patch (https://reviews.llvm.org/D22356) to do the 
former, which includes a fix for a subtle linking issue in the distributed 
backend case. I was planning to follow that up with another patch to add the 
internalization, after first removing the forced linkonce linking. However, I 
like having the weak resolution and internalization outside of the 
FunctionImporter pass, as is done here. So I think the best thing is to change 
my https://reviews.llvm.org/D22356 to not add weak resolution to the pass, but 
just have it address the linker issue requiring the new PreserveNonPrevailing 
flag and the test case. It should probably go in immediately after this one (or 
my distributed backend testing will start getting failures).


https://reviews.llvm.org/D21545



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


r275430 - Removing a few more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/bu

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 10:32:11 2016
New Revision: 275430

URL: http://llvm.org/viewvc/llvm-project?rev=275430&view=rev
Log:
Removing a few more :option: tags that we do not have corresponding .. option 
directives for; these are causing the sphinx bot to fail 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15197/steps/docs-clang-html/logs/stdio).

Modified:
cfe/trunk/docs/PCHInternals.rst

Modified: cfe/trunk/docs/PCHInternals.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/PCHInternals.rst?rev=275430&r1=275429&r2=275430&view=diff
==
--- cfe/trunk/docs/PCHInternals.rst (original)
+++ cfe/trunk/docs/PCHInternals.rst Thu Jul 14 10:32:11 2016
@@ -15,7 +15,7 @@ Using Precompiled Headers with ``clang``
 The Clang compiler frontend, ``clang -cc1``, supports two command line options
 for generating and using PCH files.
 
-To generate PCH files using ``clang -cc1``, use the option :option:`-emit-pch`:
+To generate PCH files using ``clang -cc1``, use the option `-emit-pch`:
 
 .. code-block:: bash
 
@@ -24,7 +24,7 @@ To generate PCH files using ``clang -cc1
 This option is transparently used by ``clang`` when generating PCH files.  The
 resulting PCH file contains the serialized form of the compiler's internal
 representation after it has completed parsing and semantic analysis.  The PCH
-file can then be used as a prefix header with the :option:`-include-pch`
+file can then be used as a prefix header with the `-include-pch`
 option:
 
 .. code-block:: bash
@@ -84,7 +84,7 @@ With this approach, the cost of using an
 proportional to the amount of code actually used from the AST file, rather than
 being proportional to the size of the AST file itself.
 
-When given the :option:`-print-stats` option, Clang produces statistics
+When given the `-print-stats` option, Clang produces statistics
 describing how much of the AST file was actually loaded from disk.  For a
 simple "Hello, World!" program that includes the Apple ``Cocoa.h`` header
 (which is built as a precompiled header), this option illustrates how little of


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


Re: [PATCH] D22292: [libunwind] Fix unw_getcontext for ARMv6-m

2016-07-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Update: Almost there, should be able to put it up for review tomorrow.

Cheers,

/ Asiri


https://reviews.llvm.org/D22292



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


Re: [PATCH] D22270: [ASTImporter] Properly report the locations of anonymous structs declared as part of named fields

2016-07-14 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks,
Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D22270



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


[PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D22367

Files:
  include-fixer/IncludeFixerContext.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers;
-  RawSymbolName.split(SymbolQualifiers, "::");
+  auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
@@ -43,11 +50,27 @@
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
 
-  // Skips symbol scoped qualifiers prefix.
-  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
-return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
 
-  return FullyQualifiedName;
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);
+  auto FullySymbolQualifiersIter = FullySymbolQualifiers.begin();
+  auto SymbolScopedQualifiersIter = ScopedQualifiers.begin();
+  // Find and skip the common prefix qualifiers.
+  while (FullySymbolQualifiersIter != FullySymbolQualifiers.end() &&
+ SymbolScopedQualifiersIter != ScopedQualifiers.end()) {
+if (*FullySymbolQualifiersIter != *SymbolScopedQualifiersIter)
+  break;
+++FullySymbolQualifiersIter;
+++SymbolScopedQualifiersIter;
+  }
+  std::string Result;
+  for (; FullySymbolQualifiersIter != FullySymbolQualifiers.end();
+   ++FullySymbolQualifiersIter) {
+if (!Result.empty())
+  Result += "::";
+Result += *FullySymbolQualifiersIter;
+  }
+  return Result;
 }
 
 } // anonymous namespace


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameF

Re: [PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-14 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
This revision is now accepted and ready to land.


Comment at: include-fixer/IncludeFixerContext.cpp:54
@@ -49,2 +53,3 @@
 
-  return FullyQualifiedName;
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);

Add a comment that you're trying to find the minimal scope qualifier here.


https://reviews.llvm.org/D22367



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Paul Robinson via cfe-commits
probinson added a comment.

Ping.


https://reviews.llvm.org/D22113



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! I don't think we intended this to be an extension for C.


https://reviews.llvm.org/D22113



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


Re: [PATCH] D22113: C does not have inline variables

2016-07-14 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Sema/SemaDecl.cpp:6189-6191
@@ -6188,2 +6188,5 @@
 << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+} else if (!getLangOpts().CPlusPlus) {
+  Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+  << 0;
 } else {

I'd suggest sorting this condition higher.  It doesn't make much sense to 
mention block scopes when inline variables are prohibited in all contexts in C.


https://reviews.llvm.org/D22113



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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Nico Weber via cfe-commits
Hi,

this fires on (at least) usrsctplib [1]:

FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15:
error: taking address of packed member 'time_entered' of class or structure
'sctp_state_cookie' may result in an unaligned pointer value
[-Werror,-Waddress-of-packed-member]

&cookie->time_entered,

 ^~~~
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10:
error: taking address of packed member 'time_entered' of class or structure
'sctp_state_cookie' may result in an unaligned pointer value
[-Werror,-Waddress-of-packed-member]
  &cookie->time_entered,
sctp_align_unsafe_makecopy,
   ^~~~
2 errors generated.

The struct looks like so [2]:

struct sctp_state_cookie { /* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered; /* the time I built cookie */
  ...

The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field
should be aligned as well, right? And while the struct is packed, its
alignment isn't overwritten (unless the packed attribute does that too, but
the docs at least don't mention that). Should the warning really fire here?

1:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
2:
https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium&dr=C&rcl=1468495044&l=190

On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rogfer01
> Date: Thu Jul 14 09:10:43 2016
> New Revision: 275417
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275417&view=rev
> Log:
> Diagnose taking address and reference binding of packed members
>
> This patch implements PR#22821.
>
> Taking the address of a packed member is dangerous since the reduced
> alignment of the pointee is lost. This can lead to memory alignment
> faults in some architectures if the pointer value is dereferenced.
>
> This change adds a new warning to clang emitted when taking the address
> of a packed member. A packed member is either a field/data member
> declared as attribute((packed)) or belonging to a struct/class
> declared as such. The associated flag is -Waddress-of-packed-member.
> Conversions (either implicit or via a valid casting) to pointer types
> with lower or equal alignment requirements (e.g. void* or char*)
> silence the warning.
>
> This change also adds a new error diagnostic when the user attempts to
> bind a reference to a packed member, regardless of the alignment.
>
> Differential Revision: https://reviews.llvm.org/D20561
>
>
>
> Added:
> cfe/trunk/test/Sema/address-packed-member-memops.c
> cfe/trunk/test/Sema/address-packed.c
> cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
> cfe/trunk/test/SemaCXX/address-packed.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417&r1=275416&r2=275417&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14
> 09:10:43 2016
> @@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
>"dereference of type %1 that was reinterpret_cast from type %0 has
> undefined "
>"behavior">,
>InGroup, DefaultIgnore;
> +def warn_taking_address_of_packed_member : Warning<
> +  "taking address of packed member %0 of class or structure %q1 may
> result in an unaligned pointer value">,
> +  InGroup>;
> +def err_binding_reference_to_packed_member : Error<
> +  "binding reference to packed member %0 of class or structure %q1">;
>
>  def err_objc_object_assignment : Error<
>"cannot assign to class object (%0 invalid)">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275417&r1=275416&r2=275417&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 09:10:43 2016
> @@ -9518,6 +9518,10 @@ private:
>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>  const Expr * const *ExprArgs);
>
> +  /// \brief Check if we are taking the address of a packed fiel

Re: [PATCH] D22290: [PATCH 2/2] [Driver] Compute effective target triples once per job (NFCI)

2016-07-14 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

On the thread you suggested it would affect out-of-tree targets, so this 
probably deserves a release note?


https://reviews.llvm.org/D22290



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


r275440 - Despite there being an option, it seems that Sphinx has decided that "=123" is part of the option directive name, and so having "=0" in the option tag is problematic. Since the option tag is

2016-07-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jul 14 12:15:06 2016
New Revision: 275440

URL: http://llvm.org/viewvc/llvm-project?rev=275440&view=rev
Log:
Despite there being an option, it seems that Sphinx has decided that "=123" is 
part of the option directive name, and so having "=0" in the option tag is 
problematic. Since the option tag is part of the option directive definition, 
it's superfluous, and so I've removed it.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=275440&r1=275439&r2=275440&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Jul 14 12:15:06 2016
@@ -133,13 +133,13 @@ Options to Control Error and Warning Mes
 .. option:: -ferror-limit=123
 
   Stop emitting diagnostics after 123 errors have been produced. The default is
-  20, and the error limit can be disabled with :option:`-ferror-limit=0`.
+  20, and the error limit can be disabled with `-ferror-limit=0`.
 
 .. option:: -ftemplate-backtrace-limit=123
 
   Only emit up to 123 template instantiation notes within the template
   instantiation backtrace for a single warning or error. The default is 10, and
-  the limit can be disabled with :option:`-ftemplate-backtrace-limit=0`.
+  the limit can be disabled with `-ftemplate-backtrace-limit=0`.
 
 .. _cl_diag_formatting:
 


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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 64004.
hokein added a comment.

Add an option to make move-cursor configurable.


https://reviews.llvm.org/D22351

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,13 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 
+if jump_to_include:
+  # Set cursor to the #include line.
+  include_header = "#include " + header["HeaderInfos"][0]["Header"]
+  line_num = lines.index(include_header) + 1
+  vim.current.window.cursor = (line_num, 0)
+
 
 def main():
   parser = argparse.ArgumentParser(
@@ -128,22 +140,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print "Couldn't find a header for {0}.\n".format(symbol)
-return
-
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
+print "Couldn't find a header for {0}.".format(symbol)
 return
 
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print "Added #include {0} for {1}.".format(unique_headers[0], symbol)
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +165,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": selected_header_infos}, text)
-print "Added #include {0} for {1}.\n".format(selected, symbol)
+print "Added #include {0} for {1}.".format(selected, symbol)
   except Exception as error:
 print >> sys.stderr, error.message
   return


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,13 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] is not 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
 
+if jump_to_include:
+  # Set cursor to the #include line.
+  include_header = "#include " + header["HeaderInfos"][0]["Header"]
+  line_num = lines.index(include_header) + 1
+  vim.current.window.cursor = (line_num, 0)
+
 
 def main():
   parser = argparse.ArgumentParser(
@@ -128,22 +140,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print 

Re: [PATCH] D22248: [Sema] Create a separate group for incompatible function pointer warning

2016-07-14 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D22248



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-14 Thread Haojian Wu via cfe-commits
hokein added a comment.

+Daniel who suggests this feature ;)


https://reviews.llvm.org/D22351



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-14 Thread Matt via cfe-commits
mmasten added a comment.

Hello all,

Just wanted to see if you guys have some time to review.

Thanks,

Matt


https://reviews.llvm.org/D19544



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


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

2016-07-14 Thread James Y Knight via cfe-commits
jyknight added a subscriber: jyknight.
jyknight added a comment.

This seems to trigger even for the implicitly generated copier of a packed 
struct. E.g.

  #include 
  
  void copyit(epoll_event&out, const epoll_event &in) {
out = in;
  }

Is that as intended?


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-14 Thread Sanjay Patel via cfe-commits
spatel added a comment.

Hi Matt -

This looks like the right first step in the path that Hal suggested, except I 
think we need a test case for each function that you want to enable. Please see 
test/Transforms/LoopVectorize/X86/veclib-calls.ll as a reference for how to do 
that.


https://reviews.llvm.org/D19544



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


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

2016-07-14 Thread James Y Knight via cfe-commits
jyknight added a comment.

Regardless, I think this should not have added a new un-disableable error, but 
instead only a default-on warning.

The ""binding reference to packed member" error is firing on some of our code, 
and even if it's not a false-positive, it should be possible to disable it 
until the code is modified.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 64016.
ioeric marked 6 inline comments as done.
ioeric added a comment.

- Merge branch 'master' of http://llvm.org/git/clang into replace
- Addressed reviewer's comments.


https://reviews.llvm.org/D21748

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/TokenAnalyzer.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  lib/Tooling/RefactoringCallbacks.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp
  unittests/Tooling/RewriterTest.cpp

Index: unittests/Tooling/RewriterTest.cpp
===
--- unittests/Tooling/RewriterTest.cpp
+++ unittests/Tooling/RewriterTest.cpp
@@ -39,8 +39,11 @@
 
 TEST(Rewriter, AdjacentInsertAndDelete) {
   Replacements Replaces;
-  Replaces.insert(Replacement("", 6, 6, ""));
-  Replaces.insert(Replacement("", 6, 0, "replaced\n"));
+  auto Err = Replaces.add(Replacement("", 6, 6, ""));
+  EXPECT_TRUE(!Err);
+  Replaces =
+  Replaces.merge(Replacements(Replacement("", 6, 0, "replaced\n")));
+
   auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces);
   EXPECT_TRUE(static_cast(Rewritten));
   EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten);
Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -109,62 +109,72 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+static Replacements toReplacements(const std::set &Replaces) {
+  Replacements Result;
+  for (const auto &R : Replaces) {
+auto Err = Result.add(R);
+EXPECT_TRUE(!Err);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return Replacements();
+}
+  }
+  return Result;
+}
+
+TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),
-  5, "other"));
-  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
+  auto Err = Replaces.add(Replacement("x.cc", 0, 10, "3"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
 }
 
-// FIXME: Remove this test case when Replacements is implemented as std::vector
-// instead of std::set. The other ReplacementTest tests will need to be updated
-// at that point as well.
-TEST_F(ReplacementTest, VectorCanApplyReplacements) {
+TEST_F(ReplacementTest, CanApplyReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  std::vector Replaces;
-  Replaces.push_back(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
- 5, "replaced"));
-  Replaces.push_back(
-  Replacement(Context.Sources, Context.getLocation(ID, 3, 1), 5, "other"));
+  Replacements Replaces =
+  toReplacements({Replacement(Context.Sources,
+  Context.getLocation(ID, 2, 1), 5, "replaced"),
+  Replacement(Context.Sources,
+  Context.getLocation(ID, 3, 1), 5, "other")});
   EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
   EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, SkipsDuplicateReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
+  auto Replaces = toReplacements({Replacement(
+  Context.Sources, Context

Re: r275040 - [CodeGen] Treat imported static local variables as declarations

2016-07-14 Thread David Blaikie via cfe-commits
On Tue, Jul 12, 2016 at 3:51 PM David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Jul 12, 2016 at 2:55 PM, Robinson, Paul 
> wrote:
>
>> A declaration that gets used within the CU generally does get a
>> debug-info description.
>>
>
> It does except if it is a static data member:
> $ cat t.cpp
> struct S {
>   static int i;
> };
> int &gv = &S::i;
> $ ~/llvm/Debug+Asserts/bin/clang t.cpp -target x86_64-gnu-linux -g -S
> -emit-llvm -o -
> ; ModuleID = 't.cpp'
> source_filename = "t.cpp"
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64--linux-gnu"
>
> @_ZN1S1iE = external global i32, align 4
> @gv = global i32* @_ZN1S1iE, align 8
>
> !llvm.dbg.cu = !{!0}
> !llvm.module.flags = !{!7, !8}
> !llvm.ident = !{!9}
>
> !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
> producer: "clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)",
> isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2,
> globals: !3)
> !1 = !DIFile(filename: "t.cpp", directory:
> "/usr/local/google/home/majnemer")
> !2 = !{}
> !3 = !{!4}
> !4 = distinct !DIGlobalVariable(name: "gv", scope: !0, file: !1, line: 4,
> type: !5, isLocal: false, isDefinition: true, variable: i32** @gv)
> !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64,
> align: 64)
> !6 = !DIBasicType(name: "int", size: 32, align: 32, encoding:
> DW_ATE_signed)
> !7 = !{i32 2, !"Dwarf Version", i32 4}
> !8 = !{i32 2, !"Debug Info Version", i32 3}
> !9 = !{!"clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)"}
>
> Note that there is no DIGlobalVariable for S::i.  I agree that this is not
> great behavior.  I merely changed a dllimport'd template instantiation of a
> static data member to behave the same way, poor, way a declaration is
> treated.
>

Yep, in theory (if anyone's interested) we could add such types to the
retained types list (that's what it's there for - when a type not
referenced from the debug info graph (variables, parameters, etc) is still
used).

I'm not too fussed by this. Mostly it's going to hit traits classes (that
don't have other members) that are careful to have no odr uses, so they
don't have a real definition anywhere. (or uses of -fstandalone-debug,
where the TU containing the definition is compiled without debug info, etc)

- Dave


>
>
>> I think no DWARF-using target has dllimport (yet) so you are actually
>> handling a new situation here.  Being unable to find the entity in the
>> dllimport-using CU is not a friendly debugging experience.
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Tuesday, July 12, 2016 2:07 PM
>>
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Jul 12, 2016 at 2:02 PM, Robinson, Paul 
>> wrote:
>>
>> I was asking for the debug info to describe the entity as a declaration,
>> rather than a definition.
>>
>> Instead you eliminated the debug-info description entirely.  These are
>> pretty different things.
>>
>>
>>
>> I treated the dllimported entity the same way we currently treat
>> declarations: ignore them.
>>
>> I don't have the bandwidth to generically improve debug info beyond what
>> we can do for DWARF/GDB targets.
>>
>>
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Monday, July 11, 2016 12:27 PM
>>
>>
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Jul 11, 2016 at 11:45 AM, Robinson, Paul 
>> wrote:
>>
>> It was not particularly obvious that by "static local variables" you
>> actually meant "template static data members."
>>
>> Now I can tell that this is not addressing what I was asking about in the
>> comment on r274986.
>>
>>
>>
>> I'm not sure I understand.  How is this not addressing what you are
>> asking for?  We will no longer emit a DIGlobalVariable for the imported
>> static data member.
>>
>>
>>
>> --paulr
>>
>>
>>
>> *From:* David Majnemer [mailto:david.majne...@gmail.com]
>> *Sent:* Monday, July 11, 2016 9:53 AM
>> *To:* Robinson, Paul
>> *Cc:* cfe-commits (cfe-commits@lists.llvm.org)
>> *Subject:* Re: r275040 - [CodeGen] Treat imported static local variables
>> as declarations
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Jul 11, 2016 at 9:48 AM, Robinson, Paul 
>> wrote:
>>
>> This changes the IR but not the debug-info metadata?
>> --paulr
>>
>>
>>
>> The net effect is that the debug-info metadata is not generated for such
>> static members.
>>
>>
>>
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf Of
>> > David Majnemer via cfe-commits
>> > Sent: Sunday, July 10, 2016 9:28 PM
>> > To: cfe-commits@lists.llvm.org
>> > Subject: r275040

Re: [PATCH] D21749: Changes related to new implementation of tooling::Replacements as class.

2016-07-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 64015.
ioeric added a comment.

- merged with origin/master
- Addressed reviewer's comments in the corresponding patch.


https://reviews.llvm.org/D21749

Files:
  
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  include-fixer/IncludeFixer.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  tool-template/ToolTemplate.cpp
  unittests/clang-tidy/ClangTidyTest.h
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -89,18 +89,28 @@
   runOnCode(&Factory, Code, FakeFileName, ExtraArgs);
   if (FixerContext.getHeaderInfos().empty())
 return Code;
-  auto Replaces = clang::include_fixer::createInsertHeaderReplacements(
+  auto ReplacesOrError = clang::include_fixer::createInsertHeaderReplacements(
   Code, FakeFileName, FixerContext.getHeaderInfos().front().Header);
-  EXPECT_TRUE(static_cast(Replaces))
-  << llvm::toString(Replaces.takeError()) << "\n";
-  if (!Replaces)
+  EXPECT_TRUE(static_cast(ReplacesOrError))
+  << llvm::toString(ReplacesOrError.takeError()) << "\n";
+  if (!ReplacesOrError)
 return "";
+  auto Replaces = std::move(*ReplacesOrError);
+  auto R = tooling::Replacement(
+  FakeFileName, FixerContext.getSymbolRange().getOffset(),
+  FixerContext.getSymbolRange().getLength(),
+  FixerContext.getHeaderInfos().front().QualifiedName);
+  auto Err = Replaces.add(R);
+  if (Err) {
+llvm::consumeError(std::move(Err));
+R = tooling::Replacement(R.getFilePath(),
+ Replaces.getShiftedCodePosition(R.getOffset()),
+ R.getLength(), R.getReplacementText());
+Replaces = Replaces.merge(tooling::Replacements(R));
+  }
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
-  Replaces->insert({FakeFileName, FixerContext.getSymbolRange().getOffset(),
-FixerContext.getSymbolRange().getLength(),
-FixerContext.getHeaderInfos().front().QualifiedName});
-  clang::tooling::applyAllReplacements(*Replaces, Context.Rewrite);
+  EXPECT_TRUE(clang::tooling::applyAllReplacements(Replaces, Context.Rewrite));
   return Context.getRewrittenText(ID);
 }
 
Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -119,7 +119,14 @@
   DiagConsumer.finish();
   tooling::Replacements Fixes;
   for (const ClangTidyError &Error : Context.getErrors())
-Fixes.insert(Error.Fix.begin(), Error.Fix.end());
+for (const auto &Fix : Error.Fix) {
+  auto Err = Fixes.add(Fix);
+  // FIXME: better error handling.
+  if (Err) {
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+return "";
+  }
+}
   if (Errors)
 *Errors = Context.getErrors();
   auto Result = tooling::applyAllReplacements(Code, Fixes);
Index: tool-template/ToolTemplate.cpp
===
--- tool-template/ToolTemplate.cpp
+++ tool-template/ToolTemplate.cpp
@@ -53,18 +53,20 @@
 
 namespace {
 class ToolTemplateCallback : public MatchFinder::MatchCallback {
- public:
-  ToolTemplateCallback(Replacements *Replace) : Replace(Replace) {}
+public:
+  ToolTemplateCallback(std::map *Replace)
+  : Replace(Replace) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-// TODO: This routine will get called for each thing that the matchers find.
+// TODO: This routine will get called for each thing that the matchers
+// find.
 // At this point, you can examine the match, and do whatever you want,
 // including replacing the matched text with other text
 (void)Replace; // This to prevent an "unused member variable" warning;
   }
 
- private:
-  Replacements *Replace;
+private:
+  std::map *Replace;
 };
 } // end anonymous namespace
 
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -262,12 +262,14 @@
   return 1;
 }
 
-auto Replacements = clang::include_fixer::createInsertHeaderReplacements(
+// FIXME: pull code for generating header insertion and namespace insertion
+// replacements into a function since similar stuff is performed below.
+auto ReplacesOrError = clang::include_fixer::cre

[PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-07-14 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added a reviewer: dcoughlin.
baloghadamsoftware added subscribers: cfe-commits, o.gyorgy, xazax.hun.

Many classes (e.g. in common stl implementations) contain user-written copy and 
move constructors that are identical to the implicit ones. This far ExprEngine 
could only handle the official "trivial" case. This patch extends ExprEngine 
for copy and move constructors that are user provided but in all other aspects 
they are the same as trivial ones.

A typical example is the GNU implementation of the iterator of std::deque, 
where the user provided copy constructor of the non-const version also accepts 
an instance of the const version as parameter. This patch allows correct 
simulation of this iterator.

https://reviews.llvm.org/D22374

Files:
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/ctor.mm

Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -144,11 +144,11 @@
 
 NonPOD() {}
 NonPOD(const NonPOD &Other)
-  : x(Other.x), y(Other.y) // expected-warning {{undefined}}
+  : x(Other.x), y(Other.y) // no-warning
 {
 }
 NonPOD(NonPOD &&Other)
-: x(Other.x), y(Other.y) // expected-warning {{undefined}}
+: x(Other.x), y(Other.y) // no-warning
 {
 }
 
@@ -174,11 +174,11 @@
 
   Inner() {}
   Inner(const Inner &Other)
-: x(Other.x), y(Other.y) // expected-warning {{undefined}}
+: x(Other.x), y(Other.y) // no-warning
   {
   }
   Inner(Inner &&Other)
-  : x(Other.x), y(Other.y) // expected-warning {{undefined}}
+  : x(Other.x), y(Other.y) // no-warning
   {
   }
 
@@ -224,25 +224,29 @@
   void testNonPOD() {
 NonPOD p;
 p.x = 1;
-NonPOD p2 = p;
+NonPOD p2 = p; // no-warning
+clang_analyzer_eval(p2.x == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODMove() {
 NonPOD p;
 p.x = 1;
-NonPOD p2 = move(p);
+NonPOD p2 = move(p); // no-warning
+clang_analyzer_eval(p2.x == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODWrapper() {
 NonPODWrapper w;
 w.p.y = 1;
-NonPODWrapper w2 = w;
+NonPODWrapper w2 = w; // no-warning
+clang_analyzer_eval(w2.p.y == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODWrapperMove() {
 NonPODWrapper w;
 w.p.y = 1;
-NonPODWrapper w2 = move(w);
+NonPODWrapper w2 = move(w); // no-warning
+clang_analyzer_eval(w2.p.y == 1); // expected-warning{{TRUE}}
   }
 
   // Not strictly about constructors, but trivial assignment operators should
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -34,19 +34,132 @@
   Bldr.generateNode(ME, Pred, state);
 }
 
+bool isCopyOrMoveLike(const CXXConstructorDecl *Constr) {
+  if (Constr->isCopyOrMoveConstructor())
+return true;
+
+  if(Constr->getNumParams() != 1)
+return false;
+
+  const auto ParamType =
+Constr->getParamDecl(0)->getType()->getUnqualifiedDesugaredType();
+  if(!ParamType->isReferenceType())
+return false;
+
+  const auto ParamPointeeType =
+ParamType->getAs()->getPointeeType();
+  if(!ParamPointeeType->isRecordType())
+return false;
+  
+  const auto *ParamRecDecl = ParamPointeeType->getAs()->getDecl();
+  const auto *ThisRecDecl = Constr->getParent();
+
+  if(ParamRecDecl!=ThisRecDecl)
+return false;
+
+  return true;
+}
+
+bool isAlmostTrivial(const CXXMethodDecl *Met) {
+  if (Met->isTrivial())
+return true;
+
+  if(!Met->hasTrivialBody())
+return false;
+
+  if(Met->getNumParams() != 1)
+return false;
+
+  const auto *Param = Met->getParamDecl(0);
+  const auto *ThisRecDecl = Met->getParent();
+
+  const auto *Constr = dyn_cast(Met);
+  if(!Constr)
+return false;
+  
+  if(ThisRecDecl->getNumVBases()>0)
+return false;
+
+  for(const auto Base: ThisRecDecl->bases()) {
+if(Base.getType()->getAsCXXRecordDecl()->field_empty())
+  continue;
+for(const auto *Initzer: Constr->inits()) {
+  if(Initzer->isBaseInitializer() &&
+ Initzer->getBaseClass() == &*Base.getType()) {
+if(const auto *CtrCall = dyn_cast(Initzer->getInit()->IgnoreParenImpCasts())) {
+  if(!isCopyOrMoveLike(CtrCall->getConstructor()) ||
+ !isAlmostTrivial(CtrCall->getConstructor()))
+return false;
+  if(const auto *Init = dyn_cast(CtrCall->getArg(0)->IgnoreParenImpCasts())) {
+if(Init->getDecl() != Param)
+  return false;
+  } else {
+return false;
+  }
+} else {
+  return false;
+}
+break;
+  }
+}
+  }
+
+  for(const auto *Field: ThisRecDecl->fields()) {
+if(!Field->getType()->isScalarType() &&
+   !Field->getType()->isRecordType())
+

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

2016-07-14 Thread Aaron Ballman via cfe-commits
Roger, can you please revert? This seems to have caused some pain for
our users, and it would be good to unblock them while deciding what to
do about the issues.

~Aaron

On Thu, Jul 14, 2016 at 2:19 PM, James Y Knight  wrote:
> jyknight added a comment.
>
> Regardless, I think this should not have added a new un-disableable error, 
> but instead only a default-on warning.
>
> The ""binding reference to packed member" error is firing on some of our 
> code, and even if it's not a false-positive, it should be possible to disable 
> it until the code is modified.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D20561
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275454 - [index] Index system ImportDecls even when there is a DeclarationsOnly filter

2016-07-14 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Jul 14 13:51:55 2016
New Revision: 275454

URL: http://llvm.org/viewvc/llvm-project?rev=275454&view=rev
Log:
[index] Index system ImportDecls even when there is a DeclarationsOnly filter

Whether we call an ImportDecl a decl or a reference symbol role is
somewhat academic, but in practice it's more like a declaration because
it is interesting even to consumers who wouldn't care about references.
Most importantly, we want to report the module dependencies of system
modules even when we have declaration-only filtering.

rdar://problem/27134855

Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-with-module.m
cfe/trunk/test/Index/index-module.m

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=275454&r1=275453&r2=275454&view=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Thu Jul 14 13:51:55 2016
@@ -83,14 +83,14 @@ bool IndexingContext::importedModule(con
   if (SEntry.getFile().getFileCharacteristic() != SrcMgr::C_User) {
 switch (IndexOpts.SystemSymbolFilter) {
 case IndexingOptions::SystemSymbolFilterKind::None:
-case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly:
   return true;
+case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly:
 case IndexingOptions::SystemSymbolFilterKind::All:
   break;
 }
   }
 
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
+  SymbolRoleSet Roles = (unsigned)SymbolRole::Declaration;
   if (ImportD->isImplicit())
 Roles |= (unsigned)SymbolRole::Implicit;
 

Modified: cfe/trunk/test/Index/Core/index-with-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-with-module.m?rev=275454&r1=275453&r2=275454&view=diff
==
--- cfe/trunk/test/Index/Core/index-with-module.m (original)
+++ cfe/trunk/test/Index/Core/index-with-module.m Thu Jul 14 13:51:55 2016
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t.mcp
 // RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module 
-fmodules -fmodules-cache-path=%t.mcp | FileCheck %s
 
-// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref |
+// CHECK: [[@LINE+1]]:9 | module/C | ModA | Decl |
 @import ModA;
-// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl |
+// CHECK: [[@LINE+1]]:1 | module/C | ModA | Decl,Impl |
 #include "ModA.h"
 
 void foo() {
   // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | 
Ref,Call,RelCall | rel: 1
   ModA_func();
-}
\ No newline at end of file
+}

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275454&r1=275453&r2=275454&view=diff
==
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Thu Jul 14 13:51:55 2016
@@ -6,6 +6,8 @@ int glob;
 // RUN: rm -rf %t.cache
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F 
%S/../Modules/Inputs \
 // RUN:  -Xclang -fdisable-module-hash | FileCheck %s
+// RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache.sys 
-fmodules -iframework %S/../Modules/Inputs \
+// RUN:  -Xclang -fdisable-module-hash | FileCheck %s
 // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules 
-gmodules -F %S/../Modules/Inputs \
 // RUN:  -Xclang -fdisable-module-hash | FileCheck %s
 
@@ -18,6 +20,7 @@ int glob;
 // CHECK-NOT: [indexDeclaration]
 
 // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
+// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
 
 // CHECK-DMOD:  [startedTranslationUnit]
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
@@ -27,7 +30,8 @@ int glob;
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule.SubFramework
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
 | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | 
isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: 
DependsOnMo

Re: [PATCH] D22290: [PATCH 2/2] [Driver] Compute effective target triples once per job (NFCI)

2016-07-14 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 64023.
vsk added a comment.

- Addressed Paul's comment: added a release note about this.
- Rebased onto master to pick up an Xray change.


https://reviews.llvm.org/D22290

Files:
  docs/ReleaseNotes.rst
  include/clang/Driver/Driver.h
  include/clang/Driver/SanitizerArgs.h
  include/clang/Driver/Tool.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h

Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -60,7 +60,8 @@
const InputInfoList &Inputs,
const ToolChain *AuxToolChain) const;
 
-  void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
+  void AddAArch64TargetArgs(const llvm::Triple &EffectiveTriple,
+const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
   void AddARMTargetArgs(const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args,
@@ -115,6 +116,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -132,6 +134,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -159,6 +162,7 @@
   bool hasIntegratedAssembler() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 
@@ -218,6 +222,7 @@
llvm::opt::ArgStringList &CmdArgs) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -233,6 +238,7 @@
llvm::opt::ArgStringList &CmdArgs) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -247,6 +253,7 @@
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -262,6 +269,7 @@
   bool hasIntegratedCPP() const override;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -323,6 +331,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -362,6 +371,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -382,6 +392,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
@@ -394,6 +405,7 @@
 
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &O

Re: [PATCH] D21537: Frontend: Simplify ownership model for clang's output streams.

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

Ping.


https://reviews.llvm.org/D21537



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


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:740
@@ +739,3 @@
+  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
+ImportList);
+

This should go away at some point right?
Just to double check if my memory is correct: the linker plugin will emit the 
import decision and the backend will take it as an input instead of recomputing 
anything?


https://reviews.llvm.org/D21545



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


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64025.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Forgot to add asserts for main() in the testcase.


https://reviews.llvm.org/D22237



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


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64027.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-07-14 Thread Teresa Johnson via cfe-commits
tejohnson added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:740
@@ +739,3 @@
+  ComputeCrossModuleImportForModule(M->getModuleIdentifier(), *CombinedIndex,
+ImportList);
+

mehdi_amini wrote:
> This should go away at some point right?
> Just to double check if my memory is correct: the linker plugin will emit the 
> import decision and the backend will take it as an input instead of 
> recomputing anything?
The way they are passed down is via the individual combined index. So it simply 
computes via what is in the index, which will only include summaries for what 
should be imported. I suppose we could make the logic even simpler tho and just 
blindly import what is in the index. 

Peter, can you add a fixme? 


https://reviews.llvm.org/D21545



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


r275460 - When importing classes and structs with anonymous structs, it is critical that

2016-07-14 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Thu Jul 14 14:53:44 2016
New Revision: 275460

URL: http://llvm.org/viewvc/llvm-project?rev=275460&view=rev
Log:
When importing classes and structs with anonymous structs, it is critical that
distinct anonymous structs remain distinct despite having similar layout.

This is already ensured by distinguishing based on their placement in the parent
struct, using the function `findAnonymousStructOrUnionIndex`.

The problem is that this function only handles anonymous structs, like
```
class Foo { struct { int a; } }
```
and not untagged structs like
```
class Foo { struct { int a; } var; }
```
Both need to be handled, and this patch fixes that.  The test case ensures that 
this functionality doesn't regress.

Thanks to Manman Ren for review.

https://reviews.llvm.org/D22270

Added:
cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp
cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp
cfe/trunk/test/ASTMerge/anonymous-fields.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=275460&r1=275459&r2=275460&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Jul 14 14:53:44 2016
@@ -1029,7 +1029,7 @@ static bool IsStructurallyEquivalent(Str
 /// including the next assigned index (if none of them match). Returns an
 /// empty option if the context is not a record, i.e.. if the anonymous
 /// struct/union is at namespace or block scope.
-static Optional findAnonymousStructOrUnionIndex(RecordDecl *Anon) {
+static Optional findUntaggedStructOrUnionIndex(RecordDecl *Anon) {
   ASTContext &Context = Anon->getASTContext();
   QualType AnonTy = Context.getRecordType(Anon);
 
@@ -1040,13 +1040,29 @@ static Optional findAnonymousS
   unsigned Index = 0;
   for (const auto *D : Owner->noload_decls()) {
 const auto *F = dyn_cast(D);
-if (!F || !F->isAnonymousStructOrUnion())
+if (!F)
   continue;
 
-if (Context.hasSameType(F->getType(), AnonTy))
-  break;
+if (F->isAnonymousStructOrUnion()) {
+  if (Context.hasSameType(F->getType(), AnonTy))
+break;
+  ++Index;
+  continue;
+}
 
-++Index;
+// If the field looks like this:
+// struct { ... } A;
+QualType FieldType = F->getType();
+if (const auto *RecType = dyn_cast(FieldType)) {
+  const RecordDecl *RecDecl = RecType->getDecl();
+  if (RecDecl->getDeclContext() == Owner &&
+  !RecDecl->getIdentifier()) {
+if (Context.hasSameType(FieldType, AnonTy))
+  break;
+++Index;
+continue;
+  }
+}
   }
 
   return Index;
@@ -1068,8 +1084,8 @@ static bool IsStructurallyEquivalent(Str
   if (D1->isAnonymousStructOrUnion() && D2->isAnonymousStructOrUnion()) {
 // If both anonymous structs/unions are in a record context, make sure
 // they occur in the same location in the context records.
-if (Optional Index1 = findAnonymousStructOrUnionIndex(D1)) {
-  if (Optional Index2 = findAnonymousStructOrUnionIndex(D2)) {
+if (Optional Index1 = findUntaggedStructOrUnionIndex(D1)) {
+  if (Optional Index2 = findUntaggedStructOrUnionIndex(D2)) {
 if (*Index1 != *Index2)
   return false;
   }
@@ -2749,9 +2765,9 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   // If both anonymous structs/unions are in a record context, make 
sure
   // they occur in the same location in the context records.
   if (Optional Index1
-  = findAnonymousStructOrUnionIndex(D)) {
+  = findUntaggedStructOrUnionIndex(D)) {
 if (Optional Index2 =
-findAnonymousStructOrUnionIndex(FoundRecord)) {
+findUntaggedStructOrUnionIndex(FoundRecord)) {
   if (*Index1 != *Index2)
 continue;
 }

Added: cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp?rev=275460&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp (added)
+++ cfe/trunk/test/ASTMerge/Inputs/anonymous-fields1.cpp Thu Jul 14 14:53:44 
2016
@@ -0,0 +1,5 @@
+class A {
+public:
+  struct { int foo; } f;
+  struct { int foo; } g;
+};

Added: cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp?rev=275460&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp (added)
+++ cfe/trunk/test/ASTMerge/Inputs/anonymous-fields2.cpp Thu Jul 14 14:53:44 
2016
@@ -0,0 +1,9 @@
+class A {
+public:
+  struct { int foo; } f;
+  struct { int foo; 

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

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Yes I will revert this ASAP.


Sorry for the fuss.


From: Aaron Ballman 
Sent: 14 July 2016 19:30:58
To: reviews+d20561+public+af1fea8a731d8...@reviews.llvm.org
Cc: Roger Ferrer Ibanez; Richard Smith; James Y Knight; Evgenii Stepanov; 
cfe-commits
Subject: Re: [PATCH] D20561: Warn when taking address of packed member

Roger, can you please revert? This seems to have caused some pain for
our users, and it would be good to unblock them while deciding what to
do about the issues.

~Aaron

On Thu, Jul 14, 2016 at 2:19 PM, James Y Knight  wrote:
> jyknight added a comment.
>
> Regardless, I think this should not have added a new un-disableable error, 
> but instead only a default-on warning.
>
> The ""binding reference to packed member" error is firing on some of our 
> code, and even if it's not a false-positive, it should be possible to disable 
> it until the code is modified.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D20561
>
>
>

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r275461 - cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-14 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Thu Jul 14 15:00:48 2016
New Revision: 275461

URL: http://llvm.org/viewvc/llvm-project?rev=275461&view=rev
Log:
cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent 
index in c++03 mode

Summary:
When the expression is value dependent,
isIntegerConstantExpr() crashes in C++03 mode with
 ../tools/clang/lib/AST/ExprConstant.cpp:9330: (anonymous namespace)::ICEDiag 
CheckICE(const clang::Expr *, const clang::ASTContext &):
  Assertion `!E->isValueDependent() && "Should not see value dependent exprs!"' 
failed.
In C++11 mode, that assert does not trigger.

This commit works around this in the check. We don't check
value-dependent indices and instead check their specialization.

Reviewers: alexfh, aaron.ballman

Subscribers: nemanjai, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=275461&r1=275460&r2=275461&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 Thu Jul 14 15:00:48 2016
@@ -65,6 +65,10 @@ void ProBoundsConstantArrayIndexCheck::c
 const MatchFinder::MatchResult &Result) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {

Added: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c%2B%2B03.cpp?rev=275461&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
 Thu Jul 14 15:00:48 2016
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s 
-checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | 
count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};


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


Re: [PATCH] D22190: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-14 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275461: cppcoreguidelines-pro-bounds-constant-array-index: 
crash for value dependent… (authored by mgehre).

Changed prior to commit:
  https://reviews.llvm.org/D22190?vs=63795&id=64030#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22190

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp

Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -65,6 +65,10 @@
 const MatchFinder::MatchResult &Result) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s 
-checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | 
count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -65,6 +65,10 @@
 const MatchFinder::MatchResult &Result) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
   const auto *IndexExpr = Result.Nodes.getNodeAs("index");
+
+  if (IndexExpr->isValueDependent())
+return; // We check in the specialization.
+
   llvm::APSInt Index;
   if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
 /*isEvaluated=*/true)) {
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index-c++03.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s -checks=-*,cppcoreguidelines-pro-bounds-constant-array-index -- -std=c++03 | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+template  struct B {
+  int get() {
+// The next line used to crash the check (in C++03 mode only).
+return x[index];
+  }
+  int x[3];
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275462 - Reverting 275417

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Jul 14 15:05:30 2016
New Revision: 275462

URL: http://llvm.org/viewvc/llvm-project?rev=275462&view=rev
Log:
Reverting 275417

This change has triggered unexpected failures.


Removed:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275462&r1=275461&r2=275462&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 15:05:30 
2016
@@ -5425,11 +5425,6 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
-def warn_taking_address_of_packed_member : Warning<
-  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
-  InGroup>;
-def err_binding_reference_to_packed_member : Error<
-  "binding reference to packed member %0 of class or structure %q1">;
 
 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275462&r1=275461&r2=275462&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 14 15:05:30 2016
@@ -9518,10 +9518,6 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);
 
-  /// \brief Check if we are taking the address of a packed field
-  /// as this may be a problem if the pointer value is dereferenced.
-  void CheckAddressOfPackedMember(Expr *rhs);
-
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9600,51 +9596,6 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
-
-private:
-  /// \brief Helper class that collects misaligned member designations and
-  /// their location info for delayed diagnostics.
-  struct MisalignedMember {
-Expr *E;
-RecordDecl *RD;
-ValueDecl *MD;
-CharUnits Alignment;
-
-MisalignedMember() : E(), RD(), MD(), Alignment() {}
-MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
- CharUnits Alignment)
-: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
-explicit MisalignedMember(Expr *E)
-: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
-
-bool operator==(const MisalignedMember &m) { return this->E == m.E; }
-  };
-  /// \brief Small set of gathered accesses to potentially misaligned members
-  /// due to the packed attribute.
-  SmallVector MisalignedMembers;
-
-  /// \brief Adds an expression to the set of gathered misaligned members.
-  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
- CharUnits Alignment);
-
-public:
-  /// \brief Diagnoses the current set of gathered accesses. This typically
-  /// happens at full expression level. The set is cleared after emitting the
-  /// diagnostics.
-  void DiagnoseMisalignedMembers();
-
-  /// \brief This function checks if the expression is in the sef of 
potentially
-  /// misaligned members and it is converted to some pointer type T with lower
-  /// or equal alignment requirements.  If so it removes it. This is used when
-  /// we do not want to diagnose such misaligned access (e.g. in conversions 
to void*).
-  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
-
-  /// \brief This function calls Action when it determines that E designates a
-  /// misaligned member due to the packed attribute. This is used to emit
-  /// local diagnostics like in reference binding.
-  void RefersToMemberWithReducedAlignment(
-  Expr *E,
-  std::function 
Action);
 };
 
 /// \brief RAII object that enters a new expression evaluation context.

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=275462&r1=275461&r2=275462&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)

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

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

Reverted.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


r275464 - Attempt to workaround Windows bots after my previous commit

2016-07-14 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Jul 14 15:08:43 2016
New Revision: 275464

URL: http://llvm.org/viewvc/llvm-project?rev=275464&view=rev
Log:
Attempt to workaround Windows bots after my previous commit

For some reason it seems the second invocation is getting DMOD_OTHER_H
set to a path with/forward/slashes, but one of the use sites
has\back\slashes. There should be no difference with what was already
there, but for now try to avoid checking those paths.

Modified:
cfe/trunk/test/Index/index-module.m

Modified: cfe/trunk/test/Index/index-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=275464&r1=275463&r2=275464&view=diff
==
--- cfe/trunk/test/Index/index-module.m (original)
+++ cfe/trunk/test/Index/index-module.m Thu Jul 14 15:08:43 2016
@@ -20,7 +20,7 @@ int glob;
 // CHECK-NOT: [indexDeclaration]
 
 // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
-// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD
+// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s 
-check-prefix=CHECK-DMOD-AST
 
 // CHECK-DMOD:  [startedTranslationUnit]
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
@@ -31,7 +31,6 @@ int glob;
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
 | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | 
isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
 // CHECK-DMOD-NEXT: [ppIncludedFile]: 
[[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
 | {{.*}} | hash loc:  | {{.*}} | module: 
DependsOnModule.Private.DependsOnModule
 // CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm 
| loc: [[DMOD_MODULE_H]]:1:1 | name: "Module" | isImplicit: 1
-//
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template | 
{{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework | 
{{.*}} | loc: [[DMOD_SUB_H]]:2:8
@@ -39,6 +38,8 @@ int glob;
 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
 // CHECK-DMOD-NOT: [indexDeclaration]
 
+// CHECK-DMOD-AST: [importedASTFile]: {{.*}}.cache.sys{{[/\\]}}Module.pcm | 
loc: {{.*}}DependsOnModule.h:1:1 | name: "Module" | isImplicit: 1
+
 // RUN: c-index-test -index-tu %t.cache/Module.pcm | FileCheck %s 
-check-prefix=CHECK-TMOD
 
 // CHECK-TMOD:  [startedTranslationUnit]


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


Re: r275417 - Diagnose taking address and reference binding of packed members

2016-07-14 Thread Roger Ferrer Ibanez via cfe-commits
Hi Nico,


it seems it may be necessary to take into account the actual offset of the 
field in such cases to avoid these kind of false positives.


I reverted the change until I get a better solution.


Thanks,

Roger


From: tha...@google.com  on behalf of Nico Weber 

Sent: 14 July 2016 18:15:42
To: Roger Ferrer Ibanez
Cc: cfe-commits
Subject: Re: r275417 - Diagnose taking address and reference binding of packed 
members

Hi,

this fires on (at least) usrsctplib [1]:

FAILED: obj/third_party/usrsctp/usrsctp/sctp_input.o
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:1708:15: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  
&cookie->time_entered,
   
^~~~
../../third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:2458:10: 
error: taking address of packed member 'time_entered' of class or structure 
'sctp_state_cookie' may result in an unaligned pointer value 
[-Werror,-Waddress-of-packed-member]
  &cookie->time_entered, 
sctp_align_unsafe_makecopy,
   ^~~~
2 errors generated.

The struct looks like so [2]:

struct sctp_state_cookie { /* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered; /* the time I built cookie */
  ...

The _SIZE is 16, so as long as sctp_state_cookie is aligned, that field should 
be aligned as well, right? And while the struct is packed, its alignment isn't 
overwritten (unless the packed attribute does that too, but the docs at least 
don't mention that). Should the warning really fire here?

1: 
https://build.chromium.org/p/chromium.fyi/builders/ClangToTLinux/builds/5748/steps/compile/logs/stdio
2: 
https://cs.chromium.org/chromium/src/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h?sq=package:chromium&dr=C&rcl=1468495044&l=190

On Thu, Jul 14, 2016 at 10:10 AM, Roger Ferrer Ibanez via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: rogfer01
Date: Thu Jul 14 09:10:43 2016
New Revision: 275417

URL: http://llvm.org/viewvc/llvm-project?rev=275417&view=rev
Log:
Diagnose taking address and reference binding of packed members

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
silence the warning.

This change also adds a new error diagnostic when the user attempts to
bind a reference to a packed member, regardless of the alignment.

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



Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275417&r1=275416&r2=275417&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 14 09:10:43 
2016
@@ -5425,6 +5425,11 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;
+def err_binding_reference_to_packed_member : Error<
+  "binding reference to packed member %0 of class or structure %q1">;

 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?r

  1   2   >