[PATCH] D26452: Make output of -ast-print a valid C++ code.

2016-11-10 Thread Serge Pavlov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286439: Make output of -ast-print a valid C++ code. 
(authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D26452?vs=77354&id=77452#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26452

Files:
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/Analysis/cfg.cpp
  cfe/trunk/test/Coverage/ast-print-func.cpp
  cfe/trunk/test/Coverage/ast-print-temp-class.cpp
  cfe/trunk/test/Coverage/ast-print-temp-func.cpp
  cfe/trunk/test/Coverage/ast-printing.cpp
  cfe/trunk/test/Index/comment-cplus-decls.cpp
  cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
  cfe/trunk/test/Misc/ast-dump-templates.cpp
  cfe/trunk/test/OpenMP/atomic_ast_print.cpp
  cfe/trunk/test/OpenMP/barrier_ast_print.cpp
  cfe/trunk/test/OpenMP/critical_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/flush_ast_print.cpp
  cfe/trunk/test/OpenMP/for_ast_print.cpp
  cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/ordered_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp
  cfe/trunk/test/OpenMP/sections_ast_print.cpp
  cfe/trunk/test/OpenMP/simd_ast_print.cpp
  cfe/trunk/test/OpenMP/single_ast_print.cpp
  cfe/trunk/test/OpenMP/target_ast_print.cpp
  cfe/trunk/test/OpenMP/target_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/target_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/target_update_ast_print.cpp
  cfe/trunk/test/OpenMP/task_ast_print.cpp
  cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
  cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/taskwait_ast_print.cpp
  cfe/trunk/test/OpenMP/taskyield_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp
  cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
  cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp
  cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp
  cfe/trunk/unittests/AST/ASTTypeTraitsTest.cpp
  cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -78,6 +78,10 @@
 void VisitTemplateDecl(const TemplateDecl *D);
 void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
+void VisitClassTemplateSpecializationDecl(
+ClassTemplateSpecializationDecl *D);
+void VisitClassTemplatePartialSpecializationDecl(
+ ClassTemplatePartialSpecializationDecl *D);
 void VisitObjCMethodDecl(ObjCMethodDecl *D);
 void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
 void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
@@ -95,8 +99,9 @@
 void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
 void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
 
-void PrintTemplateParameters(const TemplateParameterList *Params,
- const TemplateArgumentList *Args = nullptr);
+void printTemplateParameters(const TemplateParameterList *Params);
+void printTemplateArguments(const TemplateArgumentList &Args,
+const TemplateParameterList *Params = nullptr);
 void prettyPrintAttributes(Decl *D);
 void prettyPrintPragmas(Decl *D);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
@@ -290,6 +295,13 @@
 if (D->isImplicit())
   continue;
 
+// Don't print implicit specializations, as they are printed when visiting
+// corresponding templates.
+if (auto FD = dyn_cast(*D))
+  if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation &&
+  !isa(DC))
+continue;
+
 // The next bits of code handles stuff like "struct {int x;} a,b"; we're
 // forced to merge the declarations because t

Re: [PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

2016-11-10 Thread Serge Pavlov via cfe-commits
I don't see any reason why we should adhere particular solution. If you can
solve the problem with another approach, please go forward.

Thanks,
--Serge

2016-11-10 10:12 GMT+07:00 Akira Hatanaka :

> ahatanak added a comment.
>
> Do you think we can transform the Exprs for the uninstantiated default
> arguments in TreeTransform::TransformLambdaExpr? I guess it
> would be much simpler than trying to make getTemplateInstantiationArgs
> return the correct template arguments.
>
>
> https://reviews.llvm.org/D23096
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

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

Store new option.


https://reviews.llvm.org/D26453

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/modernize-pass-by-value.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,4 +1,7 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \
+// RUN: -- -std=c++11 -isystem %S/Inputs/Headers
 
 #include 
 
@@ -28,8 +31,8 @@
   D() : B() {}
   D(const D &RHS) : B(RHS) {}
   // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
-  // CHECK-MESSAGES: 23:3: note: copy constructor being called
-  // CHECK-MESSAGES: 24:3: note: candidate move constructor here
+  // CHECK-MESSAGES: 26:3: note: copy constructor being called
+  // CHECK-MESSAGES: 27:3: note: candidate move constructor here
   D(D &&RHS) : B(RHS) {}
 };
 
@@ -96,7 +99,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
@@ -121,6 +124,7 @@
 };
 
 struct NegativeNotPassedByValue {
+  // This const ref constructor isn't warned about because the ValuesOnly option is set.
   NegativeNotPassedByValue(const Movable &M) : M_(M) {}
   NegativeNotPassedByValue(const Movable M) : M_(M) {}
   NegativeNotPassedByValue(Movable &M) : M_(M) {}
Index: docs/clang-tidy/checks/modernize-pass-by-value.rst
===
--- docs/clang-tidy/checks/modernize-pass-by-value.rst
+++ docs/clang-tidy/checks/modernize-pass-by-value.rst
@@ -159,3 +159,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: ValuesOnly
+
+   When non-zero, the check only warns about copied parameters that are already
+   passed by value. Default is `0`.
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -9,20 +9,10 @@
 initializing a member or base class through a copy constructor instead of a
 move constructor.
 
-It also flags constructor arguments that are passed by value, have a non-deleted
-move-constructor and are assigned to a class field by copy construction.
-
 Options
 ---
 
 .. option:: IncludeStyle
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
-
-.. option:: UseCERTSemantics
-
-   When non-zero, the check conforms to the behavior expected by the CERT secure
-   coding recommendation
-   `OOP11-CPP `_.
-   Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp.
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -75,7 +75,7 @@
 
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
-  //misc-move-constructor-init which will suggest to move the argument.
+  //modernize-pass-by-value which will suggest to move the argument.
   if (!IsConstQualified && (llvm::isa(Function) ||
 !Function->doesThisDeclarationHaveABody()))
 return;
Index: clang-tidy/modernize/PassByValueCheck.h
===
--- clang-tidy/modernize/PassByValueCheck.h
+++ clang-tidy/modernize/PassByValueCheck.h
@@ -30,6 +30,7 @@
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
+  const bool ValuesOnly;
 };
 
 } // namespace modernize
Index: clan

Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-10 Thread Malcolm Parsons via cfe-commits
On 9 November 2016 at 18:50, Devin Coughlin  wrote:

> We agree that this is a valuable checker and are committed to getting it out 
> of alpha. This check is in alpha because:
>
> a) The diagnostic experience is not very good. It reports a call path 
> directly in the diagnostic message (for example “Call path: foo <— bar” for a 
> call to foo() in bar()) rather than as a path diagnostic.

Agreed.

> b) The lack of path-sensitive reasoning may result in false positives when a 
> called function uses a member variable flag to track whether initialization 
> is complete and does not call the virtual member function during 
> initialization.

Right, we're not doing this.

> c) The check issues a warning for both calls to pure virtual functions (which 
> is always an error) and non-pure virtual functions (which is more of a code 
> smell and may be a false positive).

I'm using static analysis to find code smells.

> I’ll commit to doing Step 1) in the immediate future and Step 2) eventually. 
> Once the checker is on by default we’ll need to assess whether the false 
> positive rate from c) is too high — if so, we’ll need to turn the 
> non-pure-virtual case off by default.

LGTM.

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


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-10 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/google/GlobalNamesCheck.cpp:96
+// main() should be in the global namespace.
+if (FDecl->isMain())
+  return;

Should `isMSVCRTEntryPoint()` be checked too?


https://reviews.llvm.org/D23130



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-10 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D26406#590741, @kastiglione wrote:

> Thanks @arphaman, are you able to commit this?


Yes, I can commit this for you. Let me know what commit message I should use.


https://reviews.llvm.org/D26406



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


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

2016-11-10 Thread Sven van Haastregt via cfe-commits
svenvh added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:3431
+.getSupportedOpenCLOpts()
+.cl_khr_fp64) ||
getOpenCLOptions().cl_khr_fp64)) {

yaxunl wrote:
> neil.hickey wrote:
> > yaxunl wrote:
> > > This check 
> > >   (getLangOpts().OpenCLVersion >= 120 &&
> > > Context.getTargetInfo()
> > > .getSupportedOpenCLOpts()
> > > .cl_khr_fp64)
> > > 
> > > is redundant since for CL 1.2 and above getOpenCLOptions().cl_khr_fp64 is 
> > > set to be true by default.
> > This is get**Supported**OpenCLOpts(). Some hardware may not support doubles
> In Sema::Initialize(), there is code to initialize enabled extensions:
> 
> ```
>   // Initialize predefined OpenCL types and supported optional core features.
>   if (getLangOpts().OpenCL) {
> #define OPENCLEXT(Ext) \
>  if 
> (Context.getTargetInfo().getSupportedOpenCLOpts().is_##Ext##_supported_core( \
>  getLangOpts().OpenCLVersion)) \
>getOpenCLOptions().Ext = 1;
> #include "clang/Basic/OpenCLExtensions.def"
> 
> ```
> `is_##Ext##_supported_core` accounts for two factors: 1. whether the target 
> supports the extension; 2. whether the extension has become OpenCL core 
> featrue.
> 
> Since getOpenCLOptions().cl_khr_fp64 is initialized with the same value as in 
> the mentioned check, the check is redundant.
Your new patch no longer does version checks, so there is no need to mention it 
in the comments anymore I'd say.


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] D26415: [XRay] Support AArch64 in Clang

2016-11-10 Thread Serge Rogatch via cfe-commits
rSerge added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

dberris wrote:
> rSerge wrote:
> > dberris wrote:
> > > I'm wondering whether it's worth turning this into a `switch` statement 
> > > now that we have more than two supported architectures?
> > I think that would lead to more awkward code: there wouldn't be a single 
> > decision outcome point (like the current `else` block), so to avoid 
> > duplicating the code which currently prints the message, a `bool` variable 
> > would be needed. I think it's more neat to just enumerate all the OS&CPU 
> > combinations in the `if` condition for now.
> > This place is not performance-critical and the compiler should convert 
> > appropriate `if`s into `switch`es anyway.
> This is an issue of making it more readable, something like:
> 
> ```
> if (Triple.getOS() != llvm::Triple::Linux)
>   D.Diag(...) << ...; // Unsupported OS.
> switch (Triple.getArch()) {
>   case llvm::Triple::arm:
>   case llvm::Triple::x86_64:
>   case llvm::Tripe::aarch64:
> // Supported.
> break;
>   default:
> D.Diag(...) << ...;
> }
> ```
> 
> This way any new architectures become supported, they just get added to the 
> list of cases that short-circuit.
We can't say that an OS is supported or unsupported unless all CPU 
architectures for this OS support or don't support XRay, and this is not going 
to happen in the near future. So it is more accurate to say about the triple: 
some triples are supported and some are not. So in coding it is natural to 
check for the triple with `||` and `&&`.


https://reviews.llvm.org/D26415



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


[PATCH] D25985: [analyzer] Export coverage information from the analyzer.

2016-11-10 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:262
+
+static void dumpCoverageInfo(llvm::SmallVectorImpl &Path,
+ SourceManager &SM) {

zaks.anna wrote:
> xazax.hun wrote:
> > zaks.anna wrote:
> > > Can this be a debug checker?
> > You mean the dumping part or also collecting the coverage? It can be a 
> > debug checker if we add a new callback like "checkBasicBlockBegin". I did 
> > not want to add such callback just for a debug check. However, it is 
> > possible to move only the dumping part to a separate checker. What would 
> > you prefer?
> I would prefer to add a "checkBasicBlockBegin" callback and move all of this 
> diagnostic code into a debug checker. 
Do you think the checkers should be able to add state transitions from 
BeginBasicBlock callback? Would you prefer to have an EndBasicBlock callback 
for symmetry?


https://reviews.llvm.org/D25985



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


[PATCH] D26415: [XRay] Support AArch64 in Clang

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



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

rSerge wrote:
> dberris wrote:
> > rSerge wrote:
> > > dberris wrote:
> > > > I'm wondering whether it's worth turning this into a `switch` statement 
> > > > now that we have more than two supported architectures?
> > > I think that would lead to more awkward code: there wouldn't be a single 
> > > decision outcome point (like the current `else` block), so to avoid 
> > > duplicating the code which currently prints the message, a `bool` 
> > > variable would be needed. I think it's more neat to just enumerate all 
> > > the OS&CPU combinations in the `if` condition for now.
> > > This place is not performance-critical and the compiler should convert 
> > > appropriate `if`s into `switch`es anyway.
> > This is an issue of making it more readable, something like:
> > 
> > ```
> > if (Triple.getOS() != llvm::Triple::Linux)
> >   D.Diag(...) << ...; // Unsupported OS.
> > switch (Triple.getArch()) {
> >   case llvm::Triple::arm:
> >   case llvm::Triple::x86_64:
> >   case llvm::Tripe::aarch64:
> > // Supported.
> > break;
> >   default:
> > D.Diag(...) << ...;
> > }
> > ```
> > 
> > This way any new architectures become supported, they just get added to the 
> > list of cases that short-circuit.
> We can't say that an OS is supported or unsupported unless all CPU 
> architectures for this OS support or don't support XRay, and this is not 
> going to happen in the near future. So it is more accurate to say about the 
> triple: some triples are supported and some are not. So in coding it is 
> natural to check for the triple with `||` and `&&`.
> We can't say that an OS is supported or unsupported unless all CPU 
> architectures for this OS support or don't support XRay, and this is not 
> going to happen in the near future.

I don't get it. Right now, as written, it doesn't matter what OS it is -- any 
OS other than Linux wouldn't be supported anyway. Maybe I mis-wrote, but:

```
if (Triple.getOS() != llvm::Triple::Linux)
  D.Diag(...) << ...;
else switch(Triple.getArch()) {
  ...
  default:
D.Diag(...) << ...;
}
```

Is a direct translation that's more readable than the current complex if 
statement conditional.

> So it is more accurate to say about the triple: some triples are supported 
> and some are not. So in coding it is natural to check for the triple with || 
> and &&.

Sure, but conditional is already unwieldy with just three supported platforms.


https://reviews.llvm.org/D26415



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


[clang-tools-extra] r286449 - Fix -Wdocumentation warning

2016-11-10 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Nov 10 07:54:39 2016
New Revision: 286449

URL: http://llvm.org/viewvc/llvm-project?rev=286449&view=rev
Log:
Fix -Wdocumentation warning

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.h

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=286449&r1=286448&r2=286449&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Thu Nov 10 07:54:39 2016
@@ -72,7 +72,7 @@ public:
   /// \param SearchPath The search path which was used to find the 
IncludeHeader
   /// in the file system. It can be a relative path or an absolute path.
   /// \param FileName The name of file where the IncludeHeader comes from.
-  /// \param IncludeRange The source range for the written file name in 
#include
+  /// \param IncludeFilenameRange The source range for the written file name 
in #include
   ///  (i.e. "old.h" for #include "old.h") in old.cc.
   /// \param SM The SourceManager.
   void addIncludes(llvm::StringRef IncludeHeader, bool IsAngled,


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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-10 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423
+
+void IteratorPastEndChecker::handleComparison(CheckerContext &C,
+  const SVal &LVal,

baloghadamsoftware wrote:
> NoQ wrote:
> > baloghadamsoftware wrote:
> > > NoQ wrote:
> > > > a.sidorin wrote:
> > > > > What will happen if we write something like this:
> > > > > ```
> > > > > bool Eq1 = it1 == it2;
> > > > > bool Eq2 = it3 == it4;
> > > > > if (Eq1) {...}?
> > > > > ```
> > > > > 
> > > > > As I understand, we'll assume the second condition instead of first.
> > > > Had a look. So the problem is, we obtain the result of the comparison 
> > > > as a symbol, from which it is too hard to recover the operands in order 
> > > > to move iterator position data from one value to another.
> > > > 
> > > > Normally we obtain a simple SymbolConjured for the return value of the 
> > > > `operator==()` call (or, similarly, `operator!=()`). For plain-value 
> > > > iterators (eg. `typedef T *iterator`) we might be obtaining an actual 
> > > > binary symbolic expression, but even then it's not quite clear how to 
> > > > obtain operands (the structure of the expression might have changed due 
> > > > to algebraic simplifications). Additionally, LHS and RHS aren't 
> > > > necessarily symbols (they might be semi-concrete), so composing 
> > > > symbolic expressions from them in general is problematic with our 
> > > > symbol hierarchy, which is rarely a problem for numbers but for 
> > > > structural symbols it'd be a mess.
> > > > 
> > > > For now i suggest, instead of storing only the last LHS and RHS, to 
> > > > save a map from symbols (which are results of comparisons) to (LHS 
> > > > value, RHS value) pairs. This map should, apart from the obvious, be 
> > > > cleaned up whenever one of the iterators in the pair gets mutated 
> > > > (incremented or decremented). This should take care of the problem 
> > > > Alexey points out, and should work with semi-concrete stuff.
> > > > 
> > > > For the future i suggest to let users construct their own symbols and 
> > > > symbolic expressions more easily. In fact, if only we had all iterators 
> > > > as regions, we should have probably used SymbolMetadata for this 
> > > > purpose: it's easy to both recover the parent region from it and use it 
> > > > in symbolic expressions. We could also deprecate the confusing 
> > > > structural symbols (provide default-bound lazy compound values for 
> > > > conjured structures instead), and then it'd be possible to transition 
> > > > to SymbolMetadata entirely.
> > > Thank you for the suggestion. I am not sure if I fully understand you. If 
> > > I create a map where the key is the resulting symbol of the comparison, 
> > > it will not work because evalAssume is called for the innermost 
> > > comparison. So if the body of operator== (or operator!=) is inlined, then 
> > > I get a binary symbolic expression in evalAssume, not the SymbolConjured. 
> > > This binary Symbolic expression is a comparison of the internals of the 
> > > iterators, e.g. the internal pointer. So the key will not match any LHS 
> > > and RHS value pair in the map. I also thought on such solution earlier 
> > > but I dismissed it because of this.
> > Well, even if the body of the comparison operator is inlined, 
> > PreStmt/PostStmt callbacks should still work, and it doesn't really matter 
> > if there's a `SymbolConjured` or not, we can still add the symbolic 
> > expression to our map as a key.
> > 
> > Essentially, you ignore whatever happens in the iterator's operator==() 
> > when it's inlined (including any evalAssume events), then in PostStmt of 
> > operator==() you map the return-value symbol of the operator to the 
> > operator's arguments (operands), then whenever an assumption is being made 
> > against the return-value symbol, you carry over this assumption to the 
> > operands. I think it shouldn't really matter if the operator call was 
> > inlined.
> > 
> > The only unexpected thing that may happen due to inlining is if the inlined 
> > operator returns a concrete value (plain true or plain false) instead of 
> > the symbol, but in this case what we need to do is to just carry over the 
> > assumption to the operands instantly.
> Maybe if I evaluate the operator==() call for iterators using evalCall()?
Sorry, maybe my phrasing was not accurate enough. The problem is that the 
assumption is not being made against the return-value symbol of the 
operator==(), but if inlined, against the internal == operator. So I do not 
have the same key in evalAssume() thus I cannot access the operands from the 
map I stored in checkPostCall(). The only solution I can imagine is that I 
evalCall() the operator==() but then we lose the opportunity to check anything 
inside the body of the operator.


https://reviews.llvm.org/D25660



__

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-10 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:204
+  CheckerContext &C) const {
+  const auto *ThisExpr = COCE->getArg(0);
+

NoQ wrote:
> This code definitely deserves comments. I managed to understand that this is 
> a workaround for completely replacing the conjured symbol with a lazy value 
> upon calling a method over temporary, which the core does from time to time, 
> and i suspect that this code may break whenever more than one checker starts 
> doing this (i.e. you'd have to skip more than one predecessor node in this 
> case).
> 
> I still think that the root cause here is conjured structural symbols which 
> i'd probably prefer to get rid of completely, and then this hack wouldn't be 
> necessary.
I think I do not fully understand you here: do you mean some fix in the core?


https://reviews.llvm.org/D25660



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


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/google-global-names.cpp:13-14
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global 
namespace
+extern int ii = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global 
namespace
+

bkramer wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > bkramer wrote:
> > > > aaron.ballman wrote:
> > > > > This strikes me as being intentional enough to warrant not diagnosing 
> > > > > because of the `extern` keyword.
> > > > The only case I see where this pattern is valuable is interfacing with 
> > > > C code. Not sure yet if we want to allow that or enforce extern "C" 
> > > > instead. Ideas?
> > > > 
> > > > an extern global in the global namespace still feels like something we 
> > > > should warn on :|
> > > Yet externs in the global namespace do happen for valid reasons (such as 
> > > not breaking ABIs by putting the extern definition into a namespace or 
> > > changing the language linkage) -- I'm trying to think of ways we can 
> > > allow the user to silence this diagnostic in those cases. I feel like in 
> > > cases where the user writes "extern", they're explicitly specifying their 
> > > intent and that doesn't seem like a case to warn them about, in some 
> > > regards. It would give us two ways to silence the diagnostic (well, 
> > > three, but two are morally close enough):
> > > 
> > > 1) Put it into a namespace
> > > 2) Slap `extern` on it if it is global for C++ compatibility (such as 
> > > ABIs)
> > > 3) Slap `extern "C"` on it if it global for C compatibility
> > > 
> > > I suppose we could require `extern "C++"` instead of `extern`, but I 
> > > don't think that's a particularly common use of the language linkage 
> > > specifier?
> > I still think that a user explicitly writing 'extern' is expecting external 
> > linkage and all that goes along with it.
> I disagree. If this is a special variable to be accessed via dlopen it should 
> be extern "C". If not it should be in a namespace.
I'm thinking more that it's not a special variable to be accessed via dlopen, 
but instead is a special implementation detail that doesn't need to be exposed 
via a header file. For instance, see ClangTidyMain.cpp. Such uses have no way 
to silence this check, which may be fine since it's in the Google module. I 
merely wanted to point it out because it does happen for valid reasons, and 
having a way to silence a diagnostic aside from NOLINT is nice.


https://reviews.llvm.org/D23130



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


r286455 - [PowerPC] Implement plain VSX load/store builtins.

2016-11-10 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Thu Nov 10 08:39:56 2016
New Revision: 286455

URL: http://llvm.org/viewvc/llvm-project?rev=286455&view=rev
Log:
[PowerPC] Implement plain VSX load/store builtins.

Implement all the different 24 overloads for vec_xl and vec_xst.

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-quadword.c
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=286455&r1=286454&r2=286455&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Thu Nov 10 08:39:56 2016
@@ -15606,6 +15606,150 @@ vec_revb(vector unsigned __int128 __a) {
 }
 #endif /* END __POWER8_VECTOR__ && __powerpc64__ */
 
+
+/* vec_xl */
+
+static inline __ATTRS_o_ai vector signed char vec_xl(signed long long __offset,
+ signed char *__ptr) {
+  return *(vector signed char *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector unsigned char
+vec_xl(signed long long __offset, unsigned char *__ptr) {
+  return *(vector unsigned char *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector signed short vec_xl(signed long long 
__offset,
+  signed short *__ptr) {
+  return *(vector signed short *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector unsigned short
+vec_xl(signed long long __offset, unsigned short *__ptr) {
+  return *(vector unsigned short *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector signed int vec_xl(signed long long __offset,
+signed int *__ptr) {
+  return *(vector signed int *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector unsigned int vec_xl(signed long long 
__offset,
+  unsigned int *__ptr) {
+  return *(vector unsigned int *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector float vec_xl(signed long long __offset,
+   float *__ptr) {
+  return *(vector float *)(__ptr + __offset);
+}
+
+#ifdef __VSX__
+static inline __ATTRS_o_ai vector signed long long
+vec_xl(signed long long __offset, signed long long *__ptr) {
+  return *(vector signed long long *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector unsigned long long
+vec_xl(signed long long __offset, unsigned long long *__ptr) {
+  return *(vector unsigned long long *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector double vec_xl(signed long long __offset,
+double *__ptr) {
+  return *(vector double *)(__ptr + __offset);
+}
+#endif
+
+#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+static inline __ATTRS_o_ai vector signed __int128
+vec_xl(signed long long __offset, signed __int128 *__ptr) {
+  return *(vector signed __int128 *)(__ptr + __offset);
+}
+
+static inline __ATTRS_o_ai vector unsigned __int128
+vec_xl(signed long long __offset, unsigned __int128 *__ptr) {
+  return *(vector unsigned __int128 *)(__ptr + __offset);
+}
+#endif
+
+/* vec_xst */
+
+static inline __ATTRS_o_ai void vec_xst(vector signed char __vec,
+signed long long __offset,
+signed char *__ptr) {
+  *(vector signed char *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector unsigned char __vec,
+signed long long __offset,
+unsigned char *__ptr) {
+  *(vector unsigned char *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector signed short __vec,
+signed long long __offset,
+signed short *__ptr) {
+  *(vector signed short *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
+signed long long __offset,
+unsigned short *__ptr) {
+  *(vector unsigned short *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector signed int __vec,
+signed long long __offset,
+signed int *__ptr) {
+  *(vector signed int *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector unsigned int __vec,
+signed long long __offset,
+unsigned int *__ptr) {
+  *(vector unsigned int *)(__ptr + __offset) = __vec;
+}
+
+static inline __ATTRS_o_ai void vec_xst(vector float __vec,
+ 

[PATCH] D26459: Fix mismatched enum value name and diagnostic text.

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for this!


https://reviews.llvm.org/D26459



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


[PATCH] D25764: Add end location of loop to loop metadata.

2016-11-10 Thread Amara Emerson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286456: Add the loop end location to the loop metadata. This 
additional information (authored by aemerson).

Changed prior to commit:
  https://reviews.llvm.org/D25764?vs=77317&id=77478#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25764

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
  cfe/trunk/lib/CodeGen/CGLoopInfo.h
  cfe/trunk/lib/CodeGen/CGStmt.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-loops.cpp

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -320,6 +320,9 @@
   /// ignored.
   void setLocation(SourceLocation Loc);
 
+  // Converts a SourceLocation to a DebugLoc
+  llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc);
+
   /// Emit metadata to indicate a change in line/column information in
   /// the source file. If the location is invalid, the previous
   /// location will be reused.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -2080,3 +2080,10 @@
   IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
   CGM.getSanStats().create(IRB, SSK);
 }
+
+llvm::DebugLoc CodeGenFunction::SourceLocToDebugLoc(SourceLocation Location) {
+  if (CGDebugInfo *DI = getDebugInfo())
+return DI->SourceLocToDebugLoc(Location);
+
+  return llvm::DebugLoc();
+}
Index: cfe/trunk/lib/CodeGen/CGLoopInfo.h
===
--- cfe/trunk/lib/CodeGen/CGLoopInfo.h
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.h
@@ -67,7 +67,7 @@
 public:
   /// \brief Construct a new LoopInfo for the loop with entry Header.
   LoopInfo(llvm::BasicBlock *Header, const LoopAttributes &Attrs,
-   llvm::DebugLoc Location);
+   llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc);
 
   /// \brief Get the loop id metadata for this loop.
   llvm::MDNode *getLoopID() const { return LoopID; }
@@ -99,14 +99,14 @@
 
   /// \brief Begin a new structured loop. The set of staged attributes will be
   /// applied to the loop and then cleared.
-  void push(llvm::BasicBlock *Header,
-llvm::DebugLoc Location = llvm::DebugLoc());
+  void push(llvm::BasicBlock *Header, llvm::DebugLoc StartLoc,
+llvm::DebugLoc EndLoc);
 
   /// \brief Begin a new structured loop. Stage attributes from the Attrs list.
   /// The staged attributes are applied to the loop and then cleared.
   void push(llvm::BasicBlock *Header, clang::ASTContext &Ctx,
-llvm::ArrayRef Attrs,
-llvm::DebugLoc Location = llvm::DebugLoc());
+llvm::ArrayRef Attrs, llvm::DebugLoc StartLoc,
+llvm::DebugLoc EndLoc);
 
   /// \brief End the current loop.
   void pop();
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -2113,6 +2113,10 @@
   OffsetValue);
   }
 
+  /// Converts Location to a DebugLoc, if debug information is enabled.
+  llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
+
+
   //======//
   //Declaration Emission
   //======//
Index: cfe/trunk/lib/CodeGen/CGStmt.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmt.cpp
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp
@@ -663,8 +663,10 @@
   JumpDest LoopHeader = getJumpDestInCurrentScope("while.cond");
   EmitBlock(LoopHeader.getBlock());
 
+  const SourceRange &R = S.getSourceRange();
   LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), WhileAttrs,
- Builder.getCurrentDebugLocation());
+ SourceLocToDebugLoc(R.getBegin()),
+ SourceLocToDebugLoc(R.getEnd()));
 
   // Create an exit block for when the condition fails, which will
   // also become the break target.
@@ -755,8 +757,10 @@
   // Emit the body of the loop.
   llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
 
+  const SourceRange &R = S.getSourceRange();
   LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
- Builder.getCurrentDebugLocation());
+ SourceLocToDebugLoc(R.getBegin()),
+ SourceLocToDebugLoc(R.getEnd()));
 
   EmitBlockWithFallThrough(LoopBody, &S);
   {
@@ -808,8 +812,

r286456 - Add the loop end location to the loop metadata. This additional information

2016-11-10 Thread Amara Emerson via cfe-commits
Author: aemerson
Date: Thu Nov 10 08:44:30 2016
New Revision: 286456

URL: http://llvm.org/viewvc/llvm-project?rev=286456&view=rev
Log:
Add the loop end location to the loop metadata. This additional information
can be used to improve the locations when generating remarks for loops.

Depends on the companion LLVM change r286227.

Patch by Florian Hahn.

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


Added:
cfe/trunk/test/CodeGenCXX/debug-info-loops.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGLoopInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenCXX/debug-info-line-if.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=286456&r1=286455&r2=286456&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov 10 08:44:30 2016
@@ -3924,3 +3924,12 @@ void CGDebugInfo::EmitExplicitCastType(Q
 // Don't ignore in case of explicit cast where it is referenced indirectly.
 DBuilder.retainType(DieTy);
 }
+
+llvm::DebugLoc CGDebugInfo::SourceLocToDebugLoc(SourceLocation Loc) {
+  if (LexicalBlockStack.empty())
+return llvm::DebugLoc();
+
+  llvm::MDNode *Scope = LexicalBlockStack.back();
+  return llvm::DebugLoc::get(
+  getLineNumber(Loc), getColumnNumber(Loc), Scope);
+}

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=286456&r1=286455&r2=286456&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Nov 10 08:44:30 2016
@@ -320,6 +320,9 @@ public:
   /// ignored.
   void setLocation(SourceLocation Loc);
 
+  // Converts a SourceLocation to a DebugLoc
+  llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Loc);
+
   /// Emit metadata to indicate a change in line/column information in
   /// the source file. If the location is invalid, the previous
   /// location will be reused.

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=286456&r1=286455&r2=286456&view=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Thu Nov 10 08:44:30 2016
@@ -20,14 +20,14 @@ using namespace clang::CodeGen;
 using namespace llvm;
 
 static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs,
-  llvm::DebugLoc Location) {
+  llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc) {
 
   if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 &&
   Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 &&
   Attrs.VectorizeEnable == LoopAttributes::Unspecified &&
   Attrs.UnrollEnable == LoopAttributes::Unspecified &&
   Attrs.DistributeEnable == LoopAttributes::Unspecified &&
-  !Location)
+  !StartLoc && !EndLoc)
 return nullptr;
 
   SmallVector Args;
@@ -35,9 +35,14 @@ static MDNode *createMetadata(LLVMContex
   auto TempNode = MDNode::getTemporary(Ctx, None);
   Args.push_back(TempNode.get());
 
-  // If we have a valid debug location for the loop, add it.
-  if (Location)
-Args.push_back(Location.getAsMDNode());
+  // If we have a valid start debug location for the loop, add it.
+  if (StartLoc) {
+Args.push_back(StartLoc.getAsMDNode());
+
+// If we also have a valid end debug location for the loop, add it.
+if (EndLoc)
+  Args.push_back(EndLoc.getAsMDNode());
+  }
 
   // Setting vectorize.width
   if (Attrs.VectorizeWidth > 0) {
@@ -116,20 +121,21 @@ void LoopAttributes::clear() {
 }
 
 LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs,
-   llvm::DebugLoc Location)
+   llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc)
 : LoopID(nullptr), Header(Header), Attrs(Attrs) {
-  LoopID = createMetadata(Header->getContext(), Attrs, Location);
+  LoopID = createMetadata(Header->getContext(), Attrs, StartLoc, EndLoc);
 }
 
-void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc Location) {
-  Active.push_back(LoopInfo(Header, StagedAttrs, Location));
+void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc StartLoc,
+ llvm::DebugLoc EndLoc) {
+  Active.push_back(LoopInfo(Header, StagedAttrs, StartLoc, EndLoc));
   // Clear the attributes so nested loops do not inherit them.
   StagedAttrs.clear();
 }
 
 void LoopInfoStack::push(BasicBlock *H

[PATCH] D26454: Implement no_sanitize_address for global vars

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/CodeGen/SanitizerMetadata.cpp:68
+  bool IsBlacklisted = false;
+  for (auto Attr : D.specific_attrs())
+if (Attr->getMask() & SanitizerKind::Address)

Should use `const auto *` (feel free to change the other use(s) in a separate 
commit, no review required).



Comment at: lib/Sema/SemaDeclAttr.cpp:5316
 
-  D->addAttr(::new (S.Context) DeprecatedAttr(Attr.getRange(), S.Context, Str,
-   Replacement,
-   Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context)
+ DeprecatedAttr(Attr.getRange(), S.Context, Str, Replacement,

This formatting change is unrelated.



Comment at: lib/Sema/SemaDeclAttr.cpp:5343
+else if (isGlobalVar(D) && SanitizerName != "address")
+  S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+  << Attr.getName() << ExpectedFunctionOrMethod;

You diagnose this as an error, but don't early return if the attribute is 
invalid. Is that intentional?



Comment at: lib/Sema/SemaDeclAttr.cpp:5364
+S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+<< Attr.getName() << ExpectedFunction;
   D->addAttr(::new (S.Context)

You diagnose it as an error, but then add the attribute anyway. Is that 
intentional?



Comment at: test/CodeGen/asan-globals.cpp:10
 int dyn_init_global = global;
+int __attribute__((no_sanitize("address"))) attributed_global;
 int blacklisted_global;

You modified no_sanitize_address, but did not add any test cases for it.



Comment at: test/SemaCXX/attr-no-sanitize-address.cpp:24
 
-int noanal_test_var NO_SANITIZE_ADDRESS; // \
-  // expected-error {{'no_sanitize_address' attribute only applies to 
functions}}

Please add a new test case to replace this one, showing that the attribute is 
properly diagnosed when applied to something the attribute cannot appertain to.



Comment at: test/SemaCXX/attr-no-sanitize.cpp:5
 
-int v1 __attribute__((no_sanitize("address"))); // 
expected-error{{'no_sanitize' attribute only applies to functions and methods}}
-

Please add a new test case to replace this one, showing that the attribute is 
properly diagnosed when applied to something the attribute cannot appertain to.


https://reviews.llvm.org/D26454



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


[PATCH] D26503: [Parser][ObjC] Improve diagnostics and recovery when C++ keywords are used as identifiers in Objective-C++

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

This patch improves the 'expected identifier' errors that are presented when a 
C++ keyword is used as an identifier in Objective-C++ by mentioning that this 
is a C++ keyword in the diagnostic message. It also improves the error 
recovery: the parser will treat the C++ keywords as identifiers to prevent 
unrelated parsing errors.


Repository:
  rL LLVM

https://reviews.llvm.org/D26503

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/IdentifierTable.h
  include/clang/Parse/Parser.h
  lib/Basic/IdentifierTable.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseObjc.cpp
  test/Parser/objc-cxx-keyword-identifiers.mm

Index: test/Parser/objc-cxx-keyword-identifiers.mm
===
--- /dev/null
+++ test/Parser/objc-cxx-keyword-identifiers.mm
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-objc-root-class -Wno-incomplete-implementation -triple x86_64-apple-macosx10.10.0 -verify %s
+
+// rdar://20626062
+
+struct S {
+  int throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}}
+};
+
+@interface class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@interface Bar: class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@protocol P // ok
+@end
+
+@protocol new // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
+@end
+
+@protocol P2, delete; // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
+
+@class Foo, try; // expected-error {{expected identifier; 'try' is a keyword in Objective-C++}}
+
+@interface Foo
+
+@property (readwrite, nonatomic) int a, b, throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}}
+
+-foo:(int)class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
++foo:(int)constexpr; // expected-error {{expected identifier; 'constexpr' is a keyword in Objective-C++}}
+
+@end
+
+@interface Foo ()  // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
+@end
+
+@implementation Foo
+
+@synthesize a = _a; // ok
+@synthesize b = virtual; // expected-error {{expected identifier; 'virtual' is a keyword in Objective-C++}}
+
+@dynamic throw; // expected-error {{expected identifier; 'throw' is a keyword in Objective-C++}}
+
+-foo:(int)class { // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+}
+
+@end
+
+@implementation class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@implementation Bar: class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@compatibility_alias C Foo; // ok
+@compatibility_alias const_cast Bar; // expected-error {{expected identifier; 'const_cast' is a keyword in Objective-C++}}
+@compatibility_alias C2 class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+
+void func() {
+  (void)@protocol(P); // ok
+  (void)@protocol(delete); // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
+}
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -24,6 +24,19 @@
 
 using namespace clang;
 
+bool Parser::diagnoseExpectedObjCIdentifier() {
+  if (const auto *II = Tok.getIdentifierInfo()) {
+if (II->isCPlusPlusKeyword(getLangOpts())) {
+  Diag(Tok, diag::err_expected_objcxx_keyword) << tok::identifier
+   << Tok.getIdentifierInfo();
+  // Objective-C++: Recover by treating this keyword as a valid identifier.
+  return false;
+}
+  }
+  Diag(Tok, diag::err_expected) << tok::identifier;
+  return true;
+}
+
 /// Skips attributes after an Objective-C @ directive. Emits a diagnostic.
 void Parser::MaybeSkipAttributes(tok::ObjCKeywordKind Kind) {
   ParsedAttributes attrs(AttrFactory);
@@ -137,8 +150,7 @@
 
   while (1) {
 MaybeSkipAttributes(tok::objc_class);
-if (Tok.isNot(tok::identifier)) {
-  Diag(Tok, diag::err_expected) << tok::identifier;
+if (Tok.isNot(tok::identifier) && diagnoseExpectedObjCIdentifier()) {
   SkipUntil(tok::semi);
   return Actions.ConvertDeclToDeclGroup(nullptr);
 }
@@ -229,11 +241,8 @@
 
   MaybeSkipAttributes(tok::objc_interface);
 
-  if (Tok.isNot(tok::identifier)) {
-Diag(Tok, diag::err_expected)
-<< tok::identifier; // missing class or category name.
-return nullptr;
-  }
+  if (Tok.isNot(tok::identifier) && diagnoseExpectedObjCIdentifier())
+return nullptr; // missing class or categ

[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

2016-11-10 Thread Ehsan Amiri via cfe-commits
amehsan added a comment.

I actually wanted to check some surrounding guards.


Repository:
  rL LLVM

https://reviews.llvm.org/D26479



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


[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

2016-11-10 Thread Ehsan Amiri via cfe-commits
amehsan added a comment.

more context?


Repository:
  rL LLVM

https://reviews.llvm.org/D26479



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


[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

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

Looks good. Thank you!


https://reviews.llvm.org/D26163



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


[PATCH] D25659: [clang-tidy] Avoid running aliased checks twice

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

In https://reviews.llvm.org/D25659#589386, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D25659#588658, @alexfh wrote:
>
> > I think, silently choosing one of the checks may be confusing and 
> > counter-intuitive. Should we just warn in case we see the same check 
> > enabled by multiple aliases?
>
>
> A warning is useful if the checks have different settings, e.g. 
> google-readability-braces-around-statements and 
> readability-braces-around-statements.
>
> But a warning is just noise for other aliases, e.g. cert-dcl54-cpp and 
> misc-new-delete-overloads.


That's why I don't think there's a good default behavior without capturing 
further information about whether an alias is an identical copy under a 
different name or a partial copy with differing semantics. If we have that 
information, then my preference is for warning the user about enabling the 
(effectively) same check twice.


https://reviews.llvm.org/D25659



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


[PATCH] D26507: [OpenCL] Change to clk_event parameter in enqueue_kernel

2016-11-10 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: yaxunl.
Anastasia added a subscriber: cfe-commits.

- Accept NULL pointer as a valid parameter value for clk_event
- Generate clk_events_t arguments of internal  __enqueue_kernel_XXX function to 
be pointers in generic address space


https://reviews.llvm.org/D26507

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl

Index: test/SemaOpenCL/cl20-device-side-enqueue.cl
===
--- test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -36,8 +36,12 @@
 
   // Testing the second overload type
   enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, ^(void) {
-return 0;
-  });
+ return 0;
+   });
+
+  enqueue_kernel(default_queue, flags, ndrange, 1, 0, 0, ^(void) {
+   return 0;
+ });
 
   enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
{
@@ -109,6 +113,12 @@
  },
  1024, 1024);
 
+  enqueue_kernel(default_queue, flags, ndrange, 1, 0, 0,
+ ^(local void *a, local void *b) {
+   return 0;
+ },
+ 1024, 1024);
+
   enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
  ^(local void *a, local void *b) {
return 0;
Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -31,10 +31,12 @@
 
   // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
   // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+  // CHECK: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t addrspace(1)** %event_wait_list to %opencl.clk_event_t addrspace(1)* addrspace(4)*
+  // CHECK: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t addrspace(1)** %clk_event to %opencl.clk_event_t addrspace(1)* addrspace(4)*
   // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
   // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(3)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
   // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
-  // CHECK: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** %event_wait_list, %opencl.clk_event_t** %clk_event, i8* [[BL_I8]])
+  // CHECK: call i32 @__enqueue_kernel_basic_events(%opencl_queue_t addrspace(1)* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]], i8* [[BL_I8]])
   enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
  ^(void) {
a[i] = b[i];
@@ -65,7 +67,9 @@
   // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
   // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
   // CHECK: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
-  // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** [[AD]], %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(3)* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+  // CHECK: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t addrspace(1)** [[AD]] to %opencl.clk_event_t addrspace(1)* addrspace(4)*
+  // CHECK: [[EVNT:%[0-9]+]]  = addrspacecast %opencl.clk_event_t addrspace(1)** %clk_event to %opencl.clk_event_t addrspace(1)* addrspace(4)*
+  // CHECK: call i32 (%opencl_queue_t addrspace(1)*, i32, %struct.ndrange_t*, i32, %opencl.clk_event_t{{.*}}* addrspace(4)*, %opencl.clk_event_t{{.*}}* addrspace(4)*, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl_queue_t addrspace(1)* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}} [[WAIT_

[PATCH] D26274: clang-format: [JS] do not break after declare namespace.

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

Looks good.


https://reviews.llvm.org/D26274



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/DeleteNullPointerCheck.cpp:54
+  diag(IfWithDelete->getLocStart(),
+   "if statement is unnecessary (deleting null pointer has no 
effect)");
+  std::string ReplacementText = Lexer::getSourceText(

Rather than a parenthetical, I would just use a semicolon to distinguish the 
clauses. Also, I would quote 'if' to make it clear that you're talking about 
syntax rather than an English term.



Comment at: clang-tidy/misc/DeleteNullPointerCheck.h:19
+
+/// FIXME: Write a short description.
+///

You should write that short description.


https://reviews.llvm.org/D21298



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


[clang-tools-extra] r286466 - [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC

2016-11-10 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 10 10:19:17 2016
New Revision: 286466

URL: http://llvm.org/viewvc/llvm-project?rev=286466&view=rev
Log:
[clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst?rev=286466&r1=286465&r2=286466&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst Thu Nov 10 
10:19:17 2016
@@ -1,4 +1,6 @@
 .. title:: clang-tidy - cert-msc30-c
+.. meta::
+   :http-equiv=refresh: 5;URL=cert-msc50-cpp.html
 
 cert-msc30-c
 


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


[PATCH] D26448: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with a default capture specifier

2016-11-10 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286465: [Sema] Avoid -Wshadow warnings for shadowed 
variables that (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26448?vs=77335&id=77492#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26448

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6233,8 +6233,8 @@
   def note_lambda_to_block_conv : Note<
 "implicit capture of lambda object due to conversion to block pointer "
 "here">;
-  def note_var_explicitly_captured_here : Note<"variable %0 is explicitly "
-"captured here">;
+  def note_var_explicitly_captured_here : Note<"variable %0 is"
+"%select{| explicitly}1 captured here">;
 
   // C++14 lambda init-captures.
   def warn_cxx11_compat_init_capture : Warning<
Index: cfe/trunk/include/clang/Sema/ScopeInfo.h
===
--- cfe/trunk/include/clang/Sema/ScopeInfo.h
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h
@@ -735,7 +735,16 @@
   ///  to local variables that are usable as constant expressions and
   ///  do not involve an odr-use (they may still need to be captured
   ///  if the enclosing full-expression is instantiation dependent).
-  llvm::SmallSet NonODRUsedCapturingExprs; 
+  llvm::SmallSet NonODRUsedCapturingExprs;
+
+  /// Contains all of the variables defined in this lambda that shadow variables
+  /// that were defined in parent contexts. Used to avoid warnings when the
+  /// shadowed variables are uncaptured by this lambda.
+  struct ShadowedOuterDecl {
+const VarDecl *VD;
+const VarDecl *ShadowedDecl;
+  };
+  llvm::SmallVector ShadowingDecls;
 
   SourceLocation PotentialThisCaptureLocation;
 
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1716,6 +1716,8 @@
   /// to a shadowing declaration.
   void CheckShadowingDeclModification(Expr *E, SourceLocation Loc);
 
+  void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI);
+
 private:
   /// Map of current shadowing declarations to shadowed declarations. Warn if
   /// it looks like the user is trying to modify the shadowing declaration.
Index: cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -5,12 +5,48 @@
 void foo(int param) { // expected-note 1+ {{previous declaration is here}}
   int var = 0; // expected-note 1+ {{previous declaration is here}}
 
-  // Warn for lambdas with a default capture specifier.
+  // Avoid warnings for variables that aren't implicitly captured.
   {
+#ifdef AVOID
+auto f1 = [=] { int var = 1; };  // no warning
+auto f2 = [&] { int var = 2; };  // no warning
+auto f3 = [=] (int param) { ; }; // no warning
+auto f4 = [&] (int param) { ; }; // no warning
+#else
 auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
 auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
 auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
 auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  }
+
+  // Warn for variables that are implicitly captured.
+  {
+auto f1 = [=] () {
+  {
+int var = 1; // expected-warning {{declaration shadows a local variable}}
+  }
+  int x = var; // expected-note {{variable 'var' is captured here}}
+};
+auto f2 = [&]
+#ifdef AVOID
+  (int param) {
+#else
+  (int param) { // expected-warning {{declaration shadows a local variable}}
+#endif
+  int x = var; // expected-note {{variable 'var' is captured here}}
+  int var = param; // expected-warning {{declaration shadows a local variable}}
+};
+  }
+
+  // Warn for variables that are explicitly captured when a lambda has a default
+  // capture specifier.
+  {
+auto f1 = [=, &var] () { // expected-note {{variable 'var' is captured here}}
+  int x = param; // expected-note {{variable 'param' is captured here}}
+  int var = 0; // expected-warning {{declaration shadows a local variable}}
+  int param = 0; // expected-warning {{declaration shadows a local variable}}
+};
   }
 
   // Warn normally i

r286465 - [Sema] Avoid -Wshadow warnings for shadowed variables that

2016-11-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Nov 10 10:19:11 2016
New Revision: 286465

URL: http://llvm.org/viewvc/llvm-project?rev=286465&view=rev
Log:
[Sema] Avoid -Wshadow warnings for shadowed variables that
aren't captured by lambdas with a default capture specifier

This commit is a follow-up to r286354. It avoids the -Wshadow warning for
variables which shadow variables that aren't captured by lambdas with a default
capture specifier. It provides an additional note that points to location of
the capture.

The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.

rdar://14984176

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286465&r1=286464&r2=286465&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 10:19:11 
2016
@@ -6233,8 +6233,8 @@ let CategoryName = "Lambda Issue" in {
   def note_lambda_to_block_conv : Note<
 "implicit capture of lambda object due to conversion to block pointer "
 "here">;
-  def note_var_explicitly_captured_here : Note<"variable %0 is explicitly "
-"captured here">;
+  def note_var_explicitly_captured_here : Note<"variable %0 is"
+"%select{| explicitly}1 captured here">;
 
   // C++14 lambda init-captures.
   def warn_cxx11_compat_init_capture : Warning<

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=286465&r1=286464&r2=286465&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Nov 10 10:19:11 2016
@@ -735,7 +735,16 @@ public:
   ///  to local variables that are usable as constant expressions and
   ///  do not involve an odr-use (they may still need to be captured
   ///  if the enclosing full-expression is instantiation dependent).
-  llvm::SmallSet NonODRUsedCapturingExprs; 
+  llvm::SmallSet NonODRUsedCapturingExprs;
+
+  /// Contains all of the variables defined in this lambda that shadow 
variables
+  /// that were defined in parent contexts. Used to avoid warnings when the
+  /// shadowed variables are uncaptured by this lambda.
+  struct ShadowedOuterDecl {
+const VarDecl *VD;
+const VarDecl *ShadowedDecl;
+  };
+  llvm::SmallVector ShadowingDecls;
 
   SourceLocation PotentialThisCaptureLocation;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286465&r1=286464&r2=286465&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Nov 10 10:19:11 2016
@@ -1716,6 +1716,8 @@ public:
   /// to a shadowing declaration.
   void CheckShadowingDeclModification(Expr *E, SourceLocation Loc);
 
+  void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI);
+
 private:
   /// Map of current shadowing declarations to shadowed declarations. Warn if
   /// it looks like the user is trying to modify the shadowing declaration.

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=286465&r1=286464&r2=286465&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Nov 10 10:19:11 2016
@@ -6655,14 +6655,21 @@ void Sema::CheckShadow(Scope *S, VarDecl
   SourceLocation CaptureLoc;
   if (isa(ShadowedDecl) && NewDC && isa(NewDC)) {
 if (const auto *RD = dyn_cast(NewDC->getParent())) {
-  // Try to avoid warnings for lambdas with an explicit capture list.
-  if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent()) &&
-  RD->getLambdaCaptureDefault() == LCD_None) {
-const auto *LSI = cast(getCurFunction());
-// Warn only when the lambda captures the shadowed decl explicitly.
-CaptureLoc = getCaptureLocation(LSI, cast(ShadowedDecl));
-if (CaptureLoc.isInvalid())
-  WarningDiag = diag::warn_decl_shadow_uncaptured_local;
+  if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent())) {
+if (RD->getLambdaCaptureDefault() == LCD_None) {
+  // Try to avoid warnings for lambdas with an explicit capture list.
+  const auto *LSI = cas

r286468 - clang-format: [JS] do not break after declare namespace.

2016-11-10 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Nov 10 10:21:02 2016
New Revision: 286468

URL: http://llvm.org/viewvc/llvm-project?rev=286468&view=rev
Log:
clang-format: [JS] do not break after declare namespace.

Summary:
See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10

Additional minor change:
clang-format: [JS] Prevent ASI before const.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=286468&r1=286467&r2=286468&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Nov 10 10:21:02 2016
@@ -669,14 +669,14 @@ static bool mustBeJSIdent(const Addition
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
-  Keywords.kw_async, Keywords.kw_await,
-  Keywords.kw_yield, Keywords.kw_finally,
-  Keywords.kw_function, Keywords.kw_import,
-  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
-  Keywords.kw_abstract, Keywords.kw_extends,
-  Keywords.kw_implements, Keywords.kw_instanceof,
-  Keywords.kw_interface, Keywords.kw_throws));
+  !FormatTok->isOneOf(
+  Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, 
Keywords.kw_async,
+  Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var, tok::kw_const,
+  Keywords.kw_abstract, Keywords.kw_extends, 
Keywords.kw_implements,
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_throws));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,


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


r286467 - clang-format: [JS] do not break after declare namespace.

2016-11-10 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Nov 10 10:20:58 2016
New Revision: 286467

URL: http://llvm.org/viewvc/llvm-project?rev=286467&view=rev
Log:
clang-format: [JS] do not break after declare namespace.

See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=286467&r1=286466&r2=286467&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Thu Nov 10 10:20:58 2016
@@ -580,12 +580,14 @@ struct AdditionalKeywords {
 kw_as = &IdentTable.get("as");
 kw_async = &IdentTable.get("async");
 kw_await = &IdentTable.get("await");
+kw_declare = &IdentTable.get("declare");
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
+kw_module = &IdentTable.get("module");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -632,12 +634,14 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_as;
   IdentifierInfo *kw_async;
   IdentifierInfo *kw_await;
+  IdentifierInfo *kw_declare;
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo *kw_function;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
+  IdentifierInfo *kw_module;
   IdentifierInfo *kw_type;
   IdentifierInfo *kw_var;
   IdentifierInfo *kw_yield;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286467&r1=286466&r2=286467&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 10:20:58 2016
@@ -2426,10 +2426,10 @@ bool TokenAnnotator::canBreakBefore(cons
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw) ||
+ tok::kw_throw, Keywords.kw_module) ||
 (NonComment &&
  NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw)))
+ tok::kw_throw, Keywords.kw_module)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
@@ -2443,6 +2443,18 @@ bool TokenAnnotator::canBreakBefore(cons
   return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
 if (Right.is(Keywords.kw_as))
   return false; // must not break before as in 'x as type' casts
+if (Left.is(Keywords.kw_declare) &&
+Right.isOneOf(Keywords.kw_module, tok::kw_namespace,
+  Keywords.kw_function, tok::kw_class, tok::kw_enum,
+  Keywords.kw_interface, Keywords.kw_type, Keywords.kw_var,
+  Keywords.kw_let, tok::kw_const))
+  // See grammar for 'declare' statements at:
+  // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10
+  return false;
+if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
+Right.isOneOf(tok::identifier, tok::string_literal)) {
+  return false; // must not break in "module foo { ...}"
+}
   }
 
   if (Left.is(tok::at))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=286467&r1=286466&r2=286467&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Nov 10 10:20:58 2016
@@ -349,6 +349,37 @@ TEST_F(FormatTestJS, FormatsNamespaces)
"}\n");
 }
 
+TEST_F(FormatTestJS, NamespacesMayNotWrap) {
+  verifyFormat("declare namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(18));
+  verifyFormat("declare module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(15));
+  verifyFormat("namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(10));
+  verifyFormat("module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(7));
+}
+
+TEST_F(FormatTestJS, AmbientDeclarations) {
+  FormatStyle NineCols = getGoogleJSStyleWithColumns(9);
+  verifyFormat(
+   

r286469 - drop kw_module from ASI protection block

2016-11-10 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Nov 10 10:21:04 2016
New Revision: 286469

URL: http://llvm.org/viewvc/llvm-project?rev=286469&view=rev
Log:
drop kw_module from ASI protection block

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286469&r1=286468&r2=286469&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 10:21:04 2016
@@ -2426,10 +2426,10 @@ bool TokenAnnotator::canBreakBefore(cons
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw, Keywords.kw_module) ||
+ tok::kw_throw) ||
 (NonComment &&
  NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw, Keywords.kw_module)))
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;


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


[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

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

In https://reviews.llvm.org/D26479#591723, @amehsan wrote:

> more context?


Really sorry. It appears that I uploaded the wrong patch file. Updating now.


Repository:
  rL LLVM

https://reviews.llvm.org/D26479



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


[PATCH] D26274: clang-format: [JS] do not break after declare namespace.

2016-11-10 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286468: clang-format: [JS] do not break after declare 
namespace. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D26274?vs=76831&id=77493#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26274

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -669,14 +669,14 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
-  Keywords.kw_async, Keywords.kw_await,
-  Keywords.kw_yield, Keywords.kw_finally,
-  Keywords.kw_function, Keywords.kw_import,
-  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
-  Keywords.kw_abstract, Keywords.kw_extends,
-  Keywords.kw_implements, Keywords.kw_instanceof,
-  Keywords.kw_interface, Keywords.kw_throws));
+  !FormatTok->isOneOf(
+  Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, 
Keywords.kw_async,
+  Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var, tok::kw_const,
+  Keywords.kw_abstract, Keywords.kw_extends, 
Keywords.kw_implements,
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_throws));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -669,14 +669,14 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
-  Keywords.kw_async, Keywords.kw_await,
-  Keywords.kw_yield, Keywords.kw_finally,
-  Keywords.kw_function, Keywords.kw_import,
-  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
-  Keywords.kw_abstract, Keywords.kw_extends,
-  Keywords.kw_implements, Keywords.kw_instanceof,
-  Keywords.kw_interface, Keywords.kw_throws));
+  !FormatTok->isOneOf(
+  Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async,
+  Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var, tok::kw_const,
+  Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements,
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_throws));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

2016-11-10 Thread Nemanja Ivanovic via cfe-commits
nemanjai updated this revision to Diff 77494.
nemanjai added a comment.

Accidentally uploaded the wrong patch so it was missing full context.


Repository:
  rL LLVM

https://reviews.llvm.org/D26479

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-crypto.c
  test/CodeGen/builtins-ppc-p8vector.c
  test/CodeGen/builtins-ppc-p9vector.c

Index: test/CodeGen/builtins-ppc-p9vector.c
===
--- test/CodeGen/builtins-ppc-p9vector.c
+++ test/CodeGen/builtins-ppc-p9vector.c
@@ -827,4 +827,101 @@
 // CHECK-NEXT: ret <16 x i8>
   return vec_srv (vuca, vucb);
 }
-
+vector unsigned short test74(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK-BE: @llvm.ppc.altivec.vperm
+// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK: @llvm.ppc.altivec.vperm
+  return vec_pack_to_short_fp32(vfa, vfb);
+}
+vector unsigned int test75(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrlwmi(<4 x i32
+// CHECK-BE-NEXT: ret <4 x i32>
+// CHECK: @llvm.ppc.altivec.vrlwmi(<4 x i32
+// CHECK-NEXT: ret <4 x i32>
+  return vec_rlmi(vuia, vuia, vuia);
+}
+vector unsigned long long test76(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrldmi(<2 x i64
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.altivec.vrldmi(<2 x i64
+// CHECK-NEXT: ret <2 x i64>
+  return vec_rlmi(vula, vula, vula);
+}
+vector unsigned int test77(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrlwnm(<4 x i32
+// CHECK-BE: and <4 x i32
+// CHECK-BE: ret <4 x i32>
+// CHECK: @llvm.ppc.altivec.vrlwnm(<4 x i32
+// CHECK: and <4 x i32
+// CHECK: ret <4 x i32>
+  return vec_rlnm(vuia, vuia, vuia);
+}
+vector unsigned long long test78(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrldnm(<2 x i64
+// CHECK-BE: and <2 x i64
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.altivec.vrldnm(<2 x i64
+// CHECK: and <2 x i64
+// CHECK-NEXT: ret <2 x i64>
+  return vec_rlnm(vula, vula, vula);
+}
+vector double test79(void) {
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+  return vec_unpackh(vfa);
+}
+vector double test80(void) {
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+  return vec_unpackl(vfa);
+}
+vector double test81(void) {
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK-LE: extractelement <2 x double>
+  // CHECK-LE: fptrunc double
+  // CHECK-LE: insertelement <4 x float>
+  // CHECK-LE: extractelement <2 x double>
+  // CHECK-LE: fptrunc double
+  // CHECK-LE: insertelement <4 x float>
+  // CHECK-LE: extractelement <2 x double>
+  // CHECK-LE: fptrunc double
+  // CHECK-LE: insertelement <4 x float>
+  // CHECK-LE: extractelement <2 x double>
+  // CHECK-LE: fptrunc double
+  // CHECK-LE: insertelement <4 x float>
+  return vec_pack(vda, vdb);
+}
Index: test/CodeGen/builtins-ppc-p8vector.c
===
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -136,6 +136,26 @@
 // CHECK-LE: @llvm.ppc.altivec.vperm
 // CHECK-PPC: warning: implicit declaration of function 'vec_mergee'
 
+  res_vbll = vec_mergee(vbll, vbll);
+// CHECK: @llvm.ppc.altivec.vperm
+// CHECK-LE: @llvm.ppc.altivec.vperm
+
+  res_vsll = vec_mergee(vsll, vsll);
+// CHECK: @llvm.ppc.altivec.vperm
+// CHECK-LE: @llvm.ppc.altivec.vperm
+
+  res_vull = vec_mergee(vull, vull);
+// CHECK: @llvm.ppc.altivec.vperm
+// CHECK-LE: @llvm.ppc.altivec.vperm
+
+  res_vf = vec_mergee(vfa, vfa);
+// CHECK: @llvm.ppc.altivec.vperm
+// CHECK-LE: @llvm.ppc.altivec.vperm
+
+  res_vd = vec_mergee(vda, vda);
+// CHECK: @llvm.ppc.altivec.vperm
+// CHECK-LE: @llvm.ppc.altivec.vperm
+
   /* vec_mergeo */
   res_vbi = vec_mergeo(vbi, vbi);
 // CHECK: @llvm.ppc.altivec.vperm
Index: test/CodeGen/builtins-ppc-crypto.c
===

[PATCH] D24894: [clang-tidy] Prefer transparent functors to non-transparent one.

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:71
+
+static const StringRef Message = "prefer transparent functors (%0)";
+

You should quote the %0 to clarify that you're referring to syntax.



Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:89
+diag(FuncInst->getLocStart(), Message)
+<< (FuncClass->getName() + "<>").str();
+return;

Is the `.str()` required? (Same question applies below.)


https://reviews.llvm.org/D24894



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


Re: [clang-tools-extra] r286466 - [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC

2016-11-10 Thread Aaron Ballman via cfe-commits
On Thu, Nov 10, 2016 at 11:19 AM, Malcolm Parsons via cfe-commits
 wrote:
> Author: malcolm.parsons
> Date: Thu Nov 10 10:19:17 2016
> New Revision: 286466
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286466&view=rev
> Log:
> [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC

Thank you for this! (Though I would claim it's not NFC since it
definitely makes a functional improvement to the docs.)

~Aaron

>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst?rev=286466&r1=286465&r2=286466&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst Thu Nov 
> 10 10:19:17 2016
> @@ -1,4 +1,6 @@
>  .. title:: clang-tidy - cert-msc30-c
> +.. meta::
> +   :http-equiv=refresh: 5;URL=cert-msc50-cpp.html
>
>  cert-msc30-c
>  
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!




Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:58
+  << FixItHint::CreateInsertion(StartLoc, "public: ")
+  << FixItHint::CreateInsertion(AfterLoc, " private:");
+}

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > I am on the fence about this fixit. On the one hand, the fix is a 
> > > > technical improvement because it means that implementations will 
> > > > consistently find the declaration and bark about it being explicitly 
> > > > deleted. On the other hand, the fixit suggests code that should never 
> > > > pass a reasonable code review.
> > > > 
> > > > I'm wondering if it would make more sense to leave the access 
> > > > specifiers alone and just put a FIXME in the code to point the 
> > > > situation out. I am guessing that at some point we will have a 
> > > > refactoring tool that can help without resorting to making declarations 
> > > > like `public: C() = delete; private:`.
> > > > 
> > > > What do you think?
> > > I'm wondering whether no fixit would be better than a not-good-enough 
> > > fixit.
> > Generally, no. Incremental improvements are almost always fine. However, 
> > the user is asking to have their code modernized, and the fixit results in 
> > code that looks more foreign than modern (at least, to me).
> > 
> > I won't block the patch moving forward regardless of whether the fixit is 
> > in or out, but I am curious if @alexfh has an opinion, or if you have a 
> > strong preference one way or the other.
> I'll change the check to warn about deleted methods that aren't public; the 
> user can fix those manually until a better fixit is possible.
I think that's a good solution for now, thanks!


https://reviews.llvm.org/D26138



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


[PATCH] D26509: [OpenCL] Fix integer parameters of enqueue_kernel

2016-11-10 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: yaxunl.
Anastasia added a subscriber: cfe-commits.

Parameters representing number of events as well as sizes of enqueued block 
arguments in enqueue_kernel function are specified as uint type. This prevents 
passing sizeof(int) type expressions on the  64 bit architectures because they 
return size_t which is a 64 bit wide in contrast to uint that is always 32 bits.

The suggestion is to accept any integer type as soon as the compiler can prove 
that the range fits in the data width of uint for number of event or size_t for 
block argument sizes (and if not appropriate error is emitted).

The proposed enqueue_kernel signature would be:

  int enqueue_kernel (queue_t queue, kernel_enqueue_flags_t flags, const 
ndrange_t ndrange, uint num_events_in_wait_list, const clk_event_t 
*event_wait_list, clk_event_t *event_ret, void (^block)(local void *, ...), 
size_t size0, ...)

and therefore compiler should allow the call:

  enqueue_kernel(default_queue, flags, ndrange, 
sizeof(event_wait_list)/sizeof(event_wait_list[0]), event_wait_list2, 
&clk_event,
 ^(local void *p) {
   return;
 },
 sizeof(int[2]));

See tests for more examples.


https://reviews.llvm.org/D26509

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl

Index: test/SemaOpenCL/cl20-device-side-enqueue.cl
===
--- test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wconversion -DWCONV
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV
 
 // Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
 kernel void enqueue_kernel_tests() {
@@ -39,6 +40,10 @@
 return 0;
   });
 
+  enqueue_kernel(default_queue, flags, ndrange, vptr, &event_wait_list, &evt, ^(void) { // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}}
+return 0;
+  });
+
   enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
{
  return 0;
@@ -62,16 +67,35 @@
  ^(local void *a, local void *b) {
return 0;
  },
- 1024, 1024L); // expected-error{{local memory sizes need to be specified as uint}}
+ 1024L, 1024);
+
+  enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+   return 0;
+ },
+ 1024, 4294967296L);
+#ifdef B32
+// expected-warning@-2{{implicit conversion from 'long' to 'unsigned int' changes value from 4294967296 to 0}}
+#endif
 
   char c;
   enqueue_kernel(default_queue, flags, ndrange,
  ^(local void *a, local void *b) {
return 0;
  },
- c, 1024);
+ c, 1024L);
 #ifdef WCONV
-// expected-warning@-2{{implicit conversion changes signedness: 'char' to 'unsigned int'}}
+// expected-warning-re@-2{{implicit conversion changes signedness: 'char' to 'unsigned {{int|long}}'}}
+#endif
+#define UINT_MAX 4294967295
+
+  enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+   return 0;
+ },
+ sizeof(int), sizeof(int) * UINT_MAX);
+#ifdef B32
+// expected-warning@-2{{implicit conversion from 'long' to 'unsigned int' changes value from 17179869180 to 4294967292}}
 #endif
 
   typedef void (^bl_A_t)(local void *);
@@ -97,10 +121,13 @@
  ^(local void *a, local void *b) {
return 0;
  },
- illegal_mem_size, illegal_mem_size); // expected-error{{local memory sizes need to be specified as uint}} expected-error{{local memory sizes need to be specified as uint}}
-#ifdef WCONV
-// expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}} expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}}
-#endif
+ illegal_mem_size, illegal_mem_size); // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}} 

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

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 77498.
rogfer01 added a comment.

- Address comments.
- Rebase test with current trunk
- Make the check resilient under errors

If no comments arise from this change I will be commiting it Monday next week.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -196,3 +202,130 @@
 int *anonymousInnerUnion(struct S6 *s) {
   return &s->x; // expected-warning {{packed member 'x' of class or structure 'S6::(anonymous)'}}
 }
+
+struct S6a {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6a'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} _

[clang-tools-extra] r286472 - [clang-tidy] Add modernize-use-equals-delete check

2016-11-10 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 10 10:46:59 2016
New Revision: 286472

URL: http://llvm.org/viewvc/llvm-project?rev=286472&view=rev
Log:
[clang-tidy] Add modernize-use-equals-delete check

Summary: Fixes PR27872

Reviewers: klimek, hokein, alexfh, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, danielmarjamaki, cfe-commits, mgorny

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=286472&r1=286471&r2=286472&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Nov 10 
10:46:59 2016
@@ -18,6 +18,7 @@ add_clang_library(clangTidyModernizeModu
   UseBoolLiteralsCheck.cpp
   UseDefaultCheck.cpp
   UseEmplaceCheck.cpp
+  UseEqualsDeleteCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseUsingCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=286472&r1=286471&r2=286472&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Nov 10 10:46:59 2016
@@ -24,6 +24,7 @@
 #include "UseBoolLiteralsCheck.h"
 #include "UseDefaultCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEqualsDeleteCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseUsingCheck.h"
@@ -56,6 +57,8 @@ public:
 "modernize-use-bool-literals");
 CheckFactories.registerCheck("modernize-use-default");
 CheckFactories.registerCheck("modernize-use-emplace");
+CheckFactories.registerCheck(
+"modernize-use-equals-delete");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck("modernize-use-using");

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=286472&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Thu 
Nov 10 10:46:59 2016
@@ -0,0 +1,69 @@
+//===--- UseEqualsDeleteCheck.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 "UseEqualsDeleteCheck.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 modernize {
+
+static const char SpecialFunction[] = "SpecialFunction";
+static const char DeletedNotPublic[] = "DeletedNotPublic";
+
+void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
+  auto PrivateSpecialFn = cxxMethodDecl(
+  isPrivate(),
+  anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),
+ isCopyConstructor(), 
isMoveConstructor())),
+cxxMethodDecl(
+anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),
+cxxDestructorDecl()));
+
+  Finder->addMatcher(
+  cxxMethodDecl(
+  PrivateSpecialFn,
+  unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+   // Ensure that all methods except private special member
+   // functions are defined.
+   hasParent(cxxRecordDecl(hasMethod(unless(
+   anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(),
+ isD

[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-10 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286472: [clang-tidy] Add modernize-use-equals-delete check 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26138?vs=76971&id=77500#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26138

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
@@ -0,0 +1,134 @@
+// RUN: %check_clang_tidy %s modernize-use-equals-delete %t
+
+struct PositivePrivate {
+private:
+  PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate() = delete;
+  PositivePrivate(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate(const PositivePrivate &) = delete;
+  PositivePrivate &operator=(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate &operator=(const PositivePrivate &) = delete;
+  PositivePrivate(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate(PositivePrivate &&) = delete;
+  PositivePrivate &operator=(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivate &operator=(PositivePrivate &&) = delete;
+  ~PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: ~PositivePrivate() = delete;
+};
+
+struct NegativePublic {
+  NegativePublic(const NegativePublic &);
+};
+
+struct NegativeProtected {
+protected:
+  NegativeProtected(const NegativeProtected &);
+};
+
+struct PositiveInlineMember {
+  int foo() { return 0; }
+
+private:
+  PositiveInlineMember(const PositiveInlineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveInlineMember(const PositiveInlineMember &) = delete;
+};
+
+struct PositiveOutOfLineMember {
+  int foo();
+
+private:
+  PositiveOutOfLineMember(const PositiveOutOfLineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveOutOfLineMember(const PositiveOutOfLineMember &) = delete;
+};
+
+int PositiveOutOfLineMember::foo() { return 0; }
+
+struct PositiveAbstractMember {
+  virtual int foo() = 0;
+
+private:
+  PositiveAbstractMember(const PositiveAbstractMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositiveAbstractMember(const PositiveAbstractMember &) = delete;
+};
+
+struct NegativeMemberNotImpl {
+  int foo();
+
+private:
+  NegativeMemberNotImpl(const NegativeMemberNotImpl &);
+};
+
+struct NegativeStaticMemberNotImpl {
+  static int foo();
+
+private:
+  NegativeStaticMemberNotImpl(const NegativeStaticMemberNotImpl &);
+};
+
+struct NegativeInline {
+private:
+  NegativeInline(const NegativeInline &) {}
+};
+
+struct NegativeOutOfLine {
+private:
+  NegativeOutOfLine(const NegativeOutOfLine &);
+};
+
+NegativeOutOfLine::NegativeOutOfLine(const NegativeOutOfLine &) {}
+
+struct NegativeConstructNotImpl {
+  NegativeConstructNotImpl();
+
+private:
+  NegativeConstructNotImpl(const NegativeConstructNotImpl &);
+};
+
+struct PositiveDefaultedConstruct {
+  PositiveDefaultedConstruct() = default;
+
+private:
+  PositiveDefaultedConstruct(const PositiveDefaultedConstruct &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '=

[libcxx] r286474 - Protect bitset tests under libcpp-no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov 10 10:54:55 2016
New Revision: 286474

URL: http://llvm.org/viewvc/llvm-project?rev=286474&view=rev
Log:
Protect bitset tests under libcpp-no-exceptions

Bitset tests feature a sequence of tests of increasing bitset sizes,
but these tests rely on exceptions when the bitset size is less than
50 elements.

This change adds a flag to tell whether a test should throw. If it must
throw it will be skipped under no-exceptions.

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


Modified:

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/test.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
 Thu Nov 10 10:54:55 2016
@@ -7,13 +7,14 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test bitset& flip(size_t pos);
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 std::bitset
 make_bitset()
@@ -25,11 +26,15 @@ make_bitset()
 }
 
 template 
-void test_flip_one()
+void test_flip_one(bool test_throws)
 {
 std::bitset v = make_bitset();
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (test_throws) return;
+#else
 try
 {
+#endif
 v.flip(50);
 bool b = v[50];
 if (50 >= v.size())
@@ -39,21 +44,25 @@ void test_flip_one()
 assert(v[50] != b);
 v.flip(50);
 assert(v[50] == b);
+assert(!test_throws);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 }
 catch (std::out_of_range&)
 {
+assert(test_throws);
 }
+#endif
 }
 
 int main()
 {
-test_flip_one<0>();
-test_flip_one<1>();
-test_flip_one<31>();
-test_flip_one<32>();
-test_flip_one<33>();
-test_flip_one<63>();
-test_flip_one<64>();
-test_flip_one<65>();
-test_flip_one<1000>();
+test_flip_one<0>(true);
+test_flip_one<1>(true);
+test_flip_one<31>(true);
+test_flip_one<32>(true);
+test_flip_one<33>(true);
+test_flip_one<63>(false);
+test_flip_one<64>(false);
+test_flip_one<65>(false);
+test_flip_one<1000>(false);
 }

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
 Thu Nov 10 10:54:55 2016
@@ -7,18 +7,23 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test bitset& reset(size_t pos);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
-void test_reset_one()
+void test_reset_one(bool test_throws)
 {
 std::bitset v;
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (test_throws) return;
+#else
 try
 {
+#endif
 v.set();
 v.reset(50);
 if (50 >= v.size())
@@ -28,21 +33,25 @@ void test_reset_one()
 assert(!v[i]);
 else
 assert(v[i]);
+assert(!test_throws);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 }
 catch (std::out_of_range&)
 {
+assert(test_throws);
 }
+#endif
 }
 
 int main()
 {
-test_reset_one<0>();
-test_reset_one<1>();
-test_reset_one<31>();
-test_reset_one<32>();
-test_reset_one<33>();
-test_reset_one<63>();
-test_reset_one<64>();
-test_reset_one<65>();
-test_reset_one<1000>();
+test_reset_one<0>(true);
+test_reset_one<1>(true);
+test_reset_one<31>(true);
+test_reset_one<32>(true);
+test_reset_one<33>(true);
+test_reset_one<63>(false);
+test_reset_one<64>(false);
+test_reset_one<65>(false);
+test_reset_one<1000>(false);
 }

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
===

[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

@rmaprath well each case is testing a different special member: the assignment 
operator, the copy constructor and the default constructor. My feeling is that 
at least the non-throwing part must be tested under no-exceptions. But I 
understand, that this class is probably useless in the context of no-exceptions.


https://reviews.llvm.org/D26458



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-11-10 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh, angelgarcia.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D26511

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tidy/modernize/UseDefaultCheck.h
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tidy/modernize/UseEqualsDefaultCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-equals-default.rst
  test/clang-tidy/modernize-use-default-copy.cpp
  test/clang-tidy/modernize-use-default-delayed.cpp
  test/clang-tidy/modernize-use-default.cpp
  test/clang-tidy/modernize-use-equals-default-copy.cpp
  test/clang-tidy/modernize-use-equals-default-delayed.cpp
  test/clang-tidy/modernize-use-equals-default.cpp

Index: test/clang-tidy/modernize-use-equals-default.cpp
===
--- test/clang-tidy/modernize-use-equals-default.cpp
+++ test/clang-tidy/modernize-use-equals-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
 
 // Out of line definition.
 class OL {
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
Index: test/clang-tidy/modernize-use-equals-default-delayed.cpp
===
--- test/clang-tidy/modernize-use-equals-default-delayed.cpp
+++ test/clang-tidy/modernize-use-equals-default-delayed.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
+// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
 // Note: this test expects no diagnostics, but FileCheck cannot handle that,
 // hence the use of | count 0.
 
Index: test/clang-tidy/modernize-use-equals-default-copy.cpp
===
--- test/clang-tidy/modernize-use-equals-default-copy.cpp
+++ test/clang-tidy/modernize-use-equals-default-copy.cpp
@@ -1,19 +1,19 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
 
 // Out of line definition.
 struct OL {
   OL(const OL &);
   OL &operator=(const OL &);
   int Field;
 };
 OL::OL(const OL &Other) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL(const OL &Other)  = default;
 OL &OL::operator=(const OL &Other) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
 // CHECK-FIXES: OL &OL::operator=(const OL &Other) = default;
 
 // Inline.
Index: docs/clang-tidy/checks/modernize-use-equals-default.rst
===
--- docs/clang-tidy/checks/modernize-use-equals-default.rst
+++ docs/clang-tidy/checks/modernize-use-equals-default.rst
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - modernize-use-default
+.. title:: clang-tidy - modernize-use-equals-default
 
-modernize-use-default
-=
+modernize-use-equals-default
+
 
 This check replaces default bodies of special member functions with ``=
 default;``.  The explicitly defaulted function declarations enable more
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,7 +109,7 @@
modernize-shrink-to-fit
  

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

What do we want to do, if anything, for people who have scripts using the old 
name? Do we want to keep the old name as an alias to the new name for some 
period of time?


https://reviews.llvm.org/D26511



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


[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown.


https://reviews.llvm.org/D26512

Files:
  test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
  test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
  
test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp

Index: test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,14 +17,17 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.setstate(std::ios::goodbit);
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -51,6 +53,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
@@ -27,6 +28,7 @@
 assert(ios.exceptions() == std::ios::goodbit);
 ios.exceptions(std::ios::eofbit);
 assert(ios.exceptions() == std::ios::eofbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -36,6 +38,7 @@
 {
 }
 assert(ios.exceptions() == std::ios::badbit);
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,14 +17,17 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.clear();
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -51,6 +53,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf
 : public std::streambuf
 {
@@ -35,24 +36,28 @@
 testbuf sb1;
 testbuf sb2;
 testios ios(&sb1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(&sb2);
 assert(ios.rdbuf() == &sb2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(0);
 assert(ios.rdbuf() == 0);
 }
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.member

[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added inline comments.



Comment at: 
test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp:171-173
+#else
+ios1.copyfmt(ios2);
+#endif

This is a bit unexpected. It looks like if the copyfmt, even if it throws, were 
able to copy part of the information. Is this reasonable?


https://reviews.llvm.org/D26512



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-11-10 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

aaron.ballman wrote:
> What do we want to do, if anything, for people who have scripts using the old 
> name? Do we want to keep the old name as an alias to the new name for some 
> period of time?
An alias helps if the check was enabled by name, but not if it was disabled by 
name.
If the alias is temporary, would you want a deprecation warning?
I wouldn't want to warn about `-checks=modernize*`, but maybe warning for 
`-checks=modernize-use-default` would be useful.


https://reviews.llvm.org/D26511



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-11-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");
+
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck("modernize-use-emplace");

malcolm.parsons wrote:
> aaron.ballman wrote:
> > What do we want to do, if anything, for people who have scripts using the 
> > old name? Do we want to keep the old name as an alias to the new name for 
> > some period of time?
> An alias helps if the check was enabled by name, but not if it was disabled 
> by name.
> If the alias is temporary, would you want a deprecation warning?
> I wouldn't want to warn about `-checks=modernize*`, but maybe warning for 
> `-checks=modernize-use-default` would be useful.
> An alias helps if the check was enabled by name, but not if it was disabled 
> by name.

Oye, this is true and unfortunate.

> If the alias is temporary, would you want a deprecation warning?
> I wouldn't want to warn about -checks=modernize*, but maybe warning for 
> -checks=modernize-use-default would be useful.

I think a deprecation warning would be a helpful feature, but not required. I 
do agree that I would not want a warning for wildcard matches.

I would also be fine if we simply had the documentation for 
`modernize-use-default` forward to the documentation for 
`modernize-use-equals-default` and put a note in there about the old name being 
deprecated and leave in an alias to the old name.

To be complete, I would also be fine if we remove the old name as in this 
patch. I am mostly thinking about what default policy we want to have when this 
situation arises. FWIW, the check was exposed under this name around Oct 2015, 
so it's been in the wild for over a year, and in a public release.


https://reviews.llvm.org/D26511



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


[PATCH] D25985: [analyzer] Export coverage information from the analyzer.

2016-11-10 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:262
+
+static void dumpCoverageInfo(llvm::SmallVectorImpl &Path,
+ SourceManager &SM) {

xazax.hun wrote:
> zaks.anna wrote:
> > xazax.hun wrote:
> > > zaks.anna wrote:
> > > > Can this be a debug checker?
> > > You mean the dumping part or also collecting the coverage? It can be a 
> > > debug checker if we add a new callback like "checkBasicBlockBegin". I did 
> > > not want to add such callback just for a debug check. However, it is 
> > > possible to move only the dumping part to a separate checker. What would 
> > > you prefer?
> > I would prefer to add a "checkBasicBlockBegin" callback and move all of 
> > this diagnostic code into a debug checker. 
> Do you think the checkers should be able to add state transitions from 
> BeginBasicBlock callback? Would you prefer to have an EndBasicBlock callback 
> for symmetry?
I cannot think of any right now. The main advantages of having this as a debug 
checker are:
 - Not having this code in ExprEngine.cpp - it's not related to the core engine 
functionality.
 - More importantly, discoverability of this functionality.

On the downside, we would not want to add a checker API if it has no useful 
users.



https://reviews.llvm.org/D25985



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-10 Thread Dave Lee via cfe-commits
kastiglione added a comment.

@arphaman Is the summary here sufficient, or should I elaborate in some way? 
I'm fine with this summary if you are.


https://reviews.llvm.org/D26406



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


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

2016-11-10 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.



Comment at: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp:396
+  // Calculate the name of the `NsDecl` after it is moved to new namespace.
+  std::string OldNs = NsDecl->getQualifiedNameAsString();
+  llvm::StringRef Postfix = OldNs;

You shouldn't dereference after a `dyn_cast`. Either null-check or use `cast`.


Repository:
  rL LLVM

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] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-10 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

It seems sufficient enough, I will commit it with the summary. Thanks!


https://reviews.llvm.org/D26406



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


[clang-tools-extra] r286485 - [change-namespace] dyn_cast -> cast.

2016-11-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Nov 10 12:15:34 2016
New Revision: 286485

URL: http://llvm.org/viewvc/llvm-project?rev=286485&view=rev
Log:
[change-namespace] dyn_cast -> cast.

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286485&r1=286484&r2=286485&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Nov 10 
12:15:34 2016
@@ -404,7 +404,7 @@ void ChangeNamespaceTool::run(
 clang::SourceRange VarRefRange = VarRef->getSourceRange();
 replaceQualifiedSymbolInDeclContext(
 Result, Context->getDeclContext(), VarRefRange.getBegin(),
-VarRefRange.getEnd(), llvm::dyn_cast(Var));
+VarRefRange.getEnd(), llvm::cast(Var));
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
@@ -421,7 +421,7 @@ void ChangeNamespaceTool::run(
 clang::SourceRange CalleeRange = Call->getCallee()->getSourceRange();
 replaceQualifiedSymbolInDeclContext(
 Result, Context->getDeclContext(), CalleeRange.getBegin(),
-CalleeRange.getEnd(), llvm::dyn_cast(Func));
+CalleeRange.getEnd(), llvm::cast(Func));
   }
 }
 
@@ -543,7 +543,7 @@ void ChangeNamespaceTool::replaceQualifi
 const DeclContext *DeclCtx, SourceLocation Start, SourceLocation End,
 const NamedDecl *FromDecl) {
   const auto *NsDeclContext = DeclCtx->getEnclosingNamespaceContext();
-  const auto *NsDecl = llvm::dyn_cast(NsDeclContext);
+  const auto *NsDecl = llvm::cast(NsDeclContext);
   // Calculate the name of the `NsDecl` after it is moved to new namespace.
   std::string OldNs = NsDecl->getQualifiedNameAsString();
   llvm::StringRef Postfix = OldNs;


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


[PATCH] D26456: Handle adding new nested namespace in old namespace.

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

LGTM with two nits.




Comment at: change-namespace/ChangeNamespace.cpp:475
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);

missing a trailing `.`.



Comment at: change-namespace/ChangeNamespace.cpp:477
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc;
+  if (OuterNs) {

How about `SourceLocation InsertionLoc = Start;` so that you don't need else 
statement below?


https://reviews.llvm.org/D26456



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


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

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



Comment at: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp:396
+  // Calculate the name of the `NsDecl` after it is moved to new namespace.
+  std::string OldNs = NsDecl->getQualifiedNameAsString();
+  llvm::StringRef Postfix = OldNs;

mehdi_amini wrote:
> You shouldn't dereference after a `dyn_cast`. Either null-check or use `cast`.
Thanks! Fixed by rL286485


Repository:
  rL LLVM

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] D24933: Enable configuration files in clang

2016-11-10 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

>> Default config file is searched for only in the directory where clang 
>> executable resides. It allows SDK suppliers to customize compiler, for 
>> instance by turning off unneeded warnings, by providing their own clang.cfg. 
>> On the other hand developers cannot by accident override default setting 
>> because clang.cfg is placed in system directory.
> 
> I thought one of the stated goals for this patch would be to allow users to 
> set default flags without touching the project's build system.

Yes, that's true. Initially it was supposed that a user can override compiler 
defaults by putting `clang.cfg` into well-knows places, including `~/llvm`, in 
particular. Then this idea was rejected as a result of feedback, and default 
config file now is allowed only in the directory where `clang` executable 
resides. It still allows to override default settings by SDK suppliers but 
limit this possibility to powerful users.

> What about this line?
> 
>   static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" });
> 
> That sounds like you'll be searching the home directory for a default config 
> file.

These are directories where config files specified by option `--config` are 
searched for. There is a big difference between default config files and those 
specified explicitly. Default file adds option silently, user does not specify 
anything in the command line. Due to this point it can represent a source of 
troubles, such as problems with bug reports. In contrast the named config files 
are specified explicitly in clang invocation. A user may set the same set of 
option by listing them in command line. Such config file does not represents 
any dander, it is only a convenience feature.

> And even if we ignore that, the CLANGCFG environment variable presents the 
> same problem.
> 
> Let's say a developer uses that to point to a config file with their 
> favourite compiler flags for compiling on their x86_64 machine.
> 
> But then they want to build something using the Android NDK, whose Clang will 
> now pull in that config file and start passing flags which doesn't apply to 
> the target, e.g. ARM. The user might not even be invoking the NDK directly; 
> it might be through Android Studio which certainly doesn't expect other flags 
> to be used than the ones it passes.

If a user forget to update LIBRARY_PATH or C_INCLUDE_PATH the result would be 
the same. Config file set by environment variable is similar to default config 
file as user does not specify anything in command line. But the user must 
explicitly specify the file, it is not made automatically.

Ability to append compiler options via environment variable is important 
feature, I think, because:

- This feature implemented by Intel compiles has proven its convenience.

- Build systems provided by software components are not perfect. Some do not 
honor CFLAGS, some require setting options inside makefiles etc. Changing 
compiler options might be a challenge. Environment variable solves this problem 
easily and effectively.

- most compilers support it, in particular:
  - Intel compiler: ICCCFG (https://software.intel.com/en-us/node/522775),
  - Keil C compilers: ARMCOMPILER6_CLANGOPT 
(http://www.keil.com/support/man/docs/armclang_intro/armclang_intro_chr1374139991387.htm)
  - Visual C: CL (https://msdn.microsoft.com/en-us/library/kezkeayy.aspx)
  - IBM XL C/C++: XLC_USR_CONFIG 
(http://www.ibm.com/support/knowledgecenter/en/SSGH3R_13.1.3/com.ibm.xlcpp1313.aix.doc/compiler_ref/tusetenv1.html)




https://reviews.llvm.org/D24933



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


[PATCH] D26456: Handle adding new nested namespace in old namespace.

2016-11-10 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 77509.
ioeric added a comment.

- Address comments.


https://reviews.llvm.org/D26456

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,48 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::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"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
   NewNamespace = "na::nc";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -57,16 +57,19 @@
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,20 @@
   // "x::y" will be inserted inside the existing namespace "a" and after "a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace.
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc = Start;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.SourceManager->getSpellingLoc(InsertionLoc));
   Mov

[PATCH] D26456: Handle adding new nested namespace in old namespace.

2016-11-10 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 77511.
ioeric added a comment.

- Merged origin/master


https://reviews.llvm.org/D26456

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,48 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::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"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
   NewNamespace = "na::nc";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -57,16 +57,19 @@
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,20 @@
   // "x::y" will be inserted inside the existing namespace "a" and after "a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace.
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc = Start;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.SourceManager->getSpellingLoc(InsertionLoc));
   

[clang-tools-extra] r286486 - Handle adding new nested namespace in old namespace.

2016-11-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Nov 10 12:29:01 2016
New Revision: 286486

URL: http://llvm.org/viewvc/llvm-project?rev=286486&view=rev
Log:
Handle adding new nested namespace in old namespace.

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286486&r1=286485&r2=286486&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Nov 10 
12:29:01 2016
@@ -57,16 +57,19 @@ SourceLocation EndLocationForType(TypeLo
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,20 @@ void ChangeNamespaceTool::moveOldNamespa
   // "x::y" will be inserted inside the existing namespace "a" and after 
"a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace.
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc = Start;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.SourceManager->getSpellingLoc(InsertionLoc));
   MoveNs.FID = Result.SourceManager->getFileID(Start);
   MoveNs.SourceMgr = Result.SourceManager;
   MoveNamespaces[R.getFilePath()].push_back(MoveNs);

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=286486&r1=286485&r2=286486&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Thu Nov 10 12:29:01 2016
@@ -97,6 +97,48 @@ TEST_F(ChangeNamespaceTest, SimpleMoveWi
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::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"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
+  NewNamespace = "

r286487 - Add -Wduplicate-protocol for existing diagnostic

2016-11-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Nov 10 12:30:26 2016
New Revision: 286487

URL: http://llvm.org/viewvc/llvm-project?rev=286487&view=rev
Log:
Add -Wduplicate-protocol for existing diagnostic

Expose a warning flag for warn_duplicate_protocol_def. This allows control
over the severity of duplicate protocol definitions.

For example -Werror=duplicate-protocol or
#pragma clang diagnostic ignored "-Wduplicate-protocol".

Patch provided by Dave Lee!

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Misc/warning-flags.c
cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286487&r1=286486&r2=286487&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 12:30:26 
2016
@@ -742,7 +742,9 @@ def err_recursive_superclass : Error<
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">;
+def warn_duplicate_protocol_def : Warning<
+  "duplicate protocol definition of %0 is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=286487&r1=286486&r2=286487&view=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Thu Nov 10 12:30:26 2016
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@ CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant

Modified: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m?rev=286487&r1=286486&r2=286487&view=diff
==
--- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original)
+++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Thu Nov 10 12:30:26 2016
@@ -35,6 +35,12 @@ void Gorf() // expected-error {{redefini
 @protocol PP @end  // expected-note {{previous definition is here}}
 @protocol PP @end  // expected-warning {{duplicate protocol definition of 
'PP'}}
 
+@protocol DP @end
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wduplicate-protocol"
+@protocol DP @end
+#pragma clang diagnostic pop
+
 @interface A(Cat) @end // expected-note {{previous definition is here}}
 @interface A(Cat) @end // expected-warning {{duplicate definition of 
category 'Cat' on interface 'A'}}
 


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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-10 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286487: Add -Wduplicate-protocol for existing diagnostic 
(authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26406?vs=77232&id=77514#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26406

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/test/Misc/warning-flags.c
  cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -742,7 +742,9 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">;
+def warn_duplicate_protocol_def : Warning<
+  "duplicate protocol definition of %0 is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;
Index: cfe/trunk/test/Misc/warning-flags.c
===
--- cfe/trunk/test/Misc/warning-flags.c
+++ cfe/trunk/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
===
--- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
+++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
@@ -35,6 +35,12 @@
 @protocol PP @end  // expected-note {{previous definition is here}}
 @protocol PP @end  // expected-warning {{duplicate protocol definition of 
'PP'}}
 
+@protocol DP @end
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wduplicate-protocol"
+@protocol DP @end
+#pragma clang diagnostic pop
+
 @interface A(Cat) @end // expected-note {{previous definition is here}}
 @interface A(Cat) @end // expected-warning {{duplicate definition of 
category 'Cat' on interface 'A'}}
 


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -742,7 +742,9 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">;
+def warn_duplicate_protocol_def : Warning<
+  "duplicate protocol definition of %0 is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;
Index: cfe/trunk/test/Misc/warning-flags.c
===
--- cfe/trunk/test/Misc/warning-flags.c
+++ cfe/trunk/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
===
--- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
+++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
@@ -35,6 +35,12 @@
 @protocol PP @end  // expected-note {{previous definition is here}}
 @protocol PP @end  // expected-warning {{duplicate protocol definition of 'PP

[PATCH] D26456: Handle adding new nested namespace in old namespace.

2016-11-10 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286486: Handle adding new nested namespace in old namespace. 
(authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D26456?vs=77511&id=77513#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26456

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -57,16 +57,19 @@
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,20 @@
   // "x::y" will be inserted inside the existing namespace "a" and after "a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace.
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc = Start;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.SourceManager->getSpellingLoc(InsertionLoc));
   MoveNs.FID = Result.SourceManager->getFileID(Start);
   MoveNs.SourceMgr = Result.SourceManager;
   MoveNamespaces[R.getFilePath()].push_back(MoveNs);
Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,48 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::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"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "namesp

[PATCH] D26493: [clang-move] Make the output code look more pretty.

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



Comment at: clang-move/ClangMove.cpp:273
 }
+bool IsNamespaceStart = false;
 while (DeclIt != DeclNamespaces.end()) {

It's been a while since the last time I reviewed this, and I need to struggle 
to understand what CurrentNamespaces, NextNamespaces, and IsNamespaceStart 
are... some comments for them are really appreciated.


https://reviews.llvm.org/D26493



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


[PATCH] D25985: [analyzer] Export coverage information from the analyzer.

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

Maybe you could instead make a checker that subscribes for `checkEndAnalysis` 
and scans the provided `ExplodedGraph`'s `nodes_begin()..nodes_end()` for 
visited statement-based program points (as in 
`PathDiagnosticLocation::getStmt(N)`)? This should give you per-statement 
precision, and you'd avoid dealing with the CFG element kinds. That sounds more 
straightforward and that's essentially how our deadcode checker works (but it 
suppresses its positives for incomplete analyses - you don't need even that).


https://reviews.llvm.org/D25985



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


[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.

2016-11-10 Thread Pirama Arumuga Nainar via cfe-commits
pirama accepted this revision.
pirama added a reviewer: pirama.
pirama added a comment.
This revision is now accepted and ready to land.

The bug points back to this Phab page instead of a bug.  LGTM otherwise.


https://reviews.llvm.org/D26491



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


[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

2016-11-10 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D26479



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


[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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

No functionality change.

This is a refactoring patch, which makes the code more readable and easy
to extend it to support more types.


https://reviews.llvm.org/D26515

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h

Index: clang-move/ClangMove.h
===
--- clang-move/ClangMove.h
+++ clang-move/ClangMove.h
@@ -16,6 +16,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -80,6 +81,14 @@
clang::CharSourceRange IncludeFilenameRange,
const SourceManager &SM);
 
+  std::vector &getMovedDecls() { return MovedDecls; }
+
+  std::vector &getRemovedDecls() { return RemovedDecls; }
+
+  llvm::SmallPtrSet &getUnremovedDeclsInOldHeader() {
+return UnremovedDeclsInOldHeader;
+  }
+
 private:
   // Make the Path absolute using the OrignalRunningDirectory if the Path is not
   // an absolute path. An empty Path will result in an empty string.
@@ -90,6 +99,9 @@
   void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile);
 
   MoveDefinitionSpec Spec;
+  // Stores all MatchCallbacks created by this tool.
+  std::vector>
+  MatchCallbacksHolder;
   // The Key is file path, value is the replacements being applied to the file.
   std::map &FileToReplacements;
   // All declarations (the class decl being moved, forward decls) that need to
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -136,6 +136,54 @@
   ClangMoveTool *const MoveTool;
 };
 
+class ClassDeclarationMatcher : public MatchFinder::MatchCallback {
+public:
+  explicit ClassDeclarationMatcher(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {
+  // Skip inline class methods. isInline() ast matcher doesn't ignore this
+  // case.
+  if (!CMD->isInlined()) {
+MoveTool->getMovedDecls().emplace_back(
+CMD, &Result.Context->getSourceManager());
+MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+// Get template class method from its method declaration as
+// UnremovedDecls stores template class method.
+if (const auto *FTD = CMD->getDescribedFunctionTemplate()) {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(FTD);
+} else {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(CMD);
+}
+  }
+} else if (const auto *VD = Result.Nodes.getNodeAs(
+   "class_static_var_decl")) {
+  MoveTool->getMovedDecls().emplace_back(
+  VD, &Result.Context->getSourceManager());
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(VD);
+} else if (const auto *CD = Result.Nodes.getNodeAs(
+   "moved_class")) {
+  // Get class template from its class declaration as UnremovedDecls stores
+  // class template.
+  if (const auto *TC = CD->getDescribedClassTemplate()) {
+MoveTool->getMovedDecls().emplace_back(
+TC, &Result.Context->getSourceManager());
+  } else {
+MoveTool->getMovedDecls().emplace_back(
+CD, &Result.Context->getSourceManager());
+  }
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(
+  MoveTool->getMovedDecls().back().Decl);
+}
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 // Expand to get the end location of the line where the EndLoc of the given
 // Decl.
 SourceLocation
@@ -352,23 +400,28 @@
   //
   // Matchers for old files, including old.h/old.cc
   //
+  auto ClassMatchCallback = llvm::make_unique(this);
   // Match moved class declarations.
-  auto MovedClass = cxxRecordDecl(
-  InOldFiles, *InMovedClassNames, isDefinition(),
-  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
-  Finder->addMatcher(MovedClass.bind("moved_class"), this);
+  auto MovedClass =
+  cxxRecordDecl(
+  InOldFiles, *InMovedClassNames, isDefinition(),
+  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(
+  .bind("moved_class");
+  Finder->addMatcher(MovedClass, ClassMatchCallback.get());
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
   Finder->addMatcher(
   cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNa

[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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



Comment at: clang-move/ClangMove.cpp:144
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {

It'd be more readable if you pull each case below into a helper function.



Comment at: clang-move/ClangMove.cpp:403
   
//
+  auto ClassMatchCallback = llvm::make_unique(this);
   // Match moved class declarations.

`push_back` and then use `back()` would save you a variable.



Comment at: clang-move/ClangMove.cpp:424
+  // Extend the MatchCallback lifetime.
+  MatchCallbacksHolder.push_back(std::move(ClassMatchCallback));
 

I'd first move `push_back` to the top, and then use 
`MatchCallbacksHolder.back()`.



Comment at: clang-move/ClangMove.h:104
+  std::vector>
+  MatchCallbacksHolder;
   // The Key is file path, value is the replacements being applied to the file.

Simply `MatchCallbacks` would be a better name IMO.


https://reviews.llvm.org/D26515



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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-10 Thread Yaxun Liu via cfe-commits
yaxunl marked 12 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7040
+ auto AS = PT->getAddressSpace();
+ return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0;
+}

rjmccall wrote:
> This check is definitely not correct; this function needs to return true when 
> AS == 0, right?
> 
> Also, you should really just be checking QT.getAddressSpace().
The null pointer of amdgpu target in addr space 0 does not have zero value.

I will change it use QT.getAddressSpace() though.


https://reviews.llvm.org/D26196



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-10 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:219
+
+  assert(LCtx->getKind() == LocationContext::StackFrame &&
+ "Function does not begin with stack frame context");

a.sidorin wrote:
> `isa(LCtx)`?
> And `cast<>` below already does the same check with an assertion.
At least one advantage of the assert is that it provides an error message. I'd 
not try to minimize the number of asserts.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423
+
+void IteratorPastEndChecker::handleComparison(CheckerContext &C,
+  const SVal &LVal,

baloghadamsoftware wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > baloghadamsoftware wrote:
> > > > NoQ wrote:
> > > > > a.sidorin wrote:
> > > > > > What will happen if we write something like this:
> > > > > > ```
> > > > > > bool Eq1 = it1 == it2;
> > > > > > bool Eq2 = it3 == it4;
> > > > > > if (Eq1) {...}?
> > > > > > ```
> > > > > > 
> > > > > > As I understand, we'll assume the second condition instead of first.
> > > > > Had a look. So the problem is, we obtain the result of the comparison 
> > > > > as a symbol, from which it is too hard to recover the operands in 
> > > > > order to move iterator position data from one value to another.
> > > > > 
> > > > > Normally we obtain a simple SymbolConjured for the return value of 
> > > > > the `operator==()` call (or, similarly, `operator!=()`). For 
> > > > > plain-value iterators (eg. `typedef T *iterator`) we might be 
> > > > > obtaining an actual binary symbolic expression, but even then it's 
> > > > > not quite clear how to obtain operands (the structure of the 
> > > > > expression might have changed due to algebraic simplifications). 
> > > > > Additionally, LHS and RHS aren't necessarily symbols (they might be 
> > > > > semi-concrete), so composing symbolic expressions from them in 
> > > > > general is problematic with our symbol hierarchy, which is rarely a 
> > > > > problem for numbers but for structural symbols it'd be a mess.
> > > > > 
> > > > > For now i suggest, instead of storing only the last LHS and RHS, to 
> > > > > save a map from symbols (which are results of comparisons) to (LHS 
> > > > > value, RHS value) pairs. This map should, apart from the obvious, be 
> > > > > cleaned up whenever one of the iterators in the pair gets mutated 
> > > > > (incremented or decremented). This should take care of the problem 
> > > > > Alexey points out, and should work with semi-concrete stuff.
> > > > > 
> > > > > For the future i suggest to let users construct their own symbols and 
> > > > > symbolic expressions more easily. In fact, if only we had all 
> > > > > iterators as regions, we should have probably used SymbolMetadata for 
> > > > > this purpose: it's easy to both recover the parent region from it and 
> > > > > use it in symbolic expressions. We could also deprecate the confusing 
> > > > > structural symbols (provide default-bound lazy compound values for 
> > > > > conjured structures instead), and then it'd be possible to transition 
> > > > > to SymbolMetadata entirely.
> > > > Thank you for the suggestion. I am not sure if I fully understand you. 
> > > > If I create a map where the key is the resulting symbol of the 
> > > > comparison, it will not work because evalAssume is called for the 
> > > > innermost comparison. So if the body of operator== (or operator!=) is 
> > > > inlined, then I get a binary symbolic expression in evalAssume, not the 
> > > > SymbolConjured. This binary Symbolic expression is a comparison of the 
> > > > internals of the iterators, e.g. the internal pointer. So the key will 
> > > > not match any LHS and RHS value pair in the map. I also thought on such 
> > > > solution earlier but I dismissed it because of this.
> > > Well, even if the body of the comparison operator is inlined, 
> > > PreStmt/PostStmt callbacks should still work, and it doesn't really 
> > > matter if there's a `SymbolConjured` or not, we can still add the 
> > > symbolic expression to our map as a key.
> > > 
> > > Essentially, you ignore whatever happens in the iterator's operator==() 
> > > when it's inlined (including any evalAssume events), then in PostStmt of 
> > > operator==() you map the return-value symbol of the operator to the 
> > > operator's arguments (operands), then whenever an assumption is being 
> > > made against the return-value symbol, you carry over this assumption to 
> > > the operands. I think it shouldn't really matter if the operator call was 
> > > inlined.
> > > 
> > > The only unexpected thing that may happen due to inlining is if the 
> > > inlined operator returns a concrete value (plain true or plain false) 
> > > instead of the symbol, but in this case what we need to do is to just 
> > > carry over the assumption to the operands instantly.
> > Maybe if I evalua

[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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

Address comments.


https://reviews.llvm.org/D26515

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h

Index: clang-move/ClangMove.h
===
--- clang-move/ClangMove.h
+++ clang-move/ClangMove.h
@@ -16,6 +16,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -80,6 +81,14 @@
clang::CharSourceRange IncludeFilenameRange,
const SourceManager &SM);
 
+  std::vector &getMovedDecls() { return MovedDecls; }
+
+  std::vector &getRemovedDecls() { return RemovedDecls; }
+
+  llvm::SmallPtrSet &getUnremovedDeclsInOldHeader() {
+return UnremovedDeclsInOldHeader;
+  }
+
 private:
   // Make the Path absolute using the OrignalRunningDirectory if the Path is not
   // an absolute path. An empty Path will result in an empty string.
@@ -90,6 +99,9 @@
   void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile);
 
   MoveDefinitionSpec Spec;
+  // Stores all MatchCallbacks created by this tool.
+  std::vector>
+  MatchCallbacks;
   // The Key is file path, value is the replacements being applied to the file.
   std::map &FileToReplacements;
   // All declarations (the class decl being moved, forward decls) that need to
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -136,6 +136,54 @@
   ClangMoveTool *const MoveTool;
 };
 
+class ClassDeclarationMatcher : public MatchFinder::MatchCallback {
+public:
+  explicit ClassDeclarationMatcher(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {
+  // Skip inline class methods. isInline() ast matcher doesn't ignore this
+  // case.
+  if (!CMD->isInlined()) {
+MoveTool->getMovedDecls().emplace_back(
+CMD, &Result.Context->getSourceManager());
+MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+// Get template class method from its method declaration as
+// UnremovedDecls stores template class method.
+if (const auto *FTD = CMD->getDescribedFunctionTemplate()) {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(FTD);
+} else {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(CMD);
+}
+  }
+} else if (const auto *VD = Result.Nodes.getNodeAs(
+   "class_static_var_decl")) {
+  MoveTool->getMovedDecls().emplace_back(
+  VD, &Result.Context->getSourceManager());
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(VD);
+} else if (const auto *CD = Result.Nodes.getNodeAs(
+   "moved_class")) {
+  // Get class template from its class declaration as UnremovedDecls stores
+  // class template.
+  if (const auto *TC = CD->getDescribedClassTemplate()) {
+MoveTool->getMovedDecls().emplace_back(
+TC, &Result.Context->getSourceManager());
+  } else {
+MoveTool->getMovedDecls().emplace_back(
+CD, &Result.Context->getSourceManager());
+  }
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(
+  MoveTool->getMovedDecls().back().Decl);
+}
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 // Expand to get the end location of the line where the EndLoc of the given
 // Decl.
 SourceLocation
@@ -352,23 +400,27 @@
   //
   // Matchers for old files, including old.h/old.cc
   //
+  // Create a MatchCallback for class declarations.
+  MatchCallbacks.push_back(llvm::make_unique(this));
   // Match moved class declarations.
-  auto MovedClass = cxxRecordDecl(
-  InOldFiles, *InMovedClassNames, isDefinition(),
-  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
-  Finder->addMatcher(MovedClass.bind("moved_class"), this);
+  auto MovedClass =
+  cxxRecordDecl(
+  InOldFiles, *InMovedClassNames, isDefinition(),
+  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(
+  .bind("moved_class");
+  Finder->addMatcher(MovedClass, MatchCallbacks.back().get());
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
   Finder->addMatcher(
   cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNames),
 isDefinition())
   .bind("

[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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



Comment at: clang-move/ClangMove.cpp:144
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {

ioeric wrote:
> It'd be more readable if you pull each case below into a helper function.
hmm, I'd prefer current way. Because I don't see significant advantage by 
pulling each case into a helper function, since the code for each condition is 
used only once. 
 


https://reviews.llvm.org/D26515



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


[PATCH] D26442: [analyzer] Fix crash on getSVal: handle case of CompoundVal

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

Wow, this crash must have been hard to notice!

I think we shouldn't be default-binding non-lazy compound values. Normally we 
unpack them into field bindings right away, but it seems that nobody cared to 
implement this for unions.

The current crash goes through `RegionStoreManager::bind()`,

 2000   if (Ty->isVectorType())
 2001 return bindVector(B, TR, V);
 2002   if (Ty->isUnionType())
  -> 2003 return bindAggregate(B, TR, V);

I think that instead of doing `bindAggregate()`, we should do something similar 
to what `RegionStoreManager::bindStruct()` does (the code that handles compound 
values should probably be factored out). It should be even easier because 
unions hold only one value.

I'm not sure if my suggestion has any immediate benefits to overweight its 
complexity, but it should make improving support for unions easier in the 
future.

Also, the code for the lazy compound value is really out of place here. All it 
does is works around the huge and famous FIXME in 
`getBindingForFieldOrElementCommon()`. But i don't think we should grow this 
FIXME into unions.


Repository:
  rL LLVM

https://reviews.llvm.org/D26442



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


[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.

2016-11-10 Thread Evgeniy Stepanov via cfe-commits
eugenis accepted this revision.
eugenis added a reviewer: eugenis.
eugenis added a comment.

Looks great!


https://reviews.llvm.org/D26491



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


[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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



Comment at: clang-move/ClangMove.cpp:144
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {

hokein wrote:
> ioeric wrote:
> > It'd be more readable if you pull each case below into a helper function.
> hmm, I'd prefer current way. Because I don't see significant advantage by 
> pulling each case into a helper function, since the code for each condition 
> is used only once. 
>  
Generally, we prefer short functions to long functions. 



Comment at: clang-move/ClangMove.cpp:139
 
+class ClassDeclarationMatcher : public MatchFinder::MatchCallback {
+public:

Why is this called a Matcher?


https://reviews.llvm.org/D26515



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


r286494 - Correcting a documentation formatting bug; NFC.

2016-11-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Nov 10 13:45:49 2016
New Revision: 286494

URL: http://llvm.org/viewvc/llvm-project?rev=286494&view=rev
Log:
Correcting a documentation formatting bug; NFC.

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=286494&r1=286493&r2=286494&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Nov 10 13:45:49 2016
@@ -2697,11 +2697,11 @@ functions that have an argument with a t
 behaviour is changed in the following manner:
 
 - A value whose type is any member of the transparent union can be passed as an
-argument without the need to cast that value.
+  argument without the need to cast that value.
 
 - The argument is passed to the function using the calling convention of the
-first member of the transparent union. Consequently, all the members of the
-transparent union should have the same calling convention as its first member.
+  first member of the transparent union. Consequently, all the members of the
+  transparent union should have the same calling convention as its first 
member.
 
 Transparent unions are not supported in C++.
   }];


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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-10 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 77525.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Changed APValue to differentiate with null pointer and pointers casted from 
integer. Fixed casting integer to pointer.

Refactored isNullPtrZero to use just QualType as parameter.

Added tests for casting integer to pointer, initialization of static and 
function-scope variable, and cast pointer to bool.


https://reviews.llvm.org/D26196

Files:
  include/clang/AST/APValue.h
  lib/AST/APValue.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,487 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test default initialization of pointers.
+
+// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *p1;
+
+// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *p2;
+
+// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *p3;
+
+// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *p4;
+
+// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *p5;
+
+// Test default initialization of sturcture.
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4
+StructTy1 S1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+
+// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4
+StructTy2 S2;
+
+// Test default initialization of array.
+// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4
+StructTy1 A1[2];
+
+// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroi

[PATCH] D26415: [XRay] Support AArch64 in Clang

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

https://reviews.llvm.org/D26415

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


Index: test/Driver/XRay/xray-instrument-os.c
===
--- test/Driver/XRay/xray-instrument-os.c
+++ test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: test/Driver/XRay/xray-instrument-cpu.c
===
--- test/Driver/XRay/xray-instrument-cpu.c
+++ test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4900,11 +4900,16 @@
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 const char *const XRayInstrumentOption = "-fxray-instrument";
-if (Triple.getOS() == llvm::Triple::Linux &&
-(Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+if (Triple.getOS() != llvm::Triple::Linux)
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS.");
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::arm:
+case llvm::Triple::aarch64:
   // Supported.
-} else {
+  break;
+default:
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }


Index: test/Driver/XRay/xray-instrument-os.c
===
--- test/Driver/XRay/xray-instrument-os.c
+++ test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: test/Driver/XRay/xray-instrument-cpu.c
===
--- test/Driver/XRay/xray-instrument-cpu.c
+++ test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4900,11 +4900,16 @@
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 const char *const XRayInstrumentOption = "-fxray-instrument";
-if (Triple.getOS() == llvm::Triple::Linux &&
-(Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+if (Triple.getOS() != llvm::Triple::Linux)
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS.");
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::arm:
+case llvm::Triple::aarch64:
   // Supported.
-} else {
+  break;
+default:
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-10 Thread Serge Rogatch via cfe-commits
rSerge marked 5 inline comments as done.
rSerge added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

dberris wrote:
> rSerge wrote:
> > dberris wrote:
> > > rSerge wrote:
> > > > dberris wrote:
> > > > > I'm wondering whether it's worth turning this into a `switch` 
> > > > > statement now that we have more than two supported architectures?
> > > > I think that would lead to more awkward code: there wouldn't be a 
> > > > single decision outcome point (like the current `else` block), so to 
> > > > avoid duplicating the code which currently prints the message, a `bool` 
> > > > variable would be needed. I think it's more neat to just enumerate all 
> > > > the OS&CPU combinations in the `if` condition for now.
> > > > This place is not performance-critical and the compiler should convert 
> > > > appropriate `if`s into `switch`es anyway.
> > > This is an issue of making it more readable, something like:
> > > 
> > > ```
> > > if (Triple.getOS() != llvm::Triple::Linux)
> > >   D.Diag(...) << ...; // Unsupported OS.
> > > switch (Triple.getArch()) {
> > >   case llvm::Triple::arm:
> > >   case llvm::Triple::x86_64:
> > >   case llvm::Tripe::aarch64:
> > > // Supported.
> > > break;
> > >   default:
> > > D.Diag(...) << ...;
> > > }
> > > ```
> > > 
> > > This way any new architectures become supported, they just get added to 
> > > the list of cases that short-circuit.
> > We can't say that an OS is supported or unsupported unless all CPU 
> > architectures for this OS support or don't support XRay, and this is not 
> > going to happen in the near future. So it is more accurate to say about the 
> > triple: some triples are supported and some are not. So in coding it is 
> > natural to check for the triple with `||` and `&&`.
> > We can't say that an OS is supported or unsupported unless all CPU 
> > architectures for this OS support or don't support XRay, and this is not 
> > going to happen in the near future.
> 
> I don't get it. Right now, as written, it doesn't matter what OS it is -- any 
> OS other than Linux wouldn't be supported anyway. Maybe I mis-wrote, but:
> 
> ```
> if (Triple.getOS() != llvm::Triple::Linux)
>   D.Diag(...) << ...;
> else switch(Triple.getArch()) {
>   ...
>   default:
> D.Diag(...) << ...;
> }
> ```
> 
> Is a direct translation that's more readable than the current complex if 
> statement conditional.
> 
> > So it is more accurate to say about the triple: some triples are supported 
> > and some are not. So in coding it is natural to check for the triple with 
> > || and &&.
> 
> Sure, but conditional is already unwieldy with just three supported platforms.
Changed.


https://reviews.llvm.org/D26415



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


[PATCH] D26519: [PowerPC] Implement BE VSX load/store builtins - clang portion.

2016-11-10 Thread Tony Jiang via cfe-commits
jtony created this revision.
jtony added reviewers: nemanjai, amehsan, kbarton, sfertile, syzaara, lei.
jtony added subscribers: cfe-commits, echristo, llvm-commits.

This patch implements all the overloads for vec_xl_be and vec_xst_be. On BE,
they behaves exactly the same with vec_xl and vec_xst, therefore they are
simply implemented by defining a matching macro. On LE, they are implemented
by defining new builtins and intrinsics. For int/float/long long/double, it
is just a load (lxvw4x/lxvd2x) or store(stxvw4x/stxvd2x). For char/char/short,
we also need some extra shuffling before or after call the builtins to get the
desired BE order. For int128, simply call vec_xl or vec_xst.

Signatures:
vector signed char vec_xl_be (signed long long, signed char *);
vector unsigned char vec_xl_be (signed long long, unsigned char *);
vector signed int vec_xl_be (signed long long, signed int *);
vector unsigned int vec_xl_be (signed long long, unsigned int *);
vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
vector signed long long vec_xl_be (signed long long, signed long long *);
vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
vector signed short vec_xl_be (signed long long, signed short *);
vector unsigned short vec_xl_be (signed long long, unsigned short *);
vector double vec_xl_be (signed long long, double *);
vector float vec_xl_be (signed long long, float *);
void vec_xst_be (vector signed char, signed long long, signed char *);
void vec_xst_be (vector unsigned char, signed long long, unsigned char *);
void vec_xst_be (vector signed int, signed long long, signed int *);
void vec_xst_be (vector unsigned int, signed long long, unsigned int *);
void vec_xst_be (vector signed __int128, signed long long, signed __int128 *);
void vec_xst_be (vector unsigned __int128, signed long long, unsigned __int128 
*);
void vec_xst_be (vector signed long long, signed long long, signed long long *);
void vec_xst_be (vector unsigned long long, signed long long, unsigned long 
long *);
void vec_xst_be (vector signed short, signed long long, signed short *);
void vec_xst_be (vector unsigned short, signed long long, unsigned short *);
void vec_xst_be (vector double, signed long long, double *);
void vec_xst_be (vector float, signed long long, float *);


https://reviews.llvm.org/D26519

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-quadword.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -1273,4 +1273,28 @@
 vec_xst(vd, sll, ad);
 // CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 // CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+
+res_vsll = vec_xl_be(sll, asll);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+
+res_vull = vec_xl_be(sll, aull);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+
+res_vd = vec_xl_be(sll, ad);
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+
+vec_xst_be(vsll, sll, asll);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
+
+vec_xst_be(vull, sll, aull);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
+
+vec_xst_be(vd, sll, ad);
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
 }
Index: test/CodeGen/builtins-ppc-quadword.c
===
--- test/CodeGen/builtins-ppc-quadword.c
+++ test/CodeGen/builtins-ppc-quadword.c
@@ -193,4 +193,26 @@
   // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
   // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
   // CHECK-PPC: error: call to 'vec_xst' is ambiguous
+
+  /* vec_xl_be */
+  res_vlll = vec_xl_be(param_sll, ¶m_lll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xl' is ambiguous
+
+  res_vulll = vec_xl_be(param_sll, ¶m_ulll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC

r286500 - Clean up uses of unique_ptr for RAII objects. NFC.

2016-11-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Nov 10 14:43:52 2016
New Revision: 286500

URL: http://llvm.org/viewvc/llvm-project?rev=286500&view=rev
Log:
Clean up uses of unique_ptr for RAII objects. NFC.

- EnterExpressionEvaluationContext allows you to specify whether you
  *actually* want to enter an evaluation context.
- For types that don't allow that, llvm::Optional should do the
  same thing as std::unique_ptr, but with 100% less heap
  allocations.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=286500&r1=286499&r2=286500&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Nov 10 14:43:52 2016
@@ -25,6 +25,7 @@
 #include "clang/Sema/PrettyDeclStackTrace.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -301,10 +302,10 @@ unsigned Parser::ParseAttributeArgsCommo
 
 // Parse the non-empty comma-separated list of expressions.
 do {
-  std::unique_ptr Unevaluated;
-  if (attributeParsedArgsUnevaluated(*AttrName))
-Unevaluated.reset(
-new EnterExpressionEvaluationContext(Actions, Sema::Unevaluated));
+  bool ShouldEnter = attributeParsedArgsUnevaluated(*AttrName);
+  EnterExpressionEvaluationContext Unevaluated(
+  Actions, Sema::Unevaluated, /*LambdaContextDecl=*/nullptr,
+  /*IsDecltype=*/false, ShouldEnter);
 
   ExprResult ArgExpr(
   Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
@@ -366,13 +367,13 @@ void Parser::ParseGNUAttributeArgs(Ident
 
   // These may refer to the function arguments, but need to be parsed early to
   // participate in determining whether it's a redeclaration.
-  std::unique_ptr PrototypeScope;
+  llvm::Optional PrototypeScope;
   if (normalizeAttrName(AttrName->getName()) == "enable_if" &&
   D && D->isFunctionDeclarator()) {
 DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo();
-PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope |
-Scope::FunctionDeclarationScope |
-Scope::DeclScope));
+PrototypeScope.emplace(this, Scope::FunctionPrototypeScope |
+ Scope::FunctionDeclarationScope |
+ Scope::DeclScope);
 for (unsigned i = 0; i != FTI.NumParams; ++i) {
   ParmVarDecl *Param = cast(FTI.Params[i].Param);
   Actions.ActOnReenterCXXMethodParameter(getCurScope(), Param);


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


[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

2016-11-10 Thread Branko Kokanovic via cfe-commits
branko added a comment.

Thanks. @djasper - can you commit this for me, please?


https://reviews.llvm.org/D26163



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


[PATCH] D26520: [PowerPC] Implement BE VSX load/store builtins - llvm portion.

2016-11-10 Thread Tony Jiang via cfe-commits
jtony created this revision.
jtony added reviewers: nemanjai, sfertile, syzaara, lei, kbarton, amehsan.
jtony added subscribers: llvm-commits, cfe-commits, echristo.

This patch implements all the overloads for vec_xl_be and vec_xst_be. On BE,
they behaves exactly the same with vec_xl and vec_xst, therefore they are
simply implemented by defining a matching macro. On LE, they are implemented
by defining new builtins and intrinsics. For int/float/long long/double, it
is just a load (lxvw4x/lxvd2x) or store(stxvw4x/stxvd2x). For char/char/short,
we also need some extra shuffling before or after call the builtins to get the
desired BE order. For int128, simply call vec_xl or vec_xst.

Signatures:
vector signed char vec_xl_be (signed long long, signed char *);
vector unsigned char vec_xl_be (signed long long, unsigned char *);
vector signed int vec_xl_be (signed long long, signed int *);
vector unsigned int vec_xl_be (signed long long, unsigned int *);
vector signed int128 vec_xl_be (signed long long, signed int128 *);
vector unsigned int128 vec_xl_be (signed long long, unsigned int128 *);
vector signed long long vec_xl_be (signed long long, signed long long *);
vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
vector signed short vec_xl_be (signed long long, signed short *);
vector unsigned short vec_xl_be (signed long long, unsigned short *);
vector double vec_xl_be (signed long long, double *);
vector float vec_xl_be (signed long long, float *);
void vec_xst_be (vector signed char, signed long long, signed char *);
void vec_xst_be (vector unsigned char, signed long long, unsigned char *);
void vec_xst_be (vector signed int, signed long long, signed int *);
void vec_xst_be (vector unsigned int, signed long long, unsigned int *);
void vec_xst_be (vector signed int128, signed long long, signed int128 *);
void vec_xst_be (vector unsigned int128, signed long long, unsigned int128 *);
void vec_xst_be (vector signed long long, signed long long, signed long long *);
void vec_xst_be (vector unsigned long long, signed long long, unsigned long 
long *);
void vec_xst_be (vector signed short, signed long long, signed short *);
void vec_xst_be (vector unsigned short, signed long long, unsigned short *);
void vec_xst_be (vector double, signed long long, double *);
void vec_xst_be (vector float, signed long long, float *);


https://reviews.llvm.org/D26520

Files:
  include/llvm/IR/IntrinsicsPowerPC.td
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCInstrVSX.td
  test/CodeGen/PowerPC/vsx.ll

Index: test/CodeGen/PowerPC/vsx.ll
===
--- test/CodeGen/PowerPC/vsx.ll
+++ test/CodeGen/PowerPC/vsx.ll
@@ -1190,3 +1190,51 @@
 ; CHECK-LE: xscmpudp [[REG:[0-9]+]], 3, 4
 ; CHECK-LE: beqlr [[REG]]
 }
+
+; Function Attrs: nounwind readnone
+define <4 x i32> @test83(i8* %a) {
+  entry:
+%0 = tail call <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8* %a)
+  ret <4 x i32> %0
+  ; CHECK-LABEL: test83
+  ; CHECK: lxvw4x 34, 0, 3
+  ; CHECK: blr
+}
+; Function Attrs: nounwind readnone
+declare <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8*)
+
+; Function Attrs: nounwind readnone
+define <2 x double> @test84(i8* %a) {
+  entry:
+%0 = tail call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %a)
+  ret <2 x double> %0
+  ; CHECK-LABEL: test84
+  ; CHECK: lxvd2x 34, 0, 3
+  ; CHECK: blr
+}
+; Function Attrs: nounwind readnone
+declare <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8*)
+
+; Function Attrs: nounwind readnone
+define void @test85(<4 x i32> %a, i8* %b) {
+  entry:
+tail call void @llvm.ppc.vsx.stxvw4x.be(<4 x i32> %a, i8* %b)
+ret void
+  ; CHECK-LABEL: test85
+  ; CHECK: stxvw4x 34, 0, 5
+  ; CHECK: blr
+}
+; Function Attrs: nounwind readnone
+declare void @llvm.ppc.vsx.stxvw4x.be(<4 x i32>, i8*)
+
+; Function Attrs: nounwind readnone
+define void @test86(<2 x double> %a, i8* %b) {
+  entry:
+tail call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %a, i8* %b)
+ret void
+  ; CHECK-LABEL: test86
+  ; CHECK: stxvd2x 34, 0, 5
+  ; CHECK: blr
+}
+; Function Attrs: nounwind readnone
+declare void @llvm.ppc.vsx.stxvd2x.be(<2 x double>, i8*)
Index: lib/Target/PowerPC/PPCInstrVSX.td
===
--- lib/Target/PowerPC/PPCInstrVSX.td
+++ lib/Target/PowerPC/PPCInstrVSX.td
@@ -1012,6 +1012,10 @@
 (STXVD2X $rS, xoaddr:$dst)>;
   def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, xoaddr:$dst),
 (STXVW4X $rS, xoaddr:$dst)>;
+  def : Pat<(int_ppc_vsx_stxvd2x_be v2f64:$rS, xoaddr:$dst),
+(STXVD2X $rS, xoaddr:$dst)>;
+  def : Pat<(int_ppc_vsx_stxvw4x_be v4i32:$rS, xoaddr:$dst),
+(STXVW4X $rS, xoaddr:$dst)>;
   def : Pat<(PPCstxvd2x v2f64:$rS, xoaddr:$dst), (STXVD2X $rS, xoaddr:$dst)>;
 }
 let Predicates = [IsBigEndian, HasVSX, HasOnlySwappingMemOps] in {
@@ -1840,6 +1844,9 @@
   def : Pat<(f64 (vector_extract v

[PATCH] D24933: Enable configuration files in clang

2016-11-10 Thread Hans Wennborg via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D24933#591943, @sepavloff wrote:

> >> Default config file is searched for only in the directory where clang 
> >> executable resides. It allows SDK suppliers to customize compiler, for 
> >> instance by turning off unneeded warnings, by providing their own 
> >> clang.cfg. On the other hand developers cannot by accident override 
> >> default setting because clang.cfg is placed in system directory.
> > 
> > I thought one of the stated goals for this patch would be to allow users to 
> > set default flags without touching the project's build system.
>
> Yes, that's true. Initially it was supposed that a user can override compiler 
> defaults by putting `clang.cfg` into well-knows places, including `~/llvm`, 
> in particular. Then this idea was rejected as a result of feedback, and 
> default config file now is allowed only in the directory where `clang` 
> executable resides. It still allows to override default settings by SDK 
> suppliers but limit this possibility to powerful users.


I see. The SDK use case seems quite reasonable to me.

>> What about this line?
>> 
>>   static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" });
>> 
>> That sounds like you'll be searching the home directory for a default config 
>> file.
> 
> These are directories where config files specified by option `--config` are 
> searched for. There is a big difference between default config files and 
> those specified explicitly. Default file adds option silently, user does not 
> specify anything in the command line. Due to this point it can represent a 
> source of troubles, such as problems with bug reports. In contrast the named 
> config files are specified explicitly in clang invocation. A user may set the 
> same set of option by listing them in command line. Such config file does not 
> represents any dander, it is only a convenience feature.

Oh, I misunderstood then. Thanks for clarifying.

>> And even if we ignore that, the CLANGCFG environment variable presents the 
>> same problem.
>> 
>> Let's say a developer uses that to point to a config file with their 
>> favourite compiler flags for compiling on their x86_64 machine.
>> 
>> But then they want to build something using the Android NDK, whose Clang 
>> will now pull in that config file and start passing flags which doesn't 
>> apply to the target, e.g. ARM. The user might not even be invoking the NDK 
>> directly; it might be through Android Studio which certainly doesn't expect 
>> other flags to be used than the ones it passes.
> 
> If a user forget to update LIBRARY_PATH or C_INCLUDE_PATH the result would be 
> the same.

I don't like those either :-)

> Config file set by environment variable is similar to default config file as 
> user does not specify anything in command line. But the user must explicitly 
> specify the file, it is not made automatically.

Sorry, I don't understand this part.

> Ability to append compiler options via environment variable is important 
> feature, I think, because:
> 
> - This feature implemented by Intel compiles has proven its convenience.
> - Build systems provided by software components are not perfect. Some do not 
> honor CFLAGS, some require setting options inside makefiles etc. Changing 
> compiler options might be a challenge. Environment variable solves this 
> problem easily and effectively.

But now you seem to be serving the goal about letting the user set flags 
without using the build system, which I thought wasn't a goal anymore?

Again, allowing SDKs to configure the compiler (such as setting the default 
target) without actually changing it in the source seems somewhat reasonable, 
but this other part worries me.


https://reviews.llvm.org/D24933



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


[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-10 Thread Jacob Gravelle via cfe-commits
jgravelle-google abandoned this revision.
jgravelle-google added a comment.

Abandoning in favor of https://github.com/kripken/emscripten/pull/4718


https://reviews.llvm.org/D26431



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


[PATCH] D26522: Improve handling of __FUNCTION__ and other predefined expression for Objective-C Blocks

2016-11-10 Thread Mehdi AMINI via cfe-commits
mehdi_amini created this revision.
mehdi_amini added a reviewer: arphaman.
mehdi_amini added a subscriber: cfe-commits.

Instead of always displaying the mangled name, try to do better
and get something closer to regular functions.


https://reviews.llvm.org/D26522

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/block-with-perdefinedexpr.cpp
  clang/test/CodeGenCXX/predefined-expr-cxx14.cpp

Index: clang/test/CodeGenCXX/predefined-expr-cxx14.cpp
===
--- clang/test/CodeGenCXX/predefined-expr-cxx14.cpp
+++ clang/test/CodeGenCXX/predefined-expr-cxx14.cpp
@@ -17,8 +17,8 @@
 // CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
 // CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [60 x i8] c"auto *ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
 
-// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrD2Ev_block_invoke\00"
-// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC2Ev_block_invoke\00"
+// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
+// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
 
 int printf(const char * _Format, ...);
 
Index: clang/test/CodeGen/block-with-perdefinedexpr.cpp
===
--- /dev/null
+++ clang/test/CodeGen/block-with-perdefinedexpr.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s
+
+void bar() {
+  // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke = private unnamed_addr constant [17 x i8] c"bar_block_invoke\00", align 1
+  const char * (^block1)() = ^() {
+return __FUNCTION__;
+  };
+  // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke_2 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_2\00", align 1
+  const char * (^block2)() = ^() {
+return __FUNCTION__;
+  };
+}
+
+void baz() {
+  // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke = private unnamed_addr constant [24 x i8] c"void baz()_block_invoke\00", align 1
+  const char * (^block1)() = ^() {
+return __PRETTY_FUNCTION__;
+  };
+  // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke_2 = private unnamed_addr constant [26 x i8] c"void baz()_block_invoke_2\00", align 1
+  const char * (^block2)() = ^() {
+return __PRETTY_FUNCTION__;
+  };
+}
+
+namespace foonamespace {
+class Foo {
+public:
+  Foo() {
+// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke = private unnamed_addr constant [38 x i8] c"foonamespace::Foo::Foo()_block_invoke\00", align 1
+const char * (^block1)() = ^() {
+  return __PRETTY_FUNCTION__;
+};
+// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke_2 = private unnamed_addr constant [40 x i8] c"foonamespace::Foo::Foo()_block_invoke_2\00", align 1
+const char * (^block2)() = ^() {
+  return __PRETTY_FUNCTION__;
+};
+// CHECK-DAG: @__func__.___ZN12foonamespace3FooC2Ev_block_invoke_3 = private unnamed_addr constant [19 x i8] c"Foo_block_invoke_3\00", align 1
+const char * (^block3)() = ^() {
+  return __func__;
+};
+bar();
+  }
+  ~Foo() {
+// CHECK-DAG: @__func__.___ZN12foonamespace3FooD2Ev_block_invoke = private unnamed_addr constant [18 x i8] c"~Foo_block_invoke\00", align 1
+const char * (^block1)() = ^() {
+  return __func__;
+};
+// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooD2Ev_block_invoke_2 = private unnamed_addr constant [41 x i8] c"foonamespace::Foo::~Foo()_block_invoke_2\00", align 1
+const char * (^block2)() = ^() {
+  return __PRETTY_FUNCTION__;
+};
+  }
+  void bar() {
+// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke = private unnamed_addr constant [43 x i8] c"void foonamespace::Foo::bar()_block_invoke\00", align 1
+const char * (^block1)() = ^() {
+  return __PRETTY_FUNCTION__;
+};
+// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke_2 = private unnamed_addr constant [45 x i8] c"void foonamespace::Foo::bar()_block_invoke_2\00", align 1
+const char * (^block2)() = ^() {
+  return __PRETTY_FUNCTION__;
+};
+// CHECK-DAG: @__func__.___ZN12foonamespace3Foo3barEv_block_invoke_3 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_3\00", align 1
+const char * (^block3)() = ^() {
+  return __func__;
+};
+  }
+};
+Foo f;
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===

[PATCH] D26196: Add support for non-zero null pointers

2016-11-10 Thread John McCall via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7040
+ auto AS = PT->getAddressSpace();
+ return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0;
+}

yaxunl wrote:
> rjmccall wrote:
> > This check is definitely not correct; this function needs to return true 
> > when AS == 0, right?
> > 
> > Also, you should really just be checking QT.getAddressSpace().
> The null pointer of amdgpu target in addr space 0 does not have zero value.
> 
> I will change it use QT.getAddressSpace() though.
Oh, if the *default* address space — the address space of the stack — has a 
non-zero null pointer value, that will definitely change a lot of things, and 
LLVM will probably be deeply unhappy with you.  I feel like that's a much 
bigger and more problematic change.  This is still the right approach for 
working around it in Clang, but... it's concerning.

And that does mean you'll have to fix a bunch of the other languages that in 
principle you could otherwise have avoided.


https://reviews.llvm.org/D26196



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


r286506 - [Sema] Range-ify for loop, add period to comment. NFC.

2016-11-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Nov 10 15:47:12 2016
New Revision: 286506

URL: http://llvm.org/viewvc/llvm-project?rev=286506&view=rev
Log:
[Sema] Range-ify for loop, add period to comment. NFC.

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=286506&r1=286505&r2=286506&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Nov 10 15:47:12 2016
@@ -825,8 +825,8 @@ static void handleEnableIfAttr(Sema &S,
   !Expr::isPotentialConstantExprUnevaluated(Cond, cast(D),
 Diags)) {
 S.Diag(Attr.getLoc(), diag::err_enable_if_never_constant_expr);
-for (int I = 0, N = Diags.size(); I != N; ++I)
-  S.Diag(Diags[I].first, Diags[I].second);
+for (const PartialDiagnosticAt &PDiag : Diags)
+  S.Diag(PDiag.first, PDiag.second);
 return;
   }
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=286506&r1=286505&r2=286506&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov 10 15:47:12 2016
@@ -12498,7 +12498,7 @@ Sema::BuildCallToMemberFunction(Scope *S
 
   // In the case the method to call was not selected by the overloading
   // resolution process, we still need to handle the enable_if attribute. Do
-  // that here, so it will not hide previous -- and more relevant -- errors
+  // that here, so it will not hide previous -- and more relevant -- errors.
   if (isa(NakedMemExpr)) {
 if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) {
   Diag(MemExprE->getLocStart(),


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


[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

2016-11-10 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

Landed in r286507. Thanks!


https://reviews.llvm.org/D26163



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


r286507 - [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

2016-11-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Nov 10 15:49:25 2016
New Revision: 286507

URL: http://llvm.org/viewvc/llvm-project?rev=286507&view=rev
Log:
[clang-format] Fix PR30527: Regression when clang-format insert spaces in [] 
when in template

Actual regression was introduced in r272668. This revision fixes JS script, but
also regress Cpp case. It manifests with spaces added when template is followed
with array. Bug 30527 mentions case of array as a nested template type
(foo[]>). Fix is to detect such case and to prevent treating it as
array initialization, but as a subscript case. However, before r272668, this
case was treated simple because we were detecting it as a StartsObjCMethodExpr.
Same was true for other similar case - array of templates (foo[]). This
patch tries to address two problems: 1) fixing regression 2) making sure both
cases (array as a nested type, array of templates) which were entering
StartsObjCMethodExpr branch are handled now appropriately.

https://reviews.llvm.org/D26163
Patch from Branko Kokanovic !

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286507&r1=286506&r2=286507&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 15:49:25 2016
@@ -306,7 +306,17 @@ private:
 FormatToken *Left = CurrentToken->Previous;
 Left->ParentBracket = Contexts.back().ContextKind;
 FormatToken *Parent = Left->getPreviousNonComment();
-bool StartsObjCMethodExpr =
+
+// Cases where '>' is followed by '['.
+// In C++, this can happen either in array of templates (foo[10])
+// or when array is a nested template type (unique_ptr[]>).
+bool CppArrayTemplates =
+Style.Language == FormatStyle::LK_Cpp && Parent &&
+Parent->is(TT_TemplateCloser) &&
+(Contexts.back().CanBeExpression || Contexts.back().IsExpression ||
+ Contexts.back().InTemplateArgument);
+
+bool StartsObjCMethodExpr = !CppArrayTemplates &&
 Style.Language == FormatStyle::LK_Cpp &&
 Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
 CurrentToken->isNot(tok::l_brace) &&
@@ -327,7 +337,7 @@ private:
  Parent->isOneOf(tok::l_brace, tok::comma)) {
 Left->Type = TT_JsComputedPropertyName;
   } else if (Style.Language == FormatStyle::LK_Proto ||
- (Parent &&
+ (!CppArrayTemplates && Parent &&
   Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, 
tok::at,
   tok::comma, tok::l_paren, tok::l_square,
   tok::question, tok::colon, tok::kw_return,

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=286507&r1=286506&r2=286507&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Nov 10 15:49:25 2016
@@ -11544,6 +11544,26 @@ TEST_F(FormatTest, FormatsTableGenCode)
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST_F(FormatTest, ArrayOfTemplates) {
+  EXPECT_EQ("auto a = new unique_ptr[10];",
+format("auto a = new unique_ptr [ 10];"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = new unique_ptr[ 10 ];",
+format("auto a = new unique_ptr [10];", Spaces));
+}
+
+TEST_F(FormatTest, ArrayAsTemplateType) {
+  EXPECT_EQ("auto a = unique_ptr[10]>;",
+format("auto a = unique_ptr < Foo < Bar>[ 10]> ;"));
+
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInSquareBrackets = true;
+  EXPECT_EQ("auto a = unique_ptr[ 10 ]>;",
+format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
+}
+
 // Since this test case uses UNIX-style file path. We disable it for MS
 // compiler.
 #if !defined(_MSC_VER) && !defined(__MINGW32__)


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


r286512 - [test] Remove implicit deps on libLTO.dylib on Darwin (NFC)

2016-11-10 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Nov 10 16:31:06 2016
New Revision: 286512

URL: http://llvm.org/viewvc/llvm-project?rev=286512&view=rev
Log:
[test] Remove implicit deps on libLTO.dylib on Darwin (NFC)

This un-breaks the `check-clang` target.

Modified:
cfe/trunk/test/Driver/nostdlib.c
cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp

Modified: cfe/trunk/test/Driver/nostdlib.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=286512&r1=286511&r2=286512&view=diff
==
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Thu Nov 10 16:31:06 2016
@@ -6,24 +6,24 @@
 // Most of the toolchains would check for -nostartfiles and -nostdlib
 // in a short-circuiting boolean expression, so if both of the preceding
 // options were present, the second would warn about being unused.
-// RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \
+// RUN: %clang -### -Wno-liblto -nostartfiles -nostdlib -target 
i386-apple-darwin %s \
 // RUN:   2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED
 // ARGSCLAIMED-NOT: warning:
 
 // In the presence of -nostdlib, the standard libraries should not be
 // passed down to link line
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### -Wno-liblto -o %t.o 2>&1 \
 // RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \
 // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
 //
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### -Wno-liblto -o %t.o 2>&1 \
 // RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \
 // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
 //
-// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
-// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib 
-### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt 
-### -Wno-liblto %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib 
-### -Wno-liblto %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
 //
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"

Modified: cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp?rev=286512&r1=286511&r2=286512&view=diff
==
--- cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp (original)
+++ cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Thu Nov 10 16:31:06 
2016
@@ -8,7 +8,7 @@
 
 // Test that link invocations don't emit an "argument unused during 
compilation" diagnostic.
 // RUN: touch %t.o
-// RUN: %clang -Werror -Wframe-larger-than=0 %t.o -###  2>&1 | not grep ' 
error: '
+// RUN: %clang -Werror -Wno-liblto -Wframe-larger-than=0 %t.o -###  2>&1 | not 
grep ' error: '
 
 // TODO: Support rich backend diagnostics for Objective-C methods.
 


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


r286518 - [index] Add SymbolSubKind for the GKInspectable annotation.

2016-11-10 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Nov 10 17:27:11 2016
New Revision: 286518

URL: http://llvm.org/viewvc/llvm-project?rev=286518&view=rev
Log:
[index] Add SymbolSubKind for the GKInspectable annotation.

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-subkinds.m

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=286518&r1=286517&r2=286518&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Thu Nov 10 17:27:11 2016
@@ -66,8 +66,9 @@ enum class SymbolSubKind : uint8_t {
   UnitTest  = 1 << 3,
   IBAnnotated   = 1 << 4,
   IBOutletCollection= 1 << 5,
+  GKInspectable = 1 << 6,
 };
-static const unsigned SymbolSubKindBitNum = 6;
+static const unsigned SymbolSubKindBitNum = 7;
 typedef unsigned SymbolSubKindSet;
 
 /// Set of roles that are attributed to symbol occurrences.

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=286518&r1=286517&r2=286518&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Nov 10 17:27:11 2016
@@ -165,6 +165,10 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::InstanceProperty;
   Info.Lang = SymbolLanguage::ObjC;
   checkForIBOutlets(D, Info.SubKinds);
+  if (auto *Annot = D->getAttr()) {
+if (Annot->getAnnotation() == "gk_inspectable")
+  Info.SubKinds |= (unsigned)SymbolSubKind::GKInspectable;
+  }
   break;
 case Decl::ObjCIvar:
   Info.Kind = SymbolKind::Field;
@@ -380,6 +384,7 @@ void index::applyForEachSymbolSubKind(Sy
   APPLY_FOR_SUBKIND(UnitTest);
   APPLY_FOR_SUBKIND(IBAnnotated);
   APPLY_FOR_SUBKIND(IBOutletCollection);
+  APPLY_FOR_SUBKIND(GKInspectable);
 
 #undef APPLY_FOR_SUBKIND
 }
@@ -398,6 +403,7 @@ void index::printSymbolSubKinds(SymbolSu
 case SymbolSubKind::UnitTest: OS << "test"; break;
 case SymbolSubKind::IBAnnotated: OS << "IB"; break;
 case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break;
+case SymbolSubKind::GKInspectable: OS << "GKI"; break;
 }
   });
 }

Modified: cfe/trunk/test/Index/Core/index-subkinds.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-subkinds.m?rev=286518&r1=286517&r2=286518&view=diff
==
--- cfe/trunk/test/Index/Core/index-subkinds.m (original)
+++ cfe/trunk/test/Index/Core/index-subkinds.m Thu Nov 10 17:27:11 2016
@@ -50,3 +50,11 @@
 // CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | 
c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
 -(IBAction)doIt;
 @end
+
+
+#define GKInspectable __attribute__((annotate("gk_inspectable")))
+
+@interface GKI
+// CHECK: [[@LINE+1]]:40 | instance-property(GKI)/ObjC | gkIntProp | 
c:objc(cs)GKI(py)gkIntProp |  | Decl,RelChild | rel: 1
+@property (readonly) GKInspectable int gkIntProp;
+@end


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


r286522 - Don't require nullability on 'va_list'.

2016-11-10 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Thu Nov 10 17:28:34 2016
New Revision: 286522

URL: http://llvm.org/viewvc/llvm-project?rev=286522&view=rev
Log:
Don't require nullability on 'va_list'.

There are many non-portable typedefs, but va_list is one that nobody
ever thinks of as a pointer or an array. (When's the last time you saw
someone check for a NULL va_list?) Make an exception for this one
special type.

Part of rdar://problem/25846421.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286522&r1=286521&r2=286522&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:34 2016
@@ -3919,8 +3919,22 @@ static TypeSourceInfo *GetFullTypeForDec
 attr->setUsedAsTypeAttr();
   }
 }
+
+auto isVaList = [&S](QualType T) -> bool {
+  auto *typedefTy = T->getAs();
+  if (!typedefTy)
+return false;
+  TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl();
+  do {
+if (typedefTy->getDecl() == vaListTypedef)
+  return true;
+typedefTy = typedefTy->desugar()->getAs();
+  } while (typedefTy);
+  return false;
+};
+
 if (complainAboutMissingNullability == CAMN_Yes &&
-T->isArrayType() && !T->getNullability(S.Context) &&
+T->isArrayType() && !T->getNullability(S.Context) && !isVaList(T) &&
 D.isPrototypeContext() &&
 !hasOuterPointerLikeChunk(D, D.getNumTypeObjects())) {
   checkNullabilityConsistency(S, SimplePointerKind::Array,

Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h?rev=286522&r1=286521&r2=286522&view=diff
==
--- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h (original)
+++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h Thu Nov 
10 17:28:34 2016
@@ -1,3 +1,5 @@
+#include 
+
 void firstThingInTheFileThatNeedsNullabilityIsAnArray(int ints[]);
 #if ARRAYS_CHECKED
 // expected-warning@-2 {{array parameter is missing a nullability type 
specifier (_Nonnull, _Nullable, or _Null_unspecified)}}
@@ -33,6 +35,26 @@ void testAllOK(
 void * _Nullable ptrs[_Nonnull],
 void * _Nullable * _Nullable nestedPtrs[_Nonnull]);
 
+void testVAList(va_list ok); // no warning
+
+#if __cplusplus
+// Carefully construct a test case such that if a platform's va_list is an 
array
+// or pointer type, it gets tested, but otherwise it does not.
+template
+struct pointer_like_or { typedef F type; };
+template
+struct pointer_like_or { typedef T *type; };
+template
+struct pointer_like_or { typedef T * const type; };
+template
+struct pointer_like_or { typedef T type[]; };
+template
+struct pointer_like_or { typedef T type[size]; };
+
+void testVAListWithNullability(
+  pointer_like_or::type _Nonnull x); // no errors
+#endif
+
 void nestedArrays(int x[5][1]) {}
 #if ARRAYS_CHECKED
 // expected-warning@-2 {{array parameter is missing a nullability type 
specifier (_Nonnull, _Nullable, or _Null_unspecified)}}


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


r286521 - Warn when 'assume_nonnull' infers nullability within an array.

2016-11-10 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Thu Nov 10 17:28:30 2016
New Revision: 286521

URL: http://llvm.org/viewvc/llvm-project?rev=286521&view=rev
Log:
Warn when 'assume_nonnull' infers nullability within an array.

...or within a reference. Both of these add an extra level of
indirection that make us less certain that the pointer really was
supposed to be non-nullable. However, changing the default behavior
would be a breaking change, so we'll just make it a warning instead.

Part of rdar://problem/25846421

Added:
cfe/trunk/test/FixIt/nullability.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjCXX/nullability-consistency-arrays.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=286521&r1=286520&r2=286521&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 10 17:28:30 2016
@@ -277,6 +277,7 @@ def ModuleFileExtension : DiagGroup<"mod
 def NewlineEOF : DiagGroup<"newline-eof">;
 def Nullability : DiagGroup<"nullability">;
 def NullabilityDeclSpec : DiagGroup<"nullability-declspec">;
+def NullabilityInferredOnNestedType : 
DiagGroup<"nullability-inferred-on-nested-type">;
 def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">;
 def NullabilityCompletenessOnArrays : 
DiagGroup<"nullability-completeness-on-arrays">;
 def NullabilityCompleteness : DiagGroup<"nullability-completeness",

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286521&r1=286520&r2=286521&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 17:28:30 
2016
@@ -8737,6 +8737,11 @@ def warn_nullability_missing_array : War
   "_Nullable, or _Null_unspecified)">,
   InGroup;
 
+def warn_nullability_inferred_on_nested_type : Warning<
+  "inferring '_Nonnull' for pointer type within %select{array|reference}0 is "
+  "deprecated">,
+  InGroup;
+
 def err_objc_type_arg_explicit_nullability : Error<
   "type argument %0 cannot explicitly specify nullability">;
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286521&r1=286520&r2=286521&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:30 2016
@@ -3274,15 +3274,27 @@ namespace {
 // NSError**
 NSErrorPointerPointer,
   };
+
+  /// Describes a declarator chunk wrapping a pointer that marks inference as
+  /// unexpected.
+  // These values must be kept in sync with diagnostics.
+  enum class PointerWrappingDeclaratorKind {
+/// Pointer is top-level.
+None = -1,
+/// Pointer is an array element.
+Array = 0,
+/// Pointer is the referent type of a C++ reference.
+Reference = 1
+  };
 } // end anonymous namespace
 
 /// Classify the given declarator, whose type-specified is \c type, based on
 /// what kind of pointer it refers to.
 ///
 /// This is used to determine the default nullability.
-static PointerDeclaratorKind classifyPointerDeclarator(Sema &S,
-   QualType type,
-   Declarator &declarator) 
{
+static PointerDeclaratorKind
+classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator,
+  PointerWrappingDeclaratorKind &wrappingKind) {
   unsigned numNormalPointers = 0;
 
   // For any dependent type, we consider it a non-pointer.
@@ -3294,6 +3306,10 @@ static PointerDeclaratorKind classifyPoi
 DeclaratorChunk &chunk = declarator.getTypeObject(i);
 switch (chunk.Kind) {
 case DeclaratorChunk::Array:
+  if (numNormalPointers == 0)
+wrappingKind = PointerWrappingDeclaratorKind::Array;
+  break;
+
 case DeclaratorChunk::Function:
 case DeclaratorChunk::Pipe:
   break;
@@ -3304,14 +3320,18 @@ static PointerDeclaratorKind classifyPoi
: PointerDeclaratorKind::SingleLevelPointer;
 
 case DeclaratorChunk::Paren:
+  break;
+
 case DeclaratorChunk::Reference:
-  continue;
+  if (numNormalPointers == 0)
+wrappingKind = PointerWrappingDeclaratorKind::Reference;
+  break;
 
 case DeclaratorChunk::Pointer:
   ++numNormalPointers;
   if (numNormalPointers > 2)
 return PointerDeclaratorKind::MultiLevelPointer;
-  con

r286520 - Add -Wnullability-completeness-on-arrays.

2016-11-10 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Thu Nov 10 17:28:26 2016
New Revision: 286520

URL: http://llvm.org/viewvc/llvm-project?rev=286520&view=rev
Log:
Add -Wnullability-completeness-on-arrays.

This is an addition to (and sub-warning of) -Wnullability-completeness
that warns when an array parameter is missing nullability. When the
specific warning is switched off, the compiler falls back to only
warning on pointer types written as pointer types.

Note that use of nullability /within/ an array triggers the
completeness checks regardless of whether or not the array-specific
warning is enabled; the intent there is simply to determine whether a
particular header is trying to be nullability-aware at all.

Part of rdar://problem/25846421.

Added:
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h
cfe/trunk/test/SemaObjCXX/nullability-consistency-arrays.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=286520&r1=286519&r2=286520&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 10 17:28:26 2016
@@ -278,7 +278,9 @@ def NewlineEOF : DiagGroup<"newline-eof"
 def Nullability : DiagGroup<"nullability">;
 def NullabilityDeclSpec : DiagGroup<"nullability-declspec">;
 def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">;
-def NullabilityCompleteness : DiagGroup<"nullability-completeness">;
+def NullabilityCompletenessOnArrays : 
DiagGroup<"nullability-completeness-on-arrays">;
+def NullabilityCompleteness : DiagGroup<"nullability-completeness",
+[NullabilityCompletenessOnArrays]>;
 def NullArithmetic : DiagGroup<"null-arithmetic">;
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286520&r1=286519&r2=286520&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 17:28:26 
2016
@@ -8732,6 +8732,10 @@ def warn_nullability_missing : Warning<
   "%select{pointer|block pointer|member pointer}0 is missing a nullability "
   "type specifier (_Nonnull, _Nullable, or _Null_unspecified)">,
   InGroup;
+def warn_nullability_missing_array : Warning<
+  "array parameter is missing a nullability type specifier (_Nonnull, "
+  "_Nullable, or _Null_unspecified)">,
+  InGroup;
 
 def err_objc_type_arg_explicit_nullability : Error<
   "type argument %0 cannot explicitly specify nullability">;

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286520&r1=286519&r2=286520&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:26 2016
@@ -3212,6 +3212,7 @@ namespace {
 Pointer,
 BlockPointer,
 MemberPointer,
+Array,
   };
 } // end anonymous namespace
 
@@ -3453,12 +3454,15 @@ static FileID getNullabilityCompleteness
   return file;
 }
 
-/// Check for consistent use of nullability.
-static void checkNullabilityConsistency(TypeProcessingState &state,
+/// Complains about missing nullability if the file containing \p pointerLoc
+/// has other uses of nullability (either the keywords or the \c assume_nonnull
+/// pragma).
+///
+/// If the file has \e not seen other uses of nullability, this particular
+/// pointer is saved for possible later diagnosis. See recordNullabilitySeen().
+static void checkNullabilityConsistency(Sema &S,
 SimplePointerKind pointerKind,
 SourceLocation pointerLoc) {
-  Sema &S = state.getSema();
-
   // Determine which file we're performing consistency checking for.
   FileID file = getNullabilityCompletenessCheckFileID(S, pointerLoc);
   if (file.isInvalid())
@@ -3468,10 +3472,16 @@ static void checkNullabilityConsistency(
   // about anything.
   FileNullability &fileNullability = S.NullabilityMap[file];
   if (!fileNullability.SawTypeNullability) {
-// If this is the first pointer declarator in the file, record it.
+// If this is the first pointer declarator in the file, and the appropriate
+// warning is on, record it in case we need to diagnose it retroactively.
+diag::kind diagKind;
+if (pointerKind == SimplePointerKind::Array)

r286519 - Accept nullability qualifiers on array parameters.

2016-11-10 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Thu Nov 10 17:28:17 2016
New Revision: 286519

URL: http://llvm.org/viewvc/llvm-project?rev=286519&view=rev
Log:
Accept nullability qualifiers on array parameters.

Since array parameters decay to pointers, '_Nullable' and friends
should be available for use there as well. This is especially
important for parameters that are typedefs of arrays. The unsugared
syntax for this follows the syntax for 'static'-sized arrays in C:

  void test(int values[_Nullable]);

This syntax was previously accepted but the '_Nullable' (and any other
attributes) were silently discarded. However, applying '_Nullable' to
a typedef was previously rejected and is now accepted; therefore, it
may be necessary to test for the presence of this feature:

  #if __has_feature(nullability_on_arrays)

One important change here is that DecayedTypes don't always
immediately contain PointerTypes anymore; they may contain an
AttributedType instead. This only affected one place in-tree, so I
would guess it's not likely to cause problems elsewhere.

This commit does not change -Wnullability-completeness just yet. I
want to think about whether it's worth doing something special to
avoid breaking existing clients that compile with -Werror. It also
doesn't change '#pragma clang assume_nonnull' behavior, which
currently treats the following two declarations as equivalent:

  #pragma clang assume_nonnull begin
  void test(void *pointers[]);
  #pragma clang assume_nonnull end

  void test(void * _Nonnull pointers[]);

This is not the desired behavior, but changing it would break
backwards-compatibility. Most likely the best answer is going to be
adding a new warning.

Part of rdar://problem/25846421

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/nullability.c
cfe/trunk/test/Sema/nullability.c
cfe/trunk/test/SemaCXX/nullability.cpp
cfe/trunk/test/SemaObjC/nullability.m

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=286519&r1=286518&r2=286519&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Nov 10 17:28:17 2016
@@ -2266,19 +2266,15 @@ public:
 /// Represents a pointer type decayed from an array or function type.
 class DecayedType : public AdjustedType {
 
-  DecayedType(QualType OriginalType, QualType DecayedPtr, QualType 
CanonicalPtr)
-  : AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) {
-assert(isa(getAdjustedType()));
-  }
+  inline
+  DecayedType(QualType OriginalType, QualType Decayed, QualType Canonical);
 
   friend class ASTContext;  // ASTContext creates these.
 
 public:
   QualType getDecayedType() const { return getAdjustedType(); }
 
-  QualType getPointeeType() const {
-return cast(getDecayedType())->getPointeeType();
-  }
+  inline QualType getPointeeType() const;
 
   static bool classof(const Type *T) { return T->getTypeClass() == Decayed; }
 };
@@ -5962,6 +5958,23 @@ inline const ArrayType *Type::castAsArra
   return cast(getUnqualifiedDesugaredType());
 }
 
+DecayedType::DecayedType(QualType OriginalType, QualType DecayedPtr,
+ QualType CanonicalPtr)
+: AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) {
+#ifndef NDEBUG
+  QualType Adjusted = getAdjustedType();
+  (void)AttributedType::stripOuterNullability(Adjusted);
+  assert(isa(Adjusted));
+#endif
+}
+
+QualType DecayedType::getPointeeType() const {
+  QualType Decayed = getDecayedType();
+  (void)AttributedType::stripOuterNullability(Decayed);
+  return cast(Decayed)->getPointeeType();
+}
+
+
 }  // end namespace clang
 
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286519&r1=286518&r2=286519&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Nov 10 17:28:17 2016
@@ -3122,10 +3122,14 @@ public:
   /// method) or an Objective-C property attribute, rather than as an
   /// underscored type specifier.
   ///
+  /// \param allowArrayTypes Whether to accept nullability specifiers on an
+  /// array type (e.g., because it will decay to a pointer).
+  ///
   /// \returns true if nullability cannot be applied, false otherwise.
   bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind 
nullability,
  SourceLocation nullabilityLoc,
- bool isContextSensitive);
+ bool isContextSensitiv

[PATCH] D26415: [XRay] Support AArch64 in Clang

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



Comment at: lib/Driver/Tools.cpp:4903-4906
+if (Triple.getOS() != llvm::Triple::Linux)
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on non-Linux target OS.");
+switch (Triple.getArch()) {

Did you need to put an `else` before the switch? I don't know what happens when 
you're on Windows non-supported platform -- will this cause two diagnostics to 
be printed?


https://reviews.llvm.org/D26415



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


  1   2   >