[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 &P = *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 &PP) 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 &PP) {
+  // 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 &DebugInfo;
+  Preprocessor &PP;
+  SourceLocation LastHashLoc;
+  SourceLocation FirstIncludeFile;
+  bool FirstInclude;
+  bool FirstIncludeDone;
+  int CommandIncludeFiles;
+  int SkipFiles;
+  std::vector Parents;
+
+
+  static void getMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
+ Preprocessor &PP, raw_ostream &Name,
+ raw_ostream &Value);
+
+public:
+  MacroPPCallbacks(CodeGen::CGDebugInfo& DI, Preprocessor &PP);
+
+  /// \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 i

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 &PP);
 };

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] 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


Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-13 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 44721.
xazax.hun added a comment.

- Moved the API to CallEvent.


http://reviews.llvm.org/D15921

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp

Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -210,6 +210,16 @@
   return PostImplicitCall(D, Loc, getLocationContext(), Tag);
 }
 
+bool CallEvent::isCalled(const CallDescription &CD) const {
+  assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  if (!CD.II)
+CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName);
+  if (getCalleeIdentifier() != CD.II)
+return false;
+  return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
+  CD.RequiredArgs == getNumArgs());
+}
+
 SVal CallEvent::getArgSVal(unsigned Index) const {
   const Expr *ArgE = getArgExpr(Index);
   if (!ArgE)
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -51,14 +51,11 @@
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext &Ctx) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent &Call,
  CheckerContext &C) const;
@@ -106,7 +103,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@
 
 void SimpleStreamChecker::checkPostCall(const CallEvent &Call,
 CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!Call.isCalled(OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@
 
 void SimpleStreamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!Call.isCalled(CloseFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -275,13 +265,6 @@
   return State;
 }
 
-void SimpleStreamChecker::initIdentifierInfo(ASTContext &Ctx) const {
-  if (IIfopen)
-return;
-  IIfopen = &Ctx.Idents.get("fopen");
-  IIfclose = &Ctx.Idents.get("fclose");
-}
-
 void ento::registerSimpleStreamChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -49,6 +49,27 @@
 class CallEvent;
 class CallEventManager;
 
+/// This class represents a description of a function call using the number of
+/// arguments and the name of the function.
+class CallDescription {
+  friend CallEvent;
+  mutable IdentifierInfo *II;
+  StringRef FuncName;
+  unsigned RequiredArgs;
+
+public:
+  const static unsigned NoArgRequirement = ~0;
+  /// \brief Constructs a CallDescription object.
+  ///
+  /// @param FuncName The name of the function that will be matched.
+  ///
+  /// @param RequiredArgs The number of arguments that is expected to match a
+  /// call. Omit this parameter to match every occurance of call with a given
+  /// name regardless the number of arguments.
+  CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
+  : FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+};
+
 template
 class CallEventRef : public IntrusiveRefCntPtr {
 public:
@@ -227,6 +248,13 @@
 return false;
   }
 
+  /// \brief Returns true if the CallEvent is a call to a function that matches
+  /// the CallDescription.
+  ///
+  /// Note that this function is not intended to be used to match Obj-C method
+  /// calls.
+  bool isCalled(const CallDescription &CD) const;
+
   /// \brief Returns a source range for the entire call, suitable for
   /// output

Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-13 Thread Gábor Horváth via cfe-commits
xazax.hun marked an inline comment as done.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:312
@@ +311,3 @@
+  /// calls.
+  bool isCalled(const CallEvent &Call, const CallDescription &CD);
+

zaks.anna wrote:
> The API is a bit awkward. Maybe it would be better if we make this a member 
> of CallEvent as you've suggested initially?
I agree. Moved it to CallEvent.


http://reviews.llvm.org/D15921



___
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 &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::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 &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::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] 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 &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::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 &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::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] 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 &Name : Names) {
+auto Iter = CheckOptions.find(Name);

There's no need to declare a vector: `for (const string &s : {"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] 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&view=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&r1=257585&r2=257586&view=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 &Stmts, bool OnlyStatement,
+  ParseStatementOrDeclaration(StmtVector &Stmts, AllowedContsructsKind Allowed,
   SourceLocation *TrailingElseLoc = nullptr);
   StmtResult ParseStatementOrDeclarationAfterAttributes(
  StmtVector &Stmts,
- bool OnlyStatement,
+ AllowedContsructsKind Allowed,
  SourceLocation *TrailingElseLoc,
  ParsedAttributesWithRange &Attrs);
   StmtResult ParseExprStatement();
@@ -1678,7 +1687,8 @@ private:
   StmtResult ParseReturnStatement();
   StmtResult ParseAsmStatement(bool &msAsm);
   StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
-  StmtResult ParsePragmaLoopHint(StmtVector &Stmts, bool OnlyStatement,
+  StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
+ AllowedContsructsKind Allowed,
  SourceLocation *TrailingElseLoc,
  ParsedAttributesWithRange &Attrs);
 
@@ -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&r1=257585&r2=257586&view=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, dia

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 &S, 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] 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] 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(&glob); // 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(&s); // 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(&s.s2[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(&z); // expected-warning-re^pointer to local variable 'z'$
+  clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$
+  clang_analyzer_explain(&stat); // expected-warning-re^pointer to static local variable 'stat'$
+  clang_analyzer_

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&view=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] D15448: [analyzer] SVal Visitor.

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

Nope, will commit without `SymbolCast` support for now, encountered some issues 
with http://reviews.llvm.org/D12901 that would probably be worth a separate 
commit.


http://reviews.llvm.org/D15448



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


[PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-01-13 Thread Bhushan Attarde via cfe-commits
bhushan created this revision.
bhushan added a reviewer: dsanders.
bhushan added subscribers: cfe-commits, jaydeep, mohit.bhakkad, nitesh.jain, 
sagar.
bhushan set the repository for this revision to rL LLVM.
Herald added a reviewer: vkalintiris.

This patch sets CPU string to its default value when it is not supplied by 
caller.

Repository:
  rL LLVM

http://reviews.llvm.org/D16139

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6545,6 +6545,8 @@
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
  const std::vector &FeaturesVec) const override {
+if (CPU.empty())
+CPU = getCPU();
 if (CPU == "octeon")
   Features["mips64r2"] = Features["cnmips"] = true;
 else


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6545,6 +6545,8 @@
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
  const std::vector &FeaturesVec) const override {
+if (CPU.empty())
+CPU = getCPU();
 if (CPU == "octeon")
   Features["mips64r2"] = Features["cnmips"] = true;
 else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16044: getVariableName() for MemRegion

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


Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:653
@@ +652,3 @@
+llvm::SmallString<2> intValAsString;
+IndexInArray.toString(intValAsString);
+std::string idx{intValAsString.begin(), intValAsString.end()};

What will be the content of IndexInArray in case the index is not a concrete 
int? Will the above code work at all in that case? In case the index is a 
variable do we want to include the name of the variable in the index?


Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:656
@@ +655,3 @@
+
+ArrayIndices = "[" + idx + "]" + ArrayIndices;
+

I do not really like this part. You could either use Twine to avoid some 
temporal values (and you could also eliminate the string copy this way) or you 
could construct the indices using the reverse of idx and than reverse the whole 
string after the loop.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16062: [analyzer] Rename kind-enumeration values of SVal, SymExpr, MemRegion classes, for consistency.

2016-01-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257598: [analyzer] Fix SVal/SymExpr/MemRegion class and enum 
names for consistency. (authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D16062?vs=44628&id=44745#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16062

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -42,14 +42,22 @@
 class SymExpr : public llvm::FoldingSetNode {
   virtual void anchor();
 public:
-  enum Kind { RegionValueKind, ConjuredKind, DerivedKind, ExtentKind,
-  MetadataKind,
-  BEGIN_SYMBOLS = RegionValueKind,
-  END_SYMBOLS = MetadataKind,
-  SymIntKind, IntSymKind, SymSymKind,
-  BEGIN_BINARYSYMEXPRS = SymIntKind,
-  END_BINARYSYMEXPRS = SymSymKind,
-  CastSymbolKind };
+  enum Kind {
+SymbolRegionValueKind,
+SymbolConjuredKind,
+SymbolDerivedKind,
+SymbolExtentKind,
+SymbolMetadataKind,
+BEGIN_SYMBOLS = SymbolRegionValueKind,
+END_SYMBOLS = SymbolMetadataKind,
+SymIntExprKind,
+IntSymExprKind,
+SymSymExprKind,
+BEGIN_BINARYSYMEXPRS = SymIntExprKind,
+END_BINARYSYMEXPRS = SymSymExprKind,
+SymbolCastKind
+  };
+
 private:
   Kind K;
 
@@ -126,12 +134,12 @@
 
 public:
   SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
-: SymbolData(RegionValueKind, sym), R(r) {}
+: SymbolData(SymbolRegionValueKind, sym), R(r) {}
 
   const TypedValueRegion* getRegion() const { return R; }
 
   static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) {
-profile.AddInteger((unsigned) RegionValueKind);
+profile.AddInteger((unsigned) SymbolRegionValueKind);
 profile.AddPointer(R);
   }
 
@@ -145,7 +153,7 @@
 
   // Implement isa support.
   static inline bool classof(const SymExpr *SE) {
-return SE->getKind() == RegionValueKind;
+return SE->getKind() == SymbolRegionValueKind;
   }
 };
 
@@ -160,11 +168,9 @@
 
 public:
   SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
-		 QualType t, unsigned count,
- const void *symbolTag)
-: SymbolData(ConjuredKind, sym), S(s), T(t), Count(count),
-  LCtx(lctx),
-  SymbolTag(symbolTag) {}
+ QualType t, unsigned count, const void *symbolTag)
+  : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
+LCtx(lctx), SymbolTag(symbolTag) {}
 
   const Stmt *getStmt() const { return S; }
   unsigned getCount() const { return Count; }
@@ -177,7 +183,7 @@
   static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S,
   QualType T, unsigned Count, const LocationContext *LCtx,
   const void *SymbolTag) {
-profile.AddInteger((unsigned) ConjuredKind);
+profile.AddInteger((unsigned) SymbolConjuredKind);
 profile.AddPointer(S);
 profile.AddPointer(LCtx);
 profile.Add(T);
@@ -191,7 +197,7 @@
 
   // Implement isa support.
   static inline bool classof(const SymExpr *SE) {
-return SE->getKind() == ConjuredKind;
+return SE->getKind() == SymbolConjuredKind;
   }
 };
 
@@ -203,7 +209,7 @@
 
 public:
   SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
-: SymbolData(DerivedKind, sym), parentSymbol(parent), R(r) {}
+: SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {}
 
   SymbolRef getParentSymbol() const { return parentSymbol; }
   const TypedValueRegion *getRegion() const { return R; }
@@ -214,7 +220,7 @@
 
   static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent,
   const TypedValueRegion *r) {
-profile.AddInteger((unsigned) DerivedKind);
+profile.AddInteger((unsigned) SymbolDerivedKind);
 profile.AddPointer(r);
 profile.AddPointer(parent);
   }
@@ -225,7 +231,7 @@
 
   // Implement isa support.
   static inline bool classof(const SymExpr *SE) {
-return SE->getKind() == DerivedKind;
+return SE->getKind() == Symbo

r257598 - [analyzer] Fix SVal/SymExpr/MemRegion class and enum names for consistency.

2016-01-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Jan 13 07:49:29 2016
New Revision: 257598

URL: http://llvm.org/viewvc/llvm-project?rev=257598&view=rev
Log:
[analyzer] Fix SVal/SymExpr/MemRegion class and enum names for consistency.

The purpose of these changes is to simplify introduction of definition files
for the three hierarchies.

1. For every sub-class C of these classes, its kind in the relevant enumeration
is changed to "CKind" (or C##Kind in preprocessor-ish terms), eg:

  MemRegionKind   -> MemRegionValKind
  RegionValueKind -> SymbolRegionValueKind
  CastSymbolKind  -> SymbolCastKind
  SymIntKind  -> SymIntExprKind

2. MemSpaceRegion used to be inconsistently used as both an abstract base and
a particular region. This region class is now an abstract base and no longer
occupies GenericMemSpaceRegionKind. Instead, a new class, CodeSpaceRegion,
is introduced for handling the unique use case for MemSpaceRegion as
"the generic memory space" (when it represents a memory space that holds all
executable code).

3. BEG_ prefixes in memory region kind ranges are renamed to BEGIN_ for
consisitency with symbol kind ranges.

4. FunctionTextRegion and BlockTextRegion are renamed to FunctionCodeRegion and
BlockCodeRegion, respectively. The term 'code' is less jargony than 'text' and
we already refer to BlockTextRegion as a 'code region' in BlockDataRegion.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=257598&r1=257597&r2=257598&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Wed 
Jan 13 07:49:29 2016
@@ -80,7 +80,7 @@ class MemRegion : public llvm::FoldingSe
 public:
   enum Kind {
 // Memory spaces.
-GenericMemSpaceRegionKind,
+CodeSpaceRegionKind,
 StackLocalsSpaceRegionKind,
 StackArgumentsSpaceRegionKind,
 HeapSpaceRegionKind,
@@ -89,29 +89,29 @@ public:
 GlobalInternalSpaceRegionKind,
 GlobalSystemSpaceRegionKind,
 GlobalImmutableSpaceRegionKind,
-BEG_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind,
+BEGIN_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind,
 END_NON_STATIC_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
-BEG_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind,
+BEGIN_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind,
 END_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
-BEG_MEMSPACES = GenericMemSpaceRegionKind,
+BEGIN_MEMSPACES = CodeSpaceRegionKind,
 END_MEMSPACES = GlobalImmutableSpaceRegionKind,
 // Untyped regions.
 SymbolicRegionKind,
 AllocaRegionKind,
 // Typed regions.
-BEG_TYPED_REGIONS,
-FunctionTextRegionKind = BEG_TYPED_REGIONS,
-BlockTextRegionKind,
+BEGIN_TYPED_REGIONS,
+FunctionCodeRegionKind = BEGIN_TYPED_REGIONS,
+BlockCodeRegionKind,
 BlockDataRegionKind,
-BEG_TYPED_VALUE_REGIONS,
-CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS,
+BEGIN_TYPED_VALUE_REGIONS,
+CompoundLiteralRegionKind = BEGIN_TYPED_VALUE_REGIONS,
 CXXThisRegionKind,
 StringRegionKind,
 ObjCStringRegionKind,
 ElementRegionKind,
 // Decl Regions.
-BEG_DECL_REGIONS,
-VarRegionKind = BEG_DECL_REGIONS,
+BEGIN_DECL_REGIONS,
+VarRegionKind = BEGIN_DECL_REGIONS,
 FieldRegionKind,
 ObjCIvarRegionKind,
 END_DECL_REGIONS = ObjCIvarRegionKind,
@@ -193,12 +193,9 @@ public:
 ///  for example, the set of global variables, the stack frame, etc.
 class MemSpaceRegion : public MemRegion {
 protected:
-  friend class MemRegionManager;
-  
   MemRegionManager *Mgr;
 
-  MemSpaceRegion(MemRegionManager *mgr, Kind k = GenericMemSpaceRegionKind)
-: MemRegion(k), Mgr(mgr) {
+  MemSpaceRegion(MemRegionManager *mgr, Kind k) : MemRegion(k), Mgr(mgr) {
 assert(classof(this));
   }
 
@@ -211,10 +208,26 @@ public:
 
   static bool classof(const MemRegion *R) {
 Kind k = R->getKind();
-return k >= BEG_MEMSPACES && k <= END

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] D15823: Support virtual-near-miss check.

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

Looks good with one nit. I'll update the comment myself and commit the patch 
for you.

Thank you for the contribution!



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:60
@@ +59,3 @@
+}
+  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
+if (const auto *BaseRT = BaseReturnTy->getAs()) {

Answering my own question: I guess, it may be useful for methods of template 
classes and for template methods, where the template declaration doesn't make 
it clear whether the method is overridden or not. However the author may want 
the compiler to ensure the instantiation actually overrides something.


Comment at: clang-tidy/misc/VirtualNearMissCheck.h:39
@@ +38,3 @@
+  ///
+  /// It should look up the PossibleMap or update it.
+  bool isPossibleToBeOverridden(const CXXMethodDecl *BaseMD);

nit: `It should look up ...` sounds like a requirement, however, you exactly 
know what the implementation does, so `It looks up ... or updates ...` is 
better. Maybe even `Results are memoized in PossibleMap.`

Same below.


http://reviews.llvm.org/D15823



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


[clang-tools-extra] r257599 - Support virtual-near-miss check.

2016-01-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Jan 13 08:16:35 2016
New Revision: 257599

URL: http://llvm.org/viewvc/llvm-project?rev=257599&view=rev
Log:
Support virtual-near-miss check.

Summary: Virtual function override near miss detection. Function complete. Test 
complete. Do not conduct Fix for now.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by Cong Liu!

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst
clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=257599&r1=257598&r2=257599&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Jan 13 08:16:35 
2016
@@ -26,6 +26,7 @@ add_clang_library(clangTidyMiscModule
   UnusedParametersCheck.cpp
   UnusedRAIICheck.cpp
   UniqueptrResetReleaseCheck.cpp
+  VirtualNearMissCheck.cpp
 
   LINK_LIBS
   clangAST

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=257599&r1=257598&r2=257599&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Wed Jan 13 
08:16:35 2016
@@ -34,6 +34,7 @@
 #include "UnusedAliasDeclsCheck.h"
 #include "UnusedParametersCheck.h"
 #include "UnusedRAIICheck.h"
+#include "VirtualNearMissCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -87,6 +88,8 @@ public:
 CheckFactories.registerCheck(
 "misc-unused-parameters");
 CheckFactories.registerCheck("misc-unused-raii");
+CheckFactories.registerCheck(
+"misc-virtual-near-miss");
   }
 };
 

Added: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp?rev=257599&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp Wed Jan 13 
08:16:35 2016
@@ -0,0 +1,266 @@
+//===--- VirtualNearMissCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "VirtualNearMissCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds out if the given method overrides some method.
+static bool isOverrideMethod(const CXXMethodDecl *MD) {
+  return MD->size_overridden_methods() > 0 || MD->hasAttr();
+}
+
+/// Checks whether the return types are covariant, according to
+/// C++[class.virtual]p7.
+///
+/// Similar with clang::Sema::CheckOverridingFunctionReturnType.
+/// \returns true if the return types of BaseMD and DerivedMD are covariant.
+static bool checkOverridingFunctionReturnType(const ASTContext *Context,
+  const CXXMethodDecl *BaseMD,
+  const CXXMethodDecl *DerivedMD) {
+  QualType BaseReturnTy =
+  BaseMD->getType()->getAs()->getReturnType();
+  QualType DerivedReturnTy =
+  DerivedMD->getType()->getAs()->getReturnType();
+
+  if (DerivedReturnTy->isDependentType() || BaseReturnTy->isDependentType())
+return false;
+
+  // Check if return types are identical.
+  if (Context->hasSameType(DerivedReturnTy, BaseReturnTy))
+return true;
+
+  /// Check if the return types are covariant.
+  /// BTy is the class type in return type of BaseMD. For example,
+  ///B* Base::md()
+  /// While BRD is the declaration of B.
+  QualType BTy, DTy;
+  const CXXRecordDecl *BRD, *DRD;
+
+  // Both types must be pointers or references to classes.
+  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
+if (const auto *BasePT = BaseReturnTy->getAs()) {
+  DTy = DerivedPT->ge

[clang-tools-extra] r257600 - [clang-tidy] Slightly clarified comments.

2016-01-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Jan 13 08:16:43 2016
New Revision: 257600

URL: http://llvm.org/viewvc/llvm-project?rev=257600&view=rev
Log:
[clang-tidy] Slightly clarified comments.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h?rev=257600&r1=257599&r2=257600&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h Wed Jan 13 
08:16:43 2016
@@ -36,13 +36,13 @@ private:
   /// Check if the given method is possible to be overridden by some other
   /// method.
   ///
-  /// It should look up the PossibleMap or update it.
+  /// Results are memoized in PossibleMap.
   bool isPossibleToBeOverridden(const CXXMethodDecl *BaseMD);
 
   /// Check if the given base method is overridden by some methods in the given
   /// derived class.
   ///
-  /// It should look up the OverriddenMap or update it.
+  /// Results are memoized in OverriddenMap.
   bool isOverriddenByDerivedClass(const CXXMethodDecl *BaseMD,
   const CXXRecordDecl *DerivedRD);
 


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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-13 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257599: Support virtual-near-miss check. (authored by 
alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D15823?vs=44661&id=44746#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15823

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-virtual-near-miss %t
+
+struct Base {
+  virtual void func();
+  virtual void gunk();
+};
+
+struct Derived : Base {
+  // Should not warn "do you want to override 'gunk'?", because gunk is already
+  // overriden by this class.
+  virtual void funk();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
+
+  void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
+
+  void func22(); // Should not warn.
+
+  void gunk(); // Should not warn: gunk is override.
+
+  void fun();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
+};
+
+class Father {
+public:
+  Father();
+  virtual void func();
+  virtual Father *create(int i);
+  virtual Base &&generate();
+};
+
+class Mother {
+public:
+  Mother();
+  static void method();
+  virtual int method(int argc, const char **argv);
+  virtual int method(int argc) const;
+};
+
+class Child : private Father, private Mother {
+public:
+  Child();
+
+  virtual void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 'Father::func'
+
+  int methoe(int x, char **strs); // Should not warn: parameter types don't match.
+
+  int methoe(int x); // Should not warn: method is not const.
+
+  void methof(int x, const char **strs); // Should not warn: return types don't match.
+
+  int methoh(int x, const char **strs);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has {{.*}} 'Mother::method'
+
+  virtual Child *creat(int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 'Father::create'
+
+  virtual Derived &&generat();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate'
+
+private:
+  void funk(); // Should not warn: access qualifers don't match.
+};
Index: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -0,0 +1,266 @@
+//===--- VirtualNearMissCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "VirtualNearMissCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds out if the given method overrides some method.
+static bool isOverrideMethod(const CXXMethodDecl *MD) {
+  return MD->size_overridden_methods() > 0 || MD->hasAttr();
+}
+
+/// Checks whether the return types are covariant, according to
+/// C++[class.virtual]p7.
+///
+/// Similar with clang::Sema::CheckOverridingFunctionReturnType.
+/// \returns true if the return types of BaseMD and DerivedMD are covariant.
+static bool checkOverridingFunctionReturnType(const ASTContext *Context,
+  const CXXMethodDecl *BaseMD,
+  const CXXMethodDecl *DerivedMD) {
+  QualType BaseReturnTy =
+  BaseMD->getType()->getAs()->getReturnType();
+  QualType DerivedReturnTy =
+  DerivedMD->getType()->getAs()->getReturnType();
+
+  if (DerivedReturnTy->isDependentType() || BaseReturnTy->isDependentType())
+return false;
+
+  // Check if return types are identical.
+  if (Context->hasSameT

r257602 - [mips] Added support for -Wa,-mips32 and similar.

2016-01-13 Thread Scott Egerton via cfe-commits
Author: s.egerton
Date: Wed Jan 13 08:27:59 2016
New Revision: 257602

URL: http://llvm.org/viewvc/llvm-project?rev=257602&view=rev
Log:
[mips] Added support for -Wa,-mips32 and similar.

Reviewers: vkalintiris, dsanders

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-ias-Wa.s

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257602&r1=257601&r2=257602&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan 13 08:27:59 2016
@@ -2580,6 +2580,7 @@ static void CollectArgsForIntegratedAsse
   // When using an integrated assembler, translate -Wa, and -Xassembler
   // options.
   bool CompressDebugSections = false;
+  const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
 A->claim();
@@ -2618,7 +2619,25 @@ static void CollectArgsForIntegratedAsse
   CmdArgs.push_back("-soft-float");
   continue;
 }
-break;
+
+MipsTargetFeature = llvm::StringSwitch(Value)
+  .Case("-mips1", "+mips1")
+  .Case("-mips2", "+mips2")
+  .Case("-mips3", "+mips3")
+  .Case("-mips4", "+mips4")
+  .Case("-mips5", "+mips5")
+  .Case("-mips32", "+mips32")
+  .Case("-mips32r2", "+mips32r2")
+  .Case("-mips32r3", "+mips32r3")
+  .Case("-mips32r5", "+mips32r5")
+  .Case("-mips32r6", "+mips32r6")
+  .Case("-mips64", "+mips64")
+  .Case("-mips64r2", "+mips64r2")
+  .Case("-mips64r3", "+mips64r3")
+  .Case("-mips64r5", "+mips64r5")
+  .Case("-mips64r6", "+mips64r6")
+  .Default(nullptr);
+continue;
   }
 
   if (Value == "-force_cpusubtype_ALL") {
@@ -2666,6 +2685,10 @@ static void CollectArgsForIntegratedAsse
 else
   D.Diag(diag::warn_debug_compression_unavailable);
   }
+  if (MipsTargetFeature != nullptr) {
+CmdArgs.push_back("-target-feature");
+CmdArgs.push_back(MipsTargetFeature);
+  }
 }
 
 // This adds the static libclang_rt.builtins-arch.a directly to the command 
line

Modified: cfe/trunk/test/Driver/mips-ias-Wa.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-ias-Wa.s?rev=257602&r1=257601&r2=257602&view=diff
==
--- cfe/trunk/test/Driver/mips-ias-Wa.s (original)
+++ cfe/trunk/test/Driver/mips-ias-Wa.s Wed Jan 13 08:27:59 2016
@@ -47,3 +47,94 @@
 // RUN:   FileCheck -check-prefix=MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST %s
 // MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST: -cc1as
 // MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST: "-target-feature" "-soft-float" 
"-target-feature" "+soft-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips1 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS1 %s
+// MIPS1: -cc1as
+// MIPS1: "-target-feature" "+mips1"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips2 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS2 %s
+// MIPS2: -cc1as
+// MIPS2: "-target-feature" "+mips2"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips3 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS3 %s
+// MIPS3: -cc1as
+// MIPS3: "-target-feature" "+mips3"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips4 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS4 %s
+// MIPS4: -cc1as
+// MIPS4: "-target-feature" "+mips4"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips5 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS5 %s
+// MIPS5: -cc1as
+// MIPS5: "-target-feature" "+mips5"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS32 %s
+// MIPS32: -cc1as
+// MIPS32: "-target-feature" "+mips32"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r2 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS32R2 %s
+// MIPS32R2: -cc1as
+// MIPS32R2: "-target-feature" "+mips32r2"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r3 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS32R3 %s
+// MIPS32R3: -cc1as
+// MIPS32R3: "-target-feature" "+mips32r3"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r5 
2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS32R5 %s
+// MIPS32R5: -cc1as
+// MIPS32R5: "-target-feature" "+mips32r5"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r6 
2>&1 | \
+

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

2016-01-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257605: [analyzer] Provide .def-files and visitors for 
SVal/SymExpr/MemRegion. (authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D15448?vs=44734&id=44752#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15448

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

Index: cfe/trunk/docs/analyzer/DebugChecks.rst
===
--- cfe/trunk/docs/analyzer/DebugChecks.rst
+++ cfe/trunk/docs/analyzer/DebugChecks.rst
@@ -162,6 +162,41 @@
 } while(0);  // expected-warning{{SYMBOL DEAD}}
 
 
+- void clang_analyzer_explain(a single argument of any type);
+
+  This function explains the value of its argument in a human-readable manner
+  in the warning message. You can make as many overrides of its prototype
+  in the test code as necessary to explain various integral, pointer,
+  or even record-type values.
+
+  Example usage::
+
+void clang_analyzer_explain(int);
+void clang_analyzer_explain(void *);
+
+void foo(int param, void *ptr) {
+  clang_analyzer_explain(param); // expected-warning{{argument 'param'}}
+  if (!ptr)
+clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}}
+}
+
+- size_t clang_analyzer_getExtent(void *);
+
+  This function returns the value that represents the extent of a memory region
+  pointed to by the argument. This value is often difficult to obtain otherwise,
+  because no valid code that produces this value. However, it may be useful
+  for testing purposes, to see how well does the analyzer model region extents.
+
+  Example usage::
+
+void foo() {
+  int x, *y;
+  size_t xs = clang_analyzer_getExtent(&x);
+  clang_analyzer_explain(xs); // expected-warning{{'4'}}
+  size_t ys = clang_analyzer_getExtent(&y);
+  clang_analyzer_explain(ys); // expected-warning{{'8'}}
+}
+
 Statistics
 ==
 
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
@@ -0,0 +1,151 @@
+//===--- SValVisitor.h - Visitor for SVal subclasses *- 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 the SValVisitor, SymExprVisitor, and MemRegionVisitor
+//  interfaces, and also FullSValVisitor, which visits all three hierarchies.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALVISITOR_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALVISITOR_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+
+namespace clang {
+
+namespace ento {
+
+/// SValVisitor - this class implements a simple visitor for SVal
+/// subclasses.
+template  class SValVisitor {
+public:
+
+#define DISPATCH(NAME, CLASS) \
+  return static_cast(this)->Visit ## NAME(V.castAs())
+
+  RetTy Visit(SVal V) {
+// Dispatch to VisitFooVal for each FooVal.
+// Take namespaces (loc:: and nonloc::) into account.
+switch (V.getBaseKind()) {
+#define BASIC_SVAL(Id, Parent) case SVal::Id ## Kind: DISPATCH(Id, Id);
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
+case SVal::LocKind:
+  switch (V.getSubKind()) {
+#define LOC_SVAL(Id, Parent) \
+  case loc::Id ## Kind: DISPATCH(Loc ## Id, loc :: Id);
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
+  }
+  llvm_unreachable("Unknown Loc sub-kind!");
+case SVal::NonLocKind:
+  switch (V.getSubKind()) {
+#define NONLOC_SVAL(Id, Parent) \
+  case nonloc::Id ## Kind: DISPATCH(NonLoc ## Id, nonloc :: Id);
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
+  }
+  ll

Re: [PATCH] D15994: Allow for unfinished #if blocks in preambles.

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

After pondering this patch for a while I couldn't come up with a case where 
this would cause problems, but it provides great improvements for editing 
headers in an interactive setup. So LGTM from my side.


http://reviews.llvm.org/D15994



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


r257605 - [analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion.

2016-01-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Jan 13 09:13:48 2016
New Revision: 257605

URL: http://llvm.org/viewvc/llvm-project?rev=257605&view=rev
Log:
[analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion.

Provide separate visitor templates for the three hierarchies, and also
the `FullSValVisitor' class, which is a union of all three visitors.

Additionally, add a particular example visitor, `SValExplainer', in order to
test the visitor templates. This visitor is capable of explaining the SVal,
SymExpr, or MemRegion in a natural language.

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

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

Modified: cfe/trunk/docs/analyzer/DebugChecks.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DebugChecks.rst?rev=257605&r1=257604&r2=257605&view=diff
==
--- cfe/trunk/docs/analyzer/DebugChecks.rst (original)
+++ cfe/trunk/docs/analyzer/DebugChecks.rst Wed Jan 13 09:13:48 2016
@@ -162,6 +162,41 @@ ExprInspection checks
 } while(0);  // expected-warning{{SYMBOL DEAD}}
 
 
+- void clang_analyzer_explain(a single argument of any type);
+
+  This function explains the value of its argument in a human-readable manner
+  in the warning message. You can make as many overrides of its prototype
+  in the test code as necessary to explain various integral, pointer,
+  or even record-type values.
+
+  Example usage::
+
+void clang_analyzer_explain(int);
+void clang_analyzer_explain(void *);
+
+void foo(int param, void *ptr) {
+  clang_analyzer_explain(param); // expected-warning{{argument 'param'}}
+  if (!ptr)
+clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}}
+}
+
+- size_t clang_analyzer_getExtent(void *);
+
+  This function returns the value that represents the extent of a memory region
+  pointed to by the argument. This value is often difficult to obtain 
otherwise,
+  because no valid code that produces this value. However, it may be useful
+  for testing purposes, to see how well does the analyzer model region extents.
+
+  Example usage::
+
+void foo() {
+  int x, *y;
+  size_t xs = clang_analyzer_getExtent(&x);
+  clang_analyzer_explain(xs); // expected-warning{{'4'}}
+  size_t ys = clang_analyzer_getExtent(&y);
+  clang_analyzer_explain(ys); // expected-warning{{'8'}}
+}
+
 Statistics
 ==
 

Added: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h?rev=257605&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h Wed Jan 13 
09:13:48 2016
@@ -0,0 +1,233 @@
+//== SValExplainer.h - Symbolic value explainer -*- 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 SValExplainer, a class for pretty-printing a
+//  human-readable description of a symbolic value. For example,
+//  "reg_$0" is turned into "initial value of variable 'x'".
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
+#define LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
+
+namespace clang {
+
+namespace ento {
+
+class SValExplainer : public FullSValVisitor {
+private:
+  ASTContext &ACtx;
+
+  std::string printStmt(const Stmt *S) {
+std::string Str;
+llvm::raw_string_ostream OS(Str);
+S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts()));
+return OS.str();
+  }
+
+  bool isThisObject(const SymbolicRegion *R) {
+if (auto S = dyn_cast(R->getSymbol()))
+  if (isa(S->getRegion()))
+return true;
+return false;
+  }
+
+p

r257608 - Revert "[analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion."

2016-01-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Jan 13 09:52:25 2016
New Revision: 257608

URL: http://llvm.org/viewvc/llvm-project?rev=257608&view=rev
Log:
Revert "[analyzer] Provide .def-files and visitors for SVal/SymExpr/MemRegion."

This reverts commit r257605.

The test fails on architectures that use unsigned int as size_t.
SymbolManager.h fails with compile errors on some platforms.


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

Modified: cfe/trunk/docs/analyzer/DebugChecks.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DebugChecks.rst?rev=257608&r1=257607&r2=257608&view=diff
==
--- cfe/trunk/docs/analyzer/DebugChecks.rst (original)
+++ cfe/trunk/docs/analyzer/DebugChecks.rst Wed Jan 13 09:52:25 2016
@@ -162,41 +162,6 @@ ExprInspection checks
 } while(0);  // expected-warning{{SYMBOL DEAD}}
 
 
-- void clang_analyzer_explain(a single argument of any type);
-
-  This function explains the value of its argument in a human-readable manner
-  in the warning message. You can make as many overrides of its prototype
-  in the test code as necessary to explain various integral, pointer,
-  or even record-type values.
-
-  Example usage::
-
-void clang_analyzer_explain(int);
-void clang_analyzer_explain(void *);
-
-void foo(int param, void *ptr) {
-  clang_analyzer_explain(param); // expected-warning{{argument 'param'}}
-  if (!ptr)
-clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}}
-}
-
-- size_t clang_analyzer_getExtent(void *);
-
-  This function returns the value that represents the extent of a memory region
-  pointed to by the argument. This value is often difficult to obtain 
otherwise,
-  because no valid code that produces this value. However, it may be useful
-  for testing purposes, to see how well does the analyzer model region extents.
-
-  Example usage::
-
-void foo() {
-  int x, *y;
-  size_t xs = clang_analyzer_getExtent(&x);
-  clang_analyzer_explain(xs); // expected-warning{{'4'}}
-  size_t ys = clang_analyzer_getExtent(&y);
-  clang_analyzer_explain(ys); // expected-warning{{'8'}}
-}
-
 Statistics
 ==
 

Removed: cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h?rev=257607&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/SValExplainer.h (removed)
@@ -1,233 +0,0 @@
-//== SValExplainer.h - Symbolic value explainer -*- 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 SValExplainer, a class for pretty-printing a
-//  human-readable description of a symbolic value. For example,
-//  "reg_$0" is turned into "initial value of variable 'x'".
-//
-//===--===//
-
-#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
-#define LLVM_CLANG_STATICANALYZER_CHECKERS_SVALEXPLAINER_H
-
-#include "clang/AST/DeclCXX.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
-
-namespace clang {
-
-namespace ento {
-
-class SValExplainer : public FullSValVisitor {
-private:
-  ASTContext &ACtx;
-
-  std::string printStmt(const Stmt *S) {
-std::string Str;
-llvm::raw_string_ostream OS(Str);
-S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts()));
-return OS.str();
-  }
-
-  bool isThisObject(const SymbolicRegion *R) {
-if (auto S = dyn_cast(R->getSymbol()))
-  if (isa(S->getRegion()))
-return true;
-return false;
-  }
-
-public:
-  SValExplainer(ASTContext &Ctx) : ACtx(Ctx) {}
-
-  std::string VisitUnknownVal(UnknownVal V) {
-return "unknown value";
-  }
-
-  std::string VisitUndefinedVal(UndefinedVal V) {
-return "undefined value";
-  }
-
-  std:

Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2016-01-13 Thread Alexey Bataev via cfe-commits
ABataev updated this revision to Diff 44754.
ABataev added a comment.

Update after review


http://reviews.llvm.org/D15709

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/attr-x86-interrupt.c
  test/CodeGenCXX/attr-x86-interrupt.cpp
  test/Sema/attr-x86-interrupt.c
  test/SemaCXX/attr-x86-interrupt.cpp

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1609,6 +1609,10 @@
   llvm::AttributeSet::FunctionIndex,
   B));
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
   }
 }
 
@@ -1914,6 +1918,16 @@
 ('T' << 24);
 return llvm::ConstantInt::get(CGM.Int32Ty, Sig);
   }
+
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule &CGM) const override {
+if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+  }
+}
+  }
 };
 
 class PS4TargetCodeGenInfo : public X86_64TargetCodeGenInfo {
@@ -2031,6 +2045,13 @@
 CodeGen::CodeGenModule &CGM) const {
   TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
 
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
+  }
+
   addStackProbeSizeTargetAttribute(D, GV, CGM);
 }
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5053,6 +5053,12 @@
   FunctionDecl *FDecl = dyn_cast_or_null(NDecl);
   unsigned BuiltinID = (FDecl ? FDecl->getBuiltinID() : 0);
 
+  // Functions with 'interrupt' attribute cannot be called directly.
+  if (FDecl && FDecl->hasAttr()) {
+Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
+return ExprError();
+  }
+
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
   // builtin functions to function pointers in the callee of a call.
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4570,17 +4570,90 @@
   Attr.getLoc(), S.Context, Kind, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAnyX86InterruptAttr(Sema &S, Decl *D,
+  const AttributeList &Attr) {
+  // Semantic checks for a function with the 'interrupt' attribute.
+  // a) Must be a function.
+  // b) Must have the 'void' return type.
+  // c) Must take 1 or 2 arguments.
+  // d) The 1st argument must be a pointer.
+  // e) The 2nd argument (if any) must be an unsigned integer.
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) || isInstanceMethod(D) ||
+  CXXMethodDecl::isStaticOverloadedOperator(
+  cast(D)->getDeclName().getCXXOverloadedOperator())) {
+S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+<< Attr.getName() << ExpectedFunctionWithProtoType;
+return;
+  }
+  // Interrupt handler must have void return type.
+  if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+S.Diag(getFunctionOrMethodResultSourceRange(D).getBegin(),
+   diag::err_anyx86_interrupt_attribute)
+<< (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86
+? 0
+: 1)
+<< 0;
+return;
+  }
+  // Interrupt handler must have 1 or 2 parameters.
+  unsigned NumParams = getFunctionOrMethodNumParams(D);
+  if (NumParams < 1 || NumParams > 2) {
+S.Diag(D->getLocStart(), diag::err_anyx86_interrupt_attribute)
+<< (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86
+? 0
+: 1)
+<< 1;
+return;
+  }
+  // The first argument must be a pointer.
+  if (!getFunctionOrMethodParamType(D, 0)->isPointerType()) {
+S.Diag(getFunctionOrMethodParamRange(D, 0).getBegin(),
+   diag::err_anyx86_interrupt_attribute)
+<< (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86
+? 0
+: 1)
+<< 2;
+return;
+  }
+  // The second argument, if present, must be an unsigned integer.
+  unsigned TypeSize =
+  S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64
+  ? 64
+  : 32;
+  if (NumParams == 2 &&
+  (!getFunctionOrMethodParamType(D, 1)->isUnsignedIntegerType() ||
+   S

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

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

Looks good with a couple of nits. I'll be happy to submit your patch once you 
address the comments.

Also, please include more context in your patches. See 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface.



Comment at: clang-tidy/ClangTidy.cpp:156
@@ -149,1 +155,3 @@
 
+  unsigned WarningsAsErrorsCount() const { return WarningsAsErrors; }
+

I'd call it `getWarningsAsErrorsCount()`


Comment at: clang-tidy/ClangTidyOptions.cpp:130
@@ +129,3 @@
+Result.WarningsAsErrors =
+(Result.WarningsAsErrors && !Result.WarningsAsErrors->empty() ? 
*Result.WarningsAsErrors + "," : "") +
+*Other.WarningsAsErrors;

This line exceeds column limit. Please run clang-format on the changed files.


http://reviews.llvm.org/D15528



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


r257610 - Revert r257602 because it breaks integrated-as.s on mips hosts.

2016-01-13 Thread Scott Egerton via cfe-commits
Author: s.egerton
Date: Wed Jan 13 10:19:33 2016
New Revision: 257610

URL: http://llvm.org/viewvc/llvm-project?rev=257610&view=rev
Log:
Revert r257602 because it breaks integrated-as.s on mips hosts.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-ias-Wa.s

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257610&r1=257609&r2=257610&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan 13 10:19:33 2016
@@ -2580,7 +2580,6 @@ static void CollectArgsForIntegratedAsse
   // When using an integrated assembler, translate -Wa, and -Xassembler
   // options.
   bool CompressDebugSections = false;
-  const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
 A->claim();
@@ -2619,25 +2618,7 @@ static void CollectArgsForIntegratedAsse
   CmdArgs.push_back("-soft-float");
   continue;
 }
-
-MipsTargetFeature = llvm::StringSwitch(Value)
-  .Case("-mips1", "+mips1")
-  .Case("-mips2", "+mips2")
-  .Case("-mips3", "+mips3")
-  .Case("-mips4", "+mips4")
-  .Case("-mips5", "+mips5")
-  .Case("-mips32", "+mips32")
-  .Case("-mips32r2", "+mips32r2")
-  .Case("-mips32r3", "+mips32r3")
-  .Case("-mips32r5", "+mips32r5")
-  .Case("-mips32r6", "+mips32r6")
-  .Case("-mips64", "+mips64")
-  .Case("-mips64r2", "+mips64r2")
-  .Case("-mips64r3", "+mips64r3")
-  .Case("-mips64r5", "+mips64r5")
-  .Case("-mips64r6", "+mips64r6")
-  .Default(nullptr);
-continue;
+break;
   }
 
   if (Value == "-force_cpusubtype_ALL") {
@@ -2685,10 +2666,6 @@ static void CollectArgsForIntegratedAsse
 else
   D.Diag(diag::warn_debug_compression_unavailable);
   }
-  if (MipsTargetFeature != nullptr) {
-CmdArgs.push_back("-target-feature");
-CmdArgs.push_back(MipsTargetFeature);
-  }
 }
 
 // This adds the static libclang_rt.builtins-arch.a directly to the command 
line

Modified: cfe/trunk/test/Driver/mips-ias-Wa.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-ias-Wa.s?rev=257610&r1=257609&r2=257610&view=diff
==
--- cfe/trunk/test/Driver/mips-ias-Wa.s (original)
+++ cfe/trunk/test/Driver/mips-ias-Wa.s Wed Jan 13 10:19:33 2016
@@ -47,94 +47,3 @@
 // RUN:   FileCheck -check-prefix=MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST %s
 // MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST: -cc1as
 // MSOFT-FLOAT-BOTH-MHARD-FLOAT-FIRST: "-target-feature" "-soft-float" 
"-target-feature" "+soft-float"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips1 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS1 %s
-// MIPS1: -cc1as
-// MIPS1: "-target-feature" "+mips1"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips2 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS2 %s
-// MIPS2: -cc1as
-// MIPS2: "-target-feature" "+mips2"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips3 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS3 %s
-// MIPS3: -cc1as
-// MIPS3: "-target-feature" "+mips3"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips4 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS4 %s
-// MIPS4: -cc1as
-// MIPS4: "-target-feature" "+mips4"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips5 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS5 %s
-// MIPS5: -cc1as
-// MIPS5: "-target-feature" "+mips5"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS32 %s
-// MIPS32: -cc1as
-// MIPS32: "-target-feature" "+mips32"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r2 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS32R2 %s
-// MIPS32R2: -cc1as
-// MIPS32R2: "-target-feature" "+mips32r2"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r3 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS32R3 %s
-// MIPS32R3: -cc1as
-// MIPS32R3: "-target-feature" "+mips32r3"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r5 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS32R5 %s
-// MIPS32R5: -cc1as
-// MIPS32R5: "-target-feature" "+mips32r5"
-
-// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,-mips32r6 
2>&1 | \
-// RUN:   FileCheck -check-prefix=MIPS32R6 %s
-// MIPS32R6: -cc1as
-// MIPS32R6: "-target-feature" "+

Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-13 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Almost LGTM. Could you re-upload with more context quickly? (ex git diff -U999)



Comment at: include/iterator:1418
@@ +1417,3 @@
+template 
+struct __libcpp_is_trivial_iterator >
+   : public 
_LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};

Should this trait handle `const` and `volatile` like most other traits do?


http://reviews.llvm.org/D15862



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


[libcxx] r257612 - [WebAssembly] Set std::numeric_limits's traps field for WebAssembly.

2016-01-13 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan 13 10:32:00 2016
New Revision: 257612

URL: http://llvm.org/viewvc/llvm-project?rev=257612&view=rev
Log:
[WebAssembly] Set std::numeric_limits's traps field for WebAssembly.

WebAssembly's integer division instruction traps on division by zero; set the
traps field of integral std::numeric_limits to true.

Modified:
libcxx/trunk/include/limits

libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp

Modified: libcxx/trunk/include/limits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits?rev=257612&r1=257611&r2=257612&view=diff
==
--- libcxx/trunk/include/limits (original)
+++ libcxx/trunk/include/limits Wed Jan 13 10:32:00 2016
@@ -237,7 +237,8 @@ protected:
 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
 static _LIBCPP_CONSTEXPR const bool is_modulo = 
!_VSTD::is_signed<_Tp>::value;
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
+defined(__wasm__)
 static _LIBCPP_CONSTEXPR const bool traps = true;
 #else
 static _LIBCPP_CONSTEXPR const bool traps = false;

Modified: 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp?rev=257612&r1=257611&r2=257612&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
 Wed Jan 13 10:32:00 2016
@@ -13,7 +13,8 @@
 
 #include 
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
+defined(__wasm__)
 static const bool integral_types_trap = true;
 #else
 static const bool integral_types_trap = false;


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


[libcxxabi] r257614 - [WebAssembly] Accomodate wasm's 128-bit long double.

2016-01-13 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan 13 10:39:30 2016
New Revision: 257614

URL: http://llvm.org/viewvc/llvm-project?rev=257614&view=rev
Log:
[WebAssembly] Accomodate wasm's 128-bit long double.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=257614&r1=257613&r2=257614&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Jan 13 10:39:30 2016
@@ -165,7 +165,8 @@ constexpr const char* float_data
 template <>
 struct float_data
 {
-#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__)
+#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
+defined(__wasm__)
 static const size_t mangled_size = 32;
 #elif defined(__arm__) || defined(__mips__)
 static const size_t mangled_size = 16;


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


r257615 - clang-format: [ObjC+JS] Allow bin-packing of array literals.

2016-01-13 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Jan 13 10:41:34 2016
New Revision: 257615

URL: http://llvm.org/viewvc/llvm-project?rev=257615&view=rev
Log:
clang-format: [ObjC+JS] Allow bin-packing of array literals.

After reading the style guides again, they don't actually say how to
pack or not pack array literals. Based on some user reports, array
initializers can unnecessarily get quite long if they contain many
small elements. Array literals with trailing commas are still formatted
one per line so that users have a way to opt out of the packing.

Before:
  var array = [
aa,
aa,
aa,
aa,
aa,
aa,
aa,
aa,
aa,
aa
  ];

After:
  var array = [
aa, aa, aa, aa, aa, aa, aa, aa, aa,
aa, aa
  ];

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=257615&r1=257614&r2=257615&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed Jan 13 10:41:34 2016
@@ -914,8 +914,12 @@ void ContinuationIndenter::moveStatePast
   NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth;
 }
 const FormatToken *NextNoComment = Current.getNextNonComment();
+bool EndsInComma = Current.MatchingParen &&
+   Current.MatchingParen->Previous &&
+   Current.MatchingParen->Previous->is(tok::comma);
 AvoidBinPacking =
-Current.isOneOf(TT_ArrayInitializerLSquare, TT_DictLiteral) ||
+(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) ||
+Current.is(TT_DictLiteral) ||
 Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
 (NextNoComment && NextNoComment->is(TT_DesignatedInitializerPeriod));
 if (Current.ParameterCount > 1)

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257615&r1=257614&r2=257615&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 13 10:41:34 2016
@@ -7763,7 +7763,12 @@ TEST_F(FormatTest, ObjCArrayLiterals) {
   "   == bbb ? @\"\" : @\"aa\",\n"
   "  @\"a\",\n"
   "  @\"a\",\n"
-  "  @\"a\"\n"
+  "  @\"a\",\n"
+  "];");
+  verifyFormat(
+  "NSArray *some_variable = @[\n"
+  "   == bbb ? @\"\" : @\"aa\",\n"
+  "  @\"\", @\"\", @\"\"\n"
   "];");
   verifyFormat("NSArray *some_variable = @[\n"
"  @\"a\",\n"
@@ -7771,12 +7776,6 @@ TEST_F(FormatTest, ObjCArrayLiterals) {
"  @\"a\",\n"
"  @\"a\",\n"
"];");
-  verifyGoogleFormat("NSArray *some_variable = @[\n"
- "  @\"a\",\n"
- "  @\"a\",\n"
- "  @\"a\",\n"
- "  @\"a\"\n"
- "];");
   verifyFormat("NSArray *array = @[\n"
"  @\"a\",\n"
"  @\"a\",\n" // Trailing comma -> one per line.

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257615&r1=257614&r2=257615&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Jan 13 10:41:34 2016
@@ -284,8 +284,7 @@ TEST_F(FormatTestJS, ArrayLiterals) {
   verifyFormat("var a: List =\n"
"[new SomeThing(), new SomeThingB()];");
   verifyFormat("return [\n"
-   "  aaa,\n"
-   "  bbb,\n"
+   "  aaa, bbb,\n"
"  ccc\n"
"];");
   verifyFormat("return [\n"
@@ -294,8 +293,7 @@ TEST_F(FormatTestJS, ArrayLiterals) {
"  ().('C'),\n"
"];");
   verifyFormat("var someVariable = SomeFunction([\n"
-   "  aaa,\n"
-   "  bbb,\n"
+   "  aaa, bbb

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

2016-01-13 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Added a few stylistic comments and request for more documentation.



Comment at: lib/CodeGen/MacroPPCallbacks.cpp:1
@@ +1,2 @@
+//===--- MacroPPCallbacks.h ---*- C++ 
-*-===//
+//

Please run your patch through clang-format.


Comment at: lib/CodeGen/MacroPPCallbacks.cpp:62
@@ +61,3 @@
+: DebugInfo(DI), PP(PP), FirstInclude(false), FirstIncludeDone(false),
+  CommandIncludeFiles(0), SkipFiles(2) {
+  Parents.push_back(nullptr);

Comment why SkipFiles is initialized to 2?


Comment at: lib/CodeGen/MacroPPCallbacks.cpp:74
@@ +73,3 @@
+  FirstIncludeFile = Loc;
+}
+if (CommandIncludeFiles) {

Comments?


Comment at: lib/CodeGen/MacroPPCallbacks.cpp:91
@@ +90,3 @@
+}
+else if (SkipFiles) {
+  if (!(--SkipFiles)) {

Please add a comment explaining this condition.


Comment at: lib/CodeGen/MacroPPCallbacks.h:34
@@ +33,3 @@
+  int CommandIncludeFiles;
+  int SkipFiles;
+  std::vector Parents;

Please comment the purpose of these fields.


Comment at: lib/CodeGen/MacroPPCallbacks.h:45
@@ +44,3 @@
+
+  /// \brief Callback invoked whenever a source file is entered or exited.
+  ///

Since r237417 LLVM enabled autobrief, so it's no longer recommended to use 
\brief for one-liners.


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] D15448: [analyzer] SVal Visitor.

2016-01-13 Thread Artem Dergachev via cfe-commits
NoQ removed rL LLVM as the repository for this revision.
NoQ updated this revision to Diff 44758.
NoQ added a comment.

Reverted the patch due to a few issues. This revision should fix these issues.

The explain-svals test is fixed to target a specific target, in order to make 
sure that the definition of size_t always agrees with the target triple, 
otherwise the test would fail (shame on me, should have guessed!).

Not quite sure what to do with the failure of the Modules buildbot 
(http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10562/steps/compile.llvm.stage2/logs/stdio).
 I added the new .def-files to the list of "textual" headers in 
module.modulemap, but i'm not brave enough to go ahead and commit again and 
make that sort of thing work through trial and error, as maybe there are more 
things i need to do.

Fix a small whitespace error introduced by the patch.

Right after committing http://reviews.llvm.org/D16062, i noticed that 
`MemRegion` itself also doesn't need to be a friend of `MemRegionManager`. 
Added this to this patch, as they're related, i guess.


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
  include/clang/module.modulemap
  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,98 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -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(&glob); // 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;
+}
+
+void test_3(S s) {
+  clang_analyzer_explain(&s); // 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(&s.s2[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 '

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

2016-01-13 Thread Jonathan Roelofs via cfe-commits
jroelofs updated this revision to Diff 44759.
jroelofs added a comment.

clang-format the patch, and rename method.


http://reviews.llvm.org/D15528

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/clang-tidy/werrors-plural.cpp

Index: test/clang-tidy/werrors-plural.cpp
===
--- test/clang-tidy/werrors-plural.cpp
+++ test/clang-tidy/werrors-plural.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR
+
+namespace j {
+}
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+
+namespace k {
+}
+// CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 2 warnings treated as errors
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -68,7 +68,9 @@
 diagnostics are displayed by clang-tidy and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect
 compilation arguments, so it can not turn on Clang warnings which are not
-already turned on in build configuration.
+already turned on in build configuration. The ``-warnings-as-errors=`` option
+upgrades any warnings emitted under the ``-checks=`` flag to errors (but it
+does not enable any checks itself).
 
 Clang diagnostics have check names starting with ``clang-diagnostic-``.
 Diagnostics which have a corresponding warning option, are named
@@ -150,6 +152,7 @@
  -checks=* to list all available checks.
 -p=- Build path
 -system-headers- Display the errors from system headers.
+-warnings-as-errors= - Upgrades warnings to errors. Same format as '-checks'.
 
   -p  is used to read a compile command database.
 
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -64,15 +64,21 @@
cl::init(""), cl::cat(ClangTidyCategory));
 
 static cl::opt
-HeaderFilter("header-filter",
- cl::desc("Regular expression matching the names of the\n"
-  "headers to output diagnostics from. Diagnostics\n"
-  "from the main file of each translation unit are\n"
-  "always displayed.\n"
-  "Can be used together with -line-filter.\n"
-  "This option overrides the value read from a\n"
-  ".clang-tidy file."),
- cl::init(""), cl::cat(ClangTidyCategory));
+WarningsAsErrors("warnings-as-errors",
+ cl::desc("Upgrades warnings to errors. "
+  "Same format as '-checks'."),
+ cl::init(""), cl::cat(ClangTidyCategory));
+
+static cl::opt
+HeaderFilter("header-filter",
+ cl::desc("Regular expression matching the names of the\n"
+  "headers to output diagnostics from. Diagnostics\n"
+  "from the main file of each translation unit are\n"
+  "always displayed.\n"
+  "Can be used together with -line-filter.\n"
+  "This option overrides the value read from a\n"
+  ".clang-tidy file."),
+ cl::init(""), cl::cat(ClangTidyCategory));
 
 static cl::opt
 SystemHeaders("system-headers",
@@ -227,6 +233,7 @@
 
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
+  DefaultOptions.WarningsAsErrors = "";
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
@@ -238,6 +245,8 @@
   ClangTidyOptions OverrideOptions;
   if (Checks.getNumOccurrences() > 0)
 OverrideOptions.Checks = Checks;
+  if (WarningsAsErrors.getNumOccurrences() > 0)
+OverrideOptions.WarningsAsErrors = WarningsAsErrors;
   if (HeaderFilter.getNumOccurrences() > 0)
 OverrideOptions.HeaderFilterRegex = HeaderFilter;
   if (SystemHeaders.getNumOccurrences() > 0)

[libcxx] r257629 - Update version to 3.9

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 11:33:21 2016
New Revision: 257629

URL: http://llvm.org/viewvc/llvm-project?rev=257629&view=rev
Log:
Update version to 3.9

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257629&r1=257628&r2=257629&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jan 13 11:33:21 2016
@@ -27,7 +27,7 @@
 #define _GNUC_VER 0
 #endif
 
-#define _LIBCPP_VERSION 3800
+#define _LIBCPP_VERSION 3900
 
 #ifndef _LIBCPP_ABI_VERSION
 #define _LIBCPP_ABI_VERSION 1


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


r257628 - Update version to 3.9

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 11:32:59 2016
New Revision: 257628

URL: http://llvm.org/viewvc/llvm-project?rev=257628&view=rev
Log:
Update version to 3.9

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/conf.py

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=257628&r1=257627&r2=257628&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jan 13 11:32:59 2016
@@ -1,5 +1,5 @@
 =
-Clang 3.8 (In-Progress) Release Notes
+Clang 3.9 (In-Progress) Release Notes
 =
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release 3.8. Here we
+frontend, part of the LLVM Compiler Infrastructure, release 3.9. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
@@ -36,7 +36,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Clang 3.8?
+What's New in Clang 3.9?
 
 
 Some of the major new features and improvements to Clang are listed
@@ -108,7 +108,7 @@ OpenCL C Language Changes in Clang
 Internal API Changes
 
 
-These are major API changes that have happened since the 3.7 release of
+These are major API changes that have happened since the 3.8 release of
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
@@ -116,46 +116,6 @@ this section should help get you past th
 
 AST Matchers
 
-The AST matcher functions were renamed to reflect the exact AST node names,
-which is a breaking change to AST matching code. The following matchers were
-affected:
-
-===
-Previous Matcher Name  New Matcher Name
-===
-recordDecl recordDecl and cxxRecordDecl
-ctorInitializercxxCtorInitializer
-constructorDeclcxxConstructorDecl
-destructorDecl cxxDestructorDecl
-methodDecl cxxMethodDecl
-conversionDecl cxxConversionDecl
-memberCallExpr cxxMemberCallExpr
-constructExpr  cxxConstructExpr
-unresolvedConstructExprcxxUnresolvedConstructExpr
-thisExpr   cxxThisExpr
-bindTemporaryExpr  cxxBindTemporaryExpr
-newExprcxxNewExpr
-deleteExpr cxxDeleteExpr
-defaultArgExpr cxxDefaultArgExpr
-operatorCallExpr   cxxOperatorCallExpr
-forRangeStmt   cxxForRangeStmt
-catchStmt  cxxCatchStmt
-tryStmtcxxTryStmt
-throwExpr  cxxThrowExpr
-boolLiteralcxxBoolLiteral
-nullPtrLiteralExpr cxxNullPtrLiteralExpr
-reinterpretCastExprcxxReinterpretCastExpr
-staticCastExpr cxxStaticCastExpr
-dynamicCastExprcxxDynamicCastExpr
-constCastExpr  cxxConstCastExpr
-functionalCastExpr cxxFunctionalCastExpr
-temporaryObjectExprcxxTemporaryObjectExpr
-CUDAKernalCallExpr cudaKernelCallExpr
-===
-
-recordDecl() previously matched AST nodes of type CXXRecordDecl, but now
-matches AST nodes of type RecordDecl. If a CXXRecordDecl is required, use the
-cxxRecordDecl() matcher instead.
 
 ...
 

Modified: cfe/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=257628&r1=257627&r2=257628&view=diff
==
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Wed Jan 13 11:32:59 2016
@@ -49,9 +49,9 @@ copyright = u'2007-%d, The Clang Team' %
 # built documents.
 #
 # The short X.Y version.
-version = '3.8'
+version = '3.9'
 # The full version, including alpha/beta/rc tags.
-release = '3.8'
+release = '3.9'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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

[libcxxabi] r257635 - Creating release_38 branch off revision 257626

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 11:35:10 2016
New Revision: 257635

URL: http://llvm.org/viewvc/llvm-project?rev=257635&view=rev
Log:
Creating release_38 branch off revision 257626

Added:
libcxxabi/branches/release_38/
  - copied from r257626, libcxxabi/trunk/

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


[libcxx] r257634 - Creating release_38 branch off revision 257626

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 11:35:07 2016
New Revision: 257634

URL: http://llvm.org/viewvc/llvm-project?rev=257634&view=rev
Log:
Creating release_38 branch off revision 257626

Added:
libcxx/branches/release_38/   (props changed)
  - copied from r257626, libcxx/trunk/

Propchange: libcxx/branches/release_38/
--
svn:mergeinfo = /libcxx/branches/apple:136569-137939


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


[libunwind] r257641 - Creating release_38 branch off revision 257626

2016-01-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan 13 11:35:29 2016
New Revision: 257641

URL: http://llvm.org/viewvc/llvm-project?rev=257641&view=rev
Log:
Creating release_38 branch off revision 257626

Added:
libunwind/branches/release_38/
  - copied from r257626, libunwind/trunk/

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


[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&view=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&r1=257641&r2=257642&view=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 &Fix : 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 &Errors, bool Fix) {
+void handleErrors(const std::vector &Errors, bool Fix,
+  unsigned &WarningsAsErrorsCount) {
   ErrorReporter Reporter(Fix);
   for (const ClangTidyError &Error : Errors)
 Reporter.reportDiagnostic(Error);
   Reporter.Finish();
+  WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
 }
 
 void exportReplacements(const std::vector &Errors,

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&r1=257641&r2=257642&view=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 &Errors, bool Fix);
+void handleErrors(const std::vector &Errors, bool Fix,
+  unsigned &WarningsAsErrorsCount);
 
 /// \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&r1=257641&r2=257642&view=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(Chec

Re: [libcxx] r257629 - Update version to 3.9

2016-01-13 Thread Hans Wennborg via cfe-commits
Marshall, Eric,

Please check that this was OK, as I don't usually commit to libc++.

Thanks,
Hans

On Wed, Jan 13, 2016 at 9:33 AM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Wed Jan 13 11:33:21 2016
> New Revision: 257629
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257629&view=rev
> Log:
> Update version to 3.9
>
> Modified:
> libcxx/trunk/include/__config
>
> Modified: libcxx/trunk/include/__config
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257629&r1=257628&r2=257629&view=diff
> ==
> --- libcxx/trunk/include/__config (original)
> +++ libcxx/trunk/include/__config Wed Jan 13 11:33:21 2016
> @@ -27,7 +27,7 @@
>  #define _GNUC_VER 0
>  #endif
>
> -#define _LIBCPP_VERSION 3800
> +#define _LIBCPP_VERSION 3900
>
>  #ifndef _LIBCPP_ABI_VERSION
>  #define _LIBCPP_ABI_VERSION 1
___
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 accepted this revision.
jroelofs added a reviewer: jroelofs.
jroelofs marked 2 inline comments as done.
jroelofs added a comment.

Thanks for the review! Committed r257642.


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] 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] D15897: [libc++] Silence warning about padding inserted at the tail of struct _Rep_base

2016-01-13 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Ping.

The same pragma is being used in other places (regex.cpp and locale.cpp) to 
silence the warning.


http://reviews.llvm.org/D15897



___
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:373
@@ -372,1 +372,3 @@
 
+  /// Whether this is a (C++ Concepts TS) function concept.
+  bool isConcept() const { return TemplatedDecl.getInt(); }

This code is not limited to function concepts.


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

The parameter is now unused and should be removed.


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] D15448: [analyzer] SVal Visitor.

2016-01-13 Thread Artem Dergachev via cfe-commits
NoQ added a reviewer: rsmith.
NoQ added a comment.

Richard: excuse me, adding you because you are an expert on the `modulemap`, 
could you have a quick look at the proposed changes here and probably point me 
in the right direction, because i'm not quite sure how to test the 
modules-enabled build on a local machine before committing?

Sorry for a bit of a newbie panic/noise in this review.


http://reviews.llvm.org/D15448



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


Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-13 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


Comment at: include/iterator:1418
@@ +1417,3 @@
+template 
+struct __libcpp_is_trivial_iterator >
+   : public 
_LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};

EricWF wrote:
> Should this trait handle `const` and `volatile` like most other traits do?
I don't think so; a const iterator cannot be incremented or decremented, so 
it's pretty useless.  Note that pointers to const (i.e, 
`__libcpp_is_trivial_iterator>::value`) is already 
true. 


http://reviews.llvm.org/D15862



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


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&view=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&r1=257651&r2=257652&view=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: r257652 - Update cxx_dr_status.html after the 3.8 branch

2016-01-13 Thread Hans Wennborg via cfe-commits
Richard, can you check that I got this right? Are there any more DRs
that were addressed in 3.8?

If it looks good, I'll merge this to the branch.

Cheers,
Hans

On Wed, Jan 13, 2016 at 11:14 AM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Wed Jan 13 13:14:03 2016
> New Revision: 257652
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257652&view=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&r1=257651&r2=257652&view=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
>   href="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
>
>
>   href="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


[PATCH] D16148: Fix for PR25271: Ensure that variadic template parameter defaults PCH roundtrip

2016-01-13 Thread Jannis Harder via cfe-commits
jix created this revision.
jix added a subscriber: cfe-commits.
jix set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

Parameter default values are expected to be attached to all redeclarations of a 
template. During serialization they are serialized only for the first 
redeclaration (probably to save space, see OwnsDefaultArg in 
ASTDeclWriter::VisitNonTypeTemplateParmDecl in ASTWriterDecl.cpp).

During deserialization the default arguments are recovered for all 
redeclartions by static void inheritDefaultTemplateArguments(... in 
ASTReaderDecl.cpp. This function includes the following optimization: As the 
parameters that have default values have to be at the end of the parameter 
list, it inherits them from back to front, stopping at the first parameter 
without a default. This works fine as long as there are no parameter packs, 
which may follow parameters with defaults.

The fix in this patch simply checks for parameter packs and skips them, 
continuing the default value inheritance for the preceding parameters.

Repository:
  rL LLVM

http://reviews.llvm.org/D16148

Files:
  lib/Serialization/ASTReaderDecl.cpp
  test/PCH/cxx-variadic-templates-with-default-params.cpp
  test/PCH/cxx-variadic-templates-with-default-params.h

Index: test/PCH/cxx-variadic-templates-with-default-params.h
===
--- test/PCH/cxx-variadic-templates-with-default-params.h
+++ test/PCH/cxx-variadic-templates-with-default-params.h
@@ -0,0 +1,8 @@
+// PR25271: Ensure that variadic template parameter defaults PCH roundtrip
+template
+class dummy;
+
+template
+class dummy {
+int field[T];
+};
Index: test/PCH/cxx-variadic-templates-with-default-params.cpp
===
--- test/PCH/cxx-variadic-templates-with-default-params.cpp
+++ test/PCH/cxx-variadic-templates-with-default-params.cpp
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -std=c++11 -include 
%S/cxx-variadic-templates-with-default-params.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t 
%S/cxx-variadic-templates-with-default-params.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+void f() {
+dummy<> x;
+(void)x;
+}
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -3000,6 +3000,8 @@
 
   for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
 NamedDecl *FromParam = FromTP->getParam(N - I - 1);
+if (FromParam->isParameterPack())
+  continue;
 NamedDecl *ToParam = ToTP->getParam(N - I - 1);
 
 if (auto *FTTP = dyn_cast(FromParam)) {


Index: test/PCH/cxx-variadic-templates-with-default-params.h
===
--- test/PCH/cxx-variadic-templates-with-default-params.h
+++ test/PCH/cxx-variadic-templates-with-default-params.h
@@ -0,0 +1,8 @@
+// PR25271: Ensure that variadic template parameter defaults PCH roundtrip
+template
+class dummy;
+
+template
+class dummy {
+int field[T];
+};
Index: test/PCH/cxx-variadic-templates-with-default-params.cpp
===
--- test/PCH/cxx-variadic-templates-with-default-params.cpp
+++ test/PCH/cxx-variadic-templates-with-default-params.cpp
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -std=c++11 -include %S/cxx-variadic-templates-with-default-params.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t %S/cxx-variadic-templates-with-default-params.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+void f() {
+dummy<> x;
+(void)x;
+}
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -3000,6 +3000,8 @@
 
   for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
 NamedDecl *FromParam = FromTP->getParam(N - I - 1);
+if (FromParam->isParameterPack())
+  continue;
 NamedDecl *ToParam = ToTP->getParam(N - I - 1);
 
 if (auto *FTTP = dyn_cast(FromParam)) {
___
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 location, avoiding adding explicit qualification / 
> > desugaring wherever possible, but the interface should at least take the 
> > context-sensi

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-13 Thread Rong Xu via cfe-commits
xur marked an inline comment as done.
xur added a comment.

I'll sent the revised patch based on the comments shortly.



Comment at: lib/CodeGen/BackendUtil.cpp:435
@@ +434,3 @@
+  if (CodeGenOpts.ProfileIRInstr) {
+assert (!CodeGenOpts.ProfileInstrGenerate);
+if (!CodeGenOpts.InstrProfileOutput.empty())

davidxl wrote:
> What is this asserting about?
Option ProfileInstrGenerate is to be used in Clang instrumentation only. If I 
reuse this options, I would need to change all the references in clang. I 
update the comments  in the coming patch.


http://reviews.llvm.org/D15829



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-13 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 44776.
xur added a comment.

added new tests and comments based on the review comments.


http://reviews.llvm.org/D15829

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/instrprof-ld.c

Index: test/Driver/instrprof-ld.c
===
--- test/Driver/instrprof-ld.c
+++ test/Driver/instrprof-ld.c
@@ -105,3 +105,23 @@
 //
 // CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-WATCHOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_watchos.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -shared \
+// RUN: -target x86_64-unknown-linux -fprofile-ir-instr -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64-SHARED-IR-Level %s
+//
+// CHECK-LINUX-X86-64-SHARED-IR-Level: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-X86-64-SHARED-IR-Level: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -shared \
+// RUN: -target x86_64-unknown-linux -fprofile-ir-instr \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64-SHARED-IR-Level-2 %s
+//
+// CHECK-LINUX-X86-64-SHARED-IR-Level-2: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-X86-64-SHARED-IR-Level-2-NOT: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -449,8 +449,16 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
-  Args.hasArg(OPT_fprofile_instr_generate_EQ);
+  // Only set ProfileIRInstr when there are profile generate or use options.
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr) &&
+(Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ) ||
+ Args.hasArg(OPT_fprofile_instr_use_EQ));
+  // Set Opts.ProfileInstrGenerate when Opts.ProfileIRInstr is false.
+  // Opts.ProfileInstrGenerate will be used for Clang instrumentation only.
+  if (!Opts.ProfileIRInstr)
+Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
+Args.hasArg(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
   Opts.CoverageMapping =
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3223,6 +3223,8 @@
   CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
 }
   }
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }
 
 static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args,
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -147,7 +147,7 @@
   if (C.getLangOpts().ObjC1)
 ObjCData = new ObjCEntrypoints();
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.ProfileIRInstr && !CodeGenOpts.InstrProfileInput.empty()) {
 auto ReaderOrErr =
 llvm::IndexedInstrProfReader::create(CodeGenOpts.InstrProfileInput);
 if (std::error_code EC = ReaderOrErr.getError()) {
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -431,6 +431,18 @@
 MPM->add(createInstrProfilingPass(Options));
   }
 
+  if (CodeGenOpts.ProfileIRInstr) {
+// Should not have ProfileInstrGenerate set -- it is for clang
+// instrumentation only.
+assert (!CodeGenOpts.ProfileInstrGenerate);
+if (!CodeGenOpts.InstrProfileInput.empty())
+  PMBuilder.PGOInstrUse = CodeGenOpts.InstrProfileInput;
+else if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+else
+  PMBuilder.PGOInstrGen = "default.profraw";
+  }
+

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

2016-01-13 Thread Argyrios Kyrtzidis via cfe-commits
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


> On Jan 9, 2016, at 7:46 PM, guibufolo+l...@gmail.com wrote:
> 
> RedX2501 added a comment.
> 
> Ping
> 
> 
> http://reviews.llvm.org/D10833
> 
> 
> 

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


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


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] 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 PREDEF_DECL_NTH_ELEMENT_ID:
+return Context.getNthElementDecl();
   }
   llvm_unreachable("PredefinedDeclIDs unknown enum value");

Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

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

Sorry, this LGTM. You should push it to 3.8 as well.



Comment at: include/iterator:1418
@@ +1417,3 @@
+template 
+struct __libcpp_is_trivial_iterator >
+   : public 
_LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};

EricWF wrote:
> Should this trait handle `const` and `volatile` like most other traits do?
It doesn't need to so long as "_Iter" is taken by value as it is in ``.


http://reviews.llvm.org/D15862



___
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
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 &Ctx,
+  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 &Ctx, 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 &Ctx, 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 &Ctx, 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 &Ctx,
+  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 (con

[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 &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-faster-string-find");
 CheckFactories.registerCheck

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 &C, DeclContext *DC) {
+  // typename IndexType

Rename this `createNthElementParameterList`.


Comment at: lib/AST/DeclTemplate.cpp:1244-1248
@@ +1243,7 @@
+createNthElement(const ASTContext &C, 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: [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] 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 &CGF, Address VAListAddr, QualType Ty,
+   const ABIArgInfo &AI) {
+  // 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()

[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&view=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&r1=257681&r2=257682&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx

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] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Louis Dionne via cfe-commits
ldionne added a comment.

In http://reviews.llvm.org/D15421#326209, @nwilson wrote:

> 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`?


If anything, I would probably start the name with `__pack`. This way, we could 
add other builtins that follow the same pattern, like `__pack_slice`, 
`__pack_reverse` and probably others.

Or if we don't want to start with `__pack`, then no problem, but we might want 
to settle on a prefix that will work for other builtins on packs as well.


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] 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


Re: [PATCH] D13453: Always generate cmake config files

2016-01-13 Thread Chris Bieneman via cfe-commits
Apologies for reviving a long dead thread, but I think we need to re-evalute 
this change.

With CMake 3.4 I’m seeing some nasty error spew on our internal builds. The 
spew can be reproduced with the following CMake invocation:

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

It seems to me that problem is that libclang’s static version depends on LLVM 
libraries which are not included in the ClangTargets export group. This wasn’t 
an issue before this change because the LLVM targets were external to CMake so 
it didn’t expect them to be in the export.

I think the right solution here is actually to make the clang targets export as 
part of the LLVMExports group when Clang is built with LLVM.

I’m about to send a patch out for review which addresses this, please provide 
feedback.

Thanks,
-Chris

> On Oct 9, 2015, at 7:43 PM, NAKAMURA Takumi  wrote:
> 
> chapuni closed this revision.
> chapuni added a comment.
> 
> Applied in r249935, thanks!
> 
> 
> http://reviews.llvm.org/D13453
> 
> 
> 

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


Re: r257652 - Update cxx_dr_status.html after the 3.8 branch

2016-01-13 Thread Richard Smith via cfe-commits
The right way to update this file is to change the www/make_cxx_dr_status
script and then rerun it. (It expects to find a copy of the cwg_index.html
page from the wg21 website in the current directory.) Done in r257695.

On Wed, Jan 13, 2016 at 11:20 AM, Hans Wennborg  wrote:

> Richard, can you check that I got this right? Are there any more DRs
> that were addressed in 3.8?
>
> If it looks good, I'll merge this to the branch.
>
> Cheers,
> Hans
>
> On Wed, Jan 13, 2016 at 11:14 AM, Hans Wennborg via cfe-commits
>  wrote:
> > Author: hans
> > Date: Wed Jan 13 13:14:03 2016
> > New Revision: 257652
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=257652&view=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&r1=257651&r2=257652&view=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


[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


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&view=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&r1=257694&r2=257695&view=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


[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&view=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&r1=257695&r2=257696&view=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


[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


[PATCH] D16159: [Sema] Fix PR26085 -- regression caused by making overload resolution more lenient in C.

2016-01-13 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added reviewers: bob.wilson, rsmith.
george.burgess.iv added a subscriber: cfe-commits.

Fix PR26085 by suppressing diags from CheckSingleAssignmentConstraints during 
overload resolution.

It seems that passing `Diagnose`/`Complain` flags around to Sema methods is a 
mildly common thing, so that’s the approach I took when making this. I’m 
certainly open to suggestions if there’s a better way to go about this, because 
"check a flag every time you call `Diag`" seems a bit fragile/error-prone.

N.B. The attached test case is the most ObjC I’ve ever written. If the added 
test cases seem unintuitive, please let me know. :)

http://reviews.llvm.org/D16159

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaObjC/ovl-check.m

Index: test/SemaObjC/ovl-check.m
===
--- /dev/null
+++ test/SemaObjC/ovl-check.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -fobjc-arc
+//
+// These tests exist as a means to help ensure that diagnostics aren't printed
+// in overload resolution in ObjC.
+
+struct Type1 { int a; };
+@interface Iface1 @end
+
+@interface NeverCalled
+- (void) test:(struct Type1 *)arg;
+@end
+
+@interface TakesIface1
+- (void) test:(Iface1 *)arg;
+@end
+
+// PR26085, rdar://problem/24111333
+void testTakesIface1(id x, Iface1 *arg) {
+  // This should resolve silently to `TakesIface1`.
+  [x test:arg];
+}
+
+@class NSString;
+@interface NeverCalledv2
+- (void) testStr:(NSString *)arg;
+@end
+
+@interface TakesVanillaConstChar
+- (void) testStr:(const void *)a;
+@end
+
+// Not called out explicitly by PR26085, but related.
+void testTakesNSString(id x) {
+  // Overload resolution should not emit a diagnostic about needing to add an
+  // '@' before "someStringLiteral".
+  [x testStr:"someStringLiteral"];
+}
+
+typedef const void *CFTypeRef;
+id CreateSomething();
+
+@interface NeverCalledv3
+- (void) testCFTypeRef:(struct Type1 *)arg;
+@end
+
+@interface TakesCFTypeRef
+- (void) testCFTypeRef:(CFTypeRef)arg;
+@end
+
+// Not called out explicitly by PR26085, but related.
+void testTakesCFTypeRef(id x) {
+  // Overload resolution should occur silently, select the CFTypeRef overload,
+  // and produce a single complaint. (with notes)
+  [x testCFTypeRef:CreateSomething()]; // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef'}} expected-note{{use __bridge}} expected-note{{use __bridge_retained}}
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -2686,15 +2686,16 @@
 bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
   CastKind &Kind,
   CXXCastPath& BasePath,
-  bool IgnoreBaseAccess) {
+  bool IgnoreBaseAccess,
+  bool Diagnose) {
   QualType FromType = From->getType();
   bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
 
   Kind = CK_BitCast;
 
-  if (!IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() &&
+  if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() &&
   From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) ==
-  Expr::NPCK_ZeroExpression) {
+  Expr::NPCK_ZeroExpression) {
 if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy))
   DiagRuntimeBehavior(From->getExprLoc(), From,
   PDiag(diag::warn_impcast_bool_to_null_pointer)
@@ -2712,18 +2713,24 @@
   !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
 // We must have a derived-to-base conversion. Check an
 // ambiguous or inaccessible conversion.
-if (CheckDerivedToBaseConversion(FromPointeeType, ToPointeeType,
- From->getExprLoc(),
- From->getSourceRange(), &BasePath,
- IgnoreBaseAccess))
+unsigned InaccessibleID = 0;
+unsigned AmbigiousID = 0;
+if (Diagnose) {
+  InaccessibleID = diag::err_upcast_to_inaccessible_base;
+  AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
+}
+if (CheckDerivedToBaseConversion(
+FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
+From->getExprLoc(), From->getSourceRange(), DeclarationName(),
+&BasePath, IgnoreBaseAccess))
   return true;
 
 // The conversion was successful.
 Kind = CK_DerivedToBase;
   }
 
-  if (!IsCStyleOrFunctionalCast && FromPointeeType->isFunctionType() &&
-  ToPoi

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&view=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] r257702 - Better comments in test. NFC

2016-01-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jan 13 17:05:15 2016
New Revision: 257702

URL: http://llvm.org/viewvc/llvm-project?rev=257702&view=rev
Log:
Better comments in test. NFC

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

Modified: libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp?rev=257702&r1=257701&r2=257702&view=diff
==
--- libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp Wed Jan 13 
17:05:15 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


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 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


Re: [PATCH] D16159: [Sema] Fix PR26085 -- regression caused by making overload resolution more lenient in C.

2016-01-13 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D16159



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


[libcxx] r257707 - Tame a -Wunknown-attributes warning

2016-01-13 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Wed Jan 13 17:27:08 2016
New Revision: 257707

URL: http://llvm.org/viewvc/llvm-project?rev=257707&view=rev
Log:
Tame a -Wunknown-attributes warning

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257707&r1=257706&r2=257707&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jan 13 17:27:08 2016
@@ -434,7 +434,7 @@ namespace std {
 #endif
 
 // Allow for build-time disabling of unsigned integer sanitization
-#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && 
__has_attribute(no_sanitize)
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute((no_sanitize("unsigned-integer-overflow")))
 #endif 
 


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


r257710 - [Sema] Suppress diags in overload resolution.

2016-01-13 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Jan 13 17:36:34 2016
New Revision: 257710

URL: http://llvm.org/viewvc/llvm-project?rev=257710&view=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&r1=257709&r2=257710&view=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 &Kind,
   CXXCastPath& BasePath,
-  bool IgnoreBaseAccess);
+  bool IgnoreBaseAccess,
+  bool Diagnose = true);
   bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType 
ToType,
  bool InOverloadResolution,
  QualType &ConvertedType);
@@ -5388,7 +5389,8 @@ public:
 unsigned AmbigiousBaseConvID,
 SourceLocation Loc, SourceRange Range,
 DeclarationName Name,
-CXXCastPath *BasePath);
+CXXCastPath *BasePath,
+bool IgnoreAccess = false);
 
   std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
 
@@ -7514,14 +7516,15 @@ public:
 ObjCMethodDecl *&ClassMethod,
 ObjCMethodDecl *&InstanceMethod,
 TypedefNameDecl *&TDNDecl,
-bool CfToNs);
-  
+bool CfToNs, bool Diagnose = true);
+
   bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
  QualType DestType, QualType SrcType,
- Expr *&SrcExpr);
-  
-  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr);
-  
+ Expr *&SrcExpr, bool Diagnose = true);
+
+  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,
+  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 *&op,
  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&r1=257709&r2=257710&view=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
 Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
unsigned InaccessibleBaseID,
unsigned AmbigiousBaseConvID,
SourceLocation Loc, SourceRange Range,
DeclarationName Name,
-   CXXCastPath *BasePath) {
+   CXXCastPath *BasePath,
+   bool IgnoreAccess) {
   // First, determine whether the path from Derived 

Re: [PATCH] D16159: [Sema] Fix PR26085 -- regression caused by making overload resolution more lenient in C.

2016-01-13 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257710: [Sema] Suppress diags in overload resolution. 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D16159?vs=44797&id=44803#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16159

Files:
  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
  cfe/trunk/test/SemaObjC/ovl-check.m

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -2229,7 +2229,8 @@
   bool CheckPointerConversion(Expr *From, QualType ToType,
   CastKind &Kind,
   CXXCastPath& BasePath,
-  bool IgnoreBaseAccess);
+  bool IgnoreBaseAccess,
+  bool Diagnose = true);
   bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
  bool InOverloadResolution,
  QualType &ConvertedType);
@@ -5388,7 +5389,8 @@
 unsigned AmbigiousBaseConvID,
 SourceLocation Loc, SourceRange Range,
 DeclarationName Name,
-CXXCastPath *BasePath);
+CXXCastPath *BasePath,
+bool IgnoreAccess = false);
 
   std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
 
@@ -7514,14 +7516,15 @@
 ObjCMethodDecl *&ClassMethod,
 ObjCMethodDecl *&InstanceMethod,
 TypedefNameDecl *&TDNDecl,
-bool CfToNs);
-  
+bool CfToNs, bool Diagnose = true);
+
   bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
  QualType DestType, QualType SrcType,
- Expr *&SrcExpr);
-  
-  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr);
-  
+ Expr *&SrcExpr, bool Diagnose = true);
+
+  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,
+  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 @@
   ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
  QualType castType, Expr *&op,
  CheckedConversionKind CCK,
+ bool Diagnose = true,
  bool DiagnoseCFAudited = false,
  BinaryOperatorKind Opc = BO_PtrMemD
  );
Index: cfe/trunk/test/SemaObjC/ovl-check.m
===
--- cfe/trunk/test/SemaObjC/ovl-check.m
+++ cfe/trunk/test/SemaObjC/ovl-check.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -fobjc-arc
+//
+// These tests exist as a means to help ensure that diagnostics aren't printed
+// in overload resolution in ObjC.
+
+struct Type1 { int a; };
+@interface Iface1 @end
+
+@interface NeverCalled
+- (void) test:(struct Type1 *)arg;
+@end
+
+@interface TakesIface1
+- (void) test:(Iface1 *)arg;
+@end
+
+// PR26085, rdar://problem/24111333
+void testTakesIface1(id x, Iface1 *arg) {
+  // This should resolve silently to `TakesIface1`.
+  [x test:arg];
+}
+
+@class NSString;
+@interface NeverCalledv2
+- (void) testStr:(NSString *)arg;
+@end
+
+@interface TakesVanillaConstChar
+- (void) testStr:(const void *)a;
+@end
+
+// Not called out explicitly by PR26085, but related.
+void testTakesNSString(id x) {
+  // Overload resolution should not emit a diagnostic about needing to add an
+  // '@' before "someStringLiteral".
+  [x testStr:"someStringLiteral"];
+}
+
+typedef const void *CFTypeRef;
+id CreateSomething();
+
+@interface NeverCalledv3
+- (void) testCFTypeRef:(struct Type1 *)arg;
+@end
+
+@interface TakesCFTypeRef
+- (void) testCFTypeRef:(CFTypeRef)arg;
+@end
+
+// Not called out explicitly by PR26085, but related.
+void testTakesCFTypeRef(id x) {
+  // Overload resolution should occur silently, select the CFTypeRef overload,
+  // and produce a single complaint. (with notes)
+  [x testCFTypeRef:CreateSomething()]; // expected-error{{implicit conversion of Objec

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

2016-01-13 Thread Arthur O'Dwyer via cfe-commits
Following Louis' suggestion, how about __pack_nth?

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


Re: [PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)

2016-01-13 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 44805.
eugenis marked 2 inline comments as done.

Repository:
  rL LLVM

http://reviews.llvm.org/D15699

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/cfi-check-fail.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/CodeGenCXX/cfi-vcall.cpp

Index: test/CodeGenCXX/cfi-vcall.cpp
===
--- test/CodeGenCXX/cfi-vcall.cpp
+++ test/CodeGenCXX/cfi-vcall.cpp
@@ -55,7 +55,7 @@
 
 // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1
 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" }
-// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8 } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]], i8 0 }
+// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] }
 
 // ITANIUM: define void @_Z2afP1A
 // MS: define void @"\01?af@@YAXPEAUA@@@Z"
@@ -69,9 +69,9 @@
   // NDIAG-NEXT: call void @llvm.trap()
   // NDIAG-NEXT: unreachable
   // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64
-  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_bad_type_abort(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-ABORT-NEXT: unreachable
-  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_bad_type(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-RECOVER-NEXT: br label %[[CONTBB]]
 
   // CHECK: [[CONTBB]]
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- test/CodeGenCXX/cfi-cross-dso.cpp
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -34,8 +34,8 @@
 // MS:   %[[TEST:.*]] = call i1 @llvm.bitset.test(i8* %[[VT2]], metadata !"?AUA@@"), !nosanitize
 // CHECK:   br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} !nosanitize
 // CHECK: [[SLOW]]
-// ITANIUM:   call void @__cfi_slowpath(i64 7004155349499253778, i8* %[[VT2]]) {{.*}} !nosanitize
-// MS:   call void @__cfi_slowpath(i64 -8005289897957287421, i8* %[[VT2]]) {{.*}} !nosanitize
+// ITANIUM:   call void @__cfi_slowpath_diag(i64 7004155349499253778, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
+// MS:   call void @__cfi_slowpath_diag(i64 -8005289897957287421, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
 // CHECK:   br label %[[CONT]], !nosanitize
 // CHECK: [[CONT]]
 // CHECK:   call void %{{.*}}(%struct.A* %{{.*}})
Index: test/CodeGen/cfi-icall-cross-dso.c
===
--- test/CodeGen/cfi-icall-cross-dso.c
+++ test/CodeGen/cfi-icall-cross-dso.c
@@ -1,5 +1,30 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 -fsanitize=cfi-icall  -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK --check-prefix=CHECK-DIAG \
+// RUN:   --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK \
+// RUN:   --check-prefix=ITANIUM --check-prefix=ITANIUM-TRAP \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK --check-prefix=CHECK-DIAG \
+// RUN:   --check-prefix=MS --check-prefix=MS-DIAG \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK \
+// RUN:   --check-prefix=MS --check-prefix=MS-TRAP \
+// RUN:   %s
 
 void caller(void (*f)()) {
   f()

Re: [PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)

2016-01-13 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CGExpr.cpp:2654-2678
@@ +2653,27 @@
+  for (auto CheckKindMaskPair : CheckKinds) {
+int Kind = CheckKindMaskPair.first;
+SanitizerMask Mask = CheckKindMaskPair.second;
+// All CFI checks are recoverable.
+assert(getRecoverableKind(Mask) == CheckRecoverableKind::Recoverable);
+if (CGM.getCodeGenOpts().SanitizeTrap.has(Mask)) {
+  SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), TrapBB);
+} else if (CGM.getCodeGenOpts().SanitizeRecover.has(Mask)) {
+  if (!RecoverBB) {
+RecoverBB = createBasicBlock("non_fatal");
+EmitBlock(RecoverBB);
+emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr},
+ "cfi_check_fail",
+ CheckRecoverableKind::Recoverable, false, ExitBB);
+  }
+  SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), RecoverBB);
+} else {
+  if (!FatalBB) {
+FatalBB = createBasicBlock("fatal");
+EmitBlock(FatalBB);
+emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr},
+ "cfi_check_fail",
+ CheckRecoverableKind::Recoverable, true, ExitBB);
+  }
+  SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), FatalBB);
+}
+  }

pcc wrote:
> Can't you replace all this code with a call to `EmitCheck` passing `icmp`s 
> for each of the check kinds? Sure, it wouldn't be a switch, but we don't care 
> about the performance of this code anyway.
Done. The code became a bit simpler, but the test looks awful now.


Comment at: test/CodeGen/cfi-icall-cross-dso.c:28
@@ -22,3 +27,3 @@
 // ITANIUM: call i1 @llvm.bitset.test(i8* %{{.*}}, metadata !"_ZTSFvE"), 
!nosanitize
-// ITANIUM: call void @__cfi_slowpath(i64 6588678392271548388, i8* %{{.*}}) 
{{.*}}, !nosanitize
+// ITANIUM: call void @__cfi_slowpath_diag(i64 6588678392271548388, i8* 
%{{.*}}, {{.*}}@[[DATA]]{{.*}}, !nosanitize
 

pcc wrote:
> Are you still testing the `__cfi_slowpath` code path?
added a test for the non-diag path


Repository:
  rL LLVM

http://reviews.llvm.org/D15699



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


Re: r257652 - Update cxx_dr_status.html after the 3.8 branch

2016-01-13 Thread Hans Wennborg via cfe-commits
Thanks. I've merged this together with r257695 to 3.8 in r257714.

On Wed, Jan 13, 2016 at 2:55 PM, Richard Smith  wrote:
> The right way to update this file is to change the www/make_cxx_dr_status
> script and then rerun it. (It expects to find a copy of the cwg_index.html
> page from the wg21 website in the current directory.) Done in r257695.
>
> On Wed, Jan 13, 2016 at 11:20 AM, Hans Wennborg  wrote:
>>
>> Richard, can you check that I got this right? Are there any more DRs
>> that were addressed in 3.8?
>>
>> If it looks good, I'll merge this to the branch.
>>
>> Cheers,
>> Hans
>>
>> On Wed, Jan 13, 2016 at 11:14 AM, Hans Wennborg via cfe-commits
>>  wrote:
>> > Author: hans
>> > Date: Wed Jan 13 13:14:03 2016
>> > New Revision: 257652
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=257652&view=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&r1=257651&r2=257652&view=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
>> >  > > href="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
>> >
>> >
>> >  > > href="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


[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&view=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

libcxx/branches/release_38/test/std/strings

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

2016-01-13 Thread George Burgess IV via cfe-commits
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 <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Wed Jan 13 17:36:34 2016
> New Revision: 257710
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257710&view=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&r1=257709&r2=257710&view=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 &Kind,
>CXXCastPath& BasePath,
> -  bool IgnoreBaseAccess);
> +  bool IgnoreBaseAccess,
> +  bool Diagnose = true);
>bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
> ToType,
>   bool InOverloadResolution,
>   QualType &ConvertedType);
> @@ -5388,7 +5389,8 @@ public:
>  unsigned AmbigiousBaseConvID,
>  SourceLocation Loc, SourceRange Range,
>  DeclarationName Name,
> -CXXCastPath *BasePath);
> +CXXCastPath *BasePath,
> +bool IgnoreAccess = false);
>
>std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
>
> @@ -7514,14 +7516,15 @@ public:
>  ObjCMethodDecl *&ClassMethod,
>  ObjCMethodDecl *&InstanceMethod,
>  TypedefNameDecl *&TDNDecl,
> -bool CfToNs);
> -
> +bool CfToNs, bool Diagnose =
> true);
> +
>bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
>   QualType DestType, QualType
> SrcType,
> - Expr *&SrcExpr);
> -
> -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
> *&SrcExpr);
> -
> + Expr *&SrcExpr, bool Diagnose =
> true);
> +
> +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
> *&SrcExpr,
> +  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 *&op,
>   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&r1=257709&r2=257710&view=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
>  Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
> unsigned InaccessibleBaseID,
> unsig

[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&view=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&r1=257719&r2=257720&view=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: 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&view=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&r1=257709&r2=257710&view=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 &Kind,
>>CXXCastPath& BasePath,
>> -  bool IgnoreBaseAccess);
>> +  bool IgnoreBaseAccess,
>> +  bool Diagnose = true);
>>bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
>> ToType,
>>   bool InOverloadResolution,
>>   QualType &ConvertedType);
>> @@ -5388,7 +5389,8 @@ public:
>>  unsigned AmbigiousBaseConvID,
>>  SourceLocation Loc, SourceRange
>> Range,
>>  DeclarationName Name,
>> -CXXCastPath *BasePath);
>> +CXXCastPath *BasePath,
>> +bool IgnoreAccess = false);
>>
>>std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
>>
>> @@ -7514,14 +7516,15 @@ public:
>>  ObjCMethodDecl *&ClassMethod,
>>  ObjCMethodDecl *&InstanceMethod,
>>  TypedefNameDecl *&TDNDecl,
>> -bool CfToNs);
>> -
>> +bool CfToNs, bool Diagnose =
>> true);
>> +
>>bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
>>   QualType DestType, QualType
>> SrcType,
>> - Expr *&SrcExpr);
>> -
>> -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>> *&SrcExpr);
>> -
>> + Expr *&SrcExpr, bool Diagnose =
>> true);
>> +
>> +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>> *&SrcExpr,
>> +  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
>> *&op,
>>   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&r1=257709&r2=257710&view=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 b

[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&view=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&r1=257720&r2=257721&view=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


Re: libc++ commits to be merged to the 3.8 release branch

2016-01-13 Thread Hans Wennborg via cfe-commits
Thanks! Merged as indicated below.

On Wed, Jan 13, 2016 at 3:48 PM, Marshall Clow  wrote:
> r257702 | marshall | 2016-01-13 15:05:15 -0800 (Wed, 13 Jan 2016) | 1 line
>
> Better comments in test. NFC

r257721.

> r257696 | marshall | 2016-01-13 14:52:36 -0800 (Wed, 13 Jan 2016) | 1 line
>
> Fix test for C++03 - lacking noexcept

r257720.

> 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

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


[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 created this revision.
nwilson added reviewers: rsmith, faisalv, hubert.reinterpretcast, aaron.ballman.
nwilson added a subscriber: cfe-commits.

Adding checks and diagnostics which fall under Concepts TS[dcl.spec.concept]p5:
function concepts are required to have 'bool' return type. 
Adding checks and  diagnostics which fall under Concepts TS[dcl.spec.concept]p6:
variable concepts are required to have 'bool' declaration type.

Remove a test in Parser which caused a regression due to the new checks.

http://reviews.llvm.org/D16163

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/Parser/cxx-concept-declaration.cpp

Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -13,9 +13,6 @@
 template
 A::Boolean concept C3(!0);
 
-template
-concept auto C4(void) -> bool { return true; }
-
 constexpr int One = 1;
 
 template 
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
@@ -0,0 +1,22 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool vc { true };
+
+template
+struct B { typedef bool Boolean; };
+
+template
+B::Boolean concept vctb(!0);
+
+template
+concept int vcti { 5 }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept float vctf { 5.5 }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept auto vcta { true }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept decltype(auto) vctd { true }; // expected-error {{declared type of variable concept must be 'bool'}}
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -11,3 +11,15 @@
 
 template
 concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept int fcrti() { return 5; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept auto fcrta(void) -> bool { return true; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept decltype(auto) fcrtd(void) { return true; } // expected-error {{declared return type of function concept must be 'bool'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5986,6 +5986,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
+  // following restrictions:
+  // - The declared type shall have the type bool.
+  if (!R->isBooleanType()) {
+SourceRange Range = D.getDeclSpec().getTypeSpecTypeLoc();
+Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl)
+<< (Range.isValid() ? FixItHint::CreateReplacement(Range, "bool")
+: FixItHint());
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7668,6 +7679,18 @@
 
 // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
 // following restrictions:
+// - The declared return type shall have the type bool.
+if (!FPT->getReturnType()->isBooleanType() ||
+D.getDeclSpec().containsPlaceholderType()) {
+  SourceRange Range = NewFD->getReturnTypeSourceRange();
+  Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret)
+  << (Range.isValid() ? FixItHint::CreateReplacement(Range, "bool")
+  : FixItHint());
+  NewFD->setInvalidDecl();
+}
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.
 if (FPT->getNumParams() > 0 || FPT->isVariadic())
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2067,6 +2067,10 @@
   "'%select{thread_local|inline|friend|constexpr}1'">;
 def err_function_concept_with_param

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


  1   2   >