Re: [PATCH] D16135: Macro Debug Info support in Clang

2016-01-13 Thread Amjad Aboud via cfe-commits
aaboud added inline comments.


Comment at: include/clang/AST/ASTConsumer.h:163
@@ -155,1 +162,3 @@
+  /// The caller takes ownership on the returned pointer.
+  virtual std::unique_ptr 
CreatePreprocessorCallbacks(Preprocessor );
 };

Richard,
I know that you suggested not to introduce the Preprocessor in anyway to the 
ASTConsumer.
However, as I could not understand the other way to support macros in Clang 
without applying a huge redesign, I decided to upload the code I suggested in 
the proposal.
http://lists.llvm.org/pipermail/llvm-dev/2015-November/092449.html

If you still think that this approach is not the right one, I would appreciate 
it if you can explain again how to implement the macro support differently.


http://reviews.llvm.org/D16135



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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-01-13 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/ClangTidyOptions.h:216
@@ +215,3 @@
+/// HeaderFileExtensions.
+bool endWithHeaderFileExtensions(llvm::StringRef FileName,
+ llvm::StringRef HeaderFileExtensions);

hokein wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > This function doesn't belong here. I'm also not sure we need this 
> > > function at all. First, it's ineffective to split the string containing 
> > > the list of extensions each time. Second, if we store a set of 
> > > extensions, then we can just search for the actual file extension in this 
> > > set.
> > endsWithHeaderFileExtension instead? However, given that uses of this all 
> > start with a SourceLocation, I wonder if that makes for a cleaner API: 
> > isLocInHeaderFile(SourceLocation, );
> > 
> > Also, how does this work if I want to include an extension-less file as the 
> > header file "extension?" It would be plausible if the extensions were 
> > passed in as a list, but as it stands it doesn't seem possible without 
> > weird conventions like leaving a blank in the list (e.g., `.h,,.hpp`), 
> > which seems error-prone.
> > 
> > Also, I'm not certain what I can pass in. The documentation should be 
> > updated to state whether these extensions are intended to include the ".".
> > endsWithHeaderFileExtension instead? However, given that uses of this all 
> > start with a SourceLocation, I wonder if that makes for a cleaner API: 
> > isLocInHeaderFile(SourceLocation, );
> 
> Using `SourceLocation` only is not enough to retrieve the belonging file name 
> (we need `SourceManager` too).
> 
> >Also, how does this work if I want to include an extension-less file as the 
> >header file "extension?" It would be plausible if the extensions were passed 
> >in as a list, but as it stands it doesn't seem possible without weird 
> >conventions like leaving a blank in the list (e.g., .h,,.hpp), which seems 
> >error-prone.
> 
> Yeah, for extensions-less header file, you can pass the string like 
> `.h,,.hpp`, which is a bit of weird. Do you have a better idea here? Passing 
> a string into `header-file-extensions` seems the most reasonable choice. 
> 
`isLocInHeaderFile(SourceLocation, ...)` is a nice idea, but we'd need to be 
more specific: either `isExpansionLocInHeaderFile(SourceLoc, ...)` or 
`isSpellingLocInHeaderFile(SourceLoc, ...)` (or both).


Repository:
  rL LLVM

http://reviews.llvm.org/D16113



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


r257586 - [OPENMP] Fix for declarative/standalone directives use.

2016-01-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Jan 13 05:18:54 2016
New Revision: 257586

URL: http://llvm.org/viewvc/llvm-project?rev=257586=rev
Log:
[OPENMP] Fix for declarative/standalone directives use.
Fixes processing of declarative directives and standalone executable 
directives. Declarative directives should not be allowed as an immediate 
statements and standalone executable directives are allowed to be used in 
case-stmt constructs.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/OpenMP/barrier_ast_print.cpp
cfe/trunk/test/OpenMP/barrier_messages.cpp
cfe/trunk/test/OpenMP/cancel_messages.cpp
cfe/trunk/test/OpenMP/cancellation_point_messages.cpp
cfe/trunk/test/OpenMP/flush_messages.cpp
cfe/trunk/test/OpenMP/taskwait_messages.cpp
cfe/trunk/test/OpenMP/taskyield_messages.cpp
cfe/trunk/test/OpenMP/threadprivate_messages.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=257586=257585=257586=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Jan 13 05:18:54 2016
@@ -1644,13 +1644,22 @@ private:
   /// A SmallVector of types.
   typedef SmallVector TypeVector;
 
-  StmtResult ParseStatement(SourceLocation *TrailingElseLoc = nullptr);
+  StmtResult ParseStatement(SourceLocation *TrailingElseLoc = nullptr,
+bool AllowOpenMPStandalone = false);
+  enum AllowedContsructsKind {
+/// \brief Allow any declarations, statements, OpenMP directives.
+ACK_Any,
+/// \brief Allow only statements and non-standalone OpenMP directives.
+ACK_StatementsOpenMPNonStandalone,
+/// \brief Allow statements and all executable OpenMP directives
+ACK_StatementsOpenMPAnyExecutable
+  };
   StmtResult
-  ParseStatementOrDeclaration(StmtVector , bool OnlyStatement,
+  ParseStatementOrDeclaration(StmtVector , AllowedContsructsKind Allowed,
   SourceLocation *TrailingElseLoc = nullptr);
   StmtResult ParseStatementOrDeclarationAfterAttributes(
  StmtVector ,
- bool OnlyStatement,
+ AllowedContsructsKind Allowed,
  SourceLocation *TrailingElseLoc,
  ParsedAttributesWithRange );
   StmtResult ParseExprStatement();
@@ -1678,7 +1687,8 @@ private:
   StmtResult ParseReturnStatement();
   StmtResult ParseAsmStatement(bool );
   StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
-  StmtResult ParsePragmaLoopHint(StmtVector , bool OnlyStatement,
+  StmtResult ParsePragmaLoopHint(StmtVector ,
+ AllowedContsructsKind Allowed,
  SourceLocation *TrailingElseLoc,
  ParsedAttributesWithRange );
 
@@ -2443,11 +2453,13 @@ private:
 bool AllowScopeSpecifier);
   /// \brief Parses declarative or executable directive.
   ///
-  /// \param StandAloneAllowed true if allowed stand-alone directives,
-  /// false - otherwise
+  /// \param Allowed ACK_Any, if any directives are allowed,
+  /// ACK_StatementsOpenMPAnyExecutable - if any executable directives are
+  /// allowed, ACK_StatementsOpenMPNonStandalone - if only non-standalone
+  /// executable directives are allowed.
   ///
   StmtResult
-  ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed);
+  ParseOpenMPDeclarativeOrExecutableDirective(AllowedContsructsKind Allowed);
   /// \brief Parses clause of kind \a CKind for directive of a kind \a Kind.
   ///
   /// \param DKind Kind of current directive.

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=257586=257585=257586=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Jan 13 05:18:54 2016
@@ -165,8 +165,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
 /// 'distribute'
 /// annot_pragma_openmp_end
 ///
-StmtResult
-Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) {
+StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
+AllowedContsructsKind Allowed) {
   assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
   SmallVector Identifiers;
@@ -186,6 +186,10 @@ Parser::ParseOpenMPDeclarativeOrExecutab
 
   switch (DKind) {
   case OMPD_threadprivate:
+if (Allowed != ACK_Any) {
+  Diag(Tok, diag::err_omp_immediate_directive)
+  << 

Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D15686#325266, @rnk wrote:

> I thought we already addressed this issue with @rjmccall and decided that, if 
> the user intentionally declares extern "C" variables with an _Z prefix, then 
> we know they are intentionally attempting to name some C++ global variable.
>
> I'd rather just warn on all extern "C" declarations starting with _Z, and let 
> users keep the pieces when things break.


That doesn't contradicts my patch at all. See the test -- where there is one 
declaration and one definition:

// We expect no warnings here, as there is only declaration of _ZN2nm3abcE
// global, no definitions.
extern "C" {

  int _ZN2nm3abcE;

}

namespace nm {

  float abc = 2;

}
// CHECK: @_ZN2nm3abcE = global float

nothing bad happens.

But if there are two definitions:

extern "C" {

  int _ZN2nm3abcE = 1; // expected-note {{previous definition is here}}

}

namespace nm {

  float abc = 2; // expected-error {{definition with same mangled name as 
another definition}}

}

an error is printed, as it should be.

Here is what John wrote himself (http://reviews.llvm.org/D11297#211351):

"I disagree with the conclusions in that thread (and wish you had CC'ed me; I 
unfortunately do not have time to keep up with cfe-dev). There is roughly zero 
chance that somebody is declaring an extern "C" symbol with a name that matches 
an Itanium mangled name with any intent other than to name that entity. We 
should not be rejecting this code or silently renaming one of the symbols. We 
should, of course, still diagnose attempts to *define* the same symbol multiple 
times."

John, may I ask you to take a look at this patch and confirm (or deny :-)) that 
it follows your understanding of how things should be?

Yours,
Andrey


http://reviews.llvm.org/D15686



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


[PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, mkuper.
andreybokhanko added a subscriber: cfe-commits.

Correct setting of UserLabelPrefix for MCU target

http://reviews.llvm.org/D16138

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3862,6 +3862,7 @@
   MCUX86_32TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = ::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3862,6 +3862,7 @@
   MCUX86_32TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = ::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16135: Macro Debug Info support in Clang

2016-01-13 Thread Amjad Aboud via cfe-commits
aaboud created this revision.
aaboud added reviewers: dblaikie, rsmith, aprantl, probinson.
aaboud added a subscriber: cfe-commits.

Added support for FE Clang to create Debug Info entries (DIMacro and 
DIMacroFile) into generated module if "debug-info-kind" flag is set to 
"standalone".

http://reviews.llvm.org/D16135

Files:
  include/clang/AST/ASTConsumer.h
  lib/AST/ASTConsumer.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/MacroPPCallbacks.cpp
  lib/CodeGen/MacroPPCallbacks.h
  lib/CodeGen/ModuleBuilder.cpp
  lib/Parse/ParseAST.cpp

Index: lib/Parse/ParseAST.cpp
===
--- lib/Parse/ParseAST.cpp
+++ lib/Parse/ParseAST.cpp
@@ -128,6 +128,12 @@
   new Parser(S.getPreprocessor(), S, SkipFunctionBodies));
   Parser  = *ParseOP.get();
 
+  std::unique_ptr Callbacks =
+  Consumer->CreatePreprocessorCallbacks(S.getPreprocessor());
+  if (Callbacks) {
+S.getPreprocessor().addPPCallbacks(std::move(Callbacks));
+  }
+
   llvm::CrashRecoveryContextCleanupRegistrar
   CleanupPrettyStack(llvm::SavePrettyStackState());
   PrettyStackTraceParserEntry CrashInfo(P);
Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -20,6 +20,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Lex/PPCallbacks.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/LLVMContext.h"
@@ -234,6 +235,11 @@
 void HandleDependentLibrary(llvm::StringRef Lib) override {
   Builder->AddDependentLib(Lib);
 }
+
+std::unique_ptr
+CreatePreprocessorCallbacks(Preprocessor ) override {
+  return Builder->createPreprocessorCallbacks(PP);
+}
   };
 }
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -24,6 +24,7 @@
 #include "CodeGenPGO.h"
 #include "CodeGenTBAA.h"
 #include "CoverageMappingGen.h"
+#include "MacroPPCallbacks.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CharUnits.h"
@@ -208,6 +209,16 @@
   CUDARuntime = CreateNVCUDARuntime(*this);
 }
 
+std::unique_ptr
+CodeGenModule::createPreprocessorCallbacks(Preprocessor ) {
+  // Enable generating macro debug info only in FullDebugInfo mode.
+  if (CodeGenOpts.getDebugInfo() < CodeGenOptions::FullDebugInfo ||
+  !getModuleDebugInfo())
+return nullptr;
+
+  return std::make_unique(*getModuleDebugInfo(), PP);
+}
+
 void CodeGenModule::addReplacement(StringRef Name, llvm::Constant *C) {
   Replacements[Name] = C;
 }
Index: lib/CodeGen/MacroPPCallbacks.h
===
--- lib/CodeGen/MacroPPCallbacks.h
+++ lib/CodeGen/MacroPPCallbacks.h
@@ -0,0 +1,94 @@
+//===--- MacroPPCallbacks.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines implementation for the macro preprocessors callbacks.
+//
+//===--===//
+
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Parse/Parser.h"
+#include 
+
+namespace llvm {
+  class DIMacroFile;
+}
+namespace clang {
+
+namespace CodeGen {
+  class CGDebugInfo;
+}
+class MacroPPCallbacks : public PPCallbacks {
+  CodeGen::CGDebugInfo 
+  Preprocessor 
+  SourceLocation LastHashLoc;
+  SourceLocation FirstIncludeFile;
+  bool FirstInclude;
+  bool FirstIncludeDone;
+  int CommandIncludeFiles;
+  int SkipFiles;
+  std::vector Parents;
+
+
+  static void getMacroDefinition(const IdentifierInfo , const MacroInfo ,
+ Preprocessor , raw_ostream ,
+ raw_ostream );
+
+public:
+  MacroPPCallbacks(CodeGen::CGDebugInfo& DI, Preprocessor );
+
+  /// \brief Callback invoked whenever a source file is entered or exited.
+  ///
+  /// \param Loc Indicates the new location.
+  /// \param PrevFID the file that was exited if \p Reason is ExitFile.
+  virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
+   SrcMgr::CharacteristicKind FileType,
+   FileID PrevFID = FileID());
+
+  /// \brief Callback invoked whenever a source file is skipped as the result
+  /// of header guard optimization.
+  ///
+  /// \param SkippedFile The file that is skipped instead of entering \#include
+  ///
+  /// 

Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

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

Thank you for the patch! I have a few concerns though. See inline comments.



Comment at: clang-tidy/ClangTidy.cpp:348
@@ +347,3 @@
+ LocalName.str() };
+  for (const auto  : Names) {
+auto Iter = CheckOptions.find(Name);

There's no need to declare a vector: `for (const string  : {"a", "b", "c"}) 
...`.

Also, I don't think it makes sense to create a vector of two elements and run a 
loop over it instead of duplicating three lines of code.


Comment at: clang-tidy/ClangTidy.h:54
@@ +53,3 @@
+  ///
+  /// Reads the option with the check-local name \p LocalName from local or
+  /// global \c CheckOptions. If the option is not present in both options,

We need to explicitly specify the order in which the options are considered: 
local, global, default.


Comment at: clang-tidy/ClangTidyOptions.cpp:269
@@ +268,3 @@
+  SmallVector Suffixes;
+  HeaderFileExtensions.split(Suffixes, ',');
+  for (const auto& Suffix : Suffixes) {

It's rather inefficient to split the string each time the function is called. 
If even we needed this function, we would better pass an `ArrayRef`. 
But even better, we can use `llvm::StringSet` and get rid of this function at 
all (we might need a helper function to parse a comma-separated list of 
extensions to a StringSet though).


Comment at: clang-tidy/ClangTidyOptions.h:216
@@ +215,3 @@
+/// HeaderFileExtensions.
+bool endWithHeaderFileExtensions(llvm::StringRef FileName,
+ llvm::StringRef HeaderFileExtensions);

This function doesn't belong here. I'm also not sure we need this function at 
all. First, it's ineffective to split the string containing the list of 
extensions each time. Second, if we store a set of extensions, then we can just 
search for the actual file extension in this set.


Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.h:23
@@ +22,3 @@
+///
+/// There is one option:
+/// - `HeaderFileExtensions`: the file extensions that regard as header file.

nit: s/There is one option:/The check supports these options:/


Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.h:24
@@ +23,3 @@
+/// There is one option:
+/// - `HeaderFileExtensions`: the file extensions that regard as header file.
+///   ".h" by default.

s/the file extensions that regard as header file/a comma-separated list of 
filename extensions of header files/

I don't think this list should include the period. It's better to just store 
extensions as returned by `llvm::sys::path::extension()`, so that it can be 
simply looked up in a set.

Also, it's common to indent lists, so please insert two spaces at the beginning 
of this line and the next one.


Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.h:33
@@ -28,1 +32,3 @@
+private:
+  const std::string HeaderFileExtensions;
 };

As mentioned earlier, this can be a set of strings (e.g. `llvm::StringSet`).


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:22
@@ -21,2 +21,3 @@
 
-AST_MATCHER(NamedDecl, isHeaderFileExtension) {
+AST_MATCHER_P(NamedDecl, useHeaderFileExtension,
+  StringRef, HeaderFileExtensions) {

s/useHeaderFileExtension/usesHeaderFileExtension/


Comment at: clang-tidy/tool/ClangTidyMain.cpp:78
@@ +77,3 @@
+static cl::opt
+HeaderFileExtensions("header-file-extensions",
+ cl::desc("File extensions that regard as header file.\n"

We don't need a command-line flag for this. The regular way to configure 
clang-tidy is .clang-tidy files. However, if needed, check options can be 
configured from the command line via the `-config=` option. 


Repository:
  rL LLVM

http://reviews.llvm.org/D16113



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


Re: [PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 44726.
andreybokhanko added a comment.

Patch updated to be in line with llvm trunk. Sorry for the noise.


http://reviews.llvm.org/D16138

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3899,6 +3899,7 @@
   MCUX86_32TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = ::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3899,6 +3899,7 @@
   MCUX86_32TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = ::APFloat::IEEEdouble;
+UserLabelPrefix = "";
   }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
 
+// CHECK: #define __USER_LABEL_PREFIX__ {{$}}
 // CHECK: #define __iamcu
 // CHECK: #define __iamcu__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-13 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 44734.
NoQ added a comment.

Rebase on top of http://reviews.llvm.org/D12901 - support `SymbolCast` in the 
explainer, as it finally appears in the wild.


http://reviews.llvm.org/D15448

Files:
  docs/analyzer/DebugChecks.rst
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  test/Analysis/explain-svals.cpp

Index: test/Analysis/explain-svals.cpp
===
--- /dev/null
+++ test/Analysis/explain-svals.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s
+
+typedef unsigned long size_t;
+
+struct S {
+  struct S3 {
+int y[10];
+  };
+  struct S2 : S3 {
+int *x;
+  } s2[10];
+  int z;
+};
+
+
+void clang_analyzer_explain(int);
+void clang_analyzer_explain(void *);
+void clang_analyzer_explain(S);
+
+size_t clang_analyzer_getExtent(void *);
+
+size_t strlen(const char *);
+
+int conjure();
+S conjure_S();
+
+int glob;
+static int stat_glob;
+void *glob_ptr;
+
+// Test strings are regex'ed because we need to match exact string
+// rather than a substring.
+
+void test_1(int param, void *ptr) {
+  clang_analyzer_explain(); // expected-warning-re^pointer to global variable 'glob'$
+  clang_analyzer_explain(param); // expected-warning-re^argument 'param'$
+  clang_analyzer_explain(ptr); // expected-warning-re^argument 'ptr'$
+  if (param == 42)
+clang_analyzer_explain(param); // expected-warning-re^signed 32-bit integer '42'$
+}
+
+void test_2(char *ptr, int ext) {
+  clang_analyzer_explain((void *) "asdf"); // expected-warning-re^pointer to element of type 'char' with index 0 of string literal "asdf"$
+  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
+  clang_analyzer_explain(conjure()); // expected-warning-re^symbol of type 'int' conjured at statement 'conjure\(\)'$
+  clang_analyzer_explain(glob); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob'$
+  clang_analyzer_explain(glob_ptr); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$
+  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^extent of pointee of argument 'ptr'$
+  int *x = new int[ext];
+  clang_analyzer_explain(x); // expected-warning-re^pointer to element of type 'int' with index 0 of pointee of symbol of type 'int \*' conjured at statement 'new int \[ext\]'$
+  // Sic! What gets computed is the extent of the element-region.
+  clang_analyzer_explain(clang_analyzer_getExtent(x)); // expected-warning-re^signed 32-bit integer '4'$
+  delete[] x;
+  if (ext >= 256)
+clang_analyzer_explain((char) ext); // expected-warning-re^cast to 'char' of argument 'ext'$
+}
+
+void test_3(S s) {
+  clang_analyzer_explain(); // expected-warning-re^pointer to parameter 's'$
+  clang_analyzer_explain(s.z); // expected-warning-re^initial value of field 'z' of parameter 's'$
+  clang_analyzer_explain([5].y[3]); // expected-warning-re^pointer to element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside element of type 'struct S::S2' with index 5 of field 's2' of parameter 's'$
+  if (!s.s2[7].x) {
+clang_analyzer_explain(s.s2[7].x); // expected-warning-re^concrete memory address '0'$
+// FIXME: we need to be explaining '1' rather than '0' here; not explainer bug.
+clang_analyzer_explain(s.s2[7].x + 1); // expected-warning-re^concrete memory address '0'$
+  }
+}
+
+void test_4(int x, int y) {
+  int z;
+  static int stat;
+  clang_analyzer_explain(x + 1); // expected-warning-re^\(argument 'x'\) \+ 1$
+  clang_analyzer_explain(1 + y); // expected-warning-re^\(argument 'y'\) \+ 1$
+  clang_analyzer_explain(x + y); // expected-warning-re^unknown value$
+  clang_analyzer_explain(z); // expected-warning-re^undefined value$
+  clang_analyzer_explain(); // expected-warning-re^pointer to local variable 'z'$
+  clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$
+  clang_analyzer_explain(); // expected-warning-re^pointer to static local variable 'stat'$
+  

Re: r257533 - D9600: Add scan-build python implementation

2016-01-13 Thread Ismail Donmez via cfe-commits
Hi,

On Wed, Jan 13, 2016 at 12:38 AM, Laszlo Nagy via cfe-commits
 wrote:
> Author: rizsotto
> Date: Tue Jan 12 16:38:41 2016
> New Revision: 257533
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257533=rev
> Log:
> D9600: Add scan-build python implementation

This doesn't seem to be installed by default, is that intended?

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


Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-13 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:37
@@ +36,3 @@
+  write_pipe(p, tmp);   // expected-error {{invalid argument type to function 
write_pipe (expecting: 'int *')}}
+  read_pipe(p, ptr);// expected-error {{invalid pipe access modifier 
(expecting read_only)}}
+  read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access 
modifier (expecting read_only)}}

Sometimes you use ":" where it's not needed.

Ex:
 invalid argument type to function write_pipe (expecting: 'int *')


http://reviews.llvm.org/D15914



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


Re: [PATCH] D16138: Correct setting of UserLabelPrefix for MCU target

2016-01-13 Thread Rafael Ávila de Espíndola via cfe-commits
rafael added a subscriber: rafael.
rafael accepted this revision.
rafael added a reviewer: rafael.
rafael added a comment.
This revision is now accepted and ready to land.

LGTM, but could you change the default in a followup commit? TargetInfo should 
really be setting it to "" since it is far more common than "_".


http://reviews.llvm.org/D16138



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


Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-01-13 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:593
@@ -592,2 +592,3 @@
+def err_no_declarators : Error<"declaration does not declare anything">;
 def ext_typedef_without_a_name : ExtWarn<"typedef requires a name">,
   InGroup;

I just can't understand the intention here. Could you give any code example or 
reference to spec?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7666
@@ +7665,3 @@
+  "dereferencing pointer of type %0 is not allowed in OpenCL">;
+def err_opencl_pointer_to_image : Error<
+  "pointer to image is invalid in OpenCL">;

I have a feeling that line numbers are broken now in this review due to patch 
reupload. 

Please, see the comment on the line 7670.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7670
@@ +7669,3 @@
+  "%0 can only be used as a function parameter">;
+def err_opencl_atomic_init_addressspace : Error<
+  "initialization of atomic variables is restricted to variables in global 
address space in opencl">;

Could you do something like:

def err_atomic_init_constant : Error<
  "atomic variable can only be %select{assigned|initialised}0 to a compile 
time constant"
  " in the declaration statement in the program scope">;



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7673
@@ +7672,3 @@
+def err_opencl_block_proto_variadic : Error<
+  "invalid block prototype, variadic arguments are not allowed in opencl">;
+def err_opencl_invalid_block_array : Error<

in OpenCL


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7674
@@ +7673,3 @@
+  "invalid block prototype, variadic arguments are not allowed in opencl">;
+def err_opencl_invalid_block_array : Error<
+  "array of block is invalid in OpenCL">;

Could we combine err_opencl_invalid_block_array and err_opencl_pointer_to_image 
saying something like:

"Declaring a %select{pointer|array}0 of type %1 is not allowed in OpenCL"


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7675
@@ +7674,3 @@
+def err_opencl_invalid_block_array : Error<
+  "array of block is invalid in OpenCL">;
+def err_opencl_ternary_with_block : Error<

array of block type is ...


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7677
@@ +7676,3 @@
+def err_opencl_ternary_with_block : Error<
+  "blocks cannot be used as expressions in ternary expressions in opencl">;
+

in OpenCL


Comment at: lib/Sema/SemaDecl.cpp:5724
@@ +5723,3 @@
+  R->isPipeType()) {
+Diag(D.getIdentifierLoc(),
+ diag::err_opencl_type_can_only_be_used_as_function_parameter)

Some of them have to be. For example for C types that we use differently in CL. 
But for CL only types do we need to check additionally that it's CL? Do we not 
know it already?


Comment at: lib/Sema/SemaExpr.cpp:6251
@@ -6250,1 +6250,3 @@
 
+/// \brief Return true if the Expr is block type
+static bool checkBlockType(Sema , const Expr *E) {

a block type


Comment at: lib/Sema/SemaExpr.cpp:6299
@@ -6286,3 +6298,3 @@
   // Now check the two expressions.
   if (LHS.get()->getType()->isVectorType() ||
   RHS.get()->getType()->isVectorType())

I am not sure what the question is?

I think using block in a condition should be disallowed. Could you add this to 
testing as well? 


Comment at: lib/Sema/SemaExpr.cpp:6316
@@ +6315,3 @@
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+// should output error for both LHS and RHS, use | instead ||
+if (checkBlockType(*this, LHS.get()) | checkBlockType(*this, RHS.get()))

Could you remove this comment?


Comment at: lib/Sema/SemaExpr.cpp:7550
@@ -7527,3 +7549,3 @@
   LHSType, RHSVecType->getElementType(),
-  RHSType))
+  RHSType, Loc))
   return RHSType;

I am not clear about the purpose of this change.


Comment at: lib/Sema/SemaExpr.cpp:10061
@@ +10060,3 @@
+  // OpenCL v2.0 s6.12.5 - The unary operators (* and &) cannot be used with a
+  // Block
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {

Block -> block


Comment at: lib/Sema/SemaExpr.cpp:10115
@@ +10114,3 @@
+// Block.
+if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 &&
+Result->isBlockPointerType()) {

The code above seems to do similar. Could we combine into one 
function/diagnostic?


Comment at: lib/Sema/SemaInit.cpp:6139
@@ +6138,3 @@
+  // OpenCL v2.0 s6.13.11.1 - The ATOMIC_VAR_INIT macro expands to a token
+  // sequence suitable for initializing an atomic 

Re: [PATCH] D16080: [CUDA] Add tests for compiling CUDA files with -E.

2016-01-13 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: test/Driver/cuda-preprocess.cu:13-16
@@ +12,6 @@
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 
--cuda-host-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch

Given it's a driver test you probably just want to check the list of commands 
generated by driver (-###)

Checking preprocessing results would probably belong to test/Preprocessor.



Comment at: test/Driver/cuda-preprocess.cu:17
@@ +16,3 @@
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch
+

This would succeed if we fail to preprocess as it would catch 
'clang_unittest_no_arch' in the #ifndef above.

I'd add some macro which will get preprocessed away:

```
#ifndef __CUDA_ARCH__
#define PREPROCESSED_AWAY
clang_unittest_no_arch __ PREPROCESSED_AWAY
...
``` 

It may be an overkill, though. Up to you.



http://reviews.llvm.org/D16080



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


Re: [PATCH] D16081: [CUDA] Add test for compiling CUDA code with -S.

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

LGTM.


http://reviews.llvm.org/D16081



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


Re: [PATCH] D15907: Allow various function attributes to be specified on Objective-C blocks too.

2016-01-13 Thread Nicholas Allegra via cfe-commits
comex added reviewers: aaron.ballman, rsmith.
comex added a comment.

Ping, and adding potential reviewers like I was supposed to do in the first 
place.


http://reviews.llvm.org/D15907



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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Louis Dionne via cfe-commits
ldionne added a reviewer: rsmith.
ldionne updated this revision to Diff 44779.
ldionne added a comment.

Rebase on top of the master branch, and add Richard Smith as a reviewer, since 
he also reviewed David Majnemer's original patch (suggested by Nathan Wilson).


http://reviews.llvm.org/D15421

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/nth-element.cpp
  test/SemaCXX/nth_element.cpp

Index: test/SemaCXX/nth_element.cpp
===
--- /dev/null
+++ test/SemaCXX/nth_element.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+static_assert(__has_builtin(__nth_element), "");
+
+template 
+using NthElement = __nth_element;
+
+template 
+struct X;
+
+static_assert(__is_same(NthElement<0, X<0>>, X<0>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>>, X<1>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>>, X<2>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>>, X<3>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>>, X<4>), "");
+
+static_assert(__is_same(NthElement<0, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<0>), "");
+static_assert(__is_same(NthElement<1, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<1>), "");
+static_assert(__is_same(NthElement<2, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<2>), "");
+static_assert(__is_same(NthElement<3, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<3>), "");
+static_assert(__is_same(NthElement<4, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<4>), "");
+static_assert(__is_same(NthElement<5, X<0>, X<1>, X<2>, X<3>, X<4>, X<5>>, X<5>), "");
+
+template 
+using ErrorNthElement1 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed1 = ErrorNthElement1, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement2 = __nth_element; // expected-error{{may not be accessed at an out of bounds index}}
+using illformed2 = ErrorNthElement2, X<1>>; // expected-note{{in instantiation}}
+
+
+template 
+using ErrorNthElement3 = __nth_element; // expected-error{{must be indexed using an integral type}}
+enum Color : int { Red, Green, Blue };
+using illformed3 = ErrorNthElement3, X<1>, X<2>>; // expected-note{{in instantiation}}
Index: test/PCH/nth-element.cpp
===
--- /dev/null
+++ test/PCH/nth-element.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template 
+struct X { };
+
+template 
+using NthElement = __nth_element;
+
+void fn1() {
+  X<0> x0 = NthElement<0, X<0>, X<1>, X<2>>{};
+  X<1> x1 = NthElement<1, X<0>, X<1>, X<2>>{};
+  X<2> x2 = NthElement<2, X<0>, X<1>, X<2>>{};
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4152,6 +4152,7 @@
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
   RegisterPredefDecl(Context.MakeIntegerSeqDecl,
  PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
+  RegisterPredefDecl(Context.NthElementDecl, PREDEF_DECL_NTH_ELEMENT_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
   // TentativeDefinitions order.  Generally, this record will be empty for
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6444,6 +6444,9 @@
 
   case PREDEF_DECL_MAKE_INTEGER_SEQ_ID:
 return Context.getMakeIntegerSeqDecl();
+
+  case 

r257652 - Update cxx_dr_status.html after the 3.8 branch

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 13:14:03 2016
New Revision: 257652

URL: http://llvm.org/viewvc/llvm-project?rev=257652=rev
Log:
Update cxx_dr_status.html after the 3.8 branch

Modified:
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=257652=257651=257652=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Jan 13 13:14:03 2016
@@ -2483,7 +2483,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#407;>407
 C++11
 Named class with associated typedef: two names or one?
-SVN
+Clang 3.8
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#408;>408


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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2016-01-13 Thread Jonathan Roelofs via cfe-commits
jroelofs abandoned this revision.
jroelofs added a comment.

Hmm. There's no "close revision" button. Abandoning it in lieu of closing it.


http://reviews.llvm.org/D15528



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


Re: [PATCH] D15861: Support fully-qualified names for all QualTypes

2016-01-13 Thread Richard Smith via cfe-commits
On Fri, Jan 8, 2016 at 1:54 PM, Philippe Canal  wrote:

> Hi Richard,
>
> In our use (Persistency of C++ objects, including the (meta)description of
> their data content as well as use the name as key to access the class'
> reflection information at run-time), the 'context' is indeed always the "at
> the end of the translation unit" (or global scope).
> Thus (for us),
>
> > What is the fully-qualified name of `B::t`'s type? Is it `B::TX` or
> `std::tuple` or `std::tuple<::A::X>`?
>
> It indeed either `B::TX` or `std::tuple` depending on whether the
> typedefs are being desugared or not.
>
> > from within namespace `B`
>
> Within our API there is no way to actually express this (and I can't think
> of a semantic where it would make sense). Thus by construction it is always
> the "end of the translation unit" case.
>
> > The "ideal interface" idea is a good--and very cool--one, but my use
> case doesn't call for it.
>
> This also our situation. In addition, I do think that supporting the
> general case would increase the implementation complexity.  One 'simple'
> adaption is to support also the case with the leading :: (i.e.
> ::std::tuple<::A::X> which would always be safe no matter which context you
> use it).
>

The primary use case for the general "how do I name this thing from *here*"
functionality is automated refactoring tools, where inserting a
fully-qualified name is about the worst (correct) way you can name any
given entity, and isn't even always possible (for instance, if you're
naming an entity from a local scope).

My principal concern here is that we clearly document the design decisions
for these interfaces, so that we know what possible results are / are not
correct. Extending this to support other clients (which want to know how to
name an entity from a specified context) is secondary, and can be postponed
until someone wants to put in the work to make it happen.

Cheers,
> Philippe.
>
>
>
>
>  Forwarded Message  Subject: Re: [PATCH] D15861: Support
> fully-qualified names for all QualTypes Date: Fri, 8 Jan 2016 19:50:16
> + From: Sterling Augustine via cfe-commits
> 
>  Reply-To:
> reviews+d15861+public+e412d660379b2...@reviews.llvm.org, Sterling
> Augustine   To:
> saugust...@google.com, rich...@metafoo.co.uk CC:
> cfe-commits@lists.llvm.org
>
>
> saugustine added a comment.
>
> Thanks for the reviews. Please take another look when you get a chance.
>
>
> 
> Comment at: include/clang/Tooling/Core/QualTypeNames.h:32-33
> @@ +31,4 @@
> +namespace TypeName {
> +///\brief Convert the type into one with fully qualified template
> +/// arguments.
> +///\param[in] QT - the type for which the fully qualified type will be
> 
> rsmith wrote:
> > rsmith wrote:
> > > Please ensure there's a space between each `/// ` and the content.
> > What do you mean by "fully qualified template arguments" here? Let me give 
> > you some examples:
> >
> > namespace A {
> >   struct X {};
> > }
> > using A::X;
> > namespace B {
> >   using std::tuple;
> >   typedef typle TX;
> >   TX t;
> >   struct A { typedef int X; };
> > }
> >
> > What is the fully-qualified name of `B::t`'s type? Is it `B::TX` or 
> > `std::tuple` or `std::tuple<::A::X>`? Note that if you want to 
> > redeclare `t` from within namespace `B`, `std::tuple` will name the 
> > wrong type.
> >
> >
> > Why does this only affect template arguments? Its name suggests it should 
> > affect the type as a whole (for instance, in the above case it should 
> > produce `std::tuple<...>`, not `tuple<...>`).
> >
> >
> > Generally, I think this interface needs to specify where the produced names 
> > can be used as a name for the specified type, otherwise I don't see how it 
> > can ever be reliable. For instance:
> >
> > > "Generates a name for a type that can be used to name the same type if 
> > > used at the end of the current translation unit." (eg, `B::TX` or 
> > > `std::tuple`)
> >
> > or:
> >
> > > "Generates a maximally-explicit name for a type that can be used in any 
> > > context where all the relevant components have been declared. In such a 
> > > context, this name will either name the intended type or produce an 
> > > ambiguity error." (eg, `::std::tuple<::A::X>`)
> >
> > You should also specify what happens when it's not possible to generate 
> > such a name. For instance, given:
> >
> > void f() {
> >   struct X {} x;
> > }
> >
> > ... there's no way to name the type of `x` from outside `f` (which makes 
> > certain refactoring operations impossible unless you also move the 
> > definition of `struct X`).
> >
> >
> > I think the ideal interface here would allow you to specify a location 
> > where you wish to insert the name, and would produce a "best possible" name 
> > for that type for that 

Re: [PATCH] D15861: Support fully-qualified names for all QualTypes

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

I think this functionality can be provided more simply by adding another flag 
to `PrintingPolicy` to request fully-qualified names always be produced. It 
already usually provides fully-qualified names; the only notable exception I 
can see is that if a qualifier was already provided, it uses that instead (in 
particular, there is a special case for printing `ElaboratedType`s that uses 
the qualifier as written).



Comment at: include/clang/Tooling/Core/QualTypeNames.h:55
@@ +54,3 @@
+// client using that name at the end of the translation unit will be
+// refering to a different type.
+//

refering -> referring


Comment at: include/clang/Tooling/Core/QualTypeNames.h:80
@@ +79,3 @@
+/// issues such as type shadowing.
+
+/// \param[in] QT - the type for which the fully qualified type will be

Missing `///` on this line.


Comment at: include/clang/Tooling/Core/QualTypeNames.h:107
@@ +106,3 @@
+  const ASTContext ,
+  const PrintingPolicy& Policy);
+

` &`, not `& `, please.


Comment at: include/clang/Tooling/Core/QualTypeNames.h:118-139
@@ +117,24 @@
+
+/// \brief Create a NestedNameSpecifier for TagDecl and its enclosing
+/// scopes.
+///
+/// \param[in] Ctx - the AST Context to be used.
+/// \param[in] TD - the TagDecl for which a NestedNameSpecifier is
+/// requested.
+/// \param[in] FullyQualify - Convert all template arguments into fully
+/// qualified names.
+NestedNameSpecifier *createNestedNameSpecifier(
+const ASTContext , const TagDecl *TD, bool FullyQualify);
+
+/// \brief Create a NestedNameSpecifier for TypedefDecl and its enclosing
+/// scopes.
+///
+/// \param[in] Ctx - the AST Context to be used.
+/// \param[in] TD - the TypedefDecl for which a NestedNameSpecifier is
+/// requested.
+/// \param[in] FullyQualify - Convert all template arguments (of possible
+/// parent scopes) into fully qualified names.
+NestedNameSpecifier *createNestedNameSpecifier(
+const ASTContext , const TypedefNameDecl *TD,
+bool FullyQualify);
+

It would probably be better to have a single function to create a 
`NestedNameSpecifier` from a `TypeDecl` rather than splitting up these two 
cases.


Comment at: include/clang/Tooling/Core/QualTypeNames.h:133
@@ +132,3 @@
+/// \param[in] Ctx - the AST Context to be used.
+/// \param[in] TD - the TypedefDecl for which a NestedNameSpecifier is
+/// requested.

TypedefDecl -> TypedefNameDecl


Comment at: lib/Tooling/Core/QualTypeNames.cpp:31
@@ +30,3 @@
+
+static NestedNameSpecifier *getFullyQualifiedNameSpecifier(
+const ASTContext , NestedNameSpecifier *scope);

NameSpecifier -> NestedNameSpecifier


Comment at: lib/Tooling/Core/QualTypeNames.cpp:51
@@ +50,3 @@
+}
+  } else {
+NNS = createNestedNameSpecifierForScopeOf(Ctx, ArgTDecl, true);

`ArgTDecl` could be null here (for instance, if the `TemplateName` is a 
dependent template name).


Comment at: lib/Tooling/Core/QualTypeNames.cpp:87
@@ +86,3 @@
+
+static const Type *getFullyQualifiedLocalType(const ASTContext ,
+  const Type *TypePtr) {

What do you mean by 'Local' here?


Comment at: lib/Tooling/Core/QualTypeNames.cpp:89
@@ +88,3 @@
+  const Type *TypePtr) {
+  // We really just want to handle the template parameter if any 
+  // In case of template specializations iterate over the arguments and

I don't think this comment is accurate, just delete it?


Comment at: lib/Tooling/Core/QualTypeNames.cpp:98-99
@@ +97,4 @@
+ I != E; ++I) {
+  // cheap to copy and potentially modified by
+  // getFullyQualifedTemplateArgument
+  TemplateArgument Arg(*I);

Comment should start with a capital letter and end in a period.


Comment at: lib/Tooling/Core/QualTypeNames.cpp:105
@@ +104,3 @@
+
+// If desugaring happened allocate new type in the AST.
+if (MightHaveChanged) {

This comment is inaccurate; you're not doing desugaring. (The name of `DesArgs` 
is also inappropriate; `QualArgs` or `FQArgs` or similar would better express 
the intent.)


Comment at: lib/Tooling/Core/QualTypeNames.cpp:107-110
@@ +106,6 @@
+if (MightHaveChanged) {
+  QualType QT = Ctx.getTemplateSpecializationType(
+  TST->getTemplateName(), DesArgs.data(), DesArgs.size(),
+  TST->getCanonicalTypeInternal());
+  return QT.getTypePtr();
+}

Don't you need to form a fully-qualified template name here too?


Comment at: lib/Tooling/Core/QualTypeNames.cpp:150-153
@@ +149,6 @@
+  if (const NamespaceDecl 

Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2016-01-13 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

Tests need to be updated, for example:

clang/test/Index/remap-load.c:7:11: error: expected string not found in input
// CHECK: remap-load.c:2:10: BinaryOperator= Extent=[2:10 - 2:23]

  ^

:334:1: note: scanning from here
// CHECK: remap-load.c:2:10: BinaryOperator=+ Extent=[2:10 - 2:23]
^
:334:11: note: possible intended match here
// CHECK: remap-load.c:2:10: BinaryOperator=+ Extent=[2:10 - 2:23]

  ^

the failing tests are:

Failing Tests (9):

  Clang :: Index/blocks.c
  Clang :: Index/c-index-api-loadTU-test.m
  Clang :: Index/nested-binaryoperators.cpp
  Clang :: Index/preamble.c
  Clang :: Index/print-type.c
  Clang :: Index/print-type.cpp
  Clang :: Index/recursive-cxx-member-calls.cpp
  Clang :: Index/remap-load.c
  Clang :: Index/usrs.m


http://reviews.llvm.org/D10833



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


[PATCH] D16152: [clang-tidy] Add check performance-faster-string-find

2016-01-13 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Add check performance-faster-string-find.
It replaces single character string literals to character literals in calls to 
string::find and friends.

http://reviews.llvm.org/D16152

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-faster-string-find.rst
  test/clang-tidy/performance-faster-string-find.cpp

Index: test/clang-tidy/performance-faster-string-find.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-faster-string-find.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy %s performance-faster-string-find %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: performance-faster-string-find.StringLikeClasses, \
+// RUN:   value: 'std::basic_string,::llvm::StringRef'}]}" --
+
+namespace std {
+template 
+struct basic_string {
+  int find(const char *, int = 0) const;
+  int find(const char *, int, int) const;
+  int rfind(const char *) const;
+  int find_first_of(const char *) const;
+  int find_first_not_of(const char *) const;
+  int find_last_of(const char *) const;
+  int find_last_not_of(const char *) const;
+};
+
+typedef basic_string string;
+}  // namespace std
+
+namespace llvm {
+struct StringRef {
+  int find(const char *) const;
+};
+}  // namespace llvm
+
+struct NotStringRef {
+  int find(const char *);
+};
+
+void StringFind() {
+  std::string Str;
+
+  Str.find("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: char overload is more efficient [performance-faster-string-find]
+  // CHECK-FIXES: Str.find('a');
+
+  // Works with the pos argument.
+  Str.find("a", 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: char overload is more efficient
+  // CHECK-FIXES: Str.find('a', 1);
+
+  // Doens't work with strings smaller or larger than 1 char.
+  Str.find("");
+  Str.find("ab");
+
+  // Doesn't do anything with the 3 argument overload.
+  Str.find("a", 1, 1);
+
+  // Some other overloads
+  Str.rfind("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: char overload is more efficient
+  // CHECK-FIXES: Str.rfind('a');
+  Str.find_first_of("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: char overload is more efficient
+  // CHECK-FIXES: Str.find_first_of('a');
+  Str.find_first_not_of("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: char overload is more efficient
+  // CHECK-FIXES: Str.find_first_not_of('a');
+  Str.find_last_of("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: char overload is more efficient
+  // CHECK-FIXES: Str.find_last_of('a');
+  Str.find_last_not_of("a");
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: char overload is more efficient
+  // CHECK-FIXES: Str.find_last_not_of('a');
+
+  // Also with other types, but only if it was specified in the options.
+  llvm::StringRef sr;
+  sr.find("x");
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: char overload is more efficient
+  // CHECK-FIXES: sr.find('x');
+  NotStringRef nsr;
+  nsr.find("x");
+}
Index: docs/clang-tidy/checks/performance-faster-string-find.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-faster-string-find.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - performance-faster-string-find
+
+performance-faster-string-find
+==
+
+Optimize calls to std::string::find() and friends when the needle passed is
+a single character string literal.
+The character literal overload is more efficient.
+
+Examples:
+
+.. code-block:: c++
+
+  str.find("A");
+
+  // becomes
+
+  str.find('A');
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -75,6 +75,7 @@
modernize-use-default
modernize-use-nullptr
modernize-use-override
+   performance-faster-string-find
readability-braces-around-statements
readability-container-size-empty
readability-else-after-return
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "FasterStringFindCheck.h"
 
 #include "UnnecessaryCopyInitialization.h"
 
@@ -20,6 +21,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"performance-faster-string-find");
 CheckFactories.registerCheck(
 

r257695 - Update make_cxx_dr_status after the 3.8 branch.

2016-01-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan 13 16:51:59 2016
New Revision: 257695

URL: http://llvm.org/viewvc/llvm-project?rev=257695=rev
Log:
Update make_cxx_dr_status after the 3.8 branch.

Modified:
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/make_cxx_dr_status
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/make_cxx_dr_status?rev=257695=257694=257695=diff
==
--- cfe/trunk/www/make_cxx_dr_status (original)
+++ cfe/trunk/www/make_cxx_dr_status Wed Jan 13 16:51:59 2016
@@ -102,10 +102,10 @@ def availability(issue):
   if status == 'unknown':
 avail = 'Unknown'
 avail_style = ' class="none"'
-  elif status == '3.8':
+  elif status == '3.9':
 avail = 'SVN'
 avail_style = ' class="svn"'
-  elif status in ('3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7'):
+  elif status.startswith('3.'):
 avail = 'Clang %s' % status
 avail_style = ' class="full"'
   elif status == 'yes':


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


[PATCH][clang-format] Sublime script: prevent console window popup

2016-01-13 Thread Johan Engelen via cfe-commits
Hello,
  In the attachment is a small patch for clang-format-sublime.py, that
prevents the console window from showing. Right now, it is flashing ever so
briefly, ever so annoyingly; this patches fixes that.
I've tested it on Windows and Mac OS X.

I do not have write access; if you agree with the patch, please commit!

Thanks,
  Johan


clang-format-sublime.py.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-01-13 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/Basic/TargetInfo.h:385
@@ +384,3 @@
+  unsigned getFloat128Width() const { return Float128Width; }
+  unsigned getFloat128Align() const { return Float128Align; }
+  const llvm::fltSemantics () const {

I think you can safely have this method hard-code the size, though. :)


Comment at: lib/AST/ASTContext.cpp:4594
@@ -4592,1 +4593,3 @@
+  case BuiltinType::Float128:
+return Float128Rank;
   }

Follow the same code styling as above, please.


Comment at: lib/AST/ASTContext.cpp:4611
@@ -4607,2 +4610,3 @@
 case LongDoubleRank: return LongDoubleComplexTy;
+case Float128Rank: return Float128ComplexTy;
 }

Indentation.


Comment at: lib/AST/ASTContext.cpp:4635
@@ +4634,3 @@
+  // If the two sides have Float128Rank and LongDoubleRank and the two types
+  // have the same representation on this platform, they have equal rank.
+  if ((LHSR == LongDoubleRank && RHSR == Float128Rank) ||

This is a really bad language rule with nasty implications for a lot of code.  
Is there a really urgent need to emulate some other compiler bug-for-bug here?

It's okay for there to a formal rank difference even when types have the same 
representation — that's basically always true for the integer types — so unless 
there's a very specific and very good reason not to, let's just use the rule 
that float128 has higher rank than long double.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D16177: Adding missing intrinsics _cvtsh_ss and _cvtss_sh

2016-01-13 Thread Katya Romanova via cfe-commits
kromanova added a subscriber: cfe-commits.
kromanova added a comment.

Adding cfe-commits as a subscriber.


Repository:
  rL LLVM

http://reviews.llvm.org/D16177



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


Re: [PATCH] D10599: [OPENMP 4.0] Initial support for '#pragma omp declare simd' directive.

2016-01-13 Thread Alexey Bataev via cfe-commits
ABataev removed a subscriber: rsmith.
ABataev updated this revision to Diff 44833.
ABataev added a comment.

Updated to latest version


http://reviews.llvm.org/D10599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Basic/OpenMPKinds.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_simd_ast_print.c
  test/OpenMP/declare_simd_ast_print.cpp
  test/OpenMP/declare_simd_messages.cpp

Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -657,8 +657,10 @@
   case tok::annot_pragma_opencl_extension:
 HandlePragmaOpenCLExtension();
 return DeclGroupPtrTy();
-  case tok::annot_pragma_openmp:
-return ParseOpenMPDeclarativeDirective();
+  case tok::annot_pragma_openmp: {
+AccessSpecifier AS = AS_none;
+return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, attrs);
+  }
   case tok::annot_pragma_ms_pointers_to_members:
 HandlePragmaMSPointersToMembers();
 return DeclGroupPtrTy();
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -31,6 +31,7 @@
   // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
   // TODO: add other combined directives in topological order.
   const OpenMPDirectiveKind F[][3] = {
+  {OMPD_unknown /*declare*/, OMPD_simd, OMPD_declare_simd},
   {OMPD_unknown /*cancellation*/, OMPD_unknown /*point*/,
OMPD_cancellation_point},
   {OMPD_target, OMPD_unknown /*data*/, OMPD_target_data},
@@ -49,11 +50,12 @@
   for (unsigned i = 0; i < llvm::array_lengthof(F); ++i) {
 if (!Tok.isAnnotation() && DKind == OMPD_unknown) {
   TokenMatched =
-  (i == 0) &&
-  !P.getPreprocessor().getSpelling(Tok).compare("cancellation");
-} else {
+  ((i == 0) &&
+   !P.getPreprocessor().getSpelling(Tok).compare("declare")) ||
+  ((i == 1) &&
+   !P.getPreprocessor().getSpelling(Tok).compare("cancellation"));
+} else
   TokenMatched = DKind == F[i][0] && DKind != OMPD_unknown;
-}
 
 if (TokenMatched) {
   Tok = P.getPreprocessor().LookAhead(0);
@@ -65,12 +67,11 @@
 
   if (!TokenIsAnnotation && SDKind == OMPD_unknown) {
 TokenMatched =
-((i == 0) &&
+((i == 1) &&
  !P.getPreprocessor().getSpelling(Tok).compare("point")) ||
-((i == 1) && !P.getPreprocessor().getSpelling(Tok).compare("data"));
-  } else {
+((i == 2) && !P.getPreprocessor().getSpelling(Tok).compare("data"));
+  } else
 TokenMatched = SDKind == F[i][1] && SDKind != OMPD_unknown;
-  }
 
   if (TokenMatched) {
 P.ConsumeToken();
@@ -85,8 +86,16 @@
 ///
 ///   threadprivate-directive:
 /// annot_pragma_openmp 'threadprivate' simple-variable-list
+/// annot_pragma_omp_end
 ///
-Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
+///   declare-simd-directive:
+/// annot_pragma_openmp 'declare simd' { [,]}
+/// annot_pragma_omp_end
+/// 
+///
+Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
+AccessSpecifier , ParsedAttributesWithRange ,
+DeclSpec::TST TagType, Decl *Tag) {
   assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
 
@@ -110,6 +119,47 @@
   return Actions.ActOnOpenMPThreadprivateDirective(Loc, Identifiers);
 }
 break;
+  case OMPD_declare_simd: {
+// The syntax is:
+// { #pragma omp declare simd }
+// 
+//
+
+ConsumeToken();
+// The last seen token is annot_pragma_openmp_end - need to check for
+// extra tokens.
+if (Tok.isNot(tok::annot_pragma_openmp_end)) {
+  Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
+  << getOpenMPDirectiveName(OMPD_declare_simd);
+  while (Tok.isNot(tok::annot_pragma_openmp_end))
+ConsumeAnyToken();
+}
+// Skip the last annot_pragma_openmp_end.
+ConsumeToken();
+
+DeclGroupPtrTy Ptr;
+if (Tok.is(tok::annot_pragma_openmp)) {
+  Ptr = ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs, TagType, Tag);
+} else if (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
+  // Here we expect to see some function declaration.
+  if (AS == AS_none) {
+assert(TagType == DeclSpec::TST_unspecified);
+MaybeParseCXX11Attributes(Attrs);
+MaybeParseMicrosoftAttributes(Attrs);
+ParsingDeclSpec PDS(*this);
+Ptr = ParseExternalDeclaration(Attrs, );
+  } else {
+Ptr =
+

r257741 - clang-format: [JS] Fix incorrect line break leading to semicolon insertion.

2016-01-13 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Jan 13 23:37:52 2016
New Revision: 257741

URL: http://llvm.org/viewvc/llvm-project?rev=257741=rev
Log:
clang-format: [JS] Fix incorrect line break leading to semicolon insertion.

clang-format only works for JavaScript code, if all the semicolons are
present anyway, so this linebreak can never be desired.

Before (with appropriate statement lengths or column limit):
  return
  [ aaa ];

After:
  return [

  ];

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=257741=257740=257741=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 13 23:37:52 2016
@@ -2268,6 +2268,8 @@ bool TokenAnnotator::canBreakBefore(cons
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
+if (Left.is(tok::kw_return))
+  return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
 if (Left.is(TT_JsTypeColon))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257741=257740=257741=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Jan 13 23:37:52 2016
@@ -591,6 +591,10 @@ TEST_F(FormatTestJS, AutomaticSemicolonI
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a--;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return [\n"
+   "  aaa\n"
+   "];",
+   getGoogleJSStyleWithColumns(12));
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


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


Re: r257533 - D9600: Add scan-build python implementation

2016-01-13 Thread Ismail Donmez via cfe-commits
Thanks for the clarification.

On Thursday, January 14, 2016, Laszlo Nagy 
wrote:

> yes, it is just an initial drop. improvements are planed to make a full
> replacement of the one written in Perl.
>
> On Thu, Jan 14, 2016 at 12:14 AM, Ismail Donmez  > wrote:
>
>> Hi,
>>
>> On Wed, Jan 13, 2016 at 12:38 AM, Laszlo Nagy via cfe-commits
>> > > wrote:
>> > Author: rizsotto
>> > Date: Tue Jan 12 16:38:41 2016
>> > New Revision: 257533
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=257533=rev
>> > Log:
>> > D9600: Add scan-build python implementation
>>
>> This doesn't seem to be installed by default, is that intended?
>>
>> Regards,
>> ismail
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16154: Default vaarg lowering should support indirect struct types.

2016-01-13 Thread James Y Knight via cfe-commits
jyknight created this revision.
jyknight added a subscriber: cfe-commits.
Herald added subscribers: jyknight, dschuff, jfb.

Fixes PR11517 for SPARC.

On most targets, clang lowers va_arg itself, eschewing the use of the
llvm vaarg instruction. This is necessary (at least for now) as the type
argument to the vaarg instruction cannot represent all the ABI
information that is needed to support complex calling conventions.

However, on targets with a simpler varrags ABIs, the LLVM instruction
can work just fine, and clang can simply lower to it. Unfortunately,
even on such targets, vaarg with a struct argument would fail, because
the default lowering to vaarg was naive: it didn't take into account the
ABI attribute computed by classifyArgumentType. In particular, for the
DefaultABIInfo, structs are supposed to be passed indirectly and so
llvm's vaarg instruction should be emitted with a pointer argument.

Now, vaarg instruction emission is able to use computed ABIArgInfo for
the provided argument type, which allows the default ABI support to work
for structs too.

I haven't touched the EmitVAArg implementation for PPC32_SVR4 or XCore,
although I believe both are now redundant, and could be switched over to
use the default implementation as well.

http://reviews.llvm.org/D16154

Files:
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/le32-vaarg.c
  test/CodeGen/sparc-vaarg.c

Index: test/CodeGen/sparc-vaarg.c
===
--- /dev/null
+++ test/CodeGen/sparc-vaarg.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple sparc -emit-llvm -o - %s | FileCheck %s
+#include 
+
+int get_int(va_list *args) {
+// CHECK-LABEL: define i32 @get_int
+// CHECK: [[RESULT:%[a-z_0-9]+]] = va_arg {{.*}}, i32{{$}}
+// CHECK: store i32 [[RESULT]], i32* [[LOC:%[a-z_0-9]+]]
+// CHECK: [[RESULT2:%[a-z_0-9]+]] = load i32, i32* [[LOC]]
+// CHECK: ret i32 [[RESULT2]]
+  return va_arg(*args, int);
+}
+
+struct Foo {
+  int x;
+};
+
+struct Foo dest;
+
+void get_struct(va_list *args) {
+ dest = va_arg(*args, struct Foo);
+}
+// CHECK-LABEL: define void @get_struct
+// CHECK: [[RESULT:%[a-z_0-9]+]] = va_arg {{.*}}, %struct.Foo*{{$}}
+// CHECK: [[RESULT2:%[a-z_0-9]+]] = bitcast {{.*}} [[RESULT]] to i8*
+// CHECK: call void @llvm.memcpy{{.*}}@dest{{.*}}, i8* [[RESULT2]]
+
+enum E { Foo_one = 1 };
+
+enum E enum_dest;
+
+void get_enum(va_list *args) {
+  enum_dest = va_arg(*args, enum E);
+}
Index: test/CodeGen/le32-vaarg.c
===
--- test/CodeGen/le32-vaarg.c
+++ test/CodeGen/le32-vaarg.c
@@ -6,7 +6,9 @@
 }
 // CHECK: define i32 @get_int
 // CHECK: [[RESULT:%[a-z_0-9]+]] = va_arg {{.*}}, i32{{$}}
-// CHECK: ret i32 [[RESULT]]
+// CHECK: store i32 [[RESULT]], i32* [[LOC:%[a-z_0-9]+]]
+// CHECK: [[RESULT2:%[a-z_0-9]+]] = load i32, i32* [[LOC]]
+// CHECK: ret i32 [[RESULT2]]
 
 struct Foo {
   int x;
@@ -19,7 +21,9 @@
 }
 // CHECK: define void @get_struct
 // CHECK: [[RESULT:%[a-z_0-9]+]] = va_arg {{.*}}, %struct.Foo{{$}}
-// CHECK: store %struct.Foo [[RESULT]], %struct.Foo* @dest
+// CHECK: store %struct.Foo [[RESULT]], %struct.Foo* [[LOC:%[a-z_0-9]+]]
+// CHECK: [[LOC2:%[a-z_0-9]+]] = bitcast {{.*}} [[LOC]] to i8*
+// CHECK: call void @llvm.memcpy{{.*}}@dest{{.*}}, i8* [[LOC2]]
 
 void skip_struct(va_list *args) {
   va_arg(*args, struct Foo);
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -523,6 +523,54 @@
 }
 
 namespace {
+Address EmitVAArgInstr(CodeGenFunction , Address VAListAddr, QualType Ty,
+   const ABIArgInfo ) {
+  // This default implementation defers to the llvm backend's va_arg
+  // instruction. It can handle only passing arguments directly
+  // (typically only handled in the backend for primitive types), or
+  // aggregates passed indirectly by pointer (NOTE: if the "byval"
+  // flag has ABI impact in the callee, this implementation cannot
+  // work.)
+
+  // Only a few cases are covered here at the moment -- those needed
+  // by the default abi.
+  llvm::Value *Val;
+
+  if (AI.isIndirect()) {
+assert(!AI.getPaddingType() &&
+   "Unepxected PaddingType seen in arginfo in generic VAArg emitter!");
+assert(
+!AI.getIndirectRealign() &&
+"Unepxected IndirectRealign seen in arginfo in generic VAArg emitter!");
+
+auto TyInfo = CGF.getContext().getTypeInfoInChars(Ty);
+CharUnits TyAlignForABI = TyInfo.second;
+
+llvm::Type *BaseTy =
+llvm::PointerType::getUnqual(CGF.ConvertTypeForMem(Ty));
+llvm::Value *Addr =
+CGF.Builder.CreateVAArg(VAListAddr.getPointer(), BaseTy);
+return Address(Addr, TyAlignForABI);
+  } else {
+assert((AI.isDirect() || AI.isExtend()) &&
+   "Unexpected ArgInfo Kind in generic VAArg emitter!");
+
+assert(!AI.getInReg() &&
+  

Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

In http://reviews.llvm.org/D15421#326144, @rsmith wrote:

> Bikeshedding on the name a bit... how about `__type_pack_element`?


Hmm, I kind of felt like having `nth` in there implied we're indexing into 
something... What about `__nth_pack_element`?


http://reviews.llvm.org/D15421



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


Re: [PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Please let me know if the subject or summary of this Patch is ambiguous.


http://reviews.llvm.org/D16163



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


[libcxx] r257682 - Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the strong exception safety guarantee'. This turned out to be a pervasive problem in , which required

2016-01-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jan 13 15:54:34 2016
New Revision: 257682

URL: http://llvm.org/viewvc/llvm-project?rev=257682=rev
Log:
Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the 
strong exception safety guarantee'. This turned out to be a pervasive problem 
in , which required a fair amount of rework. Add in an optimization for 
when iterators provide noexcept increment/comparison/assignment/dereference 
(which covers many of the iterators in libc++). Reviewed as 
http://reviews.llvm.org/D15862

Added:
libcxx/trunk/test/libcxx/iterators/
libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp
libcxx/trunk/test/libcxx/strings/
libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp
libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/iterator
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
libcxx/trunk/test/support/test_iterators.h

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=257682=257681=257682=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ 

Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-01-13 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/tool/ClangTidyMain.cpp:78
@@ +77,3 @@
+static cl::opt
+HeaderFileExtensions("header-file-extensions",
+ cl::desc("File extensions that regard as header file.\n"

alexfh wrote:
> We don't need a command-line flag for this. The regular way to configure 
> clang-tidy is .clang-tidy files. However, if needed, check options can be 
> configured from the command line via the `-config=` option. 
From my understanding, it is a global option for header-file-extensions, right? 
If we remove this command-line flag, there is only local 
`header-file-extensions` option remained for particular checks.


Repository:
  rL LLVM

http://reviews.llvm.org/D16113



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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

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


Comment at: include/clang/Basic/Builtins.h:216-219
@@ -215,3 +215,6 @@
   /// \brief This names the __make_integer_seq BuiltinTemplateDecl.
   BTK__make_integer_seq
+
+  /// \brief This names the __nth_element BuiltinTemplateDecl.
+  , BTK__nth_element
 };

Please put the comma after `BTK__make_integer_seq`, not on this line.


Comment at: lib/AST/DeclTemplate.cpp:1243
@@ +1242,3 @@
+static TemplateParameterList *
+createNthElement(const ASTContext , DeclContext *DC) {
+  // typename IndexType

Rename this `createNthElementParameterList`.


Comment at: lib/AST/DeclTemplate.cpp:1244-1248
@@ +1243,7 @@
+createNthElement(const ASTContext , DeclContext *DC) {
+  // typename IndexType
+  auto *IndexType = TemplateTypeParmDecl::Create(
+  C, DC, SourceLocation(), SourceLocation(), /*Depth=*/0, /*Position=*/0,
+  /*Id=*/nullptr, /*Typename=*/true, /*ParameterPack=*/false);
+  IndexType->setImplicit(true);
+

Use `NonTypeTemplateParmDecl::Create`. You can get `size_t` from 
`ASTContext::getSizeType`.


Comment at: lib/Sema/SemaTemplate.cpp:2102-2103
@@ +2101,4 @@
+// We simply return the type at index `Index`.
+// TODO:
+// What are the implications of calling .getExtValue() on an APSInt?
+assert(Index.getExtValue() == Index &&

`getExtValue` is OK here, as we don't support `size_t` being larger than 64 
bits.


http://reviews.llvm.org/D15421



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


Re: r257710 - [Sema] Suppress diags in overload resolution.

2016-01-13 Thread Hans Wennborg via cfe-commits
Thanks! Richard, what say the code owner?

On Wed, Jan 13, 2016 at 3:59 PM, George Burgess IV
 wrote:
> FYI: This patch should to be merged into the clang 3.8.0 branch.
>
> Thank you!
> George
>
> On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits
>  wrote:
>>
>> Author: gbiv
>> Date: Wed Jan 13 17:36:34 2016
>> New Revision: 257710
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257710=rev
>> Log:
>> [Sema] Suppress diags in overload resolution.
>>
>> We were emitting diagnostics from our shiny new C-only overload
>> resolution mode. This patch attempts to silence all such diagnostics.
>>
>> This fixes PR26085.
>> Differential Revision: http://reviews.llvm.org/D16159
>>
>> Added:
>> cfe/trunk/test/SemaObjC/ovl-check.m
>> Modified:
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaExprObjC.cpp
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710=257709=257710=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016
>> @@ -2229,7 +2229,8 @@ public:
>>bool CheckPointerConversion(Expr *From, QualType ToType,
>>CastKind ,
>>CXXCastPath& BasePath,
>> -  bool IgnoreBaseAccess);
>> +  bool IgnoreBaseAccess,
>> +  bool Diagnose = true);
>>bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
>> ToType,
>>   bool InOverloadResolution,
>>   QualType );
>> @@ -5388,7 +5389,8 @@ public:
>>  unsigned AmbigiousBaseConvID,
>>  SourceLocation Loc, SourceRange
>> Range,
>>  DeclarationName Name,
>> -CXXCastPath *BasePath);
>> +CXXCastPath *BasePath,
>> +bool IgnoreAccess = false);
>>
>>std::string getAmbiguousPathsDisplayString(CXXBasePaths );
>>
>> @@ -7514,14 +7516,15 @@ public:
>>  ObjCMethodDecl *,
>>  ObjCMethodDecl *,
>>  TypedefNameDecl *,
>> -bool CfToNs);
>> -
>> +bool CfToNs, bool Diagnose =
>> true);
>> +
>>bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
>>   QualType DestType, QualType
>> SrcType,
>> - Expr *);
>> -
>> -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>> *);
>> -
>> + Expr *, bool Diagnose =
>> true);
>> +
>> +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>> *,
>> +  bool Diagnose = true);
>> +
>>bool checkInitMethod(ObjCMethodDecl *method, QualType
>> receiverTypeIfCall);
>>
>>/// \brief Check whether the given new method is a valid override of
>> the
>> @@ -8613,6 +8616,7 @@ public:
>>ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
>>   QualType castType, Expr
>> *,
>>   CheckedConversionKind CCK,
>> + bool Diagnose = true,
>>   bool DiagnoseCFAudited =
>> false,
>>   BinaryOperatorKind Opc =
>> BO_PtrMemD
>>   );
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710=257709=257710=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016
>> @@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB
>>  /// otherwise. Loc is the location where this routine should point to
>>  /// if there is an error, and Range is the source range to highlight
>>  /// if there is an error.
>> +///
>> +/// If either InaccessibleBaseID or AmbigiousBaseConvID are 0, then the
>> +/// diagnostic for the respective type of error will be suppressed, but
>> the
>> +/// check for ill-formed code will still be performed.
>>  bool
>>  

[libcxx] r257721 - Merging r257702:

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 18:02:08 2016
New Revision: 257721

URL: http://llvm.org/viewvc/llvm-project?rev=257721=rev
Log:
Merging r257702:

r257702 | marshall | 2016-01-13 15:05:15 -0800 (Wed, 13 Jan 2016) | 1 line

Better comments in test. NFC


Modified:
libcxx/branches/release_38/   (props changed)
libcxx/branches/release_38/test/libcxx/strings/iterators.noexcept.pass.cpp

Propchange: libcxx/branches/release_38/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 13 18:02:08 2016
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:257682,257696
+/libcxx/trunk:257682,257696,257702

Modified: 
libcxx/branches/release_38/test/libcxx/strings/iterators.noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/libcxx/strings/iterators.noexcept.pass.cpp?rev=257721=257720=257721=diff
==
--- libcxx/branches/release_38/test/libcxx/strings/iterators.noexcept.pass.cpp 
(original)
+++ libcxx/branches/release_38/test/libcxx/strings/iterators.noexcept.pass.cpp 
Wed Jan 13 18:02:08 2016
@@ -14,7 +14,9 @@
 
 // __libcpp_string_gets_noexcept_iterator determines if an iterator can be used
 // w/o worrying about whether or not certain operations can throw.
-// This gives us a "fast path for string operations"
+// This gives us a "fast path for string operations".
+//
+// When exceptions are disabled, all iterators should get this "fast path"
 //
 
 #define_LIBCPP_NO_EXCEPTIONS
@@ -44,7 +46,6 @@ int main()
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator > ::value), "");
 
 //  iterators in the libc++ test suite
-// Since we have turned off exceptions, they're all noexcept
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
 static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), "");
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");


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


[libcxx] r257720 - Merging r257696:

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 18:01:17 2016
New Revision: 257720

URL: http://llvm.org/viewvc/llvm-project?rev=257720=rev
Log:
Merging r257696:

r257696 | marshall | 2016-01-13 14:52:36 -0800 (Wed, 13 Jan 2016) | 1 line

Fix test for C++03 - lacking noexcept


Modified:
libcxx/branches/release_38/   (props changed)
libcxx/branches/release_38/test/libcxx/strings/iterators.exceptions.pass.cpp

Propchange: libcxx/branches/release_38/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 13 18:01:17 2016
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:257682
+/libcxx/trunk:257682,257696

Modified: 
libcxx/branches/release_38/test/libcxx/strings/iterators.exceptions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_38/test/libcxx/strings/iterators.exceptions.pass.cpp?rev=257720=257719=257720=diff
==
--- 
libcxx/branches/release_38/test/libcxx/strings/iterators.exceptions.pass.cpp 
(original)
+++ 
libcxx/branches/release_38/test/libcxx/strings/iterators.exceptions.pass.cpp 
Wed Jan 13 18:01:17 2016
@@ -49,7 +49,11 @@ int main()
 
static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
 
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 
+#if __has_feature(cxx_noexcept)
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
+#else
+
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+#endif

 //
 //  iterators from libc++'s containers


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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

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

Bikeshedding on the name a bit... how about `__type_pack_element`?


http://reviews.llvm.org/D15421



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


[PATCH] D16158: [CMake] Add clang's targets to LLVM's export set when not building standalone

2016-01-13 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: rnk, chapuni, hintonda.
beanz added a subscriber: cfe-commits.

CMake freaks out in trivial cases like:

> cmake -G Ninja -DLLVM_ENABLE_PIC=Off -DLLVM_INSTALL_TOOLCHAIN_ONLY=On ../llvm

This is a result of static ink dependencies not all being part of the same 
export group, and was caused by r249935.

http://reviews.llvm.org/D16158

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -177,8 +177,10 @@
 
   set( CLANG_BUILT_STANDALONE 1 )
   set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
+  set(EXPORT_GROUP ClangTargets)
 else()
   set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
+  set(EXPORT_GROUP LLVMExports)
 endif()
 
 find_package(LibXml2 2.5.3 QUIET)
@@ -401,7 +403,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
   install(TARGETS ${name}
 COMPONENT ${name}
-EXPORT ClangTargets
+EXPORT ${EXPORT_GROUP}
 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
@@ -582,8 +584,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
-CMAKE_VERSION VERSION_GREATER 3)
+if (CLANG_BUILT_STANDALONE)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, 
but
   # the usual CMake convention seems to be ${Project}Targets.cmake.


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -177,8 +177,10 @@
 
   set( CLANG_BUILT_STANDALONE 1 )
   set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
+  set(EXPORT_GROUP ClangTargets)
 else()
   set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
+  set(EXPORT_GROUP LLVMExports)
 endif()
 
 find_package(LibXml2 2.5.3 QUIET)
@@ -401,7 +403,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
   install(TARGETS ${name}
 COMPONENT ${name}
-EXPORT ClangTargets
+EXPORT ${EXPORT_GROUP}
 LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
@@ -582,8 +584,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
-CMAKE_VERSION VERSION_GREATER 3)
+if (CLANG_BUILT_STANDALONE)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, but
   # the usual CMake convention seems to be ${Project}Targets.cmake.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257533 - D9600: Add scan-build python implementation

2016-01-13 Thread Laszlo Nagy via cfe-commits
yes, it is just an initial drop. improvements are planed to make a full
replacement of the one written in Perl.

On Thu, Jan 14, 2016 at 12:14 AM, Ismail Donmez  wrote:

> Hi,
>
> On Wed, Jan 13, 2016 at 12:38 AM, Laszlo Nagy via cfe-commits
>  wrote:
> > Author: rizsotto
> > Date: Tue Jan 12 16:38:41 2016
> > New Revision: 257533
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=257533=rev
> > Log:
> > D9600: Add scan-build python implementation
>
> This doesn't seem to be installed by default, is that intended?
>
> Regards,
> ismail
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r257716 - Merging r257682:

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 17:53:40 2016
New Revision: 257716

URL: http://llvm.org/viewvc/llvm-project?rev=257716=rev
Log:
Merging r257682:

r257682 | marshall | 2016-01-13 13:54:34 -0800 (Wed, 13 Jan 2016) | 1 line

Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the 
strong exception safety guarantee'. This turned out to be a pervasive problem 
in , which required a fair amount of rework. Add in an optimization for 
when iterators provide noexcept increment/comparison/assignment/dereference 
(which covers many of the iterators in libc++). Reviewed as 
http://reviews.llvm.org/D15862


Added:
libcxx/branches/release_38/test/libcxx/iterators/
  - copied from r257682, libcxx/trunk/test/libcxx/iterators/
libcxx/branches/release_38/test/libcxx/strings/
  - copied from r257682, libcxx/trunk/test/libcxx/strings/
Modified:
libcxx/branches/release_38/   (props changed)
libcxx/branches/release_38/include/algorithm
libcxx/branches/release_38/include/iterator
libcxx/branches/release_38/include/string

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp

libcxx/branches/release_38/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Richard Smith via cfe-commits
On Wed, Jan 13, 2016 at 2:31 PM, Nathan Wilson  wrote:

> nwilson added a comment.
>
> In http://reviews.llvm.org/D15421#326144, @rsmith wrote:
>
> > Bikeshedding on the name a bit... how about `__type_pack_element`?
>
> Hmm, I kind of felt like having `nth` in there implied we're indexing into
> something... What about `__nth_pack_element`?


Conversely, std::nth_element doesn't do indexing, and std::tuple_element
does.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r257696 - Fix test for C++03 - lacking noexcept

2016-01-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jan 13 16:52:36 2016
New Revision: 257696

URL: http://llvm.org/viewvc/llvm-project?rev=257696=rev
Log:
Fix test for C++03 - lacking noexcept

Modified:
libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp

Modified: libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp?rev=257696=257695=257696=diff
==
--- libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp Wed Jan 13 
16:52:36 2016
@@ -49,7 +49,11 @@ int main()
 
static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
 
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 
+#if __has_feature(cxx_noexcept)
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
+#else
+
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+#endif

 //
 //  iterators from libc++'s containers


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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

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

Yes, this seems to be exactly what I wanted, thanks!  LGTM.


http://reviews.llvm.org/D15686



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


Re: [PATCH] D16080: [CUDA] Add tests for compiling CUDA files with -E.

2016-01-13 Thread Justin Lebar via cfe-commits
jlebar marked 2 inline comments as done.
jlebar added a comment.

Thank you for the review, Artem.


http://reviews.llvm.org/D16080



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


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-01-13 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:550
@@ -548,1 +549,3 @@
   case BuiltinType::Double:
+// FIXME: For targets where lond double and __float128 have the same size,
+// they are currently indistinguishable in the debugger withouth some

There are various typos in this comment.


Comment at: lib/CodeGen/CGExprScalar.cpp:1809
@@ +1808,3 @@
+  else if (value->getType()->isHalfTy())
+FS = ().getHalfFormat();
+  F.convert(*FS, llvm::APFloat::rmTowardZero, );

It might make sense to move the call to `getLongDoubleFormat()` to the if/else 
block and perhaps to order it as long double/__float128/half.


Comment at: lib/Sema/SemaExpr.cpp:1115
@@ -1114,3 +1114,3 @@
 int order = S.Context.getFloatingTypeOrder(LHSType, RHSType);
-if (order > 0) {
+if (order >= 0) {
   RHS = S.ImpCastExprToType(RHS.get(), LHSType, CK_FloatingCast);

Are we all comfortable that if `long double` and `__float128` have the same 
representation, but are considered distinct types, then the LHS type is used? 
Is this consistent with GCC?


Comment at: lib/Sema/SemaExpr.cpp:1146
@@ +1145,3 @@
+   QualType RHSType) {
+  if (!LHSType.getTypePtr()->isFloatingType() ||
+  !RHSType.getTypePtr()->isFloatingType() ||

There's no actual need for the `.getTypePtr()` part; the overloaded 
`operator->` does the same thing.


Comment at: lib/Sema/SemaExpr.cpp:1153
@@ +1152,3 @@
+  QualType LHSElemType = LHSType->isComplexType() ?
+LHSComplexType->getElementType() : LHSType;
+  QualType RHSElemType = RHSType->isComplexType() ?

`LHSComplexType` is only used here. It could be replaced with 
`cast(LHSType.getTypePtr())` (and similarly for the RHS).

Indeed, since we are checking against specific real element types anyway, 
`dyn_cast(LHSType.getTypePtr())` (and checking for null) would 
suffice (no need to use `isComplexType()`).


Comment at: test/Sema/float128-ld-incompatibility.cpp:32
@@ +31,2 @@
+  q / ld; // expected-error {{invalid operands to binary expression 
('__float128' and 'long double')}}
+}

I believe a test for the conditional operator would be appropriate.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-13 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 44826.
pxli168 added a comment.

Fix format of diag err string, remove useless ':' after expecting.


http://reviews.llvm.org/D15914

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/pipe_builtin.cl
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+void test1(read_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  read_pipe(tmp, p);// expected-error {{first argument to read_pipe must be a pipe type}}
+  read_pipe(p);   // expected-error {{invalid number of arguments to function: read_pipe}}
+  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'reserve_id_t')}}
+  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'unsigned int')}}
+  read_pipe(p, tmp);   // expected-error {{invalid argument type to function read_pipe (expecting 'int *')}}
+  write_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+  write_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+
+  // reserve_read/write_pipe
+  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_read_pipe (expecting 'unsigned int')}}
+  work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_read_pipe must be a pipe type}}
+  sub_group_reserve_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}}
+
+  // commit_read/write_pipe
+  commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}}
+  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting 'reserve_id_t')}}
+  sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}}
+}
+
+void test2(write_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}}
+  write_pipe(p);   // expected-error {{invalid number of arguments to function: write_pipe}}
+  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'reserve_id_t')}}
+  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'unsigned int')}}
+  write_pipe(p, tmp);   // expected-error {{invalid argument type to function write_pipe (expecting 'int *')}}
+  read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+  read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+
+  // reserve_read/write_pipe
+  reserve_write_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_write_pipe (expecting 'unsigned int')}}
+  work_group_reserve_write_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_write_pipe must be a pipe type}}
+  sub_group_reserve_read_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting read_only)}}
+
+  // commit_read/write_pipe
+  commit_write_pipe(tmp, rid);// expected-error{{first argument to commit_write_pipe must be a pipe type}}
+  work_group_commit_write_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_write_pipe (expecting 'reserve_id_t')}}
+  sub_group_commit_read_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting read_only)}}
+}
+
+void test3(){
+  int tmp;
+  get_pipe_num_packets(tmp);// expected-error {{first argument to get_pipe_num_packets must be a pipe type}}
+  get_pipe_max_packets(tmp);// expected-error {{first argument to get_pipe_max_packets must be a pipe type}}
+}
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %opencl.pipe_t = type opaque
+// CHECK: %opencl.reserve_id_t = type opaque
+
+void test1(read_only pipe int p, global int *ptr) {
+  // CHECK: call i32 @read_pipe_2(%opencl.pipe_t* %{{.*}}, i8 addrspace(4)* %{{.*}})
+  read_pipe(p, ptr);
+  // CHECK: call %opencl.reserve_id_t* @reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 

Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Nathan Wilson via cfe-commits
On Wed, Jan 13, 2016 at 6:48 PM, Richard Smith 
wrote:

> On Wed, Jan 13, 2016 at 3:41 PM, Arthur O'Dwyer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Following Louis' suggestion, how about __pack_nth?
>>
>
> Maybe just __pack_element, to mirror its intended use to implement things
> like tuple_element? (I'm not completely happy about using this general name
> for something that only works for packs of types, but given that this
> template produces a type, it's probably the best we can do.)
>

That seems fine to me. I do feel like a name for something else will be
shoehorned in later as well though.

Louis - what do you think?


>
>
>> On Wed, Jan 13, 2016 at 3:16 PM, Nathan Wilson via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>>
>>> On Wed, Jan 13, 2016 at 4:52 PM, Richard Smith 
>>> wrote:
>>>
 On Wed, Jan 13, 2016 at 2:31 PM, Nathan Wilson 
 wrote:

> nwilson added a comment.
>
> In http://reviews.llvm.org/D15421#326144, @rsmith wrote:
>
> > Bikeshedding on the name a bit... how about `__type_pack_element`?
>
> Hmm, I kind of felt like having `nth` in there implied we're indexing
> into something... What about `__nth_pack_element`?


 Conversely, std::nth_element doesn't do indexing, and
 std::tuple_element does.

>>>
>>> Yeah, I was trying to combine them, but maybe that's misleading.
>>>
>>>
>>> ___
>>> 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
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-13 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:375
@@ +374,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

nwilson wrote:
> hubert.reinterpretcast wrote:
> > The parameter is now unused and should be removed.
> Hmm, I think I should actually use that parameter since it's a bug as is (and 
> would still be if I removed the parameter). I'll plan on doing that unless 
> there is another thought about this.
My interpretation of http://reviews.llvm.org/D13357?id=43469#inline-129592 is 
that the function should take no parameters (there is no need for a way to set 
the property to false). Perhaps I misunderstood Richard's intent.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.

2016-01-13 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: jroelofs.
alexfh added a comment.

In http://reviews.llvm.org/D15528#326031, @jroelofs wrote:

> Hmm. There's no "close revision" button. Abandoning it in lieu of closing it.


Weird. That's probably because I've not marked it "Accepted". Now I tried a few 
other actions on the revision and it now shows as authored by myself. Really 
weird.

Anyway, thank you for working on this!


http://reviews.llvm.org/D15528



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


[PATCH] D16171: Warning on redeclaring with a conflicting asm label

2016-01-13 Thread Weiming Zhao via cfe-commits
weimingz created this revision.
weimingz added a reviewer: nicholas.
weimingz added a subscriber: cfe-commits.

r255371 errors on redeclaring with a conflicting asm label.
This patch changes errors to warnings to prevent breaking existing codes.

http://reviews.llvm.org/D16171

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Sema/asm-label.c

Index: test/Sema/asm-label.c
===
--- test/Sema/asm-label.c
+++ test/Sema/asm-label.c
@@ -7,21 +7,21 @@
 void f() {
   g();
 }
-void g() __asm__("gold");  // expected-error{{cannot apply asm label to 
function after its first use}}
+void g() __asm__("gold");  // expected-warning{{cannot apply asm label to 
function after its first use}}
 
 void h() __asm__("hose");  // expected-note{{previous declaration is here}}
-void h() __asm__("hair");  // expected-error{{conflicting asm label}}
+void h() __asm__("hair");  // expected-warning{{conflicting asm label}}
 
 int x;
 int x __asm__("xenon");
 int y;
 
 int test() { return y; }
 
-int y __asm__("yacht");  // expected-error{{cannot apply asm label to variable 
after its first use}}
+int y __asm__("yacht");  // expected-warning{{cannot apply asm label to 
variable after its first use}}
 
 int z __asm__("zebra");  // expected-note{{previous declaration is here}}
-int z __asm__("zooms");  // expected-error{{conflicting asm label}}
+int z __asm__("zooms");  // expected-warning{{conflicting asm label}}
 
 
 // No diagnostics on the following.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2385,13 +2385,13 @@
 if (AsmLabelAttr *OldA = Old->getAttr()) {
   if (OldA->getLabel() != NewA->getLabel()) {
 // This redeclaration changes __asm__ label.
-Diag(New->getLocation(), diag::err_different_asm_label);
+Diag(New->getLocation(), diag::warn_different_asm_label);
 Diag(OldA->getLocation(), diag::note_previous_declaration);
   }
 } else if (Old->isUsed()) {
   // This redeclaration adds an __asm__ label to a declaration that has
   // already been ODR-used.
-  Diag(New->getLocation(), diag::err_late_asm_label_name)
+  Diag(New->getLocation(), diag::warn_late_asm_label_name)
 << isa(Old) << New->getAttr()->getRange();
 }
   }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4266,9 +4266,11 @@
 def err_conflicting_types : Error<"conflicting types for %0">;
 def err_different_pass_object_size_params : Error<
   "conflicting pass_object_size attributes on parameters">;
-def err_late_asm_label_name : Error<
-  "cannot apply asm label to %select{variable|function}0 after its first use">;
-def err_different_asm_label : Error<"conflicting asm label">;
+def warn_late_asm_label_name : Warning<
+  "cannot apply asm label to %select{variable|function}0 after its first use">,
+  InGroup;
+def warn_different_asm_label : Warning<"conflicting asm label">,
+  InGroup;
 def err_nested_redefinition : Error<"nested redefinition of %0">;
 def err_use_with_wrong_tag : Error<
   "use of %0 with tag type that does not match previous declaration">;


Index: test/Sema/asm-label.c
===
--- test/Sema/asm-label.c
+++ test/Sema/asm-label.c
@@ -7,21 +7,21 @@
 void f() {
   g();
 }
-void g() __asm__("gold");  // expected-error{{cannot apply asm label to function after its first use}}
+void g() __asm__("gold");  // expected-warning{{cannot apply asm label to function after its first use}}
 
 void h() __asm__("hose");  // expected-note{{previous declaration is here}}
-void h() __asm__("hair");  // expected-error{{conflicting asm label}}
+void h() __asm__("hair");  // expected-warning{{conflicting asm label}}
 
 int x;
 int x __asm__("xenon");
 int y;
 
 int test() { return y; }
 
-int y __asm__("yacht");  // expected-error{{cannot apply asm label to variable after its first use}}
+int y __asm__("yacht");  // expected-warning{{cannot apply asm label to variable after its first use}}
 
 int z __asm__("zebra");  // expected-note{{previous declaration is here}}
-int z __asm__("zooms");  // expected-error{{conflicting asm label}}
+int z __asm__("zooms");  // expected-warning{{conflicting asm label}}
 
 
 // No diagnostics on the following.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2385,13 +2385,13 @@
 if (AsmLabelAttr *OldA = Old->getAttr()) {
   if (OldA->getLabel() != NewA->getLabel()) {
 // This redeclaration changes __asm__ label.
-Diag(New->getLocation(), diag::err_different_asm_label);
+Diag(New->getLocation(), 

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:375
@@ +374,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

hubert.reinterpretcast wrote:
> The parameter is now unused and should be removed.
Hmm, I think I should actually use that parameter since it's a bug as is (and 
would still be if I removed the parameter). I'll plan on doing that unless 
there is another thought about this.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Richard Smith via cfe-commits
On Wed, Jan 13, 2016 at 3:41 PM, Arthur O'Dwyer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Following Louis' suggestion, how about __pack_nth?
>

Maybe just __pack_element, to mirror its intended use to implement things
like tuple_element? (I'm not completely happy about using this general name
for something that only works for packs of types, but given that this
template produces a type, it's probably the best we can do.)


> On Wed, Jan 13, 2016 at 3:16 PM, Nathan Wilson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>>
>> On Wed, Jan 13, 2016 at 4:52 PM, Richard Smith 
>> wrote:
>>
>>> On Wed, Jan 13, 2016 at 2:31 PM, Nathan Wilson 
>>> wrote:
>>>
 nwilson added a comment.

 In http://reviews.llvm.org/D15421#326144, @rsmith wrote:

 > Bikeshedding on the name a bit... how about `__type_pack_element`?

 Hmm, I kind of felt like having `nth` in there implied we're indexing
 into something... What about `__nth_pack_element`?
>>>
>>>
>>> Conversely, std::nth_element doesn't do indexing, and std::tuple_element
>>> does.
>>>
>>
>> Yeah, I was trying to combine them, but maybe that's misleading.
>>
>>
>> ___
>> 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
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:377
@@ -376,3 +376,3 @@
   NamedDecl *TemplatedDecl;
   TemplateParameterList* TemplateParams;
 

I can't seem to follow the link properly, but I'm assuming it's supposed to be 
where Richard is asking about whether we need a setter. I thought he meant 
whether we needed the setter function at all. Perhaps I misunderstood though.

But it seems to be the convention to give a boolean (or some other type of 
param) to a setter. I'd be fine either way though because as you said, there 
isn't a need to set the property to false. As a point of reference 
RedeclarableTemplateDecl::setMemberSpecialization doesn't take any params 
either.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D16080: [CUDA] Add tests for compiling CUDA files with -E.

2016-01-13 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44823.
jlebar added a comment.

Address tra's review comments.


http://reviews.llvm.org/D16080

Files:
  test/Preprocessor/cuda-preprocess.cu

Index: test/Preprocessor/cuda-preprocess.cu
===
--- /dev/null
+++ test/Preprocessor/cuda-preprocess.cu
@@ -0,0 +1,32 @@
+// Tests CUDA compilation with -E.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifndef __CUDA_ARCH__
+#define PREPROCESSED_AWAY
+clang_unittest_no_arch PREPROCESSED_AWAY
+#else
+clang_unittest_cuda_arch __CUDA_ARCH__
+#endif
+
+// CHECK-NOT: PREPROCESSED_AWAY
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 
--cuda-host-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 
--cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 %s
+// SM20: clang_unittest_cuda_arch 200
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 
--cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM30 %s
+// SM30: clang_unittest_cuda_arch 300
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 
--cuda-gpu-arch=sm_30 \
+// RUN:   --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 -check-prefix SM30 %s


Index: test/Preprocessor/cuda-preprocess.cu
===
--- /dev/null
+++ test/Preprocessor/cuda-preprocess.cu
@@ -0,0 +1,32 @@
+// Tests CUDA compilation with -E.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifndef __CUDA_ARCH__
+#define PREPROCESSED_AWAY
+clang_unittest_no_arch PREPROCESSED_AWAY
+#else
+clang_unittest_cuda_arch __CUDA_ARCH__
+#endif
+
+// CHECK-NOT: PREPROCESSED_AWAY
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-host-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 %s
+// SM20: clang_unittest_cuda_arch 200
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM30 %s
+// SM30: clang_unittest_cuda_arch 300
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
+// RUN:   --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 -check-prefix SM30 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16080: [CUDA] Add tests for compiling CUDA files with -E.

2016-01-13 Thread Justin Lebar via cfe-commits
jlebar marked 2 inline comments as done.


Comment at: test/Driver/cuda-preprocess.cu:13-16
@@ +12,6 @@
+
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 
--cuda-host-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch

tra wrote:
> Given it's a driver test you probably just want to check the list of commands 
> generated by driver (-###)
> 
> Checking preprocessing results would probably belong to test/Preprocessor.
> 
Cool, moved to Preprocessor/.


Comment at: test/Driver/cuda-preprocess.cu:17
@@ +16,3 @@
+// RUN:   | FileCheck -check-prefix NOARCH %s
+// NOARCH: clang_unittest_no_arch
+

tra wrote:
> This would succeed if we fail to preprocess as it would catch 
> 'clang_unittest_no_arch' in the #ifndef above.
> 
> I'd add some macro which will get preprocessed away:
> 
> ```
> #ifndef __CUDA_ARCH__
> #define PREPROCESSED_AWAY
> clang_unittest_no_arch __ PREPROCESSED_AWAY
> ...
> ``` 
> 
> It may be an overkill, though. Up to you.
> 
sgtm, done.


http://reviews.llvm.org/D16080



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


r257738 - CodeGen: Only emit CFI unrelated cast checks for bit casts.

2016-01-13 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Jan 13 20:49:48 2016
New Revision: 257738

URL: http://llvm.org/viewvc/llvm-project?rev=257738=rev
Log:
CodeGen: Only emit CFI unrelated cast checks for bit casts.

We were previously emitting them for no-op casts (e.g. implicit casts
to const).

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/cfi-cast.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=257738=257737=257738=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Jan 13 20:49:48 2016
@@ -824,7 +824,8 @@ Address CodeGenFunction::EmitPointerWith
  getNaturalPointeeTypeAlignment(E->getType(), Source));
 }
 
-if (SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
+if (SanOpts.has(SanitizerKind::CFIUnrelatedCast) &&
+CE->getCastKind() == CK_BitCast) {
   if (auto PT = E->getType()->getAs())
 EmitVTablePtrCheckForCast(PT->getPointeeType(), Addr.getPointer(),
   /*MayBeNull=*/true,

Modified: cfe/trunk/test/CodeGenCXX/cfi-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cfi-cast.cpp?rev=257738=257737=257738=diff
==
--- cfe/trunk/test/CodeGenCXX/cfi-cast.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cfi-cast.cpp Wed Jan 13 20:49:48 2016
@@ -8,6 +8,7 @@
 
 struct A {
   virtual void f();
+  int i() const;
 };
 
 struct B : A {
@@ -103,23 +104,31 @@ void vbrr(char &) {
 // CHECK-UCAST-LABEL: define void @_Z3vcpPv
 // CHECK-UCAST-STRICT-LABEL: define void @_Z3vcpPv
 void vcp(void *p) {
-  // CHECK-UCAST: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, 
metadata !"_ZTS1A")
-  // CHECK-UCAST-STRICT: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ 
]*}}, metadata !"_ZTS1C")
+  // CHECK-UCAST: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"_ZTS1A")
+  // CHECK-UCAST-STRICT: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata 
!"_ZTS1C")
   static_cast(p);
 }
 
 // CHECK-UCAST-LABEL: define void @_Z3bcpP1B
 // CHECK-UCAST-STRICT-LABEL: define void @_Z3bcpP1B
 void bcp(B *p) {
-  // CHECK-UCAST: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, 
metadata !"_ZTS1A")
-  // CHECK-UCAST-STRICT: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ 
]*}}, metadata !"_ZTS1C")
+  // CHECK-UCAST: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"_ZTS1A")
+  // CHECK-UCAST-STRICT: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata 
!"_ZTS1C")
   (C *)p;
 }
 
 // CHECK-UCAST-LABEL: define void @_Z8bcp_callP1B
 // CHECK-UCAST-STRICT-LABEL: define void @_Z8bcp_callP1B
 void bcp_call(B *p) {
-  // CHECK-UCAST: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, 
metadata !"_ZTS1A")
-  // CHECK-UCAST-STRICT: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* {{%[^ 
]*}}, metadata !"_ZTS1C")
+  // CHECK-UCAST: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata !"_ZTS1A")
+  // CHECK-UCAST-STRICT: call i1 @llvm.bitset.test(i8* {{%[^ ]*}}, metadata 
!"_ZTS1C")
   ((C *)p)->f();
 }
+
+// CHECK-UCAST-LABEL: define i32 @_Z6a_callP1A
+// CHECK-UCAST-STRICT-LABEL: define i32 @_Z6a_callP1A
+int a_call(A *a) {
+  // CHECK-UCAST-NOT: @llvm.bitset.test
+  // CHECK-UCAST-STRICT-NOT: @llvm.bitset.test
+  return a->i();
+}


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


r257739 - Driver: Remove SanitizerArgs::clear() function and SanitizerSet ctor,

2016-01-13 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Jan 13 20:49:51 2016
New Revision: 257739

URL: http://llvm.org/viewvc/llvm-project?rev=257739=rev
Log:
Driver: Remove SanitizerArgs::clear() function and SanitizerSet ctor,
replace with in-class initializers.

Modified:
cfe/trunk/include/clang/Basic/Sanitizers.h
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp

Modified: cfe/trunk/include/clang/Basic/Sanitizers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.h?rev=257739=257738=257739=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.h (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.h Wed Jan 13 20:49:51 2016
@@ -46,8 +46,6 @@ enum SanitizerOrdinal : uint64_t {
 }
 
 struct SanitizerSet {
-  SanitizerSet() : Mask(0) {}
-
   /// \brief Check if a certain (single) sanitizer is enabled.
   bool has(SanitizerMask K) const {
 assert(llvm::isPowerOf2_64(K));
@@ -70,7 +68,7 @@ struct SanitizerSet {
   bool empty() const { return Mask == 0; }
 
   /// \brief Bitmask of enabled sanitizers.
-  SanitizerMask Mask;
+  SanitizerMask Mask = 0;
 };
 
 /// Parse a single value from a -fsanitize= or -fno-sanitize= value list.

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=257739=257738=257739=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Wed Jan 13 20:49:51 2016
@@ -28,14 +28,14 @@ class SanitizerArgs {
 
   std::vector BlacklistFiles;
   std::vector ExtraDeps;
-  int CoverageFeatures;
-  int MsanTrackOrigins;
-  bool MsanUseAfterDtor;
-  bool CfiCrossDso;
-  int AsanFieldPadding;
-  bool AsanSharedRuntime;
-  bool LinkCXXRuntimes;
-  bool NeedPIE;
+  int CoverageFeatures = 0;
+  int MsanTrackOrigins = 0;
+  bool MsanUseAfterDtor = false;
+  bool CfiCrossDso = false;
+  int AsanFieldPadding = 0;
+  bool AsanSharedRuntime = false;
+  bool LinkCXXRuntimes = false;
+  bool NeedPIE = false;
 
  public:
   /// Parses the sanitizer arguments from an argument list.
@@ -62,9 +62,6 @@ class SanitizerArgs {
   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
   void addArgs(const ToolChain , const llvm::opt::ArgList ,
llvm::opt::ArgStringList , types::ID InputType) const;
-
- private:
-  void clear();
 };
 
 }  // namespace driver

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=257739=257738=257739=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed Jan 13 20:49:51 2016
@@ -180,25 +180,8 @@ bool SanitizerArgs::needsUnwindTables()
   return Sanitizers.Mask & NeedsUnwindTables;
 }
 
-void SanitizerArgs::clear() {
-  Sanitizers.clear();
-  RecoverableSanitizers.clear();
-  TrapSanitizers.clear();
-  BlacklistFiles.clear();
-  ExtraDeps.clear();
-  CoverageFeatures = 0;
-  MsanTrackOrigins = 0;
-  MsanUseAfterDtor = false;
-  NeedPIE = false;
-  AsanFieldPadding = 0;
-  AsanSharedRuntime = false;
-  LinkCXXRuntimes = false;
-  CfiCrossDso = false;
-}
-
 SanitizerArgs::SanitizerArgs(const ToolChain ,
  const llvm::opt::ArgList ) {
-  clear();
   SanitizerMask AllRemove = 0;  // During the loop below, the accumulated set 
of
 // sanitizers disabled by the current sanitizer
 // argument or any argument after it.


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


[PATCH] D16175: Introduce -fsanitize-stats flag.

2016-01-13 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: kcc, eugenis.
pcc added a subscriber: cfe-commits.

This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.

http://reviews.llvm.org/D16175

Files:
  docs/SanitizerStats.rst
  docs/UsersManual.rst
  docs/index.rst
  include/clang/AST/ASTConsumer.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  include/clang/Frontend/MultiplexConsumer.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ModuleBuilder.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/MultiplexConsumer.cpp
  lib/Sema/SemaAttr.cpp
  test/CodeGen/linker-option.c
  test/CodeGenCXX/cfi-stats.cpp
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -345,6 +345,38 @@
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-LINUX %s
+// CHECK-CFI-STATS-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-STATS-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.stats_client-x86_64.a" "-no-whole-archive"
+// CHECK-CFI-STATS-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.stats-x86_64.a" "-no-whole-archive"
+
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-DARWIN %s
+// CHECK-CFI-STATS-DARWIN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-CFI-STATS-DARWIN: "{{[^"]*}}libclang_rt.stats_client_osx.a"
+// CHECK-CFI-STATS-DARWIN: "{{[^"]*}}libclang_rt.stats_osx_dynamic.dylib"
+
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-pc-windows \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN64 %s
+// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats_client-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--linker-option=/include:__sanitizer_stats_register"
+
+// RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-windows \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN32 %s
+// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats_client-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--linker-option=/include:___sanitizer_stats_register"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fsanitize=safe-stack \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -272,6 +272,9 @@
 // CHECK-CFI-NO-CROSS-DSO: -emit-llvm-bc
 // CHECK-CFI-NO-CROSS-DSO-NOT: -fsanitize-cfi-cross-dso
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -fsanitize-stats -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-STATS
+// CHECK-CFI-STATS: -fsanitize-stats
+
 // RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
Index: test/CodeGenCXX/cfi-stats.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cfi-stats.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ELF %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MACHO %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck 

[clang-tools-extra] r257642 - Teach clang-tidy how to upgrade warnings into errors.

2016-01-13 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Wed Jan 13 11:36:41 2016
New Revision: 257642

URL: http://llvm.org/viewvc/llvm-project?rev=257642=rev
Log:
Teach clang-tidy how to upgrade warnings into errors.

Similar in format to the `-checks=` argument, this new `-warnings-as-errors=`
argument upgrades any warnings emitted by the former to errors.

http://reviews.llvm.org/D15528

Added:
clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp
clang-tools-extra/trunk/test/clang-tidy/werrors.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=257642=257641=257642=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Jan 13 11:36:41 2016
@@ -101,7 +101,8 @@ public:
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
 SourceMgr(Diags, Files), Rewrite(SourceMgr, LangOpts),
-ApplyFixes(ApplyFixes), TotalFixes(0), AppliedFixes(0) {
+ApplyFixes(ApplyFixes), TotalFixes(0), AppliedFixes(0),
+WarningsAsErrors(0) {
 DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
 DiagPrinter->BeginSourceFile(LangOpts);
   }
@@ -114,8 +115,14 @@ public:
 SmallVector, 4> FixLocations;
 {
   auto Level = static_cast(Error.DiagLevel);
+  std::string Name = Error.CheckName;
+  if (Error.IsWarningAsError) {
+Name += ",-warnings-as-errors";
+Level = DiagnosticsEngine::Error;
+WarningsAsErrors++;
+  }
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
-  << Message.Message << Error.CheckName;
+  << Message.Message << Name;
   for (const tooling::Replacement  : Error.Fix) {
 SourceLocation FixLoc = getLocation(Fix.getFilePath(), 
Fix.getOffset());
 SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
@@ -147,6 +154,8 @@ public:
 }
   }
 
+  unsigned getWarningsAsErrorsCount() const { return WarningsAsErrors; }
+
 private:
   SourceLocation getLocation(StringRef FilePath, unsigned Offset) {
 if (FilePath.empty())
@@ -174,6 +183,7 @@ private:
   bool ApplyFixes;
   unsigned TotalFixes;
   unsigned AppliedFixes;
+  unsigned WarningsAsErrors;
 };
 
 class ClangTidyASTConsumer : public MultiplexConsumer {
@@ -421,11 +431,13 @@ runClangTidy(std::unique_ptr , bool Fix) {
+void handleErrors(const std::vector , bool Fix,
+  unsigned ) {
   ErrorReporter Reporter(Fix);
   for (const ClangTidyError  : Errors)
 Reporter.reportDiagnostic(Error);
   Reporter.Finish();
+  WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
 }
 
 void exportReplacements(const std::vector ,

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=257642=257641=257642=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Wed Jan 13 11:36:41 2016
@@ -214,7 +214,8 @@ runClangTidy(std::unique_ptr , bool Fix);
+void handleErrors(const std::vector , bool Fix,
+  unsigned );
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=257642=257641=257642=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed Jan 
13 11:36:41 2016
@@ -115,8 +115,10 @@ ClangTidyMessage::ClangTidyMessage(Strin
 }
 
 ClangTidyError::ClangTidyError(StringRef CheckName,
-   ClangTidyError::Level DiagLevel)
-: CheckName(CheckName), DiagLevel(DiagLevel) {}
+   ClangTidyError::Level DiagLevel,
+   bool IsWarningAsError)
+: CheckName(CheckName), DiagLevel(DiagLevel),
+  IsWarningAsError(IsWarningAsError) {}
 
 // Returns true