r281706 - Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Fri Sep 16 02:21:24 2016
New Revision: 281706

URL: http://llvm.org/viewvc/llvm-project?rev=281706&view=rev
Log:
Fix unused result from sign extending an Offset.

Summary:
Offset was doubled in size, but the assignment was missing. We just need
to reassign to the original variable in this case to fix it.

Reviewers: cfe-commits, echristo

Subscribers: meikeb

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

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281706&r1=281705&r2=281706&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Sep 16 02:21:24 2016
@@ -3882,7 +3882,7 @@ static void sumOffsets(llvm::APSInt &Off
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }


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


Re: [PATCH] D24648: Fix unused result from sign extending an Offset.

2016-09-16 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281706: Fix unused result from sign extending an Offset. 
(authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24648?vs=71598&id=71599#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24648

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3882,7 +3882,7 @@
   // possible.
   if (Ov) {
 assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
+Offset = Offset.sext(2 * BitWidth);
 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

In https://reviews.llvm.org/D20811#544250, @dcoughlin wrote:

> I think a good rule of thumb for readability is: suppose you are a maintainer 
> and need to add a summary for a new function. Can you copy the the summary 
> for an existing function and figure out what each component means so you can 
> change it for the new function?


Seems i've written too many summaries to reliably use this rule :)

Could you have a look at another attempt?:

  SUMMARY(isalnum, ARGUMENT_TYPES { IntTy }, RETURN_TYPE(IntTy),
  INVALIDATION_APPROACH(EvalCallAsPure))
CASE // Boils down to isupper() or islower() or isdigit()
  PRE_CONDITION(ARG_NO(0), CONDITION_KIND(WithinRange))
RANGE('0', '9')
RANGE('A', 'Z')
RANGE('a', 'z')
  END_PRE_CONDITION
  POST_CONDITION(OutOfRange)
VALUE(0)
  END_POST_CONDITION
END_CASE
CASE // The locale-specific range.
  PRE_CONDITION(ARG_NO(0), CONDITION_KIND(WithinRange))
RANGE(128, 255)
  END_PRE_CONDITION
  // No post-condition. We are completely unaware of
  // locale-specific return values.
END_CASE
CASE
  PRE_CONDITION(ARG_NO(0), CONDITION_KIND(OutOfRange))
RANGE('0', '9')
RANGE('A', 'Z')
RANGE('a', 'z')
RANGE(128, 255)
  END_PRE_CONDITION
  POST_CONDITION(WithinRange)
VALUE(0)
  END_POST_CONDITION
END_CASE
  END_SUMMARY



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:419
@@ -418,1 +418,3 @@
 
+def StdLibraryFunctionsChecker : Checker<"StdLibraryFunctions">,
+  HelpText<"Improve modeling of standard library functions">,

dcoughlin wrote:
> I know you and Gábor already discussed this -- but shouldn't this be 
> CStdLibraryFunctionsChecker or 'StdCLibraryFunctionsChecker'? Or is is your 
> intent that both C and C++ standard libraries would be modeled by this 
> checker?
Hmm, i just realized what you guys were talking about :) The same checker cpp 
file and even the same checker object should probably produce different checker 
list entries here which would go into separate packages (cplusplus for C++ 
library functions, etc.). We could even split the specifications into different 
files, but the checker object would still be the same, defined in the same 
file. Will do.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:537
@@ +536,3 @@
+  SPEC_DATA {
+ARGUMENT_TYPES { IntTy },
+RETURN_TYPE(IntTy),

dcoughlin wrote:
> The argument and return types seem like more a property of the function than 
> than the summary. Why are they here and not with the function name?
Because this is where C++ initializer list syntax forces them to be. Hiding 
this detail is, as far as i see, only possible with the means of 
BEGIN_.../END_... macros (which isn't a big deal i think).


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:547
@@ +546,3 @@
+RANGE {
+  RET_VAL, RANGE_KIND(OutOfRange),
+  SET { POINT(0) }

dcoughlin wrote:
> Is it ever the case that this final 'RANGE" constrains anything other than 
> the return value? If not, can 'RET_VAL' be elided?
Some summaries only have pre-conditions: "for this argument constraint, any 
return value is possible". We should also be able to support void functions, 
which have no return values.


https://reviews.llvm.org/D20811



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


Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

This is a friendly ping :)

Thank you very much!


https://reviews.llvm.org/D23657



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


[libcxxabi] r281709 - Fix side effect in assertion

2016-09-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Sep 16 03:16:07 2016
New Revision: 281709

URL: http://llvm.org/viewvc/llvm-project?rev=281709&view=rev
Log:
Fix side effect in assertion

Modified:
libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp

Modified: libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp?rev=281709&r1=281708&r2=281709&view=diff
==
--- libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp (original)
+++ libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp Fri Sep 16 03:16:07 
2016
@@ -28,7 +28,7 @@ int main() {
   int RV = __cxxabiv1::__cxa_thread_atexit(
   reinterpret_cast(1), reinterpret_cast(2),
   reinterpret_cast(3));
-  assert(RV = 4);
+  assert(RV == 4);
   assert(AtexitImplCalled);
   return 0;
 }


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


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

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

lg



Comment at: unittests/clang-move/ClangMoveTests.cpp:122
@@ +121,3 @@
+
+const char ExpectedNewCC[] = "#include \"foo.h\"\n"
+ "namespace a {\n"

It's fine for this patch, but I think we also want to add newlines be between 
moved declarations, especially if there were newlines in the original code. 


https://reviews.llvm.org/D24243



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


Re: [PATCH] D23926: [libcxx] Don't use C99 math ops in -std=c++03 mode

2016-09-16 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Abandoning: we've decided to relax our C library to expose C99 functionality in 
C++98/03 modes. This is more inline with upstream intentions and allows us to 
get rid of some fiddly downstream libc++ patches as well.

Thanks Marshall and Eric for the comments / chats.

/ Asiri


https://reviews.llvm.org/D23926



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


[clang-tools-extra] r281710 - [clang-rename] Merge rename-{at|all} & optimise.

2016-09-16 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Sep 16 03:45:19 2016
New Revision: 281710

URL: http://llvm.org/viewvc/llvm-project?rev=281710&view=rev
Log:
[clang-rename] Merge rename-{at|all} & optimise.

Having both rename-at and rename-all both seems confusing and introduces
unneeded difficulties. After merging rename-at and rename-all maintaining main
function wrappers and custom help becomes redundant while CLI becomes less
confusing.

D24224 (which was the original patch causing buildbot failures) wasn't aware of
bugs caused by passing both -offset and -qualified-name. After D24224 was landed
it caused buildbot failures and therefor I just reverted it.

Two things that make this patch different from D24224 are:

* unittests/clang-rename was deleted, because it is unmaintained and doesn't do
much.
* Passing both `-offset` and `-qualified-name` isn't allowed anymore for the
sake of preventing bugs.

This patch is a trivial enhancement of accepted D24224 revision.

Tested with `ninja check-all`.

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

Added:
clang-tools-extra/trunk/test/clang-rename/Inputs/OffsetToNewName.yaml
clang-tools-extra/trunk/test/clang-rename/Inputs/QualifiedNameToNewName.yaml
clang-tools-extra/trunk/test/clang-rename/YAMLInput.cpp
Removed:
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp

clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml

clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt
clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
clang-tools-extra/trunk/unittests/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=281710&r1=281709&r2=281710&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Fri Sep 16 
03:45:19 2016
@@ -28,6 +28,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
+
 #include 
 #include 
 #include 
@@ -45,11 +46,10 @@ namespace {
 // to virtual method.
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
-  explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
-   std::vector *USRs)
-  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+  AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context)
+  : FoundDecl(FoundDecl), Context(Context) {}
 
-  void Find() {
+  std::vector Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
 TraverseDecl(Context.getTranslationUnitDecl());
 if (const auto *MethodDecl = dyn_cast(FoundDecl)) {
@@ -66,7 +66,7 @@ public:
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
-USRs->insert(USRs->end(), USRSet.begin(), USRSet.end());
+return std::vector(USRSet.begin(), USRSet.end());
   }
 
   bool VisitCXXMethodDecl(const CXXMethodDecl *MethodDecl) {
@@ -129,69 +129,98 @@ private:
 
   const Decl *FoundDecl;
   ASTContext &Context;
-  std::vector *USRs;
   std::set USRSet;
   std::vector OverriddenMethods;
   std::vector PartialSpecs;
 };
 } // namespace
 
-struct NamedDeclFindingConsumer : public ASTConsumer {
-  void HandleTranslationUnit(ASTContext &Context) override {
-const SourceManager &SourceMgr = Context.getSourceManager();
-// The file we look for the USR in will always be the main source file.
+class NamedDeclFindingConsumer : public ASTConsumer {
+public:
+  NamedDeclFindingConsumer(ArrayRef SymbolOffsets,
+   ArrayRef QualifiedNames,
+   std::vector &SpellingNames,
+   std::vector> &USRList,
+   bool &ErrorOccurred)
+  : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
+SpellingNames(SpellingNames), USRList(USRList),
+ErrorOccurred(ErrorOccurred) {}
+
+private:
+  bool FindSymbol(ASTContext &Context, const SourceManager &SourceMgr,
+  

Re: [PATCH] D24567: [clang-rename] Merge rename-{at|all} & optimise.

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

In https://reviews.llvm.org/D24567#543459, @vmiklos wrote:

> As mentioned earlier, I have no problem with merging rename-at and rename-all.


Good, thanks!


https://reviews.llvm.org/D24567



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


Re: [PATCH] D24567: [clang-rename] Merge rename-{at|all} & optimise.

2016-09-16 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281710: [clang-rename] Merge rename-{at|all} & optimise. 
(authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D24567?vs=71367&id=71600#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24567

Files:
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRFindingAction.h
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp
  clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
  
clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  
clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
  clang-tools-extra/trunk/test/clang-rename/Inputs/OffsetToNewName.yaml
  clang-tools-extra/trunk/test/clang-rename/Inputs/QualifiedNameToNewName.yaml
  clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
  clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
  clang-tools-extra/trunk/test/clang-rename/YAMLInput.cpp
  clang-tools-extra/trunk/unittests/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp

Index: clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
@@ -7,4 +7,4 @@
 }
 
 // Test 1.
-// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
Index: clang-tools-extra/trunk/test/clang-rename/Inputs/OffsetToNewName.yaml
===
--- clang-tools-extra/trunk/test/clang-rename/Inputs/OffsetToNewName.yaml
+++ clang-tools-extra/trunk/test/clang-rename/Inputs/OffsetToNewName.yaml
@@ -0,0 +1,6 @@
+---
+- Offset: 6
+  NewName:Bar1
+- Offset: 44
+  NewName:Bar2
+...
Index: clang-tools-extra/trunk/test/clang-rename/Inputs/QualifiedNameToNewName.yaml
===
--- clang-tools-extra/trunk/test/clang-rename/Inputs/QualifiedNameToNewName.yaml
+++ clang-tools-extra/trunk/test/clang-rename/Inputs/QualifiedNameToNewName.yaml
@@ -0,0 +1,6 @@
+---
+- QualifiedName:  Foo1
+  NewName:Bar1
+- QualifiedName:  Foo2
+  NewName:Bar2
+...
Index: clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
===
--- clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
+++ clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
@@ -1,6 +0,0 @@

-- Offset: 6
-  NewName:Bar1
-- Offset: 44
-  NewName:Bar2
-...
Index: clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
===
--- clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
+++ clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
@@ -1,6 +0,0 @@

-- OldName:Foo1
-  NewName:Bar1
-- OldName:Foo2
-  NewName:Bar2
-...
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
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: clang-rename: for the -new-name option: must be specified
+// CHECK: clang-rename: -new-name must be specified.
Index: clang-tools-extra/trunk/test/clang-rename/YAMLInput.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/YAMLInput.cpp
+++ clang-tools-extra/trunk/test/clang-rename/YAMLInput.cpp
@@ -0,0 +1,10 @@
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
+
+// Test 1.
+// RUN: clang-rename -input %S/Inputs/OffsetToNewName.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -input %S/Inputs/QualifiedNameToNewName.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: clang-tools-ext

Re: [PATCH] D24448: [atomics] New warning -Watomic-libcall when atomic operation expands to a library call

2016-09-16 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 71507.
sdardis added a comment.

Update comment and test for atomic expansion.


https://reviews.llvm.org/D24448

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-libcall.c

Index: test/Sema/atomic-libcall.c
===
--- /dev/null
+++ test/Sema/atomic-libcall.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=mips-mti-linux-gnu 
-Watomic-libcall
+
+// Test that larger than word size atomics are warned about.
+
+long long var;
+
+void foo(long long a) {
+  __sync_fetch_and_add(&var, 0, a); // expected-warning {{atomic builtin 
expands to library call}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3035,6 +3035,14 @@
 
   ASTContext& Context = this->getASTContext();
 
+  // Warn if the atomic will expand into a library call if requested.
+  TypeInfo ValueTI = Context.getTypeInfo(ValType);
+  uint64_t Size = ValueTI.Width;
+  uint64_t Align = ValueTI.Align;
+  if (!Context.getTargetInfo().hasBuiltinAtomic(Size, Align)) {
+Diag(DRE->getLocStart(), diag::warn_atomic_builtin_expands_to_libcall);
+  }
+
   // Create a new DeclRefExpr to refer to the new decl.
   DeclRefExpr* NewDRE = DeclRefExpr::Create(
   Context,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5120,6 +5120,8 @@
   "_Atomic cannot be applied to "
   "%select{incomplete |array |function |reference |atomic |qualified |}0type "
   "%1 %select{||which is not trivially copyable}0">;
+def warn_atomic_builtin_expands_to_libcall : Warning<
+  "atomic builtin expands to library call">, InGroup, 
DefaultIgnore;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -861,6 +861,8 @@
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
 
+def AtomicLibcall : DiagGroup<"atomic-libcall">;
+
 // AddressSanitizer frontent instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;
 


Index: test/Sema/atomic-libcall.c
===
--- /dev/null
+++ test/Sema/atomic-libcall.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=mips-mti-linux-gnu -Watomic-libcall
+
+// Test that larger than word size atomics are warned about.
+
+long long var;
+
+void foo(long long a) {
+  __sync_fetch_and_add(&var, 0, a); // expected-warning {{atomic builtin expands to library call}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3035,6 +3035,14 @@
 
   ASTContext& Context = this->getASTContext();
 
+  // Warn if the atomic will expand into a library call if requested.
+  TypeInfo ValueTI = Context.getTypeInfo(ValType);
+  uint64_t Size = ValueTI.Width;
+  uint64_t Align = ValueTI.Align;
+  if (!Context.getTargetInfo().hasBuiltinAtomic(Size, Align)) {
+Diag(DRE->getLocStart(), diag::warn_atomic_builtin_expands_to_libcall);
+  }
+
   // Create a new DeclRefExpr to refer to the new decl.
   DeclRefExpr* NewDRE = DeclRefExpr::Create(
   Context,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5120,6 +5120,8 @@
   "_Atomic cannot be applied to "
   "%select{incomplete |array |function |reference |atomic |qualified |}0type "
   "%1 %select{||which is not trivially copyable}0">;
+def warn_atomic_builtin_expands_to_libcall : Warning<
+  "atomic builtin expands to library call">, InGroup, DefaultIgnore;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -861,6 +861,8 @@
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
 
+def AtomicLibcall : DiagGroup<"atomic-libcall">;
+
 // AddressSanitizer frontent instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab added a comment.

Thanks all! :)



Comment at: test/SemaCXX/warn-msvc-enum-bitfield.cpp:12
@@ +11,3 @@
+
+  s.e2 = E2;
+  s.f2 = F2;

thakis wrote:
> Shouldn't this be the version that warns? The assignment with E1 assigns 0 
> which is portable, but this assigns 1 which overflows, right?
e2 is not a bitfield :) So this code is fine.

And we should warn on all assignments, since any assigned value could 
potentially be incorrect. Also, most assignments are not static so we don't 
always have that information :)


https://reviews.llvm.org/D24289



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


Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab marked an inline comment as done.
sashab added a comment.

https://reviews.llvm.org/D24289



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


Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab closed this revision.
sashab added a comment.

Is this how I commit this? Hopefully this lands... :-)


https://reviews.llvm.org/D24289



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


[PATCH] D24649: Treat instantiations of variable templates as definitions

2016-09-16 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rsmith, tra.
sepavloff added a subscriber: cfe-commits.

Current version of clang cannot build the program:
```
template int var;
int main(int argc, char *argv[]) {
  return var<0>;
}

```
as linker does not find `var<0>`, codegen treats it as declaration only.
However this program must build succesfully, because the template
declaration is a definition as none of the conditions mentioned in
[basic.def]p2 is met. With this change codegen generates definitions
for file level variable template specialization even if the declaration
does not contain an initializer.

https://reviews.llvm.org/D24649

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/variable-templates.cpp

Index: test/CodeGenCXX/variable-templates.cpp
===
--- /dev/null
+++ test/CodeGenCXX/variable-templates.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple=x86_64-linux -emit-llvm -o - | 
FileCheck %s
+
+// Unused template
+// CHECK-NOT: _Z6var_00ILi0EE
+template int var_00;
+
+// Definition without initializer
+// CHECK: @_Z6var_01ILi0EE = linkonce_odr global i32 0, comdat
+template int var_01;
+int use_01a() {
+  return var_01<0>;
+}
+int use_01b() {
+  return var_01<0>;
+}
+
+// Definitions without initializer combined with extern declaration
+
+// CHECK: @_Z6var_02ILi0EE = linkonce_odr global i32 0, comdat
+template extern int var_02;
+template int var_02;
+int use_02() {
+  return var_02<0>;
+}
+
+// CHECK: @_Z6var_03ILi0EE = linkonce_odr global i32 0, comdat
+template int var_03;
+template extern int var_03;
+int use_03() {
+  return var_03<0>;
+}
+
+// CHECK: @_Z6var_04ILi0EE = linkonce_odr global i32 0, comdat
+template extern int var_04;
+int use_04() {
+  return var_04<0>;
+}
+template int var_04;
+
+// CHECK: @_Z6var_05ILi0EE = linkonce_odr global i32 0, comdat
+template int var_05;
+int use_05() {
+  return var_05<0>;
+}
+template extern int var_05;
+
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -108,8 +108,8 @@
 template __declspec(dllexport) int VarTmplDef;
 INSTVAR(VarTmplDef)
 
-// MSC-DAG: @"\01??$VarTmplImplicitDef@UImplicitInst_Exported3HA" = 
external dllexport global
-// GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE  = 
external dllexport global
+// MSC-DAG: @"\01??$VarTmplImplicitDef@UImplicitInst_Exported3HA" = 
weak_odr dllexport global
+// GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE  = 
weak_odr dllexport global
 template __declspec(dllexport) int VarTmplImplicitDef;
 USEVAR(VarTmplImplicitDef)
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1609,7 +1609,11 @@
!VD->hasDefinition() &&
(VD->hasAttr() ||
 VD->hasAttr());
-if (!MustEmitForCuda &&
+bool MustEmitVarInst = isa(VD) &&
+   !VD->isStaticDataMember() &&
+   !VD->hasDefinition() &&
+   !VD->hasAttr();
+if (!(MustEmitForCuda || MustEmitVarInst) &&
 VD->isThisDeclarationADefinition() != VarDecl::Definition &&
 !Context.isMSStaticDataMemberInlineDefinition(VD)) {
   // If this declaration may have caused an inline variable definition to


Index: test/CodeGenCXX/variable-templates.cpp
===
--- /dev/null
+++ test/CodeGenCXX/variable-templates.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple=x86_64-linux -emit-llvm -o - | FileCheck %s
+
+// Unused template
+// CHECK-NOT: _Z6var_00ILi0EE
+template int var_00;
+
+// Definition without initializer
+// CHECK: @_Z6var_01ILi0EE = linkonce_odr global i32 0, comdat
+template int var_01;
+int use_01a() {
+  return var_01<0>;
+}
+int use_01b() {
+  return var_01<0>;
+}
+
+// Definitions without initializer combined with extern declaration
+
+// CHECK: @_Z6var_02ILi0EE = linkonce_odr global i32 0, comdat
+template extern int var_02;
+template int var_02;
+int use_02() {
+  return var_02<0>;
+}
+
+// CHECK: @_Z6var_03ILi0EE = linkonce_odr global i32 0, comdat
+template int var_03;
+template extern int var_03;
+int use_03() {
+  return var_03<0>;
+}
+
+// CHECK: @_Z6var_04ILi0EE = linkonce_odr global i32 0, comdat
+template extern int var_04;
+int use_04() {
+  return var_04<0>;
+}
+template int var_04;
+
+// CHECK: @_Z6var_05ILi0EE = linkonce_odr global i32 0, comdat
+template int var_05;
+int use_05() {
+  return var_05<0>;
+}
+template extern int var_05;
+
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: test/CodeGenCXX/dllexpor

Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics

2016-09-16 Thread Martin Storsjö via cfe-commits
mstorsjo added inline comments.


Comment at: lib/Headers/intrin.h:504
@@ +503,3 @@
+_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) {
+  long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE);
+  return (_PrevVal >> _BitPos) & 1;

compnerd wrote:
> Perhaps we should add static asserts that _BitPos is within limits for the 
> signed shift.
Sure, although I guess that also goes for the existing inline functions as well?

Which kind of assert would be suitable for that here? As far as I see, 
static_assert is C++ only, while this header also can be used from C.

If I try to add _Static_assert, which is usable in C, I get the following error 
when compiling:

intrin.h:499:18: error: 
  static_assert expression is not an integral constant expression
  _Static_assert(_BitPos < 32, "_BitPos out of range");

This even when I don't actually use the inline function anywhere, just 
including intrin.h.


Comment at: lib/Headers/intrin.h:517
@@ -501,1 +516,3 @@
+}
+#endif
 #ifdef __x86_64__

compnerd wrote:
> Are the names supposed to be all lower case?
Yes, these ones (for some reason) are all lower case:
https://msdn.microsoft.com/en-us/library/646k06sz.aspx


https://reviews.llvm.org/D24609



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


r281711 - Testing commit rights. Removing trailing white space from test file.

2016-09-16 Thread Neil Hickey via cfe-commits
Author: neil.hickey
Date: Fri Sep 16 04:38:11 2016
New Revision: 281711

URL: http://llvm.org/viewvc/llvm-project?rev=281711&view=rev
Log:
Testing commit rights. Removing trailing white space from test file.


Modified:
cfe/trunk/test/SemaCXX/attr-noreturn.cpp

Modified: cfe/trunk/test/SemaCXX/attr-noreturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-noreturn.cpp?rev=281711&r1=281710&r2=281711&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-noreturn.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-noreturn.cpp Fri Sep 16 04:38:11 2016
@@ -167,7 +167,7 @@ namespace destructor_tests {
 
 // PR5620
 void f0() __attribute__((__noreturn__));
-void f1(void (*)()); 
+void f1(void (*)());
 void f2() { f1(f0); }
 
 // Taking the address of a noreturn function


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


Re: [PATCH] D24626: [OpenCL] Diagnose assignment to dereference of half type pointer

2016-09-16 Thread Alexey Bader via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D24626



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


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

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

- Addressed review comments.


https://reviews.llvm.org/D24183

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

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

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

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


Comment at: change-namespace/ChangeNamespace.cpp:200
@@ +199,3 @@
+  while (!NsSplitted.empty()) {
+// FIXME: consider code style for comments.
+Code = ("namespace " + NsSplitted.back() + " {\n" + Code +

hokein wrote:
> Doesn't `formatAndApplyAllReplacements` format the comments for us?
formatter only adds/removes white spaces I think. 


Comment at: change-namespace/ChangeNamespace.cpp:400
@@ +399,3 @@
+  assert(Consumed && "Expect OldNS to start with OldNamespace.");
+  (void)Consumed;
+  const std::string NewNs = (NewNamespace + Postfix).str();

hokein wrote:
> how about `assert(Postfix.consume_front(OldNamespace) && "Expect OldNS to 
> start with OldNamespace.");`?
The problem with this is that `Postfix.consume_front(OldNamespace)` won't be 
executed if assertion is turned off.


https://reviews.llvm.org/D24183



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


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

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


Comment at: change-namespace/ChangeNamespace.cpp:448
@@ +447,3 @@
+  continue;
+const std::string &FilePath = FileAndNsMoves.first;
+auto &Replaces = FileToReplacements[FilePath];

`StringRef` here too.


https://reviews.llvm.org/D24183



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


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

2016-09-16 Thread Eric Liu via cfe-commits
ioeric marked an inline comment as done.


Comment at: change-namespace/ChangeNamespace.cpp:448
@@ +447,3 @@
+  continue;
+const std::string &FilePath = FileAndNsMoves.first;
+auto &Replaces = FileToReplacements[FilePath];

omtcyfz wrote:
> `StringRef` here too.
If this was a `StringRef`, then each map access would require an implicit 
conversion from `StringRef` to `std::string`, which is expensive. And this is 
already a reference anyway.


https://reviews.llvm.org/D24183



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


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

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


Comment at: change-namespace/ChangeNamespace.cpp:448
@@ +447,3 @@
+  continue;
+const std::string &FilePath = FileAndNsMoves.first;
+auto &Replaces = FileToReplacements[FilePath];

ioeric wrote:
> omtcyfz wrote:
> > `StringRef` here too.
> If this was a `StringRef`, then each map access would require an implicit 
> conversion from `StringRef` to `std::string`, which is expensive. And this is 
> already a reference anyway.
Ah, I see. Yes, that's true. Sorry.


https://reviews.llvm.org/D24183



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


[PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-09-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: alexfh, aaron.ballman, hokein.
malcolm.parsons added a subscriber: cfe-commits.

Bugfix for 30398.  Don't warn for template instantiations

https://reviews.llvm.org/D24652

Files:
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -36,7 +36,9 @@
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but they
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(),
+   // Ignore template instantiations too.
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);


Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -36,7 +36,9 @@
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but they
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxM

r281712 - Touch up [[clang::require_constant_initialization]] docs

2016-09-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Sep 16 05:04:38 2016
New Revision: 281712

URL: http://llvm.org/viewvc/llvm-project?rev=281712&view=rev
Log:
Touch up [[clang::require_constant_initialization]] docs

* Fix an egregious comma usage.
* Remove the `static` keyword in the example since the variables should have
  external linkage.
* Use C++11 attributes in the example.

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=281712&r1=281711&r2=281712&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Sep 16 05:04:38 2016
@@ -843,7 +843,7 @@ This attribute specifies that the variab
 to have a `constant initializer 
`_
 according to the rules of [basic.start.static]. The variable is required to
 have static or thread storage duration. If the initialization of the variable
-is not a constant initializer, an error will be produced. This attribute may
+is not a constant initializer an error will be produced. This attribute may
 only be used in C++.
 
 Note that in C++03 strict constant expression checking is not done. Instead
@@ -862,7 +862,7 @@ of silently falling back on dynamic init
 .. code-block:: c++
 
   // -std=c++14
-  #define SAFE_STATIC __attribute__((require_constant_initialization)) static
+  #define SAFE_STATIC [[clang::require_constant_initialization]]
   struct T {
 constexpr T(int) {}
 ~T(); // non-trivial


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


Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

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

Probably it also makes sense to reflect both `lambda` and template 
instantiation parts in documentation, since I find current wording totally 
confusing at the moment.



Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:41
@@ -40,1 +40,3 @@
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl

`ast_matchers::` is redundant here.


https://reviews.llvm.org/D24652



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


[clang-tools-extra] r281713 - [clang-tidy] Bugfix for readability-redundant-control-flow check

2016-09-16 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Sep 16 05:12:08 2016
New Revision: 281713

URL: http://llvm.org/viewvc/llvm-project?rev=281713&view=rev
Log:
[clang-tidy] Bugfix for readability-redundant-control-flow check

This check did not create FixItHints when the statement before the redundant
control flow was not followed by a semicolon.

Patch by Malcolm Parsons!

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp?rev=281713&r1=281712&r2=281713&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp 
Fri Sep 16 05:12:08 2016
@@ -83,7 +83,7 @@ void RedundantControlFlowCheck::issueDia
 dyn_cast(*Previous)->getLocEnd(), tok::semi, SM,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true);
-  else
+  if (!Start.isValid())
 Start = StmtRange.getBegin();
   auto RemovedRange = CharSourceRange::getCharRange(
   Start,

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp?rev=281713&r1=281712&r2=281713&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp 
Fri Sep 16 05:12:08 2016
@@ -179,6 +179,7 @@ void template_return(T check) {
 // CHECK-FIXES: {{^}}  if (check < T(0)) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template <>
 void template_return(int check) {
@@ -191,6 +192,7 @@ void template_return(int check) {
 // CHECK-FIXES: {{^}}  if (check < 0) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template 
 void template_loop(T end) {


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


Re: [PATCH] D24500: [clang-tidy] Bugfix for readability-redundant-control-flow check

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

In https://reviews.llvm.org/D24500#542284, @malcolm.parsons wrote:

> I didn't report a bug for this issue, and there isn't an existing one.
>
> I don't have commit access, so please commit it for me.


Since Alex is away at the moment I landed it.


Repository:
  rL LLVM

https://reviews.llvm.org/D24500



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


Re: [PATCH] D24500: [clang-tidy] Bugfix for readability-redundant-control-flow check

2016-09-16 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281713: [clang-tidy] Bugfix for 
readability-redundant-control-flow check (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D24500?vs=71140&id=71608#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24500

Files:
  clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp

Index: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
@@ -83,7 +83,7 @@
 dyn_cast(*Previous)->getLocEnd(), tok::semi, SM,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true);
-  else
+  if (!Start.isValid())
 Start = StmtRange.getBegin();
   auto RemovedRange = CharSourceRange::getCharRange(
   Start,
Index: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
@@ -179,6 +179,7 @@
 // CHECK-FIXES: {{^}}  if (check < T(0)) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template <>
 void template_return(int check) {
@@ -191,6 +192,7 @@
 // CHECK-FIXES: {{^}}  if (check < 0) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template 
 void template_loop(T end) {


Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp
@@ -83,7 +83,7 @@
 dyn_cast(*Previous)->getLocEnd(), tok::semi, SM,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true);
-  else
+  if (!Start.isValid())
 Start = StmtRange.getBegin();
   auto RemovedRange = CharSourceRange::getCharRange(
   Start,
Index: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-control-flow.cpp
@@ -179,6 +179,7 @@
 // CHECK-FIXES: {{^}}  if (check < T(0)) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template <>
 void template_return(int check) {
@@ -191,6 +192,7 @@
 // CHECK-FIXES: {{^}}  if (check < 0) {{{$}}
 // CHECK-FIXES-NEXT: {{^return;$}}
 // CHECK-FIXES-NEXT: {{^ *}$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
 
 template 
 void template_loop(T end) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281714 - Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64

2016-09-16 Thread Neil Hickey via cfe-commits
Author: neil.hickey
Date: Fri Sep 16 05:15:06 2016
New Revision: 281714

URL: http://llvm.org/viewvc/llvm-project?rev=281714&view=rev
Log:
Improve handling of floating point literals in OpenCL to only use double 
precision if the target supports fp64

https://reviews.llvm.org/D24235


Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/fpmath.cl
cfe/trunk/test/SemaOpenCL/extensions.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=281714&r1=281713&r2=281714&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep 16 05:15:06 2016
@@ -828,8 +828,18 @@ ExprResult Sema::DefaultArgumentPromotio
   // double.
   const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
-  BTy->getKind() == BuiltinType::Float))
-E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+  BTy->getKind() == BuiltinType::Float)) {
+if (getLangOpts().OpenCL &&
+!((getLangOpts().OpenCLVersion >= 120 &&
+   Context.getTargetInfo()
+   .getSupportedOpenCLOpts()
+   .cl_khr_fp64) ||
+  getOpenCLOptions().cl_khr_fp64)) {
+E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
+} else {
+  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+}
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
@@ -3406,8 +3416,14 @@ ExprResult Sema::ActOnNumericConstant(co
   if (getLangOpts().SinglePrecisionConstants) {
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   } else if (getLangOpts().OpenCL &&
- !((getLangOpts().OpenCLVersion >= 120) ||
+ !((getLangOpts().OpenCLVersion >= 120 &&
+Context.getTargetInfo()
+.getSupportedOpenCLOpts()
+.cl_khr_fp64) ||
getOpenCLOptions().cl_khr_fp64)) {
+// Impose single-precision float type when:
+//  - in CL 1.2 or above and cl_khr_fp64 is not supported, or
+//  - in CL 1.1 or below and cl_khr_fp64 is not enabled.
 Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=281714&r1=281713&r2=281714&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Sep 16 05:15:06 2016
@@ -1401,7 +1401,8 @@ static QualType ConvertDeclSpecToType(Ty
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
+!((S.getLangOpts().OpenCLVersion >= 120 
+   && S.Context.getTargetInfo().getSupportedOpenCLOpts().cl_khr_fp64) 
||
   S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";

Modified: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/fpmath.cl?rev=281714&r1=281713&r2=281714&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/fpmath.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl Fri Sep 16 05:15:06 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck 
--check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK 
--check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple 
r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck 
--check-prefix=CHECK-DBL %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
@@ -21,14 +22,26 @@ float4 spvectordiv(float4 a, float4 b) {
   return a / b;
 }
 
+void printf(constant char* fmt, ...);
+
+#ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+void testdbllit(long *val) {
+  // CHECK-DBL: float 2.00e+01
+  // CHECK: double 2.00e+01
+  printf("%f", 20.0);
+}
 
+#ifndef NOFP64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
+#endif
 
 // CHECK: attributes #[[ATTR]] = {
 // NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"

Modified: cfe/trunk/test/SemaOpenCL/extension

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

2016-09-16 Thread Neil Hickey via cfe-commits
neil.hickey closed this revision.
neil.hickey added a comment.

Commit merged to trunk


https://reviews.llvm.org/D24235



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


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

2016-09-16 Thread Neil Hickey via cfe-commits
neil.hickey added a comment.

committed @ 281714


https://reviews.llvm.org/D24235



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


[PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-16 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added a reviewer: alexfh.
danielmarjamaki added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

This is a new check that warns about redundant variable declarations.

https://reviews.llvm.org/D24656

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tidy/readability/RedundantDeclarationCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-declaration.rst
  test/clang-tidy/readability-redundant-declaration.cpp

Index: test/clang-tidy/readability-redundant-declaration.cpp
===
--- test/clang-tidy/readability-redundant-declaration.cpp
+++ test/clang-tidy/readability-redundant-declaration.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s readability-redundant-declaration %t
+
+extern int Xyz;
+extern int Xyz;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable Xyz declaration [readability-redundant-declaration]
+// CHECK-FIXES: {{^}}{{$}}
+
+extern int A;
+extern int A,B;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable A declaration
+// CHECK-FIXES: {{^}}extern int A,B;{{$}}
+
+extern int Buf[10];
+extern int Buf[10];
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable Buf declaration
+// CHECK-FIXES: {{^}}{{$}}
Index: docs/clang-tidy/checks/readability-redundant-declaration.rst
===
--- docs/clang-tidy/checks/readability-redundant-declaration.rst
+++ docs/clang-tidy/checks/readability-redundant-declaration.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - readability-redundant-declaration
+
+readability-redundant-declaration
+=
+
+Finds redundant variable declarations.
+
+.. code-block:: c++
+
+  extern int X;
+  extern int X;
+
+becomes
+
+.. code-block:: c++
+
+  extern int X;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -133,6 +133,7 @@
readability-named-parameter
readability-non-const-parameter
readability-redundant-control-flow
+   readability-redundant-declaration
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: clang-tidy/readability/RedundantDeclarationCheck.h
===
--- clang-tidy/readability/RedundantDeclarationCheck.h
+++ clang-tidy/readability/RedundantDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantDeclarationCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-declaration.html
+class RedundantDeclarationCheck : public ClangTidyCheck {
+public:
+  RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
Index: clang-tidy/readability/RedundantDeclarationCheck.cpp
===
--- clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -0,0 +1,65 @@
+//===--- RedundantDeclarationCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantDeclarationCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(va

Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-16 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

For information, I am testing this on debian packages right now. I will see the 
results next week.



Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:22
@@ +21,3 @@
+void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(varDecl().bind("Decl"), this);

I forgot to remove this FIXME comment, I will remove it.


Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:41
@@ +40,3 @@
+
+  // Don't generate fixits for multivariable declarations.
+  bool MultiVar = false;

Imho this is a clumpsy way to see if it's a "multivariable" declaration. Do you 
know if there is a better way?


Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:50
@@ +49,3 @@
+
+  if (MultiVar) {
+diag(VD->getLocation(), "redundant variable %0 declaration")

Is there a better way to rewrite this ... I tried something like this without 
success:
```
auto D = diag(..);
if (!MultiVar)
D << FixItHint..;
```



Comment at: clang-tidy/readability/RedundantDeclarationCheck.h:19
@@ +18,3 @@
+
+/// FIXME: Write a short description.
+///

I will fix this FIXME.


Comment at: test/clang-tidy/readability-redundant-declaration.cpp:11
@@ +10,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable A declaration
+// CHECK-FIXES: {{^}}extern int A,B;{{$}}
+

Ideally this would be changed to "extern int B;". I currently don't fix 
multivariable declarations.


https://reviews.llvm.org/D24656



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


Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-16 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked 2 inline comments as done.
danielmarjamaki added a comment.

https://reviews.llvm.org/D24656



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


Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-16 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 71614.
danielmarjamaki added a comment.

minor fixes


https://reviews.llvm.org/D24656

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tidy/readability/RedundantDeclarationCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-declaration.rst
  test/clang-tidy/readability-redundant-declaration.cpp

Index: test/clang-tidy/readability-redundant-declaration.cpp
===
--- test/clang-tidy/readability-redundant-declaration.cpp
+++ test/clang-tidy/readability-redundant-declaration.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s readability-redundant-declaration %t
+
+extern int Xyz;
+extern int Xyz;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable Xyz declaration [readability-redundant-declaration]
+// CHECK-FIXES: {{^}}{{$}}
+
+extern int A;
+extern int A,B;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable A declaration
+// CHECK-FIXES: {{^}}extern int A,B;{{$}}
+
+extern int Buf[10];
+extern int Buf[10];
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable Buf declaration
+// CHECK-FIXES: {{^}}{{$}}
Index: docs/clang-tidy/checks/readability-redundant-declaration.rst
===
--- docs/clang-tidy/checks/readability-redundant-declaration.rst
+++ docs/clang-tidy/checks/readability-redundant-declaration.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - readability-redundant-declaration
+
+readability-redundant-declaration
+=
+
+Finds redundant variable declarations.
+
+.. code-block:: c++
+
+  extern int X;
+  extern int X;
+
+becomes
+
+.. code-block:: c++
+
+  extern int X;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -133,6 +133,7 @@
readability-named-parameter
readability-non-const-parameter
readability-redundant-control-flow
+   readability-redundant-declaration
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: clang-tidy/readability/RedundantDeclarationCheck.h
===
--- clang-tidy/readability/RedundantDeclarationCheck.h
+++ clang-tidy/readability/RedundantDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantDeclarationCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find redundant variable declarations.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-declaration.html
+class RedundantDeclarationCheck : public ClangTidyCheck {
+public:
+  RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
Index: clang-tidy/readability/RedundantDeclarationCheck.cpp
===
--- clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -0,0 +1,70 @@
+//===--- RedundantDeclarationCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantDeclarationCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(varDecl().bind("Decl"), this);
+}
+
+void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *VD = Result.Nodes.getNodeAs("Decl")

Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-09-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.


Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:41
@@ -40,1 +40,3 @@
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl

omtcyfz wrote:
> `ast_matchers::` is redundant here.
You'd think so, but it didn't compile.


https://reviews.llvm.org/D24652



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


Re: [PATCH] D24646: [CMake] Allow building Sphinx docs in nit-picky mode

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

Abandoning. This option is only needed when using old versions of Sphinx.


https://reviews.llvm.org/D24646



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


Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

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


Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:41
@@ -40,1 +40,3 @@
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl

malcolm.parsons wrote:
> omtcyfz wrote:
> > `ast_matchers::` is redundant here.
> You'd think so, but it didn't compile.
Ah, I see.

Also, please provide more info next time:

> it didn't compile

doesn't give anything.

For the others: the actual problem is that 
`llvm/tools/clang/include/clang/Basic/Specifiers.h` has `inline bool 
isTemplateInstantiation(TemplateSpecializationKind Kind)` function. It might 
make sense to change name of the AST Matcher to something else in order to 
prevent collision. Thoughts, suggestions?

However, this, of course, is not in scope of the current patch.


https://reviews.llvm.org/D24652



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


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

2016-09-16 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

The patch looks good to me now.



Comment at: change-namespace/ChangeNamespace.h:44
@@ +43,3 @@
+class ChangeNamespaceTool : ast_matchers::MatchFinder::MatchCallback {
+public:
+  // Moves code in the old namespace `OldNs` to the new namespace `NewNs` in

You forgot this one.


Comment at: change-namespace/ChangeNamespace.h:101
@@ +100,3 @@
+  std::string FallbackStyle;
+  std::map &FileToReplacements;
+  // A fully qualified name of the old namespace without "::" prefix, e.g.

Would be clearer to add comment describing the kinds of these replacements 
(e.g. deleting the forward declarations, replacing the old qualifiers with the 
new shortest qualified name).


https://reviews.llvm.org/D24183



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


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

2016-09-16 Thread Kirill Bobyrev via cfe-commits
omtcyfz accepted this revision.
omtcyfz added a comment.

I have no other objections aswell.
LGTM.


https://reviews.llvm.org/D24183



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


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

2016-09-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 71622.
malcolm.parsons added a comment.
Herald added a subscriber: mgorny.

Handle unions and templated classes.
Add FixItHints (depends on https://reviews.llvm.org/D24572).


https://reviews.llvm.org/D24339

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

Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -0,0 +1,113 @@
+// RUN: %check_clang_tidy %s readability-redundant-member-init %t
+
+struct S {
+  S() = default;
+  S(int i) : i(i) {}
+  int i = 1;
+};
+
+struct T {
+  T(int i = 1) : i(i) {}
+  int i;
+};
+
+struct U {
+  int i;
+};
+
+// Initializer calls default constructor
+struct F1 {
+  F1() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F1()  {}
+  S f;
+};
+
+// Initializer calls default constructor with default argument
+struct F2 {
+  F2() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F2()  {}
+  T f;
+};
+
+// Multiple redundant initializers for same constructor
+struct F3 {
+  F3() : f(), g(1), h() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: initializer for 'h' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F3() : g(1) {}
+  S f, g, h;
+};
+
+// Templated class
+template 
+struct F4 {
+  F4() : f(), g() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F4() : g() {}
+  S f;
+  V g;
+};
+F4 f4i;
+F4 f4s;
+
+// Initializer not written
+struct NF1 {
+  NF1() {}
+  S f;
+};
+
+// Initializer doesn't call default constructor
+struct NF2 {
+  NF2() : f(1) {}
+  S f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF3 {
+  NF3() : f(1) {}
+  T f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF4 {
+  NF4() : f(2) {}
+  T f;
+};
+
+// Initializer is zero-initialization
+struct NF5 {
+  NF5() : i() {}
+  int i;
+};
+
+// Initializer is direct-initialization
+struct NF6 {
+  NF6() : i(1) {}
+  int i;
+};
+
+// Initializer is aggregate initialization of struct
+struct NF7 {
+  NF7() : f{} {}
+  U f;
+};
+
+// Initializer is aggregate initialization of array
+struct NF8 {
+  NF8() : f{} {}
+  int f[2];
+};
+
+struct NF9 {
+  NF9() : f{} {}
+  S f[2];
+};
+
+// Initializing member of union
+union NF10 {
+  NF10() : s() {}
+  int i;
+  S s;
+};
Index: docs/clang-tidy/checks/readability-redundant-member-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-member-init.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-redundant-member-init
+
+readability-redundant-member-init
+=
+
+Finds member initializations that are unnecessary because the same default
+constructor would be called if they were not present.
+
+Example:   
+
+.. code-block:: c++ 
+
+  // Explicitly initializing the member s is unnecessary.  
+  class Foo {
+  public:
+Foo() : s() {}
+
+  private:
+std::string s;
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -133,6 +133,7 @@
readability-named-parameter
readability-non-const-parameter
readability-redundant-control-flow
+   readability-redundant-member-init
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: docs/ReleaseNotes.rst
===
--- docs

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

2016-09-16 Thread Haojian Wu via cfe-commits
hokein added a comment.

Sorry for the delay. 
The patch only contains an unittest for `HeaderGenerato`r, which is not quite 
enough. Should we create a fake migrate-tool binary to illustrate APIs usage?



Comment at: migrate-tool/HeaderGenerator.h:22
@@ +21,3 @@
+public:
+  HeaderGenerator(llvm::StringRef HeaderName);
+

explicit.


Comment at: migrate-tool/MigrateTool.cpp:99
@@ +98,3 @@
+  MovedSymbols.push_back(Spec.getOldName());
+  // FIXME: consider source files. Need to determine whether source files send
+  // with ".cpp" or ".cc" etc.

s/send/end



Comment at: migrate-tool/MigrateTool.h:50
@@ +49,3 @@
+  public:
+enum class MigrateType {
+  Class,

What is the 'MigrateType' used for? I can't find any usage in the patch.


Comment at: migrate-tool/RefactoringManager.h:28
@@ +27,3 @@
+  addIncludesToFiles(const std::set &Includes,
+ llvm::ArrayRef Files) = 0;
+

The arguments `llvm::StringRef` and `std::string` look inconsistent to me at  
first glance. But currently it is fine, we can modify it if needed in the 
future.


https://reviews.llvm.org/D24380



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


Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-16 Thread Serge Rogatch via cfe-commits
rSerge updated this revision to Diff 71629.

https://reviews.llvm.org/D23932

Files:
  test/CodeGen/xray-attributes-supported-arm.cpp

Index: test/CodeGen/xray-attributes-supported-arm.cpp
===
--- test/CodeGen/xray-attributes-supported-arm.cpp
+++ test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: test/CodeGen/xray-attributes-supported-arm.cpp
===
--- test/CodeGen/xray-attributes-supported-arm.cpp
+++ test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-16 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 71631.
hokein added a comment.

Support fully quailified name only.


https://reviews.llvm.org/D24243

Files:
  CMakeLists.txt
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/CMakeLists.txt
  clang-move/tool/ClangMoveMain.cpp
  unittests/CMakeLists.txt
  unittests/clang-move/CMakeLists.txt
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- /dev/null
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -0,0 +1,226 @@
+//===-- ClangMoveTest.cpp - clang-move unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangMove.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace move {
+namespace {
+
+const char TestHeaderName[] = "foo.h";
+
+const char TestCCName[] = "foo.cc";
+
+const char TestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "class Foo {\n"
+  "public:\n"
+  "  void f();\n"
+  "\n"
+  "private:\n"
+  "  C1 *c1;\n"
+  "  static int b;\n"
+  "};\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char TestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "int kConstInt1 = 0;\n"
+  "} // namespace\n"
+  "\n"
+  "static int kConstInt2 = 1;\n"
+  "\n"
+  "static int help() {\n"
+  "  int a = 0;\n"
+  "  return a;\n"
+  "}\n"
+  "\n"
+  "void Foo::f() { f1(); }\n"
+  "\n"
+  "int Foo::b = 2;\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "int kConstInt1 = 0;\n"
+  "} // namespace\n"
+  "\n"
+  "static int kConstInt2 = 1;\n"
+  "\n"
+  "static int help() {\n"
+  "  int a = 0;\n"
+  "  return a;\n"
+  "}\n"
+  "\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedNewHeader[] = "namespace a {\n"
+ "class C1;\n"
+ "namespace b {\n"
+ "class Foo {\n"
+ "public:\n"
+ "  void f();\n"
+  

[PATCH] D24663: When replacements have the same offset, make replacements with smaller length order first in the set.

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

https://reviews.llvm.org/D24663

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

Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -83,11 +83,8 @@
   if (LHS.getOffset() != RHS.getOffset())
 return LHS.getOffset() < RHS.getOffset();
 
-  // Apply longer replacements first, specifically so that deletions are
-  // executed before insertions. It is (hopefully) never the intention to
-  // delete parts of newly inserted code.
   if (LHS.getLength() != RHS.getLength())
-return LHS.getLength() > RHS.getLength();
+return LHS.getLength() < RHS.getLength();
 
   if (LHS.getFilePath() != RHS.getFilePath())
 return LHS.getFilePath() < RHS.getFilePath();
@@ -407,8 +404,8 @@
 
 bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) {
   bool Result = true;
-  for (Replacements::const_iterator I = Replaces.begin(),
-E = Replaces.end();
+  for (Replacements::const_reverse_iterator I = Replaces.rbegin(),
+E = Replaces.rend();
I != E; ++I) {
 if (I->isApplicable()) {
   Result = I->apply(Rewrite) && Result;
@@ -436,7 +433,8 @@
   "", 0, llvm::MemoryBuffer::getMemBuffer(Code, ""));
   FileID ID = SourceMgr.createFileID(Files.getFile(""), 
SourceLocation(),
  clang::SrcMgr::C_User);
-  for (Replacements::const_iterator I = Replaces.begin(), E = Replaces.end();
+  for (Replacements::const_reverse_iterator I = Replaces.rbegin(),
+E = Replaces.rend();
I != E; ++I) {
 Replacement Replace("", I->getOffset(), I->getLength(),
 I->getReplacementText());
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -151,6 +151,7 @@
 
  public:
   typedef ReplacementsImpl::const_iterator const_iterator;
+  typedef ReplacementsImpl::const_reverse_iterator const_reverse_iterator;
 
   Replacements() = default;
 
@@ -193,6 +194,10 @@
 
   const_iterator end() const { return Replaces.end(); }
 
+  const_reverse_iterator rbegin() const  { return Replaces.rbegin(); }
+
+  const_reverse_iterator rend() const { return Replaces.rend(); }
+
   bool operator==(const Replacements &RHS) const {
 return Replaces == RHS.Replaces;
   }


Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -83,11 +83,8 @@
   if (LHS.getOffset() != RHS.getOffset())
 return LHS.getOffset() < RHS.getOffset();
 
-  // Apply longer replacements first, specifically so that deletions are
-  // executed before insertions. It is (hopefully) never the intention to
-  // delete parts of newly inserted code.
   if (LHS.getLength() != RHS.getLength())
-return LHS.getLength() > RHS.getLength();
+return LHS.getLength() < RHS.getLength();
 
   if (LHS.getFilePath() != RHS.getFilePath())
 return LHS.getFilePath() < RHS.getFilePath();
@@ -407,8 +404,8 @@
 
 bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) {
   bool Result = true;
-  for (Replacements::const_iterator I = Replaces.begin(),
-E = Replaces.end();
+  for (Replacements::const_reverse_iterator I = Replaces.rbegin(),
+E = Replaces.rend();
I != E; ++I) {
 if (I->isApplicable()) {
   Result = I->apply(Rewrite) && Result;
@@ -436,7 +433,8 @@
   "", 0, llvm::MemoryBuffer::getMemBuffer(Code, ""));
   FileID ID = SourceMgr.createFileID(Files.getFile(""), SourceLocation(),
  clang::SrcMgr::C_User);
-  for (Replacements::const_iterator I = Replaces.begin(), E = Replaces.end();
+  for (Replacements::const_reverse_iterator I = Replaces.rbegin(),
+E = Replaces.rend();
I != E; ++I) {
 Replacement Replace("", I->getOffset(), I->getLength(),
 I->getReplacementText());
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -151,6 +151,7 @@
 
  public:
   typedef ReplacementsImpl::const_iterator const_iterator;
+  typedef ReplacementsImpl::const_reverse_iterator const_reverse_iterator;
 
   Replacements() = default;
 
@@ -193,6 +194,10 @@
 
   const_iterator end() const { return Replaces.end(); }
 
+  cons

Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang

2016-09-16 Thread Serge Rogatch via cfe-commits
rSerge updated this revision to Diff 71635.
rSerge added a comment.

Fixed patch file format.


https://reviews.llvm.org/D23932

Files:
  test/CodeGen/xray-attributes-supported-arm.cpp

Index: test/CodeGen/xray-attributes-supported-arm.cpp
===
--- test/CodeGen/xray-attributes-supported-arm.cpp
+++ test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: test/CodeGen/xray-attributes-supported-arm.cpp
===
--- test/CodeGen/xray-attributes-supported-arm.cpp
+++ test/CodeGen/xray-attributes-supported-arm.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

2016-09-16 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader.
yaxunl added subscribers: cfe-commits, nhaustov, rampitec.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D24666

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl

Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
+kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as 
the type of a kernel parameter}} // expected-error{{declaring function 
parameter of type 'half' is not allowed; did you forget * ?}}
+
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 
@@ -11,7 +13,8 @@
 
 kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as 
the type of a kernel parameter}}
 
-kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as 
the type of a kernel parameter}}
+// half kernel argument is allowed when cl_khr_fp16 is enabled.
+kernel void half_arg(half x) { }
 
 typedef struct ContainsBool // expected-note{{within field of type 
'ContainsBool' declared here}}
 {
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -25,6 +25,9 @@
   return h;
 }
 
+kernel void half_disabled_kernel(global half *p,
+ half h);  // expected-error{{'half' cannot be 
used as the type of a kernel parameter}} // expected-error{{declaring function 
parameter of type 'half' is not allowed; did you forget * ?}}
+
 // Exactly the same as above but with the cl_khr_fp16 extension enabled.
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 constant half a = 1.0h;
@@ -48,3 +51,7 @@
 
   return h;
 }
+
+kernel void half_enabled_kernel(global half *p,
+half h);
+
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7524,7 +7524,7 @@
   RecordKernelParam
 };
 
-static OpenCLParamType getOpenCLKernelParameterType(QualType PT) {
+static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType->isPointerType())
@@ -7545,7 +7545,10 @@
   if (PT->isEventT())
 return InvalidKernelParam;
 
-  if (PT->isHalfType())
+  // OpenCL extension spec v1.2 s9.5:
+  // This extension adds support for half scalar and vector types as built-in
+  // types that can be used for arithmetic operations, conversions etc.
+  if (!S.getOpenCLOptions().cl_khr_fp16 && PT->isHalfType())
 return InvalidKernelParam;
 
   if (PT->isRecordType())
@@ -7566,7 +7569,7 @@
   if (ValidTypes.count(PT.getTypePtr()))
 return;
 
-  switch (getOpenCLKernelParameterType(PT)) {
+  switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
 // OpenCL v1.2 s6.9.a:
 // A kernel function argument cannot be declared as a
@@ -7649,7 +7652,7 @@
   if (ValidTypes.count(QT.getTypePtr()))
 continue;
 
-  OpenCLParamType ParamType = getOpenCLKernelParameterType(QT);
+  OpenCLParamType ParamType = getOpenCLKernelParameterType(S, QT);
   if (ParamType == ValidKernelParam)
 continue;
 


Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
+kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as the type of a kernel parameter}} // expected-error{{declaring function parameter of type 'half' is not allowed; did you forget * ?}}
+
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 
@@ -11,7 +13,8 @@
 
 kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as the type of a kernel parameter}}
 
-kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as the type of a kernel parameter}}
+// half kernel argument is allowed when cl_khr_fp16 is enabled.
+kernel void half_arg(half x) { }
 
 typedef struct ContainsBool // expected-note{{within field of type 'ContainsBool' declared here}}
 {
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -25,6 +25,9 @@
   return h;
 }
 
+kernel void half_disabled_kernel(global half *p,
+ half h);  // expected-error{{'half' cannot be used as the type of a kernel parameter}} // expected-error{{declaring function parameter of type 'half' is not allowe

r281730 - CodeGen: use pointer rather than reference in range loop

2016-09-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Sep 16 09:24:26 2016
New Revision: 281730

URL: http://llvm.org/viewvc/llvm-project?rev=281730&view=rev
Log:
CodeGen: use pointer rather than reference in range loop

Address post-commit comments from Justin Bogner.  Explicitly indicate
that the dereferenced iterator provides a pointer rather than a
reference.  NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=281730&r1=281729&r2=281730&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Sep 16 09:24:26 2016
@@ -5186,10 +5186,10 @@ void CGObjCMac::FinishModule() {
   Asm += '\n';
 
 llvm::raw_svector_ostream OS(Asm);
-for (const auto &Sym : DefinedSymbols)
+for (const auto *Sym : DefinedSymbols)
   OS << "\t.objc_class_name_" << Sym->getName() << "=0\n"
  << "\t.globl .objc_class_name_" << Sym->getName() << "\n";
-for (const auto &Sym : LazySymbols)
+for (const auto *Sym : LazySymbols)
   OS << "\t.lazy_reference .objc_class_name_" << Sym->getName() << "\n";
 for (const auto &Category : DefinedCategoryNames)
   OS << "\t.objc_category_name_" << Category << "=0\n"


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


Re: r281261 - CodeGen: use some range-based for loops

2016-09-16 Thread Saleem Abdulrasool via cfe-commits
On Tue, Sep 13, 2016 at 11:06 AM, Justin Bogner 
wrote:

> Saleem Abdulrasool via cfe-commits  writes:
> > Author: compnerd
> > Date: Mon Sep 12 16:15:23 2016
> > New Revision: 281261
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=281261&view=rev
> > Log:
> > CodeGen: use some range-based for loops
> >
> > Use range-based for loops to simplify the logic.  Add an explicit check
> for
> > MachO as the inline asm uses MachO specific directives.
> >
> > Modified:
> > cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGObjCMac.cpp?rev=281261&r1=281260&r2=281261&view=diff
> > 
> ==
> > --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Sep 12 16:15:23 2016
> > @@ -5178,27 +5178,23 @@ void CGObjCMac::FinishModule() {
> >// important for correct linker interaction.
> >//
> >// FIXME: It would be nice if we had an LLVM construct for this.
> > -  if (!LazySymbols.empty() || !DefinedSymbols.empty()) {
> > +  if ((!LazySymbols.empty() || !DefinedSymbols.empty()) &&
> > +  CGM.getTriple().isOSBinFormatMachO()) {
> >  SmallString<256> Asm;
> >  Asm += CGM.getModule().getModuleInlineAsm();
> >  if (!Asm.empty() && Asm.back() != '\n')
> >Asm += '\n';
> >
> >  llvm::raw_svector_ostream OS(Asm);
> > -for (llvm::SetVector::iterator I =
> DefinedSymbols.begin(),
> > -   e = DefinedSymbols.end(); I != e; ++I)
> > -  OS << "\t.objc_class_name_" << (*I)->getName() << "=0\n"
> > - << "\t.globl .objc_class_name_" << (*I)->getName() << "\n";
> > -for (llvm::SetVector::iterator I =
> LazySymbols.begin(),
> > - e = LazySymbols.end(); I != e; ++I) {
> > -  OS << "\t.lazy_reference .objc_class_name_" << (*I)->getName() <<
> "\n";
> > -}
> > +for (const auto &Sym : DefinedSymbols)
>
> Is this a reference to a pointer? Please write this as `const auto *`,
> or even just write out the type `const IdentifierInfo *`.


Sorry for the delay: SVN r281730.


> > +  OS << "\t.objc_class_name_" << Sym->getName() << "=0\n"
> > + << "\t.globl .objc_class_name_" << Sym->getName() << "\n";
> > +for (const auto &Sym : LazySymbols)
> > +  OS << "\t.lazy_reference .objc_class_name_" << Sym->getName() <<
> "\n";
> > +for (const auto &Category : DefinedCategoryNames)
> > +  OS << "\t.objc_category_name_" << Category << "=0\n"
> > + << "\t.globl .objc_category_name_" << Category << "\n";
> >
> > -for (size_t i = 0, e = DefinedCategoryNames.size(); i < e; ++i) {
> > -  OS << "\t.objc_category_name_" << DefinedCategoryNames[i] <<
> "=0\n"
> > - << "\t.globl .objc_category_name_" << DefinedCategoryNames[i]
> << "\n";
> > -}
> > -
> >  CGM.getModule().setModuleInlineAsm(OS.str());
> >}
> >  }
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



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


Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Nico Weber via cfe-commits
thakis added inline comments.


Comment at: test/SemaCXX/warn-msvc-enum-bitfield.cpp:12
@@ +11,3 @@
+
+  s.e2 = E2;
+  s.f2 = F2;

sashab wrote:
> thakis wrote:
> > Shouldn't this be the version that warns? The assignment with E1 assigns 0 
> > which is portable, but this assigns 1 which overflows, right?
> e2 is not a bitfield :) So this code is fine.
> 
> And we should warn on all assignments, since any assigned value could 
> potentially be incorrect. Also, most assignments are not static so we don't 
> always have that information :)
Do you have any data on false positive rate when we just always warn 
unconditionally? i.e. did you build some large-ish open-source program (clang, 
chromium, firefox, ...) and is the true positive / false positive rate ok? (we 
have some problems with "always warn" with other enum warning which we 
currently always have to disable, e.g. 
https://bugs.chromium.org/p/chromium/issues/detail?id=621097)

To land, you need to `svn commit` or ask someone with commit access to do that 
for you -- llvm doesn't have a commit queue.


https://reviews.llvm.org/D24289



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


[libcxx] r281731 - [libcxx] Add missing c++98 xfail. NFC.

2016-09-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Sep 16 09:32:19 2016
New Revision: 281731

URL: http://llvm.org/viewvc/llvm-project?rev=281731&view=rev
Log:
[libcxx] Add missing c++98 xfail. NFC.

This is the only test failing in c++98 mode at the moment.

Modified:
libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp

Modified: libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp?rev=281731&r1=281730&r2=281731&view=diff
==
--- libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp Fri Sep 
16 09:32:19 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: c++03
+// XFAIL: c++03, c++98
 
 // 
 // template  auto begin(C& c) -> decltype(c.begin());


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


Re: r281714 - Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64

2016-09-16 Thread Tom Stellard via cfe-commits
On Fri, Sep 16, 2016 at 10:15:06AM -, Neil Hickey via cfe-commits wrote:
> Author: neil.hickey
> Date: Fri Sep 16 05:15:06 2016
> New Revision: 281714
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=281714&view=rev
> Log:
> Improve handling of floating point literals in OpenCL to only use double 
> precision if the target supports fp64
> 
> https://reviews.llvm.org/D24235
> 
> 

Hi,

I think this commit broke the libclc build.  I'm seeing an assertion
failure:

clang-4.0:
SemaChecking.cpp:3432:
bool clang::Sema::SemaBuiltinFPClassification(clang::CallExpr*, unsigned
int): Assertion
`Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) &&
"promotion from float to double is the only expected cast here"' failed.


To reproduce:

git clone http://llvm.org/git/libclc.git
cd libclc
./configure.py --with-llvm-config=/path/to/llvm-config
make

Are you able to take a look at this?

-Tom

> Modified:
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/CodeGenOpenCL/fpmath.cl
> cfe/trunk/test/SemaOpenCL/extensions.cl
> 
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=281714&r1=281713&r2=281714&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep 16 05:15:06 2016
> @@ -828,8 +828,18 @@ ExprResult Sema::DefaultArgumentPromotio
>// double.
>const BuiltinType *BTy = Ty->getAs();
>if (BTy && (BTy->getKind() == BuiltinType::Half ||
> -  BTy->getKind() == BuiltinType::Float))
> -E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
> +  BTy->getKind() == BuiltinType::Float)) {
> +if (getLangOpts().OpenCL &&
> +!((getLangOpts().OpenCLVersion >= 120 &&
> +   Context.getTargetInfo()
> +   .getSupportedOpenCLOpts()
> +   .cl_khr_fp64) ||
> +  getOpenCLOptions().cl_khr_fp64)) {
> +E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
> +} else {
> +  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
> +}
> +  }
>  
>// C++ performs lvalue-to-rvalue conversion as a default argument
>// promotion, even on class types, but note:
> @@ -3406,8 +3416,14 @@ ExprResult Sema::ActOnNumericConstant(co
>if (getLangOpts().SinglePrecisionConstants) {
>  Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
>} else if (getLangOpts().OpenCL &&
> - !((getLangOpts().OpenCLVersion >= 120) ||
> + !((getLangOpts().OpenCLVersion >= 120 &&
> +Context.getTargetInfo()
> +.getSupportedOpenCLOpts()
> +.cl_khr_fp64) ||
> getOpenCLOptions().cl_khr_fp64)) {
> +// Impose single-precision float type when:
> +//  - in CL 1.2 or above and cl_khr_fp64 is not supported, or
> +//  - in CL 1.1 or below and cl_khr_fp64 is not enabled.
>  Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
>  Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
>}
> 
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=281714&r1=281713&r2=281714&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Fri Sep 16 05:15:06 2016
> @@ -1401,7 +1401,8 @@ static QualType ConvertDeclSpecToType(Ty
>Result = Context.DoubleTy;
>  
>  if (S.getLangOpts().OpenCL &&
> -!((S.getLangOpts().OpenCLVersion >= 120) ||
> +!((S.getLangOpts().OpenCLVersion >= 120 
> +   && 
> S.Context.getTargetInfo().getSupportedOpenCLOpts().cl_khr_fp64) ||
>S.getOpenCLOptions().cl_khr_fp64)) {
>S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
><< Result << "cl_khr_fp64";
> 
> Modified: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/fpmath.cl?rev=281714&r1=281713&r2=281714&view=diff
> ==
> --- cfe/trunk/test/CodeGenOpenCL/fpmath.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl Fri Sep 16 05:15:06 2016
> @@ -1,5 +1,6 @@
>  // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | 
> FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
>  // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
> -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK 
> --check-prefix=DIVOPT %s
> +// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple 
> r600-unknown-unknown -target-cpu r600 -pedanti

[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-09-16 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl created this revision.
vbyakovlcl added reviewers: aaron.ballman, ahatanak.
vbyakovlcl added a subscriber: cfe-commits.
vbyakovlcl set the repository for this revision to rL LLVM.

Gcc prints error if elements of left and right parts of a shift have different 
sizes. This patch is provided the GCC compatibility.

Repository:
  rL LLVM

https://reviews.llvm.org/D24669

Files:
  llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td
  llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/Sema/vecshift.c

Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8784,6 +8784,65 @@
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT) {
+BuiltinType::Kind LHSKind = LHSBT->getKind();
+BuiltinType::Kind RHSKind = RHSBT->getKind();
+bool DiffSizes = true;
+switch (LHSKind) {
+case BuiltinType::Char_S:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_U && RHSKind != BuiltinType::UChar;
+  break;
+case BuiltinType::Char_U:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_S && RHSKind != BuiltinType::UChar;
+  break;
+case BuiltinType::UChar:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_U && RHSKind != BuiltinType::Char_S;
+  break;
+case BuiltinType::Short:
+  DiffSizes = RHSKind != BuiltinType::UShort;
+  break;
+case BuiltinType::UShort:
+  DiffSizes = RHSKind != BuiltinType::Short;
+  break;
+case BuiltinType::Int:
+  DiffSizes = RHSKind != BuiltinType::UInt;
+  break;
+case BuiltinType::UInt:
+  DiffSizes = RHSKind != BuiltinType::Int;
+  break;
+case BuiltinType::Long:
+  DiffSizes = RHSKind != BuiltinType::ULong;
+  break;
+case BuiltinType::ULong:
+  DiffSizes = RHSKind != BuiltinType::Long;
+  break;
+case BuiltinType::LongLong:
+  DiffSizes = RHSKind != BuiltinType::ULongLong;
+  break;
+case BuiltinType::ULongLong:
+  DiffSizes = RHSKind != BuiltinType::LongLong;
+  break;
+default:
+  DiffSizes = true;
+  break;
+}
+if (DiffSizes) {
+  S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+  << LHS.get()->getType() << RHS.get()->getType()
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  if (S.Diags.getDiagnosticLevel(
+  diag::warn_typecheck_vector_element_sizes_not_equal, Loc) ==
+  DiagnosticsEngine::Level::Error)
+return QualType();
+}
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =
Index: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2301,6 +2301,9 @@
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup, DefaultIgnore;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
Index: llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td
@@ -519,6 +519,7 @@
 def ZeroLengthArray : DiagGroup<"zero-length-array">;
 def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
 def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">;
+def GNUVecElemSize : DiagGroup<"gnu-vec-elem-size">;
 def Fallback : DiagGroup<"fallback">;
 
 // This covers both the deprecated case (in C++98)
@@ -758,7 +759,8 @@
 GNUStringLiteralOperatorTemplate,
 GNUUnionCast, GNUVariableSizedTypeNotAtEnd,
 ZeroLengthArray, GNUZeroLineDirective,
-GNUZeroVariadicMacroArguments]>;
+GNU

Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

2016-09-16 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: test/SemaOpenCL/half.cl:29
@@ +28,3 @@
+kernel void half_disabled_kernel(global half *p,
+ half h);  // expected-error{{'half' cannot be 
used as the type of a kernel parameter}} // expected-error{{declaring function 
parameter of type 'half' is not allowed; did you forget * ?}}
+

It's not related to your change, but it looks like there are two checks that 
report the same error.
Could you remove the duplication, please?


https://reviews.llvm.org/D24666



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


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

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

I think this is much clearer! That said, now that I look at it with 
'POSTCONDITION' alone I don't think it is clear that the provided value 
describes the return value. What do you think about renaming it 'RETURN_VALUE'? 
Or adding back the RET_VAL I asked you about removing before? :-)

Also: do you think CONDITION_KIND is needed? in PRECONDITION? Or can the bare 
kind be used like in POSTCONDITION?


https://reviews.llvm.org/D20811



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-09-16 Thread Serge Pavlov via cfe-commits
Ping.

Thanks,
--Serge

2016-09-08 20:43 GMT+07:00 Serge Pavlov :

> Any feedback?
>
> Thanks,
> --Serge
>
> 2016-09-02 13:11 GMT+07:00 Serge Pavlov :
>
>> sepavloff updated this revision to Diff 70134.
>> sepavloff marked an inline comment as done.
>> sepavloff added a comment.
>>
>> Updated patch
>>
>> Rewrite the condition in shouldLinkDependentDeclWithPrevious in more
>> compact form.
>>
>>
>> https://reviews.llvm.org/D16989
>>
>> Files:
>>   include/clang/Sema/Sema.h
>>   lib/Sema/SemaDecl.cpp
>>   lib/Sema/SemaDeclCXX.cpp
>>   test/SemaCXX/PR25848.cpp
>>   test/SemaCXX/friend2.cpp
>>   test/SemaCXX/function-redecl-2.cpp
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

2016-09-16 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 71667.
yaxunl added a comment.

Remove redundant diagnostic msg.


https://reviews.llvm.org/D24666

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl

Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
+kernel void half_arg(half x) { } // expected-error{{declaring function 
parameter of type 'half' is not allowed; did you forget * ?}}
+
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 
@@ -11,7 +13,8 @@
 
 kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as 
the type of a kernel parameter}}
 
-kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as 
the type of a kernel parameter}}
+// half kernel argument is allowed when cl_khr_fp16 is enabled.
+kernel void half_arg(half x) { }
 
 typedef struct ContainsBool // expected-note{{within field of type 
'ContainsBool' declared here}}
 {
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -25,6 +25,9 @@
   return h;
 }
 
+kernel void half_disabled_kernel(global half *p,
+ half h);  // expected-error{{declaring 
function parameter of type 'half' is not allowed; did you forget * ?}}
+
 // Exactly the same as above but with the cl_khr_fp16 extension enabled.
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 constant half a = 1.0h;
@@ -48,3 +51,7 @@
 
   return h;
 }
+
+kernel void half_enabled_kernel(global half *p,
+half h);
+
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7524,7 +7524,7 @@
   RecordKernelParam
 };
 
-static OpenCLParamType getOpenCLKernelParameterType(QualType PT) {
+static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType->isPointerType())
@@ -7545,7 +7545,10 @@
   if (PT->isEventT())
 return InvalidKernelParam;
 
-  if (PT->isHalfType())
+  // OpenCL extension spec v1.2 s9.5:
+  // This extension adds support for half scalar and vector types as built-in
+  // types that can be used for arithmetic operations, conversions etc.
+  if (!S.getOpenCLOptions().cl_khr_fp16 && PT->isHalfType())
 return InvalidKernelParam;
 
   if (PT->isRecordType())
@@ -7566,7 +7569,7 @@
   if (ValidTypes.count(PT.getTypePtr()))
 return;
 
-  switch (getOpenCLKernelParameterType(PT)) {
+  switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
 // OpenCL v1.2 s6.9.a:
 // A kernel function argument cannot be declared as a
@@ -7593,7 +7596,10 @@
 // OpenCL v1.2 s6.8 n:
 // A kernel function argument cannot be declared
 // of event_t type.
-S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
+// Do not diagnose half type since it is diagnosed as invalid argument
+// type for any function eleswhere.
+if (!PT->isHalfType())
+  S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
 D.setInvalidType();
 return;
 
@@ -7649,7 +7655,7 @@
   if (ValidTypes.count(QT.getTypePtr()))
 continue;
 
-  OpenCLParamType ParamType = getOpenCLKernelParameterType(QT);
+  OpenCLParamType ParamType = getOpenCLKernelParameterType(S, QT);
   if (ParamType == ValidKernelParam)
 continue;
 


Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
+kernel void half_arg(half x) { } // expected-error{{declaring function parameter of type 'half' is not allowed; did you forget * ?}}
+
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 
@@ -11,7 +13,8 @@
 
 kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as the type of a kernel parameter}}
 
-kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as the type of a kernel parameter}}
+// half kernel argument is allowed when cl_khr_fp16 is enabled.
+kernel void half_arg(half x) { }
 
 typedef struct ContainsBool // expected-note{{within field of type 'ContainsBool' declared here}}
 {
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -25,6 +25,9 @@
   return h;
 }
 
+kernel void half_disabled_kernel(global half *p,
+   

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

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

In https://reviews.llvm.org/D20811#544927, @dcoughlin wrote:

> That said, now that I look at it with 'POSTCONDITION' alone I don't think it 
> is clear that the provided value describes the return value. What do you 
> think about renaming it 'RETURN_VALUE'? Or adding back the RET_VAL I asked 
> you about removing before? :-)


Hmm, what about

  CONSTRAIN
ARGUMENT_VALUE(0, WithinRange)
  RANGE('0', '9')
  RANGE('A', 'Z')
  RANGE('a', 'z')
END_ARGUMENT_VALUE
RETURN_VALUE(OutOfRange)
  VALUE(0)
END_RETURN_VALUE
  END_CONSTRAIN

?

Something i don't like here is that the word "value" is overloaded. Maybe 
rename the inner `VALUE` back to `POINT`?

In https://reviews.llvm.org/D20811#544927, @dcoughlin wrote:

> Also: do you think CONDITION_KIND is needed? in PRECONDITION? Or can the bare 
> kind be used like in POSTCONDITION?


I agree that it's ok to use the bare kind, because it's quite self-explanatory.


https://reviews.llvm.org/D20811



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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-09-16 Thread Jason Turner via cfe-commits
lefticus updated this revision to Diff 71668.
lefticus added a comment.

Add C++1z check around constexpr tests, based on mclow's feedback


https://reviews.llvm.org/D22584

Files:
  include/array
  include/iterator
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/iterators.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp

Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -33,12 +33,23 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
-test(random_access_iterator(s+10), 10, random_access_iterator(s));
-test(s+10, 10, s);
-
-test(bidirectional_iterator(s+1), bidirectional_iterator(s));
-test(random_access_iterator(s+1), random_access_iterator(s));
-test(s+1, s);
+{
+const char* s = "1234567890";
+test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
+test(random_access_iterator(s+10), 10, random_access_iterator(s));
+test(s+10, 10, s);
+
+test(bidirectional_iterator(s+1), bidirectional_iterator(s));
+test(random_access_iterator(s+1), random_access_iterator(s));
+test(s+1, s);
+}
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::prev(s+10, 10) == s);
+static_assert(std::prev(s+1) == s);
+}
+#endif
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -35,16 +35,27 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), 10, input_iterator(s+10));
-test(forward_iterator(s), 10, forward_iterator(s+10));
-test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
-test(random_access_iterator(s), 10, random_access_iterator(s+10));
-test(s, 10, s+10);
-
-test(input_iterator(s), input_iterator(s+1));
-test(forward_iterator(s), forward_iterator(s+1));
-test(bidirectional_iterator(s), bidirectional_iterator(s+1));
-test(random_access_iterator(s), random_access_iterator(s+1));
-test(s, s+1);
+{
+const char* s = "1234567890";
+test(input_iterator(s), 10, input_iterator(s+10));
+test(forward_iterator(s), 10, forward_iterator(s+10));
+test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
+test(random_access_iterator(s), 10, random_access_iterator(s+10));
+test(s, 10, s+10);
+
+test(input_iterator(s), input_iterator(s+1));
+test(forward_iterator(s), forward_iterator(s+1));
+test(bidirectional_iterator(s), bidirectional_iterator(s+1));
+test(random_access_iterator(s), random_access_iterator(s+1));
+test(s, s+1);
+}
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::next(s, 10) == s+10);
+static_assert(std::next(s) == s+1);
+}
+#endif
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -31,10 +31,21 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), input_iterator(s+10), 10);
-test(forward_iterator(s), forward_iterator(s+10), 10);
-test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
-test(random_access_iterator(s), random_access_iterator(s+10), 10);
-test(s, s+10, 10);
+{
+const char* s = "1234567890";
+test(input_iterator(s), input_iterator(s+10), 10);
+test(forward_iterator(s), forward_iterator(s+10), 10);
+test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
+test(random_access_iterator(s), random_access_iterator(s+10), 10);
+test(s, s+10, 10);
+}
+
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::distance(s, s+10)

Re: [PATCH] D24663: When replacements have the same offset, make replacements with smaller length order first in the set.

2016-09-16 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Test? Why are we doing this (should go into the CL description)?


https://reviews.llvm.org/D24663



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


Re: [PATCH] D24602: [libc++] Fix and document visibility attributes for Clang, GCC and Windows.

2016-09-16 Thread Shoaib Meenai via cfe-commits
smeenai added a subscriber: smeenai.


Comment at: docs/DesignDocs/VisibilityMacros.rst:33
@@ +32,3 @@
+  Mark a type's typeinfo and vtable as having default visibility.
+  `_LIBCPP_TYPE_VIS`. This macro has no effect on the visibility of the
+  type's member functions. This attribute cannot be used on class templates.

The `_LIBCPP_TYPE_VIS` at the start of this line seems out of place?


Comment at: include/__config:605
@@ +604,3 @@
+#  if __has_attribute(__type_visibility__)
+#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ 
((__visibility__("default")))
+#  else

Do you think it's worth adding a comment in the code to this effect, or even 
just a comment pointing to the visibility macros design doc? It's a bit 
confusing. Alternatively, maybe define a `_LIBCPP_OVERRIDE_TYPE_VIS` inside the 
`__has_attribute(__type_visibility__)` case of `_LIBCPP_TYPE_VIS` and use that 
macro here instead of repeating the type visibility attribute check, to make 
this self documenting.


https://reviews.llvm.org/D24602



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


Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

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

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

Will be good idea to detect redundant function prototypes.

However, I think this check should be part of Clang diagnostics. GCC has 
-Wredundant-decls 

 for a long time.


Repository:
  rL LLVM

https://reviews.llvm.org/D24656



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


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

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

In https://reviews.llvm.org/D20811#544981, @NoQ wrote:

> Hmm, what about
>
>   CONSTRAIN
> ARGUMENT_VALUE(0, WithinRange)
>   RANGE('0', '9')
>   RANGE('A', 'Z')
>   RANGE('a', 'z')
> END_ARGUMENT_VALUE
> RETURN_VALUE(OutOfRange)
>   VALUE(0)
> END_RETURN_VALUE
>   END_CONSTRAIN
>   
>
> ?


"CONSTRAIN" is a verb. What is the direct object here? It seems to me that the 
thing being constrained is the return value, so it seems odd to have 
'CONSTRAIN' around the conditions on the arguments.

> Something i don't like here is that the word "value" is overloaded. Maybe 
> rename the inner `VALUE` back to `POINT`?


I don't think the geometric metaphor of 'POINT' makes sense here, especially 
with 'RANGE' (which I think is very good). What is the analog of a range that 
has only a single element?



Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:547
@@ +546,3 @@
+RANGE {
+  RET_VAL, RANGE_KIND(OutOfRange),
+  SET { POINT(0) }

NoQ wrote:
> dcoughlin wrote:
> > Is it ever the case that this final 'RANGE" constrains anything other than 
> > the return value? If not, can 'RET_VAL' be elided?
> Some summaries only have pre-conditions: "for this argument constraint, any 
> return value is possible". We should also be able to support void functions, 
> which have no return values.
What does a postcondition on a void function mean in this context? Can you 
refer to argument values? Such as "If the the function terminates then it must 
have been the case that the first argument was in the rangy x..z even though we 
didn't know that going in? Is this useful?


https://reviews.llvm.org/D20811



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


r281753 - Introduce inline assembly parsing test is PR30372.

2016-09-16 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Fri Sep 16 12:42:02 2016
New Revision: 281753

URL: http://llvm.org/viewvc/llvm-project?rev=281753&view=rev
Log:
Introduce inline assembly parsing test is PR30372.

Added:
cfe/trunk/test/Sema/pr30372.c

Added: cfe/trunk/test/Sema/pr30372.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr30372.c?rev=281753&view=auto
==
--- cfe/trunk/test/Sema/pr30372.c (added)
+++ cfe/trunk/test/Sema/pr30372.c Fri Sep 16 12:42:02 2016
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc18.0.0 -disable-free 
-fms-volatile -fms-extensions -fms-compatibility -fms-compatibility-version=18 
-std=c++11 -x c++
+
+// Check that the parser catching an 'error' from forward declaration of 
"location" does not lexer out it's subsequent declation.
+
+void foo() {
+  __asm {
+jl location
+ location:
+ret
+  }
+}


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


Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

2016-09-16 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7599-7602
@@ -7595,3 +7598,6 @@
 // of event_t type.
-S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
+// Do not diagnose half type since it is diagnosed as invalid argument
+// type for any function eleswhere.
+if (!PT->isHalfType())
+  S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
 D.setInvalidType();

It looks strange to me. First we check if parameter type is half - we set 
InvalidKernelParam status, later we check again and do not report an error.
I think it would be simpler just return ValidKernelParam for half data type 
from getOpenCLKernelParameterType,

I think the whole patch should two deleted lines from 
getOpenCLKernelParameterType function + test case.


https://reviews.llvm.org/D24666



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


Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Andrii Grynenko via cfe-commits
andriigrynenko updated this revision to Diff 71677.
andriigrynenko added a comment.

fix the unit test


https://reviews.llvm.org/D24628

Files:
  include/sanitizer/common_interface_defs.h
  lib/asan/asan_thread.cc
  lib/asan/asan_thread.h
  test/asan/TestCases/Linux/swapcontext_annotation.cc

Index: test/asan/TestCases/Linux/swapcontext_annotation.cc
===
--- test/asan/TestCases/Linux/swapcontext_annotation.cc
+++ test/asan/TestCases/Linux/swapcontext_annotation.cc
@@ -6,7 +6,7 @@
 // RUN: %clangxx_asan -lpthread -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
 //
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 
 #include 
 #include 
@@ -44,14 +44,16 @@
 
 void NextChild() {
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
 
   char x[32] = {0};  // Stack gets poisoned.
   printf("NextChild: %p\n", x);
 
   CallNoReturn();
 
-  __sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+  __sanitizer_start_switch_fiber(NULL,
+ main_thread_stack,
+ main_thread_stacksize);
   CallNoReturn();
   if (swapcontext(&next_child_context, &orig_context) < 0) {
 perror("swapcontext");
@@ -61,19 +63,23 @@
 
 void Child(int mode) {
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
   char x[32] = {0};  // Stack gets poisoned.
   printf("Child: %p\n", x);
   CallNoReturn();
   // (a) Do nothing, just return to parent function.
   // (b) Jump into the original function. Stack remains poisoned unless we do
   // something.
   // (c) Jump to another function which will then jump back to the main function
   if (mode == 0) {
-__sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+__sanitizer_start_switch_fiber(NULL,
+   main_thread_stack,
+   main_thread_stacksize);
 CallNoReturn();
   } else if (mode == 1) {
-__sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+__sanitizer_start_switch_fiber(NULL,
+   main_thread_stack,
+   main_thread_stacksize);
 CallNoReturn();
 if (swapcontext(&child_context, &orig_context) < 0) {
   perror("swapcontext");
@@ -84,7 +90,8 @@
 next_child_context.uc_stack.ss_sp = next_child_stack;
 next_child_context.uc_stack.ss_size = kStackSize / 2;
 makecontext(&next_child_context, (void (*)())NextChild, 0);
-__sanitizer_start_switch_fiber(next_child_context.uc_stack.ss_sp,
+__sanitizer_start_switch_fiber(NULL,
+   next_child_context.uc_stack.ss_sp,
next_child_context.uc_stack.ss_size);
 CallNoReturn();
 if (swapcontext(&child_context, &next_child_context) < 0) {
@@ -105,15 +112,16 @@
   }
   makecontext(&child_context, (void (*)())Child, 1, mode);
   CallNoReturn();
-  __sanitizer_start_switch_fiber(child_context.uc_stack.ss_sp,
+  __sanitizer_start_switch_fiber(NULL,
+ child_context.uc_stack.ss_sp,
  child_context.uc_stack.ss_size);
   CallNoReturn();
   if (swapcontext(&orig_context, &child_context) < 0) {
 perror("swapcontext");
 _exit(1);
   }
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
   CallNoReturn();
 
   // Touch childs's stack to make sure it's unpoisoned.
Index: lib/asan/asan_thread.h
===
--- lib/asan/asan_thread.h
+++ lib/asan/asan_thread.h
@@ -94,7 +94,8 @@
   }
 
   void StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom, uptr size);
-  void FinishSwitchFiber(FakeStack *fake_stack_save);
+  void FinishSwitchFiber(FakeStack *fake_stack_save, uptr *bottom_old,
+ uptr *size_old);
 
   bool has_fake_stack() {
 return !atomic_load(&stack_switching_, memory_order_relaxed) &&
Index: lib/asan/asan_thread.cc
===
--- lib/asan/asan_thread.cc
+++ lib/asan/asan_thread.cc
@@ -141,7 +141,9 @@
 current_fake_stack->Destroy(this->tid());
 }
 
-void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save) {
+void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save,
+   uptr *bottom_old,
+   uptr *size_old) {
   if (!atomic_load(&stack_switching_, memory_order_relaxed)) {
 Report("ERROR: finishing a fiber switch that has not started\n");
 Die();
@@ -152,6 +154,12 @@
 fake_stack_ = fake_stack_save;
   }
 
+  if (bottom_old) {
+*bottom_old = stack_bottom_;
+  }
+  i

Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Andrii Grynenko via cfe-commits
andriigrynenko added inline comments.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:9
@@ -8,3 +8,3 @@
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 

The test was actually broken in trunk (not updated for the fakestack argument). 
Apparently it was never run (considered unsupported) because of wrong targets 
here. 


https://reviews.llvm.org/D24628



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


Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled

2016-09-16 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7599-7602
@@ -7595,3 +7598,6 @@
 // of event_t type.
-S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
+// Do not diagnose half type since it is diagnosed as invalid argument
+// type for any function eleswhere.
+if (!PT->isHalfType())
+  S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
 D.setInvalidType();

bader wrote:
> It looks strange to me. First we check if parameter type is half - we set 
> InvalidKernelParam status, later we check again and do not report an error.
> I think it would be simpler just return ValidKernelParam for half data type 
> from getOpenCLKernelParameterType,
> 
> I think the whole patch should two deleted lines from 
> getOpenCLKernelParameterType function + test case.
getOpenCLKernelParameterType should report half type as InvalidKernelParam 
since it really is an invalid kernel argument type. We do not emit diagnostic 
msg because the msg is redundant, not because half type is a valid kernel 
argument type. 

getOpenCLKernelParameterType may be used for other purpose. Reporting half type 
as a valid kernel argument violates the semantics of 
getOpenCLKernelParameterType and can cause confusion and potential error.


https://reviews.llvm.org/D24666



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


[PATCH] D24678: [libc++] Fix inline attribute for non-MSVC Windows

2016-09-16 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, EricWF, mclow.lists.
smeenai added a subscriber: cfe-commits.

gcc and clang in gcc compatibility mode do not accept __forceinline. Use
the gcc attribute for them instead.

https://reviews.llvm.org/D24678

Files:
  include/__config

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -560,9 +560,15 @@
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
-#define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#if defined(_LIBCPP_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ 
((__always_inline__))
+#endif
 #endif // _WIN32
 
 #ifndef _LIBCPP_HIDDEN


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -560,9 +560,15 @@
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
-#define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#if defined(_LIBCPP_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+#endif
 #endif // _WIN32
 
 #ifndef _LIBCPP_HIDDEN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24678: [libc++] Fix inline attribute for non-MSVC Windows

2016-09-16 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.




https://reviews.llvm.org/D24678



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


Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-16 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: test/clang-tidy/readability-redundant-declaration.cpp:9
@@ +8,3 @@
+extern int A;
+extern int A,B;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable A declaration

Please run Clang-format over test.


Repository:
  rL LLVM

https://reviews.llvm.org/D24656



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


[PATCH] D24679: [libc++] Fix extern template visibility for Windows

2016-09-16 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, EricWF, mclow.lists.
smeenai added a subscriber: cfe-commits.

On Windows, marking an `extern template class` declaration as exported
actually forces an instantiation, which is not the desired behavior.
Instead, the actual explicit instantiations need to be exported.

https://reviews.llvm.org/D24679

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config
  src/ios.cpp
  src/locale.cpp
  src/string.cpp

Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -20,10 +20,10 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template class __basic_string_common;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common;
 
-template class basic_string;
-template class basic_string;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_string;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_string;
 
 template
 string
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -6031,66 +6031,66 @@
 #endif
 }
 
-template class collate;
-template class collate;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate;
 
-template class num_get;
-template class num_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get;
 
-template struct __num_get;
-template struct __num_get;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get;
 
-template class num_put;
-template class num_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put;
 
-template struct __num_put;
-template struct __num_put;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put;
 
-template class time_get;
-template class time_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get;
 
-template class time_get_byname;
-template class time_get_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname;
 
-template class time_put;
-template class time_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put;
 
-template class time_put_byname;
-template class time_put_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname;
 
-template class moneypunct;
-template class moneypunct;
-template class moneypunct;
-template class moneypunct;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct;
 
-template class moneypunct_byname;
-template class moneypunct_byname;
-template class moneypunct_byname;
-template class moneypunct_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname;
 
-template class money_get;
-template class money_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get;
 
-template class __money_get;
-template class __money_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get;
 
-template class money_put;
-template class money_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put;
 
-template class __money_put;
-template class __money_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put;
 
-template class messages;
-template class messages;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages;
 
-template class messages_byname;
-template class messages_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname;
 
-template class codecvt_byname;
-template class 

Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Dmitry Vyukov via cfe-commits
dvyukov added a comment.

We need a test that passes non-NULL to these arguments and shows how to use the 
returned values.



Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:47
@@ -46,3 +46,3 @@
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
 

#include  for NULL


https://reviews.llvm.org/D24628



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


[libcxx] r281766 - [libc++] Fix inline attribute for non-MSVC Windows

2016-09-16 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Sep 16 14:12:54 2016
New Revision: 281766

URL: http://llvm.org/viewvc/llvm-project?rev=281766&view=rev
Log:
[libc++] Fix inline attribute for non-MSVC Windows

gcc and clang in gcc compatibility mode do not accept __forceinline. Use
the gcc attribute for them instead.

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=281766&r1=281765&r2=281766&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Sep 16 14:12:54 2016
@@ -560,9 +560,15 @@ namespace std {
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
-#define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#if defined(_LIBCPP_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ 
((__always_inline__))
+#endif
 #endif // _WIN32
 
 #ifndef _LIBCPP_HIDDEN


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


Re: [PATCH] D24678: [libc++] Fix inline attribute for non-MSVC Windows

2016-09-16 Thread Shoaib Meenai via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281766: [libc++] Fix inline attribute for non-MSVC Windows 
(authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D24678?vs=71680&id=71687#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24678

Files:
  libcxx/trunk/include/__config

Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -560,9 +560,15 @@
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
-#define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#if defined(_LIBCPP_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ 
((__always_inline__))
+#endif
 #endif // _WIN32
 
 #ifndef _LIBCPP_HIDDEN


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -560,9 +560,15 @@
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
-#define _LIBCPP_INLINE_VISIBILITY __forceinline
-#define _LIBCPP_ALWAYS_INLINE __forceinline
-#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#if defined(_LIBCPP_MSVC)
+# define _LIBCPP_INLINE_VISIBILITY __forceinline
+# define _LIBCPP_ALWAYS_INLINE __forceinline
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
+#else
+# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+#endif
 #endif // _WIN32
 
 #ifndef _LIBCPP_HIDDEN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21021: [Clang][AVX512][BuiltIn]Adding intrinsics move_{sd|ss} to clang

2016-09-16 Thread Simon Pilgrim via cfe-commits
RKSimon added a subscriber: RKSimon.


Comment at: lib/Headers/avx512fintrin.h:9124
@@ +9123,3 @@
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf) __W,

delena wrote:
> please try the following:
> if (__U)
>   return __builtin_shuffle(A, B, (0, 5, 6, 7)); // may be you need to swap A 
> and B 
>  return W;
> 
> I know that the immediate code will be less optimal, but we can optimize it 
> later.
Any update on this? I currently have a patch (D24653) looking at removing the 
movss/movsd mask intrinsics as we should be able to do this with purely generic 
shuffles. I can help with the optimization if necessary.


https://reviews.llvm.org/D21021



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


Re: [PATCH] D24663: When replacements have the same offset, make replacements with smaller length order first in the set.

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

In https://reviews.llvm.org/D24663#544993, @klimek wrote:

> Test? Why are we doing this (should go into the CL description)?


There is no behavioral change intended, and the goal here is not to break any 
test. A test for this change can be having an insertion and a deletion at the 
same offset, but this is not supported yet and will a followup patch.


https://reviews.llvm.org/D24663



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


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

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

- Updated commenting, and fix a bug in the binary.


https://reviews.llvm.org/D24183

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

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

Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Philippe Daouadi via cfe-commits
blastrock added inline comments.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:9
@@ -8,3 +8,3 @@
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 

andriigrynenko wrote:
> The test was actually broken in trunk (not updated for the fakestack 
> argument). Apparently it was never run (considered unsupported) because of 
> wrong targets here. 
Indeed, my bad, I forgot to compile and run the tests after the last 
modification I made to that patch. Sorry for that.

I didn't need to change this line to run them on my computer though, but if you 
know what you are doing with this line, it's ok. And it's strange indeed that 
no buildfarm caught this...


https://reviews.llvm.org/D24628



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


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

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

This is awesome! I have some minor comments on the dealloc notes. It is also 
fine to remove them entirely; we can add them in a later commit.



Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:604
@@ -588,1 +603,3 @@
 
+addExtraNoteForDecl(BR, "The property is declared here", PropDecl);
+

To be consistent with the rest of clang, I think it is better to remove the 
"The". That is: "Property is declared here" and "Property is synthesized here".


Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:733
@@ -712,1 +732,3 @@
 
+  addExtraNoteForDecl(BR, "The property is declared here", PropDecl);
+

Is it possible to factor this out so we only have the hard-coded note text for 
each of "declared"/"synthesized" in one spot? This will make it easier to 
update the text if we decide to change it.


https://reviews.llvm.org/D24278



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


[PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-16 Thread Aditya Kumar via cfe-commits
hiraditya created this revision.
hiraditya added reviewers: rafael, eugenis.
hiraditya added subscribers: sebpop, mclow.lists, cfe-commits, EricWF.

Inlining the destructor caused the compiler to generate bad IR which failed the 
Verifier in the backend.
https://llvm.org/bugs/show_bug.cgi?id=30341

This patch disables alias to available_externally definitions.

https://reviews.llvm.org/D24682

Files:
  clang/lib/CodeGen/CGCXX.cpp

Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -134,6 +134,10 @@
   llvm::GlobalValue::LinkageTypes TargetLinkage =
   getFunctionLinkage(TargetDecl);
 
+  // r254170: Disallow aliases to available_externally.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)
+return true;
+
   // Check if we have it already.
   StringRef MangledName = getMangledName(AliasDecl);
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
@@ -157,8 +161,7 @@
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
+  !TargetDecl.getDecl()->hasAttr()) {
 // FIXME: An extern template instantiation will create functions with
 // linkage "AvailableExternally". In libc++, some classes also define
 // members with attribute "AlwaysInline" and expect no reference to


Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -134,6 +134,10 @@
   llvm::GlobalValue::LinkageTypes TargetLinkage =
   getFunctionLinkage(TargetDecl);
 
+  // r254170: Disallow aliases to available_externally.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)
+return true;
+
   // Check if we have it already.
   StringRef MangledName = getMangledName(AliasDecl);
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
@@ -157,8 +161,7 @@
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
+  !TargetDecl.getDecl()->hasAttr()) {
 // FIXME: An extern template instantiation will create functions with
 // linkage "AvailableExternally". In libc++, some classes also define
 // members with attribute "AlwaysInline" and expect no reference to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24599: Add 'inline' but not _LIBCPP_INLINE_VISIBILITY to basic_string's destructor

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

Please also see: https://reviews.llvm.org/D24682


https://reviews.llvm.org/D24599



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


Re: [PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-16 Thread Sebastian Pop via cfe-commits
sebpop added inline comments.


Comment at: clang/lib/CodeGen/CGCXX.cpp:137
@@ -136,1 +136,3 @@
 
+  // r254170: Disallow aliases to available_externally.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)

Please remove the reference to r254170.
You may want to put a reference to a bug, or better, just describe in full why 
this is disabled.


Comment at: clang/lib/CodeGen/CGCXX.cpp:166
@@ -162,3 +165,3 @@
 // FIXME: An extern template instantiation will create functions with
 // linkage "AvailableExternally". In libc++, some classes also define
 // members with attribute "AlwaysInline" and expect no reference to

You may want to adjust this comment, now that the condition does not check for 
"AvailableExternally".
You can move part of the FIXME in the comment above.


https://reviews.llvm.org/D24682



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


Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Andrii Grynenko via cfe-commits
andriigrynenko updated this revision to Diff 71698.
andriigrynenko added a comment.

update unit test to use non-null values


https://reviews.llvm.org/D24628

Files:
  include/sanitizer/common_interface_defs.h
  lib/asan/asan_thread.cc
  lib/asan/asan_thread.h
  test/asan/TestCases/Linux/swapcontext_annotation.cc

Index: test/asan/TestCases/Linux/swapcontext_annotation.cc
===
--- test/asan/TestCases/Linux/swapcontext_annotation.cc
+++ test/asan/TestCases/Linux/swapcontext_annotation.cc
@@ -6,10 +6,11 @@
 // RUN: %clangxx_asan -lpthread -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
 //
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,7 +26,7 @@
 
 const int kStackSize = 1 << 20;
 
-void *main_thread_stack;
+const void *main_thread_stack;
 size_t main_thread_stacksize;
 
 __attribute__((noinline, noreturn)) void LongJump(jmp_buf env) {
@@ -44,14 +45,16 @@
 
 void NextChild() {
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
 
   char x[32] = {0};  // Stack gets poisoned.
   printf("NextChild: %p\n", x);
 
   CallNoReturn();
 
-  __sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+  __sanitizer_start_switch_fiber(NULL,
+ main_thread_stack,
+ main_thread_stacksize);
   CallNoReturn();
   if (swapcontext(&next_child_context, &orig_context) < 0) {
 perror("swapcontext");
@@ -61,19 +64,25 @@
 
 void Child(int mode) {
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL,
+  &main_thread_stack,
+  &main_thread_stacksize);
   char x[32] = {0};  // Stack gets poisoned.
   printf("Child: %p\n", x);
   CallNoReturn();
   // (a) Do nothing, just return to parent function.
   // (b) Jump into the original function. Stack remains poisoned unless we do
   // something.
   // (c) Jump to another function which will then jump back to the main function
   if (mode == 0) {
-__sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+__sanitizer_start_switch_fiber(NULL,
+   main_thread_stack,
+   main_thread_stacksize);
 CallNoReturn();
   } else if (mode == 1) {
-__sanitizer_start_switch_fiber(main_thread_stack, main_thread_stacksize);
+__sanitizer_start_switch_fiber(NULL,
+   main_thread_stack,
+   main_thread_stacksize);
 CallNoReturn();
 if (swapcontext(&child_context, &orig_context) < 0) {
   perror("swapcontext");
@@ -84,7 +93,8 @@
 next_child_context.uc_stack.ss_sp = next_child_stack;
 next_child_context.uc_stack.ss_size = kStackSize / 2;
 makecontext(&next_child_context, (void (*)())NextChild, 0);
-__sanitizer_start_switch_fiber(next_child_context.uc_stack.ss_sp,
+__sanitizer_start_switch_fiber(NULL,
+   next_child_context.uc_stack.ss_sp,
next_child_context.uc_stack.ss_size);
 CallNoReturn();
 if (swapcontext(&child_context, &next_child_context) < 0) {
@@ -105,15 +115,17 @@
   }
   makecontext(&child_context, (void (*)())Child, 1, mode);
   CallNoReturn();
-  __sanitizer_start_switch_fiber(child_context.uc_stack.ss_sp,
+  void* fake_stack_save;
+  __sanitizer_start_switch_fiber(&fake_stack_save,
+ child_context.uc_stack.ss_sp,
  child_context.uc_stack.ss_size);
   CallNoReturn();
   if (swapcontext(&orig_context, &child_context) < 0) {
 perror("swapcontext");
 _exit(1);
   }
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(fake_stack_save, NULL, NULL);
   CallNoReturn();
 
   // Touch childs's stack to make sure it's unpoisoned.
@@ -125,17 +137,7 @@
 
 void handler(int sig) { CallNoReturn(); }
 
-void InitStackBounds() {
-  pthread_attr_t attr;
-  pthread_attr_init(&attr);
-  pthread_getattr_np(pthread_self(), &attr);
-  pthread_attr_getstack(&attr, &main_thread_stack, &main_thread_stacksize);
-  pthread_attr_destroy(&attr);
-}
-
 int main(int argc, char **argv) {
-  InitStackBounds();
-
   // set up a signal that will spam and trigger __asan_handle_no_return at
   // tricky moments
   struct sigaction act = {};
Index: lib/asan/asan_thread.h
===
--- lib/asan/asan_thread.h
+++ lib/asan/asan_thread.h
@@ -94,7 +94,8 @@
   }
 
   void StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom, uptr size);
-  void FinishSwitchFiber(FakeStack *fake_stack_save);
+  void FinishSwitchFiber(Fak

Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-16 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

Please add some printf calls to the test, to show that you have the correct 
stack+size, too.

Thanks for working on this.
Filipe



Comment at: lib/asan/asan_thread.cc:141
@@ -140,3 +140,3 @@
   if (!fake_stack_save && current_fake_stack)
 current_fake_stack->Destroy(this->tid());
 }

Please make sure you're accounting for this. It seems the test is always 
passing nullptr to start_switch, which shouldn't be done unless you're 
finishing up a fiber execution, IIRC.


Comment at: lib/asan/asan_thread.cc:162
@@ -155,1 +161,3 @@
+*size_old = stack_top_ - stack_bottom_;
+  }
   stack_bottom_ = next_stack_bottom_;

I think the usual style is: one statement => no braces.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:9
@@ -8,3 +8,3 @@
 // This test is too subtle to try on non-x86 arch for now.
-// REQUIRES: x86_64-supported-target,i386-supported-target
+// REQUIRES: x86-target-arch
 

blastrock wrote:
> andriigrynenko wrote:
> > The test was actually broken in trunk (not updated for the fakestack 
> > argument). Apparently it was never run (considered unsupported) because of 
> > wrong targets here. 
> Indeed, my bad, I forgot to compile and run the tests after the last 
> modification I made to that patch. Sorry for that.
> 
> I didn't need to change this line to run them on my computer though, but if 
> you know what you are doing with this line, it's ok. And it's strange indeed 
> that no buildfarm caught this...
They wouldn't catch tests not being run.
Test with LLVM_LIT_ARGS=-v (instead of -sv) on your cmake config and 
double-check that the tests are run.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:47
@@ -46,3 +46,3 @@
   CallNoReturn();
-  __sanitizer_finish_switch_fiber();
+  __sanitizer_finish_switch_fiber(NULL, NULL, NULL);
 

dvyukov wrote:
> #include  for NULL
nit: nullptr?


https://reviews.llvm.org/D24628



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


LLVM buildmaster will be updated and restarted tonight

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

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-16 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D24472



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


Re: [PATCH] D24516: [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-09-16 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D24516



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


r281785 - CodeGen: Add more checks to nobuiltin.c test, add a negative test.

2016-09-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Sep 16 17:05:53 2016
New Revision: 281785

URL: http://llvm.org/viewvc/llvm-project?rev=281785&view=rev
Log:
CodeGen: Add more checks to nobuiltin.c test, add a negative test.

Modified:
cfe/trunk/test/CodeGen/nobuiltin.c

Modified: cfe/trunk/test/CodeGen/nobuiltin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nobuiltin.c?rev=281785&r1=281784&r2=281785&view=diff
==
--- cfe/trunk/test/CodeGen/nobuiltin.c (original)
+++ cfe/trunk/test/CodeGen/nobuiltin.c Fri Sep 16 17:05:53 2016
@@ -1,17 +1,19 @@
-// RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fno-builtin-memset -O1 -S -o - %s | FileCheck 
-check-prefix=MEMSET %s
+// RUN: %clang_cc1 -O1 -S -o - %s | FileCheck -check-prefix=STRCPY 
-check-prefix=MEMSET %s
+// RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck 
-check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
+// RUN: %clang_cc1 -fno-builtin-memset -O1 -S -o - %s | FileCheck 
-check-prefix=STRCPY -check-prefix=NOMEMSET %s
 
 void PR13497() {
   char content[2];
   // make sure we don't optimize this call to strcpy()
-  // CHECK: __strcpy_chk
+  // STRCPY-NOT: __strcpy_chk
+  // NOSTRCPY: __strcpy_chk
   __builtin___strcpy_chk(content, "", 1);
 }
 
 void PR4941(char *s) {
   // Make sure we don't optimize this loop to a memset().
-  // MEMSET-LABEL: PR4941:
-  // MEMSET-NOT: memset
+  // NOMEMSET-NOT: memset
+  // MEMSET: memset
   for (unsigned i = 0; i < 8192; ++i)
 s[i] = 0;
 }


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


[PATCH] D24688: Introduce "hosted" module flag.

2016-09-16 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: mehdi_amini, dexonsmith.
pcc added subscribers: llvm-commits, cfe-commits.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: nhaehnle, nemanjai, mehdi_amini, jyknight, qcolombet.

This module flag is used to mark modules which were compiled in hosted
mode. The TargetLibraryInfoImpl class now uses this module flag to initialize
library availability information.

Fixes PR30403.

https://reviews.llvm.org/D24688

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/nobuiltin.c
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCXX/strict-vtable-pointers.cpp
  lld/ELF/LTO.cpp
  lld/test/ELF/lto/undefined-puts.ll
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/LTO/UpdateCompilerUsed.cpp
  llvm/test/Analysis/GlobalsModRef/indirect-global.ll
  llvm/test/Analysis/GlobalsModRef/memset-escape.ll
  llvm/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll
  llvm/test/CodeGen/AArch64/arm64-fcopysign.ll
  llvm/test/CodeGen/AArch64/arm64-rounding.ll
  llvm/test/CodeGen/AArch64/arm64-sincos.ll
  llvm/test/CodeGen/AArch64/floatdp_1source.ll
  llvm/test/CodeGen/AArch64/round-conv.ll
  llvm/test/CodeGen/AMDGPU/complex-folding.ll
  llvm/test/CodeGen/AMDGPU/fabs.f64.ll
  llvm/test/CodeGen/AMDGPU/fabs.ll
  llvm/test/CodeGen/AMDGPU/floor.ll
  llvm/test/CodeGen/AMDGPU/fneg-fabs.f64.ll
  llvm/test/CodeGen/AMDGPU/fneg-fabs.ll
  llvm/test/CodeGen/AMDGPU/llvm.SI.fs.interp.ll
  llvm/test/CodeGen/AMDGPU/r600-infinite-loop-bug-while-reorganizing-vector.ll
  llvm/test/CodeGen/AMDGPU/schedule-if-2.ll
  llvm/test/CodeGen/AMDGPU/sgpr-copy.ll
  llvm/test/CodeGen/AMDGPU/si-sgpr-spill.ll
  llvm/test/CodeGen/ARM/apcs-vfp.ll
  llvm/test/CodeGen/ARM/arm32-round-conv.ll
  llvm/test/CodeGen/ARM/arm32-rounding.ll
  llvm/test/CodeGen/ARM/fabs-to-bfc.ll
  llvm/test/CodeGen/ARM/fabss.ll
  llvm/test/CodeGen/ARM/fcopysign.ll
  llvm/test/CodeGen/ARM/floorf.ll
  llvm/test/CodeGen/ARM/fparith.ll
  llvm/test/CodeGen/ARM/ifcvt10.ll
  llvm/test/CodeGen/ARM/sincos.ll
  llvm/test/CodeGen/ARM/v7k-libcalls.ll
  llvm/test/CodeGen/ARM/v7k-sincos.ll
  llvm/test/CodeGen/ARM/vfp.ll
  llvm/test/CodeGen/Hexagon/fminmax.ll
  llvm/test/CodeGen/Hexagon/opt-fabs.ll
  llvm/test/CodeGen/Mips/f16abs.ll
  llvm/test/CodeGen/Mips/fabs.ll
  llvm/test/CodeGen/Mips/fcopysign-f32-f64.ll
  llvm/test/CodeGen/Mips/fcopysign.ll
  llvm/test/CodeGen/Mips/llvm-ir/sqrt.ll
  llvm/test/CodeGen/Mips/mips64-f128.ll
  llvm/test/CodeGen/Mips/optimize-fp-math.ll
  llvm/test/CodeGen/PowerPC/copysignl.ll
  llvm/test/CodeGen/PowerPC/fabs.ll
  llvm/test/CodeGen/PowerPC/fcpsgn.ll
  llvm/test/CodeGen/PowerPC/fnabs.ll
  llvm/test/CodeGen/PowerPC/rounding-ops.ll
  llvm/test/CodeGen/PowerPC/vsx-elementary-arith.ll
  llvm/test/CodeGen/SPARC/64abi.ll
  llvm/test/CodeGen/SystemZ/fp-copysign-01.ll
  llvm/test/CodeGen/SystemZ/fp-sincos-01.ll
  llvm/test/CodeGen/SystemZ/fp-sqrt-01.ll
  llvm/test/CodeGen/SystemZ/fp-sqrt-02.ll
  llvm/test/CodeGen/SystemZ/memchr-01.ll
  llvm/test/CodeGen/SystemZ/memchr-02.ll
  llvm/test/CodeGen/SystemZ/memcmp-01.ll
  llvm/test/CodeGen/SystemZ/memcmp-02.ll
  llvm/test/CodeGen/SystemZ/strcmp-01.ll
  llvm/test/CodeGen/SystemZ/strcmp-02.ll
  llvm/test/CodeGen/SystemZ/strcpy-01.ll
  llvm/test/CodeGen/SystemZ/strlen-01.ll
  llvm/test/CodeGen/SystemZ/strlen-02.ll
  llvm/test/CodeGen/X86/avx-arith.ll
  llvm/test/CodeGen/X86/avx512-arith.ll
  llvm/test/CodeGen/X86/copysign-constant-magnitude.ll
  llvm/test/CodeGen/X86/fabs.ll
  llvm/test/CodeGen/X86/fmaxnum.ll
  llvm/test/CodeGen/X86/fminnum.ll
  llvm/test/CodeGen/X86/fnabs.ll
  llvm/test/CodeGen/X86/fp-in-intregs.ll
  llvm/test/CodeGen/X86/fp128-cast.ll
  llvm/test/CodeGen/X86/fp128-i128.ll
  llvm/test/CodeGen/X86/memcmp.ll
  llvm/test/CodeGen/X86/mempcpy.ll
  llvm/test/CodeGen/X86/negative-sin.ll
  llvm/test/CodeGen/X86/pr13577.ll
  llvm/test/CodeGen/X86/pr2656.ll
  llvm/test/CodeGen/X86/pr26625.ll
  llvm/test/CodeGen/X86/rounding-ops.ll
  llvm/test/CodeGen/X86/sincos-opt.ll
  llvm/test/CodeGen/X86/sincos.ll
  llvm/test/CodeGen/X86/sqrt-fastmath.ll
  llvm/test/CodeGen/X86/stack-align.ll
  llvm/test/Instrumentation/AddressSanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/BoundsChecking/simple.ll
  llvm/test/Instrumentation/EfficiencySanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/MemorySanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/ThreadSanitizer/str-nobuiltin.ll
  llvm/test/LTO/X86/runtime-library.ll
  llvm/test/LTO/X86/triple-init.ll
  llvm/test/Transforms/ConstProp/calls.ll
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll
  llvm/test/Transforms/DeadStoreElimination/calloc-store.ll
  llvm/test/Transforms/DeadStoreElimination/fence.ll
  l

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

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

It is not clear to me that we've reached a consensus on cfe-dev list that 
suppressing with comments and printing the checker name is the way to go.


https://reviews.llvm.org/D24411



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


r281790 - Add target triples to fix test on non-x86.

2016-09-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Sep 16 17:26:45 2016
New Revision: 281790

URL: http://llvm.org/viewvc/llvm-project?rev=281790&view=rev
Log:
Add target triples to fix test on non-x86.

Modified:
cfe/trunk/test/CodeGen/nobuiltin.c

Modified: cfe/trunk/test/CodeGen/nobuiltin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nobuiltin.c?rev=281790&r1=281789&r2=281790&view=diff
==
--- cfe/trunk/test/CodeGen/nobuiltin.c (original)
+++ cfe/trunk/test/CodeGen/nobuiltin.c Fri Sep 16 17:26:45 2016
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -O1 -S -o - %s | FileCheck -check-prefix=STRCPY 
-check-prefix=MEMSET %s
-// RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck 
-check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
-// RUN: %clang_cc1 -fno-builtin-memset -O1 -S -o - %s | FileCheck 
-check-prefix=STRCPY -check-prefix=NOMEMSET %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -S -o - %s | FileCheck 
-check-prefix=STRCPY -check-prefix=MEMSET %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | 
FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s 
| FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s
 
 void PR13497() {
   char content[2];


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


Re: [PATCH] D23765: Fix for clang PR 29087

2016-09-16 Thread Taewook Oh via cfe-commits
twoh updated this revision to Diff 71711.
twoh added a comment.

Updated diff. For ConstructorUsingShadowDecl, test with its target 
CXXConstructorDecl, but only when it is not a default/copy/move constructor.


https://reviews.llvm.org/D23765

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx11-crashes.cpp

Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,10 @@
   Foo(lambda);
 }
 }
+
+namespace pr29091 {
+  struct X{ X(const X &x); };
+  struct Y: X { using X::X; };
+  bool foo() { return __has_nothrow_constructor(Y); }
+  bool bar() { return __has_nothrow_copy(Y); }
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -292,7 +292,7 @@
   if (isDependent) {
 // We didn't find our type, but that's okay: it's dependent
 // anyway.
-
+
 // FIXME: What if we have no nested-name-specifier?
 QualType T = CheckTypenameType(ETK_None, SourceLocation(),
SS.getWithLocInContext(Context),
@@ -326,14 +326,14 @@
 ParsedType Sema::getDestructorType(const DeclSpec& DS, ParsedType ObjectType) {
 if (DS.getTypeSpecType() == DeclSpec::TST_error || !ObjectType)
   return nullptr;
-assert(DS.getTypeSpecType() == DeclSpec::TST_decltype 
+assert(DS.getTypeSpecType() == DeclSpec::TST_decltype
&& "only get destructor types from declspecs");
 QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc());
 QualType SearchType = GetTypeFromParser(ObjectType);
 if (SearchType->isDependentType() || Context.hasSameUnqualifiedType(SearchType, T)) {
   return ParsedType::make(T);
 }
-  
+
 Diag(DS.getTypeSpecTypeLoc(), diag::err_destructor_expr_type_mismatch)
   << T << SearchType;
 return nullptr;
@@ -662,7 +662,7 @@
   IsThrownVarInScope = true;
   break;
 }
-
+
 if (S->getFlags() &
 (Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
  Scope::FunctionPrototypeScope | Scope::ObjCMethodScope |
@@ -672,11 +672,11 @@
 }
   }
   }
-  
+
   return BuildCXXThrow(OpLoc, Ex, IsThrownVarInScope);
 }
 
-ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, 
+ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
bool IsThrownVarInScope) {
   // Don't report an error if 'throw' is used in system headers.
   if (!getLangOpts().CXXExceptions &&
@@ -903,10 +903,10 @@
I-- && isa(FunctionScopes[I]);
CurDC = getLambdaAwareParentOfDeclContext(CurDC)) {
 CurLSI = cast(FunctionScopes[I]);
-
-if (!CurLSI->isCXXThisCaptured()) 
+
+if (!CurLSI->isCXXThisCaptured())
 continue;
-  
+
 auto C = CurLSI->getCXXThisCapture();
 
 if (C.isCopyCapture()) {
@@ -922,7 +922,7 @@
 assert(CurLSI);
 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator));
 assert(CurDC == getLambdaAwareParentOfDeclContext(CurLSI->CallOperator));
-
+
 auto IsThisCaptured =
 [](CXXRecordDecl *Closure, bool &IsByCopy, bool &IsConst) {
   IsConst = false;
@@ -992,10 +992,10 @@
   return ThisTy;
 }
 
-Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S, 
+Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S,
  Decl *ContextDecl,
  unsigned CXXThisTypeQuals,
- bool Enabled) 
+ bool Enabled)
   : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(false)
 {
   if (!Enabled || !ContextDecl)
@@ -1006,13 +1006,13 @@
 Record = Template->getTemplatedDecl();
   else
 Record = cast(ContextDecl);
-
+
   // We care only for CVR qualifiers here, so cut everything else.
   CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
-  
+
   this->Enabled = true;
 }
 
@@ -1026,7 +1026,7 @@
 static Expr *captureThis(Sema &S, ASTContext &Context, RecordDecl *RD,
  QualType ThisTy, SourceLocation Loc,
  const bool ByCopy) {
- 
+
   QualType AdjustedThisTy = ThisTy;
   // The type of the corresponding data member (not a 'this' pointer if 'by
   // copy').
@@ -1039,7 +1039,7 @@
 CaptureThisFieldTy.removeLocalCVRQualifiers(Qualifiers::CVRMask);
 AdjustedThisTy = Context.getPointerType(CaptureThisFieldTy);
   }
-  
+
   FieldDecl *Field = FieldDecl::Create(
   Context, RD, Loc, Loc, nullptr, CaptureThisFieldTy,
   Context.getTrivialTypeSourceInfo(CaptureThisFieldTy, Loc), nullptr, false,
@@ -1065,41 +1065,41 @@
   return This;
 }
 

Re: [PATCH] D23765: Fix for clang PR 29087

2016-09-16 Thread Taewook Oh via cfe-commits
twoh added a comment.

@rsmith Thank you for your review! I added tests to cxx11-crashes.cpp, as the 
goal of this patch is not handling __has_* traits right but preventing ICE. 
Also, I tried to use ConstructorUsingShadowDecl::getConstructor instead of 
ConstructorUsingShadowDecl::getTargetDecl followed by casting, but clang build 
was failed with undefined references. I wonder if the definition of 
ConstructorUsingShadowDecl::getConstructor is missed in 
https://reviews.llvm.org/rL274049.


https://reviews.llvm.org/D23765



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


[libclc] r281792 - amdgcn-amdhsa: Add get_num_groups implementation

2016-09-16 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Sep 16 17:43:31 2016
New Revision: 281792

URL: http://llvm.org/viewvc/llvm-project?rev=281792&view=rev
Log:
amdgcn-amdhsa: Add get_num_groups implementation

Added:
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_num_groups.cl
Modified:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/amdgcn-amdhsa/lib/SOURCES

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=281792&r1=281791&r2=281792&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES Fri Sep 16 17:43:31 2016
@@ -0,0 +1 @@
+workitem/get_num_groups.ll

Modified: libclc/trunk/amdgcn-amdhsa/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES?rev=281792&r1=281791&r2=281792&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES Fri Sep 16 17:43:31 2016
@@ -1,2 +1,3 @@
 workitem/get_global_size.ll
 workitem/get_local_size.ll
+workitem/get_num_groups.cl

Added: libclc/trunk/amdgcn-amdhsa/lib/workitem/get_num_groups.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/workitem/get_num_groups.cl?rev=281792&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/workitem/get_num_groups.cl (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/workitem/get_num_groups.cl Fri Sep 16 
17:43:31 2016
@@ -0,0 +1,12 @@
+
+#include 
+
+_CLC_DEF size_t get_num_groups(uint dim) {
+  size_t global_size = get_global_size(dim);
+  size_t local_size = get_local_size(dim);
+  size_t num_groups = global_size / local_size;
+  if (global_size % local_size != 0) {
+num_groups++;
+  }
+  return num_groups;
+}


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


[libclc] r281791 - amdgcn-amdhsa: Add get_global_size() implementation

2016-09-16 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Sep 16 17:43:29 2016
New Revision: 281791

URL: http://llvm.org/viewvc/llvm-project?rev=281791&view=rev
Log:
amdgcn-amdhsa: Add get_global_size() implementation

Added:
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll
Modified:
libclc/trunk/amdgcn-amdhsa/lib/SOURCES

Modified: libclc/trunk/amdgcn-amdhsa/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES?rev=281791&r1=281790&r2=281791&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES Fri Sep 16 17:43:29 2016
@@ -1 +1,2 @@
+workitem/get_global_size.ll
 workitem/get_local_size.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll?rev=281791&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.ll Fri Sep 16 
17:43:29 2016
@@ -0,0 +1,39 @@
+declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #0
+
+define i64 @get_global_size(i32 %dim) #1 {
+  %dispatch_ptr = call noalias nonnull dereferenceable(64) i8 addrspace(2)* 
@llvm.amdgcn.dispatch.ptr()
+  switch i32 %dim, label %default [
+i32 0, label %x
+i32 1, label %y
+i32 2, label %z
+  ]
+
+x:
+  %ptr_x = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 12
+  %ptr_x32 = bitcast i8 addrspace(2)* %ptr_x to i32 addrspace(2)*
+  %x32 = load i32, i32 addrspace(2)* %ptr_x32, align 4, !invariant.load !0
+  %size_x = zext i32 %x32 to i64
+  ret i64 %size_x
+
+y:
+  %ptr_y = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 16
+  %ptr_y32 = bitcast i8 addrspace(2)* %ptr_y to i32 addrspace(2)*
+  %y32 = load i32, i32 addrspace(2)* %ptr_y32, align 4, !invariant.load !0
+  %size_y = zext i32 %y32 to i64
+  ret i64 %size_y
+
+z:
+  %ptr_z = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i64 20
+  %ptr_z32 = bitcast i8 addrspace(2)* %ptr_z to i32 addrspace(2)*
+  %z32 = load i32, i32 addrspace(2)* %ptr_z32, align 4, !invariant.load !0
+  %size_z = zext i32 %z32 to i64
+  ret i64 %size_z
+
+default:
+  ret i64 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}


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


[libclc] r281793 - configure: Add amdgcn-mesa-mesa3d target

2016-09-16 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Sep 16 17:43:33 2016
New Revision: 281793

URL: http://llvm.org/viewvc/llvm-project?rev=281793&view=rev
Log:
configure: Add amdgcn-mesa-mesa3d target

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=281793&r1=281792&r2=281793&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Fri Sep 16 17:43:33 2016
@@ -105,7 +105,9 @@ available_targets = {
   'nvptx64--nvidiacl' : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
 }
 
-default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 
'amdgcn--', 'amdgcn--amdhsa']
+available_targets['amdgcn-mesa-mesa3d'] = available_targets['amdgcn--']
+
+default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 
'amdgcn--', 'amdgcn--amdhsa', 'amdgcn-mesa-mesa3d']
 
 targets = args
 if not targets:
@@ -167,6 +169,8 @@ for target in targets:
   for arch in archs:
 subdirs.append("%s-%s-%s" % (arch, t_vendor, t_os))
 subdirs.append("%s-%s" % (arch, t_os))
+if t_os == 'mesa3d':
+subdirs.append('amdgcn-amdhsa')
 subdirs.append(arch)
 if arch == 'amdgcn' or arch == 'r600':
 subdirs.append('amdgpu')


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


r281796 - Add REQUIRES line.

2016-09-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Sep 16 17:56:12 2016
New Revision: 281796

URL: http://llvm.org/viewvc/llvm-project?rev=281796&view=rev
Log:
Add REQUIRES line.

Modified:
cfe/trunk/test/CodeGen/nobuiltin.c

Modified: cfe/trunk/test/CodeGen/nobuiltin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nobuiltin.c?rev=281796&r1=281795&r2=281796&view=diff
==
--- cfe/trunk/test/CodeGen/nobuiltin.c (original)
+++ cfe/trunk/test/CodeGen/nobuiltin.c Fri Sep 16 17:56:12 2016
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -S -o - %s | FileCheck 
-check-prefix=STRCPY -check-prefix=MEMSET %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | 
FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s 
| FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s


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


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

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

I do not have any more comments; however, let's wait for @NoQ to review this as 
well.
Thanks!


https://reviews.llvm.org/D24307



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


  1   2   >