Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-21 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 54464.
teemperor added a comment.

- Standard reference is now specifying what standard (C++11)
- Added test based on the standard example
- Also check base classes now for member calls (to pass the test from the 
standard example).


http://reviews.llvm.org/D19312

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/ctor-init-with-member-call-std.cpp
  test/SemaCXX/ctor-init-with-member-call.cpp

Index: test/SemaCXX/ctor-init-with-member-call.cpp
===
--- /dev/null
+++ test/SemaCXX/ctor-init-with-member-call.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wmember-call-in-ctor-init
+
+// Helper class for the following test cases.
+class A {
+public:
+  A(int i) {
+  }
+};
+
+// Calling member functions before bass class initialized is undefined behavior.
+class B : public A {
+  int member_;
+public:
+
+  B() : A(1 + get_i()) { // expected-warning {{member function call this->get_i() in ctor-initializer for base class 'A' results in undefined behavior}}
+  }
+  B(int var) : A(0), member_(get_i()) { } // no-warning
+
+  int get_i() {
+return 2;
+  }
+};
+
+// Same as previous test but with explicit this.
+class C : public A {
+public:
+  C() : A(this->get_i() + 1) { // expected-warning {{member function call this->get_i() in ctor-initializer for base class 'A' results in undefined behavior}}
+  }
+
+  int get_i() {
+return 2;
+  }
+};
+
+// Check that the whole ctor-initializer is checked for member calls.
+class OtherA {
+public:
+  OtherA(int i) {
+  }
+};
+
+class D : public OtherA, public A {
+public:
+  D() : OtherA(this->get_i() + 1), A(this->get_i() + 1) { // expected-warning {{member function call this->get_i() in ctor-initializer for base class 'OtherA' results in undefined behavior}} \
+  // expected-warning {{member function call this->get_i() in ctor-initializer for base class 'A' results in undefined behavior}}
+  }
+
+  int get_i() {
+return 2;
+  }
+};
+
+// Calling static functions of this class is not undefined behavior.
+class E : public A {
+public:
+  E() : A(this->get_i() + 1) { // no-warning
+  }
+
+  static int get_i() {
+return 2;
+  }
+};
+
+
+// Calling other functions of this class is not undefined behavior.
+int other_foo() {
+  return 2;
+}
+class F : public A {
+public:
+  F() : A(other_foo()) {} // no-warning
+};
+
+
+// Calling member functions of other classes is not undefined behavior.
+class G : public A {
+public:
+  G(B& b) : A(b.get_i()) {} // no-warning
+};
+
Index: test/SemaCXX/ctor-init-with-member-call-std.cpp
===
--- /dev/null
+++ test/SemaCXX/ctor-init-with-member-call-std.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wmember-call-in-ctor-init
+
+// Test UB in ctor-initializer with the example from [C++11 12.6.2 p13]
+class A {
+public:
+  A(int);
+};
+
+class B : public A {
+  int j;
+public:
+  int f();
+  B() : A(f()), // expected-warning {{member function call this->f() in ctor-initializer for base class 'A' results in undefined behavior}}
+  j(f()) { } // no-warning
+};
+
+class C {
+public:
+  C(int);
+};
+class D : public B, C {
+  int i;
+public:
+  D() : C(f()), // expected-warning {{member function call this->f() in ctor-initializer for base class 'C' results in undefined behavior}}
+  i(f()) { } // no-warning
+};
+
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3873,6 +3873,36 @@
   return false;
 }
 
+namespace {
+  /// \brief Searches for the first member function call to a given class.
+  class HasMemberCall : public RecursiveASTVisitor {
+CXXRecordDecl* OnlyForClass;
+CXXMemberCallExpr *FoundMemberCall = nullptr;
+
+  public:
+explicit HasMemberCall(CXXRecordDecl* OnlyForClass)
+  : OnlyForClass(OnlyForClass) {
+}
+
+/// \brief Returns the found member function call or 0 if
+/// no fitting member function call was found.
+CXXMemberCallExpr *getFoundMemberCall() {
+  return FoundMemberCall;
+}
+
+bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
+  // Check if member call is actually to the given class.
+  if (E->getRecordDecl() == nullptr
+  || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass
+	  || OnlyForClass->isDerivedFrom(E->getRecordDecl())) {
+FoundMemberCall = E;
+return false;
+  }
+  return true;
+}
+  };
+}
+
 bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
ArrayRef Initializers) {
   if (Constructor->isDependentContext()) {
@@ -3907,9 +3937,24 @@
   for (unsigned i = 0; i < Initializers.size(); i++) {
 CXXCtorInitializer *Membe

Re: r266719 - Warn if function or variable cannot be implicitly instantiated

2016-04-21 Thread Serge Pavlov via cfe-commits
Let me demonstrate the problem using excerpt from v8 sources:

-- lithium.h 
template 
struct LSubKindOperand {
  static int* Create(int index) { return &cache[index]; }
  static void SetUpCache();
  static int* cache;
};

struct LOperand {
  static void SetUpCaches();
};

#define LITHIUM_OPERAND_LIST(V)   \
  V(DoubleRegister,  1,   16)

#define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number)   \
typedef LSubKindOperand L##name;
LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS)
/* Expands to: typedef LSubKindOperand<1, 16> LDoubleRegister; */
#undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS

-- lithium.cc
#include "lithium.h"

template
int* LSubKindOperand::cache = 0;

template
void LSubKindOperand::SetUpCache() {
  cache = new int[kNumCachedOperands];
}

void LOperand::SetUpCaches() {
#define LITHIUM_OPERAND_SETUP(name, type, number) L##name::SetUpCache();
  LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
  /* Expands to: LDoubleRegister::SetUpCache(); */
#undef LITHIUM_OPERAND_SETUP
}

-- lithium-x64.cc ---
#include "lithium.h"

int* GetNextSpillSlot(int kind) {
  return LSubKindOperand<1,16>::Create(0);
}

int main(int argc, char *argv[]) {
  return 0;
}

-- build.sh -
g++ lithium.cc lithium-x64.cc
-

When compiler generates code for 'GetNextSpillSlot' it implicitly
instantiates the method 'Create'. It can do it as definition of the
template entity 'LSubKindOperand::Create' is available from lithium.h. Then
it attempts to instantiate static field 'LSubKindOperand::cache', as it is
used in the body of just instantiated method 'Create'. But definition of
this template entity  is not available while compiling lithium-x64.cc.
Failure to implicitly instantiate a template is not an error, but this
template must be instantiated somewhere else otherwise linker founds
undefined references.

Indeed, 'LSubKindOperand<1,16>::cache' is instantiated while compiling
lithium.cc. Method 'LOperand::SetUpCaches' is not a template, it references
'LSubKindOperand::SetUpCache', which in turn uses 'LSubKindOperand::cache'.
Definitions of these templates are available in lithium.cc, compiler
instantiates them and the program builds successfully. This solution is
fragile however, if lithium-x64.cc referenced
'LSubKindOperand<1,1>::Create', the build would break because in lithium.cc
this specialization is not instantiated.

Putting templates definitions into source files rather than headers is
similar to moving forward declarations into source files. It makes sense if
user wants to encapsulate some functionality. In this example he should
also move the definition 'LSubKindOperand::Create' to source file, just for
the sake of encapsulation. This would prevent compiler from implicit
instantiation of this method and thus from instantiation of the static
field as well.

If encapsulation is not an aim, moving template definition into header
seems to be more natural solution. It would allow for compiler to
instantiate all entities implicitly.

Static variables of template classes are a source of confusion for some
reason. Probably people tend to confuse them with static member template
specializations. Anyway this type of errors is too widespread, the
aforementioned https://llvm.org/bugs/show_bug.cgi?id=24425 is just one
example.  The change introduced in r266719 attempts to provide user with
some assistance in these cases.

I don't know details about  Singleton, but only existence of static
fields should not produce the warning. There must be a reference to the
field in some method defined inline. Solution could be similar: either the
method that references the static field should be encapsulated into source
file or the static field template should be exposed in header.

2016-04-21 5:36 GMT+06:00 Sean Silva :

>
>
> On Tue, Apr 19, 2016 at 7:28 AM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> (sorry, accidentally sent this mid-mail)
>>
>> ../../v8/src/crankshaft/lithium.h:322:45: error: instantiation of
>> variable
>> 'v8::internal::LSubKindOperand> 128>::cache' required here, but no definition is available
>> [-Werror,-Wundefined-var-template]
>> if (index < kNumCachedOperands) return &cache[index];
>> ^
>> ../../v8/src/crankshaft/x64/lithium-x64.cc:334:30: note: in instantiation
>> of member function
>> 'v8::internal::LSubKindOperand> 128>::Create' requested here
>> return LDoubleStackSlot::Create(index, zone());
>>  ^
>> ../../v8/src/crankshaft/lithium.h:335:27: note: forward declaration of
>> template entity is here
>>   static LSubKindOperand* cache;
>>   ^
>> ../../v8/src/crankshaft/lithium.h:322

[clang-tools-extra] r266970 - Fix cast compiler warning message in include-fixer.

2016-04-21 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Apr 21 04:16:32 2016
New Revision: 266970

URL: http://llvm.org/viewvc/llvm-project?rev=266970&view=rev
Log:
Fix cast compiler warning message in include-fixer.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=266970&r1=266969&r2=266970&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Thu Apr 21 
04:16:32 2016
@@ -18,9 +18,8 @@ using namespace clang;
 
 static llvm::cl::OptionCategory tool_options("Tool options");
 
-int main(int argc, char **argv) {
-  clang::tooling::CommonOptionsParser options(argc, (const char **)argv,
-  tool_options);
+int main(int argc, const char **argv) {
+  clang::tooling::CommonOptionsParser options(argc, argv, tool_options);
   clang::tooling::ClangTool tool(options.getCompilations(),
  options.getSourcePathList());
   // Set up the data source.


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


Re: [PATCH] D19323: Fix cast compiler warning message in include-fixer.

2016-04-21 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266970: Fix cast compiler warning message in include-fixer. 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19323?vs=54361&id=54473#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19323

Files:
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,8 @@
 
 static llvm::cl::OptionCategory tool_options("Tool options");
 
-int main(int argc, char **argv) {
-  clang::tooling::CommonOptionsParser options(argc, (const char **)argv,
-  tool_options);
+int main(int argc, const char **argv) {
+  clang::tooling::CommonOptionsParser options(argc, argv, tool_options);
   clang::tooling::ClangTool tool(options.getCompilations(),
  options.getSourcePathList());
   // Set up the data source.


Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -18,9 +18,8 @@
 
 static llvm::cl::OptionCategory tool_options("Tool options");
 
-int main(int argc, char **argv) {
-  clang::tooling::CommonOptionsParser options(argc, (const char **)argv,
-  tool_options);
+int main(int argc, const char **argv) {
+  clang::tooling::CommonOptionsParser options(argc, argv, tool_options);
   clang::tooling::ClangTool tool(options.getCompilations(),
  options.getSourcePathList());
   // Set up the data source.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19356: [Tooling] Inject -resource-dir instead of overwriting argv[0].

2016-04-21 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This allows using a different standard library (the one from argv[0] in
the compilation database) with the correct builtins.

http://reviews.llvm.org/D19356

Files:
  lib/Tooling/Tooling.cpp
  test/Tooling/clang-check-builtin-headers.cpp

Index: test/Tooling/clang-check-builtin-headers.cpp
===
--- test/Tooling/clang-check-builtin-headers.cpp
+++ test/Tooling/clang-check-builtin-headers.cpp
@@ -4,9 +4,11 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c 
%t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > 
%t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 
2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
+// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -338,17 +338,22 @@
   ArgsAdjuster = nullptr;
 }
 
+static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
+  void *MainAddr) {
+  // Allow users to override the resource dir.
+  for (StringRef Arg : Args)
+if (Arg.startswith("-resource-dir"))
+  return;
+
+  // If there's no override in place add our resource dir.
+  Args.push_back("-resource-dir=" +
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+}
+
 int ClangTool::run(ToolAction *Action) {
   // Exists solely for the purpose of lookup of the resource path.
   // This just needs to be some symbol in the binary.
   static int StaticSymbol;
-  // The driver detects the builtin header path based on the path of the
-  // executable.
-  // FIXME: On linux, GetMainExecutable is independent of the value of the
-  // first argument, thus allowing ClangTool and runToolOnCode to just
-  // pass in made-up names here. Make sure this works on other platforms.
-  std::string MainExecutable =
-  llvm::sys::fs::getMainExecutable("clang_tool", &StaticSymbol);
 
   llvm::SmallString<128> InitialDirectory;
   if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
@@ -413,7 +418,17 @@
   if (ArgsAdjuster)
 CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
   assert(!CommandLine.empty());
-  CommandLine[0] = MainExecutable;
+
+  // Add the resource dir based on the binary of this tool. argv[0] in the
+  // compilation database may refer to a different compiler and we want to
+  // pick up the very same standard library that compiler is using. The
+  // builtin headers in the resource dir need to match the exact clang
+  // version the tool is using.
+  // FIXME: On linux, GetMainExecutable is independent of the value of the
+  // first argument, thus allowing ClangTool and runToolOnCode to just
+  // pass in made-up names here. Make sure this works on other platforms.
+  injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+
   // FIXME: We need a callback mechanism for the tool writer to output a
   // customized message for each file.
   DEBUG({ llvm::dbgs() << "Processing: " << File << ".\n"; });


Index: test/Tooling/clang-check-builtin-headers.cpp
===
--- test/Tooling/clang-check-builtin-headers.cpp
+++ test/Tooling/clang-check-builtin-headers.cpp
@@ -4,9 +4,11 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
+// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -338,17 +338,22 @@
   ArgsAdjuster = nullptr;
 }
 
+static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
+  void *MainAddr) {
+  // Allow users to override the resource dir.
+  for (StringRef Arg : Args)
+if (Arg.startswith("-resource-dir"))
+  return;
+
+  // If there's no override in place add our resource dir.
+  Args.push_back("-resource-dir=" +
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+}
+
 int ClangTool::run(ToolAction *Action) {
   // Exists solely for the purpose of 

[PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added a reviewer: sbenza.
baloghadamsoftware added subscribers: cfe-commits, xazax.hun, o.gyorgy.
Herald added a subscriber: klimek.

Matcher proposed in the review of checker misc-assign-operator (name pending). 
Its goal is to find the direct enclosing function declaration of a statement 
and run the inner matcher on it. Two version is attached in this patch (thus it 
will not compile), to be decided which approach to take. The first one always 
chooses one single parent, the other one does a depth-first search upwards 
(thus a height-first search) and returns the first positive match of the inner 
matcher (thus it always returns zero or one matches, not more). Further 
questions: is it enough to implement it in-place, or ASTMatchersInternals or 
maybe ASTMatchFinder should be involved?

http://reviews.llvm.org/D19357

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5568,5 +5568,38 @@
   EXPECT_FALSE(matches("void F() { return; }", RetVal));
 }
 
+TEST(StatementMatcher, ForFunction) {
+  const auto CppString =
+"namespace std {"
+"template"
+"OIter copy_if(IIter sb, IIter se, OIter db, Pred pr);"
+"}"
+"class PosVec {"
+"  int n;"
+"public:"
+"  typedef PosVec *iterator;"
+"  typedef const PosVec *const_iterator;"
+"  iterator begin();"
+"  iterator end();"
+"  const_iterator begin() const;"
+"  const_iterator end() const;"
+"  PosVec& operator= (const PosVec& o) {"
+"std::copy_if(o.begin(), o.end(), begin(), [](PosVec& v) { return v.n > 0; });"
+"return *this;"
+"  }"
+"};";
+  EXPECT_TRUE(
+matches(
+  CppString,
+  returnStmt(forFunction(hasName("operator=")),
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_FALSE(
+matches(
+  CppString,
+  returnStmt(forFunction(hasName("operator=")),
+ has(binaryOperator(hasOperatorName(">"));
+ llvm::errs()<<"d";
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -184,6 +184,7 @@
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
+  REGISTER_MATCHER(forFunction);
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5108,6 +5108,66 @@
   gnuNullExpr(), cxxNullPtrLiteralExpr(),
   integerLiteral(equals(0), hasParent(expr(hasType(pointerType());
 }
+
+/// \brief Matches declaration of the function the statemenet belongs to
+///
+/// Given:
+/// \code
+/// F& operator=(const F& o) {
+///   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
+///   return *this;
+/// }
+/// \endcode
+/// returnStmt(forFunction(hasName("operator=")))
+///   matches 'return *this'
+///   but does match 'return > 0'
+AST_MATCHER_P(Stmt, forFunction, internal::Matcher,
+  InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+  assert(!Parents.empty() && "Found node that is not in the parent map.");
+
+  std::deque Stack(Parents.begin(),
+  Parents.end());
+  while(!Stack.empty()) {
+const auto &CurNode = Stack.back();
+Stack.pop_back();
+if(const auto *DeclNode = CurNode.get()) {
+  if(const auto *FuncDeclNode = dyn_cast(DeclNode)) {
+if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
+  return true;
+}
+  }
+}
+const auto *StmtNode = CurNode.get();
+if(StmtNode&&!isa(StmtNode)) {
+  for(const auto &Parent: Finder->getASTContext().getParents(*StmtNode))
+Stack.push_back(Parent);
+}
+  }
+  return false;
+}
+
+AST_MATCHER_P(Stmt, forFunction, internal::Matcher,
+  InnerMatcher) {
+  const auto *CurNode = &Node;
+  while(CurNode) {
+const auto &Parents = Finder->getASTContext().getParents(*CurNode);
+assert(!Parents.empty() && "Found node that is not in the parent map.");
+const auto &Parent = Parents[0];
+if(const auto *DeclNode = Parent.get()) {
+  if(const auto *FuncDeclNode = dyn_cast(DeclNode)) {
+return InnerMatcher.matches(*FuncDeclNode, Finder, Builder);
+  }
+  return false;
+}
+CurNode = Parent.get();
+   

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54476.
ioeric added a comment.

- Added comments for endsWithInternal().


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\n\nnamespace C {\n"
+ "namespace D int i; }\n   \n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Set t

Re: [PATCH] D19356: [Tooling] Inject -resource-dir instead of overwriting argv[0].

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

lg


http://reviews.llvm.org/D19356



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


r266972 - Compilation for Intel MCU (Part 1/3)

2016-04-21 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Thu Apr 21 05:16:48 2016
New Revision: 266972

URL: http://llvm.org/viewvc/llvm-project?rev=266972&view=rev
Log:
Compilation for Intel MCU (Part 1/3)

Add -miamcu option which:
  * Sets IAMCU triple
  * Sets IAMCU ABI
  * Enforces static compilation

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

Added:
cfe/trunk/test/Driver/miamcu-opt.c   (with props)
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=266972&r1=266971&r2=266972&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr 21 05:16:48 2016
@@ -1292,6 +1292,8 @@ def m3dnow : Flag<["-"], "m3dnow">, Grou
 def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, 
CoreOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, 
CoreOption]>;
 def mabi_EQ : Joined<["-"], "mabi=">, Group;
+def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, 
CoreOption]>,
+  HelpText<"Use Intel MCU ABI">;
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=266972&r1=266971&r2=266972&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 05:16:48 2016
@@ -278,6 +278,10 @@ DerivedArgList *Driver::TranslateInputAr
 DAL->append(A);
   }
 
+  // Enforce -static if -miamcu is present.
+  if (Args.hasArg(options::OPT_miamcu))
+DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
+
 // Add a default value of -mlinker-version=, if one was given and the user
 // didn't specify one.
 #if defined(HOST_LINK_VERSION)
@@ -296,7 +300,8 @@ DerivedArgList *Driver::TranslateInputAr
 ///
 /// This routine provides the logic to compute a target triple from various
 /// args passed to the driver and the default triple string.
-static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
+static llvm::Triple computeTargetTriple(const Driver &D,
+StringRef DefaultTargetTriple,
 const ArgList &Args,
 StringRef DarwinArchName = "") {
   // FIXME: Already done in Compilation *Driver::BuildCompilation
@@ -341,8 +346,9 @@ static llvm::Triple computeTargetTriple(
 return Target;
 
   // Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'.
-  if (Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
-   options::OPT_m32, options::OPT_m16)) {
+  Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
+   options::OPT_m32, options::OPT_m16);
+  if (A) {
 llvm::Triple::ArchType AT = llvm::Triple::UnknownArch;
 
 if (A->getOption().matches(options::OPT_m64)) {
@@ -367,6 +373,25 @@ static llvm::Triple computeTargetTriple(
   Target.setArch(AT);
   }
 
+  // Handle -miamcu flag.
+  if (Args.hasArg(options::OPT_miamcu)) {
+if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
+  D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
+   << Target.str();
+
+if (A && !A->getOption().matches(options::OPT_m32))
+  D.Diag(diag::err_drv_argument_not_allowed_with)
+  << "-miamcu" << A->getBaseArg().getAsString(Args);
+
+Target.setArch(llvm::Triple::x86);
+Target.setArchName("i586");
+Target.setEnvironment(llvm::Triple::UnknownEnvironment);
+Target.setEnvironmentName("");
+Target.setOS(llvm::Triple::ELFIAMCU);
+Target.setVendor(llvm::Triple::UnknownVendor);
+Target.setVendorName("intel");
+  }
+
   return Target;
 }
 
@@ -501,8 +526,8 @@ Compilation *Driver::BuildCompilation(Ar
   DerivedArgList *TranslatedArgs = TranslateInputArgs(*UArgs);
 
   // Owned by the host.
-  const ToolChain &TC =
-  getToolChain(*UArgs, computeTargetTriple(DefaultTargetTriple, *UArgs));
+  const ToolChain &TC = getToolChain(
+  *UArgs, computeTargetTriple(*this, DefaultTargetTriple, *UArgs));
 
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs);
@@ -1981,9 +2006,9 @@ InputInfo Driver::BuildJobsForActionNoCa
 const char *ArchName = BAA->getArchName();
 
 if (ArchName)
-  TC = &getToolChain(
-  C.getArgs(),
-  computeTargetTriple(DefaultTargetTriple, C.getArgs(), ArchName));
+   

r266973 - [Tooling] Inject -resource-dir instead of overwriting argv[0].

2016-04-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr 21 05:18:18 2016
New Revision: 266973

URL: http://llvm.org/viewvc/llvm-project?rev=266973&view=rev
Log:
[Tooling] Inject -resource-dir instead of overwriting argv[0].

This allows using a different standard library (the one from argv[0] in
the compilation database) with the correct builtins.

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

Modified:
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=266973&r1=266972&r2=266973&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Apr 21 05:18:18 2016
@@ -338,17 +338,22 @@ void ClangTool::clearArgumentsAdjusters(
   ArgsAdjuster = nullptr;
 }
 
+static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
+  void *MainAddr) {
+  // Allow users to override the resource dir.
+  for (StringRef Arg : Args)
+if (Arg.startswith("-resource-dir"))
+  return;
+
+  // If there's no override in place add our resource dir.
+  Args.push_back("-resource-dir=" +
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+}
+
 int ClangTool::run(ToolAction *Action) {
   // Exists solely for the purpose of lookup of the resource path.
   // This just needs to be some symbol in the binary.
   static int StaticSymbol;
-  // The driver detects the builtin header path based on the path of the
-  // executable.
-  // FIXME: On linux, GetMainExecutable is independent of the value of the
-  // first argument, thus allowing ClangTool and runToolOnCode to just
-  // pass in made-up names here. Make sure this works on other platforms.
-  std::string MainExecutable =
-  llvm::sys::fs::getMainExecutable("clang_tool", &StaticSymbol);
 
   llvm::SmallString<128> InitialDirectory;
   if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
@@ -413,7 +418,17 @@ int ClangTool::run(ToolAction *Action) {
   if (ArgsAdjuster)
 CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
   assert(!CommandLine.empty());
-  CommandLine[0] = MainExecutable;
+
+  // Add the resource dir based on the binary of this tool. argv[0] in the
+  // compilation database may refer to a different compiler and we want to
+  // pick up the very same standard library that compiler is using. The
+  // builtin headers in the resource dir need to match the exact clang
+  // version the tool is using.
+  // FIXME: On linux, GetMainExecutable is independent of the value of the
+  // first argument, thus allowing ClangTool and runToolOnCode to just
+  // pass in made-up names here. Make sure this works on other platforms.
+  injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+
   // FIXME: We need a callback mechanism for the tool writer to output a
   // customized message for each file.
   DEBUG({ llvm::dbgs() << "Processing: " << File << ".\n"; });

Modified: cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp?rev=266973&r1=266972&r2=266973&view=diff
==
--- cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp (original)
+++ cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp Thu Apr 21 05:18:18 
2016
@@ -4,9 +4,11 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c 
%t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > 
%t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 
2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
+// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;


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


Re: [PATCH] D19356: [Tooling] Inject -resource-dir instead of overwriting argv[0].

2016-04-21 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266973: [Tooling] Inject -resource-dir instead of 
overwriting argv[0]. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D19356?vs=54474&id=54478#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19356

Files:
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp

Index: cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
===
--- cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
+++ cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
@@ -4,9 +4,11 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c 
%t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > 
%t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 
2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
+// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;
Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -338,17 +338,22 @@
   ArgsAdjuster = nullptr;
 }
 
+static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
+  void *MainAddr) {
+  // Allow users to override the resource dir.
+  for (StringRef Arg : Args)
+if (Arg.startswith("-resource-dir"))
+  return;
+
+  // If there's no override in place add our resource dir.
+  Args.push_back("-resource-dir=" +
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+}
+
 int ClangTool::run(ToolAction *Action) {
   // Exists solely for the purpose of lookup of the resource path.
   // This just needs to be some symbol in the binary.
   static int StaticSymbol;
-  // The driver detects the builtin header path based on the path of the
-  // executable.
-  // FIXME: On linux, GetMainExecutable is independent of the value of the
-  // first argument, thus allowing ClangTool and runToolOnCode to just
-  // pass in made-up names here. Make sure this works on other platforms.
-  std::string MainExecutable =
-  llvm::sys::fs::getMainExecutable("clang_tool", &StaticSymbol);
 
   llvm::SmallString<128> InitialDirectory;
   if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
@@ -413,7 +418,17 @@
   if (ArgsAdjuster)
 CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
   assert(!CommandLine.empty());
-  CommandLine[0] = MainExecutable;
+
+  // Add the resource dir based on the binary of this tool. argv[0] in the
+  // compilation database may refer to a different compiler and we want to
+  // pick up the very same standard library that compiler is using. The
+  // builtin headers in the resource dir need to match the exact clang
+  // version the tool is using.
+  // FIXME: On linux, GetMainExecutable is independent of the value of the
+  // first argument, thus allowing ClangTool and runToolOnCode to just
+  // pass in made-up names here. Make sure this works on other platforms.
+  injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+
   // FIXME: We need a callback mechanism for the tool writer to output a
   // customized message for each file.
   DEBUG({ llvm::dbgs() << "Processing: " << File << ".\n"; });


Index: cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
===
--- cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
+++ cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
@@ -4,9 +4,11 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
+// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;
Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -338,17 +338,22 @@
   ArgsAdjuster = nullptr;
 }
 
+static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
+  void *MainAddr) {
+  // Allow users to override the resource dir.
+  for (StringRef Arg : Args)
+if (Arg.startswith("-resource-dir"))
+  return;
+
+  // If there's no override in place add our resource dir.
+  Args.push_back("-resource-dir=" +

r266975 - Back out the test case for r266973 for now.

2016-04-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr 21 05:46:14 2016
New Revision: 266975

URL: http://llvm.org/viewvc/llvm-project?rev=266975&view=rev
Log:
Back out the test case for r266973 for now.

It breaks on windows, need to investigate. It's not testing the
important part of that change anyways.

Modified:
cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp

Modified: cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp?rev=266975&r1=266974&r2=266975&view=diff
==
--- cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp (original)
+++ cfe/trunk/test/Tooling/clang-check-builtin-headers.cpp Thu Apr 21 05:46:14 
2016
@@ -4,11 +4,9 @@
 // RUN: echo '[{"directory":".","command":"/random/tool -c 
%t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > 
%t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s
-// RUN: not clang-check -p "%t" "%t/test.cpp" -extra-arg=-resource-dir=foo 
2>&1|FileCheck %s -check-prefix=CHECK-NOHDR
 // FIXME: Make the above easier.
 
 #include 
 
 // CHECK: C++ requires
-// CHECK-NOHDR: fatal error: 'stddef.h' file not
 invalid;


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


r266976 - Correctly parse GCC-style asm line following MS-style asm line.

2016-04-21 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Thu Apr 21 05:59:18 2016
New Revision: 266976

URL: http://llvm.org/viewvc/llvm-project?rev=266976&view=rev
Log:
Correctly parse GCC-style asm line following MS-style asm line.

Quit parsing MS-style inline assembly if the following statement has GCC style.
Enables compilation of code like

void f() {
  __asm mov ebx, ecx
  __asm__("movl %ecx, %edx");
}

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

Added:
cfe/trunk/test/CodeGen/inline-asm-mixed-style.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=266976&r1=266975&r2=266976&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Apr 21 05:59:18 
2016
@@ -27,6 +27,8 @@ def err_msasm_unable_to_create_target :
   "MS-style inline assembly is not available: %0">;
 def err_gnu_inline_asm_disabled : Error<
   "GNU-style inline assembly is disabled">;
+def err_asm_goto_not_supported_yet : Error<
+  "'asm goto' constructs are not supported yet">;
 }
 
 let CategoryName = "Parse Issue" in {

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=266976&r1=266975&r2=266976&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Apr 21 05:59:18 2016
@@ -1873,7 +1873,6 @@ private:
 
   bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false);
   bool isTypeSpecifierQualifier();
-  bool isTypeQualifier() const;
 
   /// isKnownToBeTypeSpecifier - Return true if we know that the specified 
token
   /// is definitely a type-specifier.  Return false if it isn't part of a type

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=266976&r1=266975&r2=266976&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Apr 21 05:59:18 2016
@@ -4255,27 +4255,6 @@ void Parser::ParseEnumBody(SourceLocatio
   }
 }
 
-/// isTypeSpecifierQualifier - Return true if the current token could be the
-/// start of a type-qualifier-list.
-bool Parser::isTypeQualifier() const {
-  switch (Tok.getKind()) {
-  default: return false;
-  // type-qualifier
-  case tok::kw_const:
-  case tok::kw_volatile:
-  case tok::kw_restrict:
-  case tok::kw___private:
-  case tok::kw___local:
-  case tok::kw___global:
-  case tok::kw___constant:
-  case tok::kw___generic:
-  case tok::kw___read_only:
-  case tok::kw___read_write:
-  case tok::kw___write_only:
-return true;
-  }
-}
-
 /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
 /// is definitely a type-specifier.  Return false if it isn't part of a type
 /// specifier or if we're not sure.

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=266976&r1=266975&r2=266976&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Thu Apr 21 05:59:18 2016
@@ -335,6 +335,33 @@ static bool buildMSAsmString(Preprocesso
   return false;
 }
 
+/// isTypeQualifier - Return true if the current token could be the
+/// start of a type-qualifier-list.
+static bool isTypeQualifier(const Token &Tok) {
+  switch (Tok.getKind()) {
+  default: return false;
+  // type-qualifier
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::kw_restrict:
+  case tok::kw___private:
+  case tok::kw___local:
+  case tok::kw___global:
+  case tok::kw___constant:
+  case tok::kw___generic:
+  case tok::kw___read_only:
+  case tok::kw___read_write:
+  case tok::kw___write_only:
+return true;
+  }
+}
+
+// Determine if this is a GCC-style asm statement.
+static bool isGCCAsmStatement(const Token &TokAfterAsm) {
+  return TokAfterAsm.is(tok::l_paren) || TokAfterAsm.is(tok::kw_goto) ||
+ isTypeQualifier(TokAfterAsm);
+}
+
 /// ParseMicrosoftAsmStatement. When -fms-extensions/-fasm-blocks is enabled,
 /// this routine is called to collect the tokens for an MS asm statement.
 ///
@@ -415,11 +442,11 @@ StmtResult Parser::ParseMicrosoftAsmStat
   if (ExpLoc.first != FID ||
   SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second) != LineNo) {
 // If this is a single-line __asm, we're done, except if the nex

Re: [PATCH] D18652: [Inline asm] Correctly parse GCC-style asm line following MS-style asm line

2016-04-21 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266976: Correctly parse GCC-style asm line following 
MS-style asm line. (authored by dzobnin).

Changed prior to commit:
  http://reviews.llvm.org/D18652?vs=53543&id=54480#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18652

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseStmtAsm.cpp
  cfe/trunk/test/CodeGen/inline-asm-mixed-style.c

Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -1873,7 +1873,6 @@
 
   bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false);
   bool isTypeSpecifierQualifier();
-  bool isTypeQualifier() const;
 
   /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
   /// is definitely a type-specifier.  Return false if it isn't part of a type
Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -27,6 +27,8 @@
   "MS-style inline assembly is not available: %0">;
 def err_gnu_inline_asm_disabled : Error<
   "GNU-style inline assembly is disabled">;
+def err_asm_goto_not_supported_yet : Error<
+  "'asm goto' constructs are not supported yet">;
 }
 
 let CategoryName = "Parse Issue" in {
Index: cfe/trunk/test/CodeGen/inline-asm-mixed-style.c
===
--- cfe/trunk/test/CodeGen/inline-asm-mixed-style.c
+++ cfe/trunk/test/CodeGen/inline-asm-mixed-style.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -fsyntax-only -verify %s -DCHECK_ASM_GOTO
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -O0 -emit-llvm -S %s -o - | FileCheck %s
+
+void f() {
+  __asm mov eax, ebx
+  __asm mov ebx, ecx
+  __asm__("movl %ecx, %edx");
+  // CHECK: movl%ebx, %eax
+  // CHECK: movl%ecx, %ebx
+  // CHECK: movl%ecx, %edx
+
+  __asm mov eax, ebx
+  __asm volatile ("movl %ecx, %edx");
+  // CHECK: movl%ebx, %eax
+  // CHECK: movl%ecx, %edx
+
+  __asm mov eax, ebx
+  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
+  // CHECK: movl%ebx, %eax
+  // CHECK: movl%ecx, %edx
+
+#ifdef CHECK_ASM_GOTO
+  __asm volatile goto ("movl %ecx, %edx"); // expected-error {{'asm goto' constructs are not supported yet}}
+
+  __asm mov eax, ebx
+  __asm goto ("movl %ecx, %edx"); // expected-error {{'asm goto' constructs are not supported yet}}
+#endif
+}
Index: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
===
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp
@@ -335,6 +335,33 @@
   return false;
 }
 
+/// isTypeQualifier - Return true if the current token could be the
+/// start of a type-qualifier-list.
+static bool isTypeQualifier(const Token &Tok) {
+  switch (Tok.getKind()) {
+  default: return false;
+  // type-qualifier
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::kw_restrict:
+  case tok::kw___private:
+  case tok::kw___local:
+  case tok::kw___global:
+  case tok::kw___constant:
+  case tok::kw___generic:
+  case tok::kw___read_only:
+  case tok::kw___read_write:
+  case tok::kw___write_only:
+return true;
+  }
+}
+
+// Determine if this is a GCC-style asm statement.
+static bool isGCCAsmStatement(const Token &TokAfterAsm) {
+  return TokAfterAsm.is(tok::l_paren) || TokAfterAsm.is(tok::kw_goto) ||
+ isTypeQualifier(TokAfterAsm);
+}
+
 /// ParseMicrosoftAsmStatement. When -fms-extensions/-fasm-blocks is enabled,
 /// this routine is called to collect the tokens for an MS asm statement.
 ///
@@ -415,11 +442,11 @@
   if (ExpLoc.first != FID ||
   SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second) != LineNo) {
 // If this is a single-line __asm, we're done, except if the next
-// line begins with an __asm too, in which case we finish a comment
+// line is MS-style asm too, in which case we finish a comment
 // if needed and then keep processing the next line as a single
 // line __asm.
 bool isAsm = Tok.is(tok::kw_asm);
-if (SingleLineMode && !isAsm)
+if (SingleLineMode && (!isAsm || isGCCAsmStatement(NextToken(
   break;
 // We're no longer in a comment.
 InAsmComment = false;
@@ -643,8 +670,7 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
   SourceLocation AsmLoc = ConsumeToken();
 
-  if (getLangOpts().AsmBlocks && Tok.isNot(tok::l_paren) &&
-  !isTypeQualifier()) {
+  if (getLangOpts().AsmBlocks && !isGCCAsmStatement(Tok)) {
 

Re: [PATCH] D18265: [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature

2016-04-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware retitled this revision from "[clang-tidy] New: checker 
misc-assign-operator-return" to "[clang-tidy] New: checker 
misc-unconventional-assign-operator replacing misc-assign-operator-signature".
baloghadamsoftware updated this revision to Diff 54486.
baloghadamsoftware added a comment.

Issues fixed and checker renamed.


http://reviews.llvm.org/D18265

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/misc/AssignOperatorSignatureCheck.cpp
  clang-tidy/misc/AssignOperatorSignatureCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
  clang-tidy/misc/UnconventionalAssignOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-assign-operator-signature.rst
  docs/clang-tidy/checks/misc-unconventional-assign-operator.rst
  test/clang-tidy/misc-assign-operator-signature.cpp
  test/clang-tidy/misc-unconventional-assign-operator.cpp

Index: test/clang-tidy/misc-unconventional-assign-operator.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-unconventional-assign-operator.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include 
+
+struct Good {
+  Good& operator=(const Good&);
+  Good& operator=(Good&&);
+
+  // Assign from other types is fine too.
+  Good& operator=(int);
+};
+
+struct AlsoGood {
+  // By value is also fine.
+  AlsoGood& operator=(AlsoGood);
+};
+
+struct BadReturnType {
+  void operator=(const BadReturnType&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturnType&' [misc-unconventional-assign-operator]
+  const BadReturnType& operator=(BadReturnType&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+  void operator=(int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+};
+
+struct BadReturnType2 {
+  BadReturnType2&& operator=(const BadReturnType2&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+  int operator=(BadReturnType2&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+};
+
+struct BadArgument {
+  BadArgument& operator=(BadArgument&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
+  BadArgument& operator=(const BadArgument&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr
+};
+
+struct BadModifier {
+  BadModifier& operator=(const BadModifier&) const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const'
+};
+
+struct Deleted {
+  // We don't check the return value of deleted operators.
+  void operator=(const Deleted&) = delete;
+  void operator=(Deleted&&) = delete;
+};
+
+class Private {
+  // We don't check the return value of private operators.
+  // Pre-C++11 way of disabling assignment.
+  void operator=(const Private &);
+};
+
+struct Virtual {
+  virtual Virtual& operator=(const Virtual &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'virtual'
+};
+
+class BadReturnStatement {
+  int n;
+
+public:
+  BadReturnStatement& operator=(BadReturnStatement&& rhs) {
+n = std::move(rhs.n);
+return rhs;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
+  }
+
+  // Do not check if return type is different from '&BadReturnStatement'
+  int operator=(int i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+n = i;
+return n;
+  }
+};
Index: test/clang-tidy/misc-assign-operator-signature.cpp
===
--- test/clang-tidy/misc-assign-operator-signature.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %check_clang_tidy %s misc-assign-operator-signature %t
-
-struct Good {
-  Good& operator=(const Good&);
-  Good& operator=(Good&&);
-
-  // Assign from other types is fine too.
-  Good& operator=(int);
-};
-
-struct AlsoGood {
-  // By value is also fine.
-  AlsoGood& operator=(AlsoGood);
-};
-
-struct BadReturn {
-  void operator=(const BadReturn&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturn&' [misc-assign-operator-signature]
-  const BadReturn& operator=(BadReturn&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-  void operator=(int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-struct BadReturn2 {
-  BadReturn2&& operator=(const BadReturn2&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-  int operator=(BadReturn2&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-
-struct BadArgument {
-  BadArgument& operator=(BadArg

Re: [PATCH] D19331: [Clang-tidy] Fix for crash in modernize-raw-string-literal check

2016-04-21 Thread Marek via cfe-commits
edyp87 added a comment.

Yes, please apply this patch for me.

As for macro cases - I also thought about this but check's author has taken 
care of macros in `check()` method :

  void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) {
 [...]
 if (Literal->getLocStart().isMacroID())
   return;
 [...]
  }

Thank you for quick review!


http://reviews.llvm.org/D19331



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


[PATCH] D19361: [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

2016-04-21 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added a reviewer: rnk.
d.zobnin.bugzilla added a subscriber: cfe-commits.

This patch attempts to improve implementation of several MS pragmas that use 
stack (vtordisp, { bss | code | const | data }_seg) and fix some compatibility 
issues.
Please take a look at the patch and let me know whether it's something worth 
working on and whether I'm on the right way of doing this.

This patch:
1. Changes implementation of #pragma vtordisp to use existing PragmaStack<> 
template class that *_seg pragmas use;
2. Fixes "#pragma vtordisp()" reset behavior -- it shouldn't affect the stack;
3. Supports "save-and-restore" of pragma state stacks on entering / exiting a 
C++ method body, as MSVC does.

If this work is accepted, I propose several to-do's:
1. Change #pragma pack implementation to use the same approach as other "stack" 
pragmas use;
2. Introduce diagnostics on popping named stack slots, as MSVC does

Currently I tried to make Clang behave exactly as MSVC behaves, though, I can 
think of possible better solutions, please see "Implementation notes" below.


Motivation:

Currently Clang implements "stack" pragmas in several ways: "vtordisp" and 
"pack" have their own stacks in Sema, pragma actions are performed differently.

MSVC seems to have a common implementation of all these pragmas. One common 
feature is "save-restore" on entering / exiting a C++ method body:
```
#pragma pack(4)
#pragma pack(show)

struct S {
  void f() {
#pragma pack(push, 8)
#pragma pack(show)
  }
};

#pragma pack(show)
```
MSVC's output: 4, 8, 4
Clang's output:  4, 8, 8

MSVC seems to introduce artificial sentinel slots on entering a C++ method body 
and pops them on exit. Consider
```
#pragma pack(push, 4)
struct S {
  void f() {
#pragma pack(pop)
  }
};
```
MSVC emits:
```
warning C4159: #pragma vtordisp(pop,...): has popped previously pushed 
identifier ''
```
The same approach is used for "vtordisp" pragma, although it doesn't support 
#pragma vtordisp (pop, id) syntax.
Please note that in the above example the stack gets corrupted and might lead 
to unexpected behavior later.

I implemented "save-and-restore" feature for #pragma vtordisp in 
http://reviews.llvm.org/D14467 by copying a skack to a RAII object and back, no 
matter how many times "pop" is used. Pragmas other than "vtordisp" in Clang 
don't support this feature yet.


Implementation notes:

MSVC seems to use the same name "" even for methods of 
nested classes. It is legal in correct cases, because "#pragma (pop, id)" 
will look for the closest slot with mathing name, but if the nested sentinel 
slot is mistakenly popped, it will cause popping the stack up to surrounding 
sentinel.
Maybe, if we choose this approach, we could use unique sentinel names for 
better recovery? Or even mark the sentinels to prevent a programmer from 
popping them by accident?

http://reviews.llvm.org/D19361

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp
  test/CodeGenCXX/sections.cpp
  test/SemaCXX/pragma-vtordisp.cpp

Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1928,7 +1928,8 @@
   // Save and reset current vtordisp stack if we have entered a C++ method body.
   bool IsCXXMethod =
   getLangOpts().CPlusPlus && Decl && isa(Decl);
-  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+  Sema::PragmaStackSentinelRAII
+PragmaStackSentinel(Actions, "InternalPragmaState", IsCXXMethod);
 
   // Do not enter a scope for the brace, as the arguments are in the same scope
   // (the function body) as the body itself.  Instead, just read the statement
@@ -1972,7 +1973,8 @@
   // Save and reset current vtordisp stack if we have entered a C++ method body.
   bool IsCXXMethod =
   getLangOpts().CPlusPlus && Decl && isa(Decl);
-  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+  Sema::PragmaStackSentinelRAII
+PragmaStackSentinel(Actions, "InternalPragmaState", IsCXXMethod);
 
   SourceLocation LBraceLoc = Tok.getLocation();
   StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc, /*FnTry*/true));
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -497,11 +497,11 @@
 void Parser::HandlePragmaMSVtorDisp() {
   assert(Tok.is(tok::annot_pragma_ms_vtordisp));
   uintptr_t Value = reinterpret_cast(Tok.getAnnotationValue());
-  Sema::PragmaVtorDispKind Kind =
-  static_cast((Value >> 16) & 0x);
+  Sema::PragmaMsStackAction Action =
+  static_cast((Value >> 16) & 0x);
   MSVtorDispAttr::Mode Mode = MSVtorDispAttr::Mode(Value & 0x);
   SourceLocation PragmaLoc = ConsumeToken(); // The annotation token.
-  Actions.ActOnPragmaMSVtorDisp(Kind, PragmaLoc, Mode);
+  Actions.A

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Please run clang\docs\tools\dump_ast_matchers.py to regenerate the 
documentation as well.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (auto It = Node.begin_overridden_methods();
+   It != Node.end_overridden_methods(); ++It) {

Can you range-ify this for loop?


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:2084
@@ +2083,3 @@
+  Code1, ForEachOverriddenInClass("C"),
+  new VerifyIdIsBoundTo("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(

Can you write the tests such that they don't leak?


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

Please be sure to run clang\docs\tools\dump_ast_matchers.py to regenerate the 
documentation as well.


http://reviews.llvm.org/D19357



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


Re: r266976 - Correctly parse GCC-style asm line following MS-style asm line.

2016-04-21 Thread Renato Golin via cfe-commits
On 21 April 2016 at 11:59, Denis Zobnin via cfe-commits
 wrote:
> Author: dzobnin
> Date: Thu Apr 21 05:59:18 2016
> New Revision: 266976
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266976&view=rev
> Log:
> Correctly parse GCC-style asm line following MS-style asm line.
>
> Quit parsing MS-style inline assembly if the following statement has GCC 
> style.
> Enables compilation of code like
>
> void f() {
>   __asm mov ebx, ecx
>   __asm__("movl %ecx, %edx");
> }

MS-style inline assembly is not available: No available targets are
compatible with this triple.

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/11538

Please move the file to an x86_64 specific directory or make it
REQUIRE x86_64, as

http://llvm.org/docs/TestingGuide.html#platform-specific-tests

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


Re: [PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

I will run it, once we are approaching the final version. This one is more of a 
question than a real patch.


http://reviews.llvm.org/D19357



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


r266983 - [Clang][AVX512][BuiltIn] Adding intrinsics of VGATHER{DPS|DPD} , VPGATHER{QD|QQ|DD|DQ} and VGATHERPF{0|1}{DPS|QPS|DPD|QPD} instruction set .

2016-04-21 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Apr 21 07:47:27 2016
New Revision: 266983

URL: http://llvm.org/viewvc/llvm-project?rev=266983&view=rev
Log:
[Clang][AVX512][BuiltIn] Adding intrinsics of VGATHER{DPS|DPD} , 
VPGATHER{QD|QQ|DD|DQ} and VGATHERPF{0|1}{DPS|QPS|DPD|QPD} instruction set .

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


Added:
cfe/trunk/lib/Headers/avx512pfintrin.h
cfe/trunk/test/CodeGen/avx512pf-builtins.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=266983&r1=266982&r2=266983&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Apr 21 07:47:27 2016
@@ -1059,12 +1059,28 @@ TARGET_BUILTIN(__builtin_ia32_alignd512_
 TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIiV4dUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIiV4fUc", "", 
"avx512f")
 
+TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2dvC*V2LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div2di, 
"V4iV2LLivC*V2LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div4df, "V4dV4dvC*V4LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div4di, 
"V8iV4LLivC*V4LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div4sf, "V4fV4fvC*V2LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div4si, "V4iV4ivC*V2LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div8sf, "V4fV4fvC*V4LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div8si, "V4iV4ivC*V4LLiUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv2df, "V2dV2dvC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv2di, "V4iV2LLivC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv4df, "V4dV4dvC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv4di, "V8iV4LLivC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv4sf, "V4fV4fvC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv4si, "V4iV4ivC*V4iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv8sf, "V8fV8fvC*V8iUci","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3siv8si, "V8iV8ivC*V8iUci","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8dvC*V8iUcIi", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*UsIi", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*V16fUsIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8dvC*V8LLiUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv16sf, "V8fV8fvC*V8LLiUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gathersiv8di, "V8LLiV8LLivC*V8iUcIi", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16si, "V16iV16ivC*UsIi", "", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_gathersiv16si, "V16iV16ivC*V16iUsIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv8di, "V8LLiV8LLivC*V8LLiUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv16si, "V8iV8ivC*V8LLiUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_scattersiv8df, "vv*UcV8iV8dIi", "", "avx512f")

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=266983&r1=266982&r2=266983&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Apr 21 07:47:27 2016
@@ -8,6 +8,7 @@ set(files
   avx512cdintrin.h
   avx512erintrin.h
   avx512fintrin.h
+  avx512pfintrin.h
   avx512vlbwintrin.h
   avx512vlintrin.h
   avx512dqintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=266983&r1=266982&r2=266983&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Apr 21 07:47:27 2016
@@ -6321,6 +6321,87 @@ _mm512_maskz_getexp_ps (__mmask16 __U, _
_MM_FROUND_CUR_DIRECTION);
 }
 
+#define _mm512_i64gather_ps( __index, __addr, __scale) __extension__ ({ \
+__builtin_ia32_gatherdiv16sf ((__v8sf) _mm256_undefined_ps (),\
+  __addr, (__v8di) __index, (__mmask8) -1, 
__scale);\
+})
+
+#define _mm512_mask_i64gather_ps( __v1_old, __mask, __index,\
+  __addr, __scale) __extension__({\
+__builtin_ia32_gatherdiv16sf ((__v8sf)

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:2084
@@ +2083,3 @@
+  Code1, ForEachOverriddenInClass("C"),
+  new VerifyIdIsBoundTo("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(

aaron.ballman wrote:
> Can you write the tests such that they don't leak?
matchAndVerifyResultConditionally deletes them:

```
template 
testing::AssertionResult
matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
  BoundNodesCallback *FindResultVerifier,
  bool ExpectResult) {
  std::unique_ptr ScopedVerifier(FindResultVerifier);
```

I'll send you a (separate) patch for taking a unique_ptr in. 




http://reviews.llvm.org/D19324



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (auto It = Node.begin_overridden_methods();
+   It != Node.end_overridden_methods(); ++It) {

aaron.ballman wrote:
> Can you range-ify this for loop?
I could do that , but it would require adding:

```const CXXMethodVector* ASTContext::overridden_methods() const;```

And plumbing it through. (or did I miss something ?)

Let me know what you think.


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3724
@@ +3723,3 @@
+  bool Matched = false;
+  for (auto It = Node.begin_overridden_methods();
+   It != Node.end_overridden_methods(); ++It) {

courbet wrote:
> aaron.ballman wrote:
> > Can you range-ify this for loop?
> I could do that , but it would require adding:
> 
> ```const CXXMethodVector* ASTContext::overridden_methods() const;```
> 
> And plumbing it through. (or did I miss something ?)
> 
> Let me know what you think.
I think it's an oversight that we don't have the range form of that function, 
and this seems like a reasonable use case to add it.


http://reviews.llvm.org/D19324



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


[PATCH] D19362: [ASTMatchers] Statically specify ownership of verifiers in tests. NFC

2016-04-21 Thread Clement Courbet via cfe-commits
courbet created this revision.
courbet added a reviewer: aaron.ballman.
courbet added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Statically specify ownership of verifiers in tests. NFC

http://reviews.llvm.org/D19362

Files:
  unittests/ASTMatchers/ASTMatchersTest.cpp
  unittests/ASTMatchers/ASTMatchersTest.h

Index: unittests/ASTMatchers/ASTMatchersTest.h
===
--- unittests/ASTMatchers/ASTMatchersTest.h
+++ unittests/ASTMatchers/ASTMatchersTest.h
@@ -37,8 +37,8 @@
 // If 'FindResultVerifier' is NULL, sets *Verified to true when Run is called.
 class VerifyMatch : public MatchFinder::MatchCallback {
 public:
-  VerifyMatch(BoundNodesCallback *FindResultVerifier, bool *Verified)
-  : Verified(Verified), FindResultReviewer(FindResultVerifier) {}
+  VerifyMatch(std::unique_ptr FindResultVerifier, bool *Verified)
+  : Verified(Verified), FindResultReviewer(std::move(FindResultVerifier)) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
 if (FindResultReviewer != nullptr) {
@@ -55,7 +55,7 @@
 
 private:
   bool *const Verified;
-  BoundNodesCallback *const FindResultReviewer;
+  const std::unique_ptr FindResultReviewer;
 };
 
 template 
@@ -222,12 +222,11 @@
 template 
 testing::AssertionResult
 matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
-  BoundNodesCallback *FindResultVerifier,
+  std::unique_ptr FindResultVerifier,
   bool ExpectResult) {
-  std::unique_ptr ScopedVerifier(FindResultVerifier);
   bool VerifiedResult = false;
   MatchFinder Finder;
-  VerifyMatch VerifyVerifiedResult(FindResultVerifier, &VerifiedResult);
+  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier), &VerifiedResult);
   Finder.addMatcher(AMatcher, &VerifyVerifiedResult);
   std::unique_ptr Factory(
   newFrontendActionFactory(&Finder));
@@ -266,17 +265,17 @@
 template 
 testing::AssertionResult
 matchAndVerifyResultTrue(const std::string &Code, const T &AMatcher,
- BoundNodesCallback *FindResultVerifier) {
+ std::unique_ptr FindResultVerifier) {
   return matchAndVerifyResultConditionally(
-  Code, AMatcher, FindResultVerifier, true);
+  Code, AMatcher, std::move(FindResultVerifier), true);
 }
 
 template 
 testing::AssertionResult
 matchAndVerifyResultFalse(const std::string &Code, const T &AMatcher,
-  BoundNodesCallback *FindResultVerifier) {
+  std::unique_ptr FindResultVerifier) {
   return matchAndVerifyResultConditionally(
-  Code, AMatcher, FindResultVerifier, false);
+  Code, AMatcher, std::move(FindResultVerifier), false);
 }
 
 } // end namespace ast_matchers
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -817,7 +817,7 @@
   "void f() { int a; float c; int d; int e; }",
   functionDecl(forEachDescendant(
   varDecl(hasDescendant(isInteger())).bind("x"))),
-  new VerifyIdIsBoundTo("x", 3)));
+  llvm::make_unique>("x", 3)));
 }
 
 TEST(HasDescendant, MatchesDescendantsOfTypes) {
@@ -832,7 +832,7 @@
   EXPECT_TRUE(matchAndVerifyResultTrue(
   "void f() { int*** i; }",
   qualType(asString("int ***"), forEachDescendant(pointerType().bind("x"))),
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
 }
 
 TEST(Has, MatchesChildrenOfTypes) {
@@ -843,7 +843,7 @@
   EXPECT_TRUE(matchAndVerifyResultTrue(
   "int (*f)(float, int);",
   qualType(functionType(), forEach(qualType(isInteger()).bind("x"))),
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
 }
 
 TEST(Has, MatchesChildTypes) {
@@ -976,24 +976,24 @@
   DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x"));
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
-  ClassX, new VerifyIdIsBoundTo("x")));
+  ClassX, llvm::make_unique>("x")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
-  ClassX, new VerifyIdIsBoundTo("other-id")));
+  ClassX, llvm::make_unique>("other-id")));
 
   TypeMatcher TypeAHasClassB = hasDeclaration(
   recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b";
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };",
   TypeAHasClassB,
-  new VerifyIdIsBoundTo("b")));
+  llvm::make_unique>("b")));
 
   StatementMatcher MethodX =
   callExpr(callee(cxxMethodDecl(hasName("x".bind("x");
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
   MethodX,
-  new VerifyIdIsBoundTo("x")));
+  llvm::make_unique>("x")));
 }
 
 TEST(Matcher, BindTheSameNameInAlternatives) {
@@ -1010,7 +1010,7 @@
   // The s

Re: [PATCH] D19362: [ASTMatchers] Statically specify ownership of verifiers in tests. NFC

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

LGTM! Thank you for the cleanup, this is more clear about the ownership 
semantics.


http://reviews.llvm.org/D19362



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


Re: [PATCH] D19362: [ASTMatchers] Statically specify ownership of verifiers in tests. NFC

2016-04-21 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks! Would you mind submitting this for me ?


http://reviews.llvm.org/D19362



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


Re: [PATCH] D19362: [ASTMatchers] Statically specify ownership of verifiers in tests. NFC

2016-04-21 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r266986, thank you!


http://reviews.llvm.org/D19362



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


Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-21 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

The patch needs to get through clang-format.
Should we deal with typeid and dynamic_cast, since they're mentioned in the 
same paragraph in the standard?



Comment at: lib/Sema/SemaDeclCXX.cpp:3895
@@ +3894,3 @@
+  // Check if member call is actually to the given class.
+  if (E->getRecordDecl() == nullptr
+  || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass

What's the rationale for warning if `getRecordDecl` returns `nullptr`?


Comment at: lib/Sema/SemaDeclCXX.cpp:3897
@@ +3896,3 @@
+  || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass
+ || OnlyForClass->isDerivedFrom(E->getRecordDecl())) {
+FoundMemberCall = E;

Please run clang-format on the patch.


Comment at: lib/Sema/SemaDeclCXX.cpp:3941
@@ +3940,3 @@
+if (Member->isBaseInitializer()) {
+  // Calling a member function from a ctor-initializer
+  // before the base class results in undefined behavior [C++11 12.6.2 
p13].

clang-format


Comment at: lib/Sema/SemaDeclCXX.cpp:3942
@@ +3941,3 @@
+  // Calling a member function from a ctor-initializer
+  // before the base class results in undefined behavior [C++11 12.6.2 
p13].
+  // FIXME: We only check for member functions directly called from this

"before the base class is initialized"?



http://reviews.llvm.org/D19312



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


Re: r266976 - Correctly parse GCC-style asm line following MS-style asm line.

2016-04-21 Thread Krzysztof Parzyszek via cfe-commits

On 4/21/2016 7:49 AM, Renato Golin via cfe-commits wrote:


MS-style inline assembly is not available: No available targets are
compatible with this triple.

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/11538


Same thing on Hexagon:
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/37972

-Krzysztof

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

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


r266986 - Clarify memory ownership semantics; NFC.

2016-04-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Apr 21 08:51:07 2016
New Revision: 266986

URL: http://llvm.org/viewvc/llvm-project?rev=266986&view=rev
Log:
Clarify memory ownership semantics; NFC.

Patch by Clement Courbet

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=266986&r1=266985&r2=266986&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Thu Apr 21 08:51:07 2016
@@ -830,7 +830,7 @@ TEST(HasDescendant, MatchesDescendantTyp
   "void f() { int a; float c; int d; int e; }",
   functionDecl(forEachDescendant(
   varDecl(hasDescendant(isInteger())).bind("x"))),
-  new VerifyIdIsBoundTo("x", 3)));
+  llvm::make_unique>("x", 3)));
 }
 
 TEST(HasDescendant, MatchesDescendantsOfTypes) {
@@ -845,7 +845,7 @@ TEST(HasDescendant, MatchesDescendantsOf
   EXPECT_TRUE(matchAndVerifyResultTrue(
   "void f() { int*** i; }",
   qualType(asString("int ***"), 
forEachDescendant(pointerType().bind("x"))),
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
 }
 
 TEST(Has, MatchesChildrenOfTypes) {
@@ -856,7 +856,7 @@ TEST(Has, MatchesChildrenOfTypes) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
   "int (*f)(float, int);",
   qualType(functionType(), forEach(qualType(isInteger()).bind("x"))),
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
 }
 
 TEST(Has, MatchesChildTypes) {
@@ -989,24 +989,24 @@ TEST(Matcher, BindMatchedNodes) {
   DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x"));
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
-  ClassX, new VerifyIdIsBoundTo("x")));
+  ClassX, llvm::make_unique>("x")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
-  ClassX, new VerifyIdIsBoundTo("other-id")));
+  ClassX, 
llvm::make_unique>("other-id")));
 
   TypeMatcher TypeAHasClassB = hasDeclaration(
   recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b";
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; 
};",
   TypeAHasClassB,
-  new VerifyIdIsBoundTo("b")));
+  llvm::make_unique>("b")));
 
   StatementMatcher MethodX =
   callExpr(callee(cxxMethodDecl(hasName("x".bind("x");
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
   MethodX,
-  new VerifyIdIsBoundTo("x")));
+  llvm::make_unique>("x")));
 }
 
 TEST(Matcher, BindTheSameNameInAlternatives) {
@@ -1023,7 +1023,7 @@ TEST(Matcher, BindTheSameNameInAlternati
   // The second branch binds x to f() and succeeds.
   "int f() { return 0 + f(); }",
   matcher,
-  new VerifyIdIsBoundTo("x")));
+  llvm::make_unique>("x")));
 }
 
 TEST(Matcher, BindsIDForMemoizedResults) {
@@ -1035,7 +1035,7 @@ TEST(Matcher, BindsIDForMemoizedResults)
   DeclarationMatcher(anyOf(
   recordDecl(hasName("A"), hasDescendant(ClassX)),
   recordDecl(hasName("B"), hasDescendant(ClassX,
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
 }
 
 TEST(HasDeclaration, HasDeclarationOfEnumType) {
@@ -1313,7 +1313,7 @@ TEST(Matcher, NestedOverloadedOperatorCa
   "Y& operator&&(Y& x, Y& y) { return x; }; "
   "Y a; Y b; Y c; Y d = a && b && c;",
   cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
-  new VerifyIdIsBoundTo("x", 2)));
+  llvm::make_unique>("x", 2)));
   EXPECT_TRUE(matches("class Y { }; "
   "Y& operator&&(Y& x, Y& y) { return x; }; "
   "Y a; Y b; Y c; Y d = a && b && c;",
@@ -1694,7 +1694,7 @@ TEST(ForEachArgumentWithParam, MatchesCX
   "  int y = 1;"
   "  S1[y];"
   "}",
-  CallExpr, new VerifyIdIsBoundTo("param", 1)));
+  CallExpr, llvm::make_unique>("param", 
1)));
 
   StatementMatcher CallExpr2 =
   callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
@@ -1706,7 +1706,7 @@ TEST(ForEachArgumentWithParam, MatchesCX
   "  int y = 1;"
   "  S::g(y);"
   "}",
-  CallExpr2, new VerifyIdIsBoundTo("param", 1)));
+  CallExpr2, llvm::make_unique>("param", 
1)));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCallExpr) {
@@ -1718,17 +1718,19 @@ TEST(ForEachArgumentWithParam, MatchesCa
 
   EXPECT_TRUE(
   matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr,
-   new VerifyIdIsBoundTo("param")));
+   
llvm::make_unique>(
+   "param")));
   EXPECT_TRUE(
   matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr,
-   new VerifyIdIsBoundTo("arg")))

r266989 - [Hexagon] Define architecture version macros for hexagonv55

2016-04-21 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu Apr 21 09:30:04 2016
New Revision: 266989

URL: http://llvm.org/viewvc/llvm-project?rev=266989&view=rev
Log:
[Hexagon] Define architecture version macros for hexagonv55

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/hexagon-predefines.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=266989&r1=266988&r2=266989&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr 21 09:30:04 2016
@@ -5940,6 +5940,11 @@ void HexagonTargetInfo::getTargetDefines
   Builder.defineMacro("__QDSP6_V5__");
   Builder.defineMacro("__QDSP6_ARCH__", "5");
 }
+  } else if (CPU == "hexagonv55") {
+Builder.defineMacro("__HEXAGON_V55__");
+Builder.defineMacro("__HEXAGON_ARCH__", "55");
+Builder.defineMacro("__QDSP6_V55__");
+Builder.defineMacro("__QDSP6_ARCH__", "55");
   } else if (CPU == "hexagonv60") {
 Builder.defineMacro("__HEXAGON_V60__");
 Builder.defineMacro("__HEXAGON_ARCH__", "60");

Modified: cfe/trunk/test/Preprocessor/hexagon-predefines.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/hexagon-predefines.c?rev=266989&r1=266988&r2=266989&view=diff
==
--- cfe/trunk/test/Preprocessor/hexagon-predefines.c (original)
+++ cfe/trunk/test/Preprocessor/hexagon-predefines.c Thu Apr 21 09:30:04 2016
@@ -4,6 +4,12 @@
 // CHECK-V5: #define __HEXAGON_V5__ 1
 // CHECK-V5: #define __hexagon__ 1
 
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv55 
%s | FileCheck %s -check-prefix CHECK-V55
+
+// CHECK-V55: #define __HEXAGON_ARCH__ 55
+// CHECK-V55: #define __HEXAGON_V55__ 1
+// CHECK-V55: #define __hexagon__ 1
+
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 
%s | FileCheck %s -check-prefix CHECK-V60
 
 // CHECK-V60: #define __HEXAGON_ARCH__ 60


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


[clang-tools-extra] r266992 - [Clang-tidy] Fix for crash in modernize-raw-string-literal check

2016-04-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Apr 21 09:39:12 2016
New Revision: 266992

URL: http://llvm.org/viewvc/llvm-project?rev=266992&view=rev
Log:
[Clang-tidy] Fix for crash in modernize-raw-string-literal check

Summary:
Clang-tidy modernize-raw-string-literal check crashes on run-time assert while 
it is evaluating compiler predefined identifiers such as
- __FUNCTION__
- __func__
- __PRETTY_FUNCTION__

Check is asserting because it cannot find opening quote for such string 
literal. It occurs only on debug build config.
I think that it would be good to prune such cases by crossing off predefined 
expressions - there is no need to evaluate such matches.

Reviewers: LegalizeAdulthood, alexfh

Subscribers: cfe-commits

Patch by Marek Jenda!

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp?rev=266992&r1=266991&r2=266992&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp Thu 
Apr 21 09:39:12 2016
@@ -108,7 +108,8 @@ void RawStringLiteralCheck::storeOptions
 }
 
 void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(stringLiteral().bind("lit"), this);
+  Finder->addMatcher(
+  stringLiteral(unless(hasParent(predefinedExpr(.bind("lit"), this);
 }
 
 void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp?rev=266992&r1=266991&r2=266992&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp 
Thu Apr 21 09:39:12 2016
@@ -91,6 +91,10 @@ char const *const HexPrintable("\x40\\")
 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw 
string literal
 // CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
 
+char const *const prettyFunction(__PRETTY_FUNCTION__);
+char const *const function(__FUNCTION__);
+char const *const func(__func__);
+
 #define TRICK(arg_) #arg_
 char const *const MacroBody = TRICK(foo\\bar);
 


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


r266993 - [x86] Force mixes asm syntax test to check for x86

2016-04-21 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Apr 21 09:40:06 2016
New Revision: 266993

URL: http://llvm.org/viewvc/llvm-project?rev=266993&view=rev
Log:
[x86] Force mixes asm syntax test to check for x86

Modified:
cfe/trunk/test/CodeGen/inline-asm-mixed-style.c

Modified: cfe/trunk/test/CodeGen/inline-asm-mixed-style.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-mixed-style.c?rev=266993&r1=266992&r2=266993&view=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-mixed-style.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-mixed-style.c Thu Apr 21 09:40:06 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -fsyntax-only 
-verify %s -DCHECK_ASM_GOTO
 // RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -O0 -emit-llvm -S 
%s -o - | FileCheck %s
+// REQUIRES: x86-registered-target
 
 void f() {
   __asm mov eax, ebx


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


Re: r266976 - Correctly parse GCC-style asm line following MS-style asm line.

2016-04-21 Thread Renato Golin via cfe-commits
On 21 April 2016 at 14:58, Krzysztof Parzyszek via cfe-commits
 wrote:
> Same thing on Hexagon:
> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/37972

Trying to fix in r266993.

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


Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19201#403585, @Prazek wrote:

> Do you know guys is it possible to get to noexcept source location, or we 
> have to do by hand using lexer?


If it might be possible to get the location of `noexcept(expression)` using 
`FunctionProtoType::getNoExceptExpr` (though I haven't tried this), but there 
seems to be no information left in the AST about a simple `noexcept`. However, 
it should be easy to find `noexcept` using a lexer (unless, it's hidden in a 
macro).


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


Re: [PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-21 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

Thanks for doing this!

I think we want the version that iterates all parents.
Otherwise it will have problems with templates.
That is, you won't know which `FunctionDecl` you will get: the template or the 
instantiation. And you might need one or the other specifically.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:5124
@@ +5123,3 @@
+///   but does match 'return > 0'
+AST_MATCHER_P(Stmt, forFunction, internal::Matcher,
+  InnerMatcher) {

I think this matcher works for Decls too, but we can leave it like this until 
we need the polymorphism.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5127
@@ +5126,3 @@
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+  assert(!Parents.empty() && "Found node that is not in the parent map.");
+

You should not assert() this.
Parents can be empty if the statement is not inside a function. eg a global 
variable initializer.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5132
@@ +5131,3 @@
+  while(!Stack.empty()) {
+const auto &CurNode = Stack.back();
+Stack.pop_back();

If you are taking from the back, use a vector<> instead.
Or SmallVector<> to avoid allocation in most cases.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5134
@@ +5133,3 @@
+Stack.pop_back();
+if(const auto *DeclNode = CurNode.get()) {
+  if(const auto *FuncDeclNode = dyn_cast(DeclNode)) {

Just call `CurNode.get`. It'll do the dyn_cast for you.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5139
@@ +5138,3 @@
+}
+  }
+}

We should check for `LambdaExpr` here too, and try to match against 
`LambdaExpr::getCallOperator()`


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5141
@@ +5140,3 @@
+}
+const auto *StmtNode = CurNode.get();
+if(StmtNode&&!isa(StmtNode)) {

You don't need to get a Stmt. getParents() works with DynTypedNodes.
There might be some non-stmt nodes in the middle, like variable declarations.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5142
@@ +5141,3 @@
+const auto *StmtNode = CurNode.get();
+if(StmtNode&&!isa(StmtNode)) {
+  for(const auto &Parent: Finder->getASTContext().getParents(*StmtNode))

We should also not traverse FunctionDecls.
Eg:

```
void F() {
  struct S {
void F2() {
}
  };
}
```

So, on each node: if is a FunctionDecl or a LambdaExpr run the matcher, 
otherwise traverse.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5581
@@ +5580,3 @@
+"  typedef PosVec *iterator;"
+"  typedef const PosVec *const_iterator;"
+"  iterator begin();"

All of this is kind of unnecessary for the test.
The function could just be:

```
PosVec& operator=(const PosVec&) {
  auto x = [] { return 1; };
  return *this;
}
```


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5596
@@ +5595,3 @@
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_FALSE(
+matches(

`EXPECT_TRUE(notMatches(...`


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5601
@@ +5600,3 @@
+ has(binaryOperator(hasOperatorName(">"));
+ llvm::errs()<<"d";
+}

Please add test cases for the changes suggested to the matcher.


http://reviews.llvm.org/D19357



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


Re: [PATCH] D19331: [Clang-tidy] Fix for crash in modernize-raw-string-literal check

2016-04-21 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266992: [Clang-tidy] Fix for crash in 
modernize-raw-string-literal check (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D19331?vs=54401&id=54504#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19331

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -108,7 +108,8 @@
 }
 
 void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(stringLiteral().bind("lit"), this);
+  Finder->addMatcher(
+  stringLiteral(unless(hasParent(predefinedExpr(.bind("lit"), this);
 }
 
 void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
@@ -91,6 +91,10 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw 
string literal
 // CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
 
+char const *const prettyFunction(__PRETTY_FUNCTION__);
+char const *const function(__FUNCTION__);
+char const *const func(__func__);
+
 #define TRICK(arg_) #arg_
 char const *const MacroBody = TRICK(foo\\bar);
 


Index: clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -108,7 +108,8 @@
 }
 
 void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(stringLiteral().bind("lit"), this);
+  Finder->addMatcher(
+  stringLiteral(unless(hasParent(predefinedExpr(.bind("lit"), this);
 }
 
 void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
@@ -91,6 +91,10 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal
 // CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
 
+char const *const prettyFunction(__PRETTY_FUNCTION__);
+char const *const function(__FUNCTION__);
+char const *const func(__func__);
+
 #define TRICK(arg_) #arg_
 char const *const MacroBody = TRICK(foo\\bar);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19194: fix for clang-tidy modernize-pass-by-value on copy constructor

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh requested changes to this revision.
alexfh added a reviewer: alexfh.
This revision now requires changes to proceed.


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:166
@@ -150,3 +165,3 @@
 hasDeclaration(cxxConstructorDecl(
-isCopyConstructor(), unless(isDeleted()),
+isNotCopyConstructor(),
 hasDeclContext(

You should use `unless(isCopyConstructor)` instead of creating a separate 
matcher.


http://reviews.llvm.org/D19194



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


Re: r266976 - Correctly parse GCC-style asm line following MS-style asm line.

2016-04-21 Thread Krzysztof Parzyszek via cfe-commits

On 4/21/2016 9:46 AM, Renato Golin wrote:

On 21 April 2016 at 14:58, Krzysztof Parzyszek via cfe-commits
 wrote:

Same thing on Hexagon:
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/37972


Trying to fix in r266993.


It worked!  Thanks!

-Krzysztof

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

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


Re: [PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:30
@@ +29,3 @@
+
+  Finder->addMatcher(implicitCastExpr(hasIntegerLiteralCastToBool,
+  unless(hasParent(explicitCastExpr(,

Adding two matchers that do almost the same checks is wasteful. You can do the 
same in a single matcher, which will do twice less work:

  implicitCastExpr(has(integerLiteral().bind("literal")),
   hasImplicitDestinationType(qualType(booleanType())),
   unless(isInTemplateInstantiation()),
   hasParent(anyOf(explicitCastExpr().bind("cast"), 
anything(

(if `anything()` here doesn't work, you can probably use `expr()` or something 
else).


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:56
@@ +55,3 @@
+   "converting integer literal to "
+   "bool%select{| inside a macro}0, use bool literal instead");
+

Can you explain, why is it important to note that this happens "inside a macro"?


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:58
@@ +57,3 @@
+
+  if (isPreprocessorDependent(Literal) || isPreprocessorDependent(Cast)) {
+Diag << 1;

I think, you can write `if (Cast) Literal = Cast;` and the rest of the code 
will be much shorter. Also, the `isPreprocessorDependent` doesn't seem to be 
needed.


http://reviews.llvm.org/D18745



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


Re: [PATCH] D19362: [ASTMatchers] Statically specify ownership of verifiers in tests. NFC

2016-04-21 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks !


http://reviews.llvm.org/D19362



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 54512.
courbet marked 4 inline comments as done.
courbet added a comment.

- add overridden_methods() to CXXMethodDecl and plumbing.
- Use range-based for loop for iterating over overridden methods.


http://reviews.llvm.org/D19324

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forStmt);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,12 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+const llvm::TinyPtrVector *
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this)) return nullptr;
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1259,32 +1259,30 @@
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.begin();
+  const auto* Overridden = overridden_methods(Method);
+  return Overridden == nullptr ? nullptr : Overridden->begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.end();
+

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Clement Courbet via cfe-commits
courbet marked an inline comment as done.
courbet added a comment.

http://reviews.llvm.org/D19324



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 54514.
courbet added a comment.

Regenerate doc.


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forStmt);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,12 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+const llvm::TinyPtrVector *
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this)) return nullptr;
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1259,32 +1259,30 @@
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.begin();
+  const auto* Overridden = overridden_methods(Method);
+  return Overridden == nullptr ? nullptr : Overridden->begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.end();
+  const auto* Overridden = overridden_methods(Method);
+  return Overridden == nullptr ? nullptr : Overridden->end

Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/ClangTidy.cpp:61
@@ -60,3 +60,3 @@
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "Checkers.inc"
 #undef CHECKER

As it is, the change leaves almost no context of where the Checkers.inc file 
comes from. I'd prefer to leave at least 
`lib/StaticAnalyzer/Checkers/Checkers.inc`. Will this work for you?

Another question is how do you deal with other .inc files generated from .td 
files in llvm/lib/... or llvm/tools/clang/lib/...?


http://reviews.llvm.org/D19249



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


Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-04-21 Thread Faisal Vali via cfe-commits
faisalv added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:175
@@ -152,2 +174,3 @@
+  Expr *RequiresClause;
 
 public:

Yuk - this entire guy (FizedSizeTemplateParameterListStorage) seems quite 
fragile (dependent on object layout) - are the gains (in the single use below 
during auto-type deduction) in preformance really worth the introduction of 
this fragility/ugliness? 
Unless there is a clear win from this strategy, I think i'd favor (perhaps in a 
later patch) - either just removing this structure and using TPL for the 
use-case in auto-type below, or using placement new and creating the stack TPL 
on a stack unsigned char array?
Thoughts?



http://reviews.llvm.org/D19322



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


Re: [PATCH] D19200: [clang-tidy] Cleanup some ast-matchers and lift some to utils.

2016-04-21 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 54522.
etienneb added a comment.

rebased, merge: http://reviews.llvm.org/D19262


http://reviews.llvm.org/D19200

Files:
  clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
  clang-tidy/misc/IncorrectRoundings.cpp
  clang-tidy/misc/MacroParenthesesCheck.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
  clang-tidy/misc/SizeofExpressionCheck.cpp
  clang-tidy/modernize/ShrinkToFitCheck.cpp
  clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/utils/Matchers.h

Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -17,6 +17,18 @@
 namespace tidy {
 namespace matchers {
 
+AST_MATCHER(BinaryOperator, isRelationalOperator) {
+  return Node.isRelationalOp();
+}
+
+AST_MATCHER(BinaryOperator, isEqualityOperator) {
+  return Node.isEqualityOp();
+}
+
+AST_MATCHER(BinaryOperator, isComparisonOperator) {
+  return Node.isComparisonOp();
+}
+
 AST_MATCHER(QualType, isExpensiveToCopy) {
   llvm::Optional IsExpensive =
   type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -19,16 +19,10 @@
 
 namespace {
 
-const internal::VariadicDynCastAllOfMatcher parenExpr;
-
 AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
   return Node.getCastKind() == Kind;
 }
 
-AST_MATCHER(QualType, isBool) {
-  return !Node.isNull() && Node->isBooleanType();
-}
-
 AST_MATCHER(Stmt, isMacroExpansion) {
   SourceManager &SM = Finder->getASTContext().getSourceManager();
   SourceLocation Loc = Node.getLocStart();
@@ -62,7 +56,7 @@
 allOf(anyOf(hasCastKind(CK_NullToPointer),
 hasCastKind(CK_NullToMemberPointer)),
   hasSourceExpression(cxxBoolLiteral(,
-  hasSourceExpression(expr(hasType(qualType(isBool());
+  hasSourceExpression(expr(hasType(qualType(booleanType());
 }
 
 StringRef
Index: clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -11,41 +11,11 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
+#include "../utils/Matchers.h"
 
 using namespace clang::ast_matchers;
 
-static bool isContainerName(llvm::StringRef ClassName) {
-  static const char *const ContainerNames[] = {"array",
-   "basic_string",
-   "deque",
-   "forward_list",
-   "list",
-   "map",
-   "multimap",
-   "multiset",
-   "priority_queue",
-   "queue",
-   "set",
-   "stack",
-   "unordered_map",
-   "unordered_multimap",
-   "unordered_multiset",
-   "unordered_set",
-   "vector"};
-  return std::binary_search(std::begin(ContainerNames),
-std::end(ContainerNames), ClassName);
-}
-
 namespace clang {
-namespace {
-AST_MATCHER(NamedDecl, stlContainer) {
-  if (!isContainerName(Node.getName()))
-return false;
-
-  return StringRef(Node.getQualifiedNameAsString()).startswith("std::");
-}
-} // namespace
-
 namespace tidy {
 namespace readability {
 
@@ -59,11 +29,15 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
+  const auto stlContainer = hasAnyName(
+  "array", "basic_string", "deque", "forward_list", "list", "map",
+  "multimap", "multiset", "priority_queue", "queue", "set", "stack",
+  "unordered_map", "unordered_multimap", "unordered_multiset",
+  "unordered_set", "vector");
+
   const auto WrongUse = anyOf(
   hasParent(binaryOperator(
-anyOf(hasOperatorName("<"), hasOperatorName(">="),
-  hasOperatorName(">"), hasOperatorName("<="),
-  hasOperatorName("=="), hasOperatorName("!=")),
+matchers::isComparisonOperator(),
 hasEitherOperand(ignoringImpCasts(anyOf(
  

Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-21 Thread Stephen Hines via cfe-commits
srhines added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:61
@@ -60,3 +60,3 @@
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "Checkers.inc"
 #undef CHECKER

alexfh wrote:
> As it is, the change leaves almost no context of where the Checkers.inc file 
> comes from. I'd prefer to leave at least 
> `lib/StaticAnalyzer/Checkers/Checkers.inc`. Will this work for you?
> 
> Another question is how do you deal with other .inc files generated from .td 
> files in llvm/lib/... or llvm/tools/clang/lib/...?
I think that the other .inc files have proper exported include paths so that 
you only include the final part of the name.

Looking at llvm/lib/Option/CMakeLists.txt, I see the following export o fthe 
includes:

  ADDITIONAL_HEADER_DIRS
  ${LLVM_MAIN_INCLUDE_DIR}/llvm/Option
  )

Should this export actually be happening in 
lib/StaticAnalyzer/Checkers/CMakeLists.txt? Even in that case, it will shorten 
down to just the final name, without any other part of the path (like you are 
requesting here).


http://reviews.llvm.org/D19249



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


[clang-tools-extra] r267003 - [clang-tidy] Cleanup some ast-matchers and lift some to utils.

2016-04-21 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr 21 11:57:56 2016
New Revision: 267003

URL: http://llvm.org/viewvc/llvm-project?rev=267003&view=rev
Log:
[clang-tidy] Cleanup some ast-matchers and lift some to utils.

Summary:
Little cleanup to lift-out and to remove some frequently used
ast-matchers.

Some of theses matchers are candidates to be lifted to ASTMatchers.h.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SizeofExpressionCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp?rev=267003&r1=267002&r2=267003&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp 
Thu Apr 21 11:57:56 2016
@@ -17,7 +17,6 @@ namespace {
 AST_MATCHER(CastExpr, isPointerToBoolean) {
   return Node.getCastKind() == CK_PointerToBoolean;
 }
-AST_MATCHER(QualType, isBoolean) { return Node->isBooleanType(); }
 
 } // namespace
 
@@ -31,7 +30,7 @@ void BoolPointerImplicitConversionCheck:
   ifStmt(hasCondition(findAll(implicitCastExpr(
  allOf(unless(hasParent(unaryOperator(hasOperatorName("!",
hasSourceExpression(expr(
-   hasType(pointerType(pointee(isBoolean(,
+   hasType(pointerType(pointee(booleanType(,
ignoringParenImpCasts(declRefExpr().bind("expr",
isPointerToBoolean(),
  unless(isInTemplateInstantiation())).bind("if"),

Modified: clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp?rev=267003&r1=267002&r2=267003&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp Thu Apr 21 
11:57:56 2016
@@ -24,11 +24,6 @@ AST_MATCHER(FloatingLiteral, floatHalf)
 return literal.convertToDouble() == 0.5;
   return false;
 }
-
-// TODO(hokein): Moving it to ASTMatchers.h
-AST_MATCHER(BuiltinType, isFloatingPoint) {
-  return Node.isFloatingPoint();
-}
 } // namespace ast_matchers
 } // namespace clang
 
@@ -42,7 +37,7 @@ void IncorrectRoundings::registerMatcher
   auto FloatHalf = floatLiteral(floatHalf());
 
   // Match a floating point expression.
-  auto FloatType = expr(hasType(builtinType(isFloatingPoint(;
+  auto FloatType = expr(hasType(realFloatingPointType()));
 
   // Match a floating literal of 0.5 or a floating literal of 0.5 implicitly.
   // cast to floating type.

Modified: clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp?rev=267003&r1=267002&r2=267003&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp Thu Apr 
21 11:57:56 2016
@@ -18,8 +18,8 @@ namespace tidy {
 namespace {
 class MacroParenthesesPPCallbacks : public PPCallbacks {
 public:
-  explicit MacroParenthesesPPCallbacks(Preprocessor *PP,
-   MacroParenthesesCheck *Check)
+  MacroParenthesesPPCallbacks(Preprocessor *PP,
+  MacroParenthesesCheck *Check)
   : PP(PP), Check(Check) {}
 
   void MacroDefined(const Token &MacroNameTok,

Modified: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp?rev=267003&r1=267002&r2=267003&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastChe

Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:23
@@ +22,3 @@
+  // Note: Right now we check only builtin types.
+  const auto BuiltinTypeWithId = [](const char *id) {
+return hasCanonicalType(builtinType().bind(id));

s/id/ID/g
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:39
@@ +38,3 @@
+  callee(functionDecl(
+  anyOf(hasName("::std::accumulate"), hasName("::std::reduce")),
+  hasParameter(0, parmVarDecl(hasType(hasCanonicalType(

Use the more effective `hasAnyName` matcher.


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:52
@@ +51,3 @@
+  hasName("::std::inner_product"),
+  hasParameter(0, parmVarDecl(hasType(hasCanonicalType(
+  IteratorWithValueType("IterValueType"),

You can pull a few common parts to local variables to make the code slightly 
shorter and easier to read:

  auto IteratorParam = 
parmVarDecl(hasType(hasCanonicalType(IteratorWithValueType("IterValueType";
  auto Iterator2Param = 
parmVarDecl(hasType(hasCanonicalType(IteratorWithValueType("Iter2ValueType";
  auto InitParam = parmVarDecl(hasType(BuiltinTypeWithId("InitType")));



Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:89
@@ +88,3 @@
+
+/// Returns true if ValueType is allowed to fold into InitType, i.e. if:
+///   static_cast(ValueType{some_value})

Is "fold" a commonly used term in this context? At least, it's not a language 
standard jargon and not something I heard of frequently. Maybe we should try to 
find a more clear word?


http://reviews.llvm.org/D18442



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


Re: [PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.

2016-04-21 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 54526.
etienneb marked 2 inline comments as done.
etienneb added a comment.

rebased


http://reviews.llvm.org/D18703

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-string-compare.rst
  test/clang-tidy/misc-suspicious-string-compare.c
  test/clang-tidy/misc-suspicious-string-compare.cpp

Index: test/clang-tidy/misc-suspicious-string-compare.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-string-compare.cpp
@@ -0,0 +1,299 @@
+// RUN: %check_clang_tidy %s misc-suspicious-string-compare %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: misc-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \
+// RUN:   {key: misc-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \
+// RUN: --
+
+typedef __SIZE_TYPE__ size;
+
+struct locale_t {
+  void* dummy;
+} locale;
+
+static const char A[] = "abc";
+static const unsigned char U[] = "abc";
+static const unsigned char V[] = "xyz";
+static const wchar_t W[] = L"abc";
+
+int memcmp(const void *, const void *, size);
+int wmemcmp(const wchar_t *, const wchar_t *, size);
+int memicmp(const void *, const void *, size);
+int _memicmp(const void *, const void *, size);
+int _memicmp_l(const void *, const void *, size, locale_t);
+
+int strcmp(const char *, const char *);
+int strncmp(const char *, const char *, size);
+int strcasecmp(const char *, const char *);
+int strncasecmp(const char *, const char *, size);
+int stricmp(const char *, const char *);
+int strcmpi(const char *, const char *);
+int strnicmp(const char *, const char *, size);
+int _stricmp(const char *, const char * );
+int _strnicmp(const char *, const char *, size);
+int _stricmp_l(const char *, const char *, locale_t);
+int _strnicmp_l(const char *, const char *, size, locale_t);
+
+int wcscmp(const wchar_t *, const wchar_t *);
+int wcsncmp(const wchar_t *, const wchar_t *, size);
+int wcscasecmp(const wchar_t *, const wchar_t *);
+int wcsicmp(const wchar_t *, const wchar_t *);
+int wcsnicmp(const wchar_t *, const wchar_t *, size);
+int _wcsicmp(const wchar_t *, const wchar_t *);
+int _wcsnicmp(const wchar_t *, const wchar_t *, size);
+int _wcsicmp_l(const wchar_t *, const wchar_t *, locale_t);
+int _wcsnicmp_l(const wchar_t *, const wchar_t *, size, locale_t);
+
+int _mbscmp(const unsigned char *, const unsigned char *);
+int _mbsncmp(const unsigned char *, const unsigned char *, size);
+int _mbsnbcmp(const unsigned char *, const unsigned char *, size);
+int _mbsnbicmp(const unsigned char *, const unsigned char *, size);
+int _mbsicmp(const unsigned char *, const unsigned char *);
+int _mbsnicmp(const unsigned char *, const unsigned char *, size);
+int _mbscmp_l(const unsigned char *, const unsigned char *, locale_t);
+int _mbsncmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsicmp_l(const unsigned char *, const unsigned char *, locale_t);
+int _mbsnicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsnbcmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsnbicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+
+int test_warning_patterns() {
+  if (strcmp(A, "a"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [misc-suspicious-string-compare]
+  // CHECK-FIXES: if (strcmp(A, "a") != 0)
+
+  if (strcmp(A, "a") == 0 ||
+  strcmp(A, "b"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
+  // CHECK-FIXES: strcmp(A, "b") != 0)
+
+  if (strcmp(A, "a") == 1)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") == -1)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") == true)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") < '0')
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") < 0.)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
+}
+
+int test_valid_patterns() {
+  // The following cases are valid.
+  if (strcmp(A, "a") < 0)
+return 0;
+  if (strcmp(A, "a") == 0)
+return 0;
+  if (strcmp(A, "a") <= 0)
+return 0;
+
+  if (wcscmp(W, L"a") < 0)
+return 0;
+  if (wcscmp(W, L"a") == 0)
+return 0;
+  if (wcscmp(W, L"a") <= 0)
+return 0;
+
+  return 1;
+}
+
+int test_implicit_compare

Re: [PATCH] D19194: fix for clang-tidy modernize-pass-by-value on copy constructor

2016-04-21 Thread Kamal Essoufi via cfe-commits
Kessoufi marked an inline comment as done.
Kessoufi added a comment.

Done


http://reviews.llvm.org/D19194



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


Re: [PATCH] D19194: fix for clang-tidy modernize-pass-by-value on copy constructor

2016-04-21 Thread Kamal Essoufi via cfe-commits
Kessoufi updated this revision to Diff 54524.
Kessoufi added a comment.

removed the redundant matcher


http://reviews.llvm.org/D19194

Files:
  clang-tidy/modernize/PassByValueCheck.cpp

Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -148,7 +148,7 @@
   nonConstValueType()
 .bind("Param",
 hasDeclaration(cxxConstructorDecl(
-isCopyConstructor(), unless(isDeleted()),
+unless(isCopyConstructor()),
 hasDeclContext(
 cxxRecordDecl(isMoveConstructible(
 .bind("Initializer")))


Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -148,7 +148,7 @@
   nonConstValueType()
 .bind("Param",
 hasDeclaration(cxxConstructorDecl(
-isCopyConstructor(), unless(isDeleted()),
+unless(isCopyConstructor()),
 hasDeclContext(
 cxxRecordDecl(isMoveConstructible(
 .bind("Initializer")))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19194: fix for clang-tidy modernize-pass-by-value on copy constructor

2016-04-21 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Now the problem is that the check changed behavior, but the tests are not 
updated. Do the tests still pass? If yes, we need to add tests for this 
behavior. If no, please fix the tests.


http://reviews.llvm.org/D19194



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


Re: [PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.

2016-04-21 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 54531.
etienneb added a comment.

fix integration


http://reviews.llvm.org/D18703

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-string-compare.rst
  test/clang-tidy/misc-suspicious-string-compare.c
  test/clang-tidy/misc-suspicious-string-compare.cpp

Index: test/clang-tidy/misc-suspicious-string-compare.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-string-compare.cpp
@@ -0,0 +1,299 @@
+// RUN: %check_clang_tidy %s misc-suspicious-string-compare %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: misc-suspicious-string-compare.WarnOnImplicitComparison, value: 1}, \
+// RUN:   {key: misc-suspicious-string-compare.WarnOnLogicalNotComparison, value: 1}]}' \
+// RUN: --
+
+typedef __SIZE_TYPE__ size;
+
+struct locale_t {
+  void* dummy;
+} locale;
+
+static const char A[] = "abc";
+static const unsigned char U[] = "abc";
+static const unsigned char V[] = "xyz";
+static const wchar_t W[] = L"abc";
+
+int memcmp(const void *, const void *, size);
+int wmemcmp(const wchar_t *, const wchar_t *, size);
+int memicmp(const void *, const void *, size);
+int _memicmp(const void *, const void *, size);
+int _memicmp_l(const void *, const void *, size, locale_t);
+
+int strcmp(const char *, const char *);
+int strncmp(const char *, const char *, size);
+int strcasecmp(const char *, const char *);
+int strncasecmp(const char *, const char *, size);
+int stricmp(const char *, const char *);
+int strcmpi(const char *, const char *);
+int strnicmp(const char *, const char *, size);
+int _stricmp(const char *, const char * );
+int _strnicmp(const char *, const char *, size);
+int _stricmp_l(const char *, const char *, locale_t);
+int _strnicmp_l(const char *, const char *, size, locale_t);
+
+int wcscmp(const wchar_t *, const wchar_t *);
+int wcsncmp(const wchar_t *, const wchar_t *, size);
+int wcscasecmp(const wchar_t *, const wchar_t *);
+int wcsicmp(const wchar_t *, const wchar_t *);
+int wcsnicmp(const wchar_t *, const wchar_t *, size);
+int _wcsicmp(const wchar_t *, const wchar_t *);
+int _wcsnicmp(const wchar_t *, const wchar_t *, size);
+int _wcsicmp_l(const wchar_t *, const wchar_t *, locale_t);
+int _wcsnicmp_l(const wchar_t *, const wchar_t *, size, locale_t);
+
+int _mbscmp(const unsigned char *, const unsigned char *);
+int _mbsncmp(const unsigned char *, const unsigned char *, size);
+int _mbsnbcmp(const unsigned char *, const unsigned char *, size);
+int _mbsnbicmp(const unsigned char *, const unsigned char *, size);
+int _mbsicmp(const unsigned char *, const unsigned char *);
+int _mbsnicmp(const unsigned char *, const unsigned char *, size);
+int _mbscmp_l(const unsigned char *, const unsigned char *, locale_t);
+int _mbsncmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsicmp_l(const unsigned char *, const unsigned char *, locale_t);
+int _mbsnicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsnbcmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+int _mbsnbicmp_l(const unsigned char *, const unsigned char *, size, locale_t);
+
+int test_warning_patterns() {
+  if (strcmp(A, "a"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [misc-suspicious-string-compare]
+  // CHECK-FIXES: if (strcmp(A, "a") != 0)
+
+  if (strcmp(A, "a") == 0 ||
+  strcmp(A, "b"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
+  // CHECK-FIXES: strcmp(A, "b") != 0)
+
+  if (strcmp(A, "a") == 1)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") == -1)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") == true)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") < '0')
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (strcmp(A, "a") < 0.)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
+}
+
+int test_valid_patterns() {
+  // The following cases are valid.
+  if (strcmp(A, "a") < 0)
+return 0;
+  if (strcmp(A, "a") == 0)
+return 0;
+  if (strcmp(A, "a") <= 0)
+return 0;
+
+  if (wcscmp(W, L"a") < 0)
+return 0;
+  if (wcscmp(W, L"a") == 0)
+return 0;
+  if (wcscmp(W, L"a") <= 0)
+return 0;
+
+  return 1;
+}
+
+int test_implicit_compare_with_functions() {
+
+  if (memcmp

Re: [PATCH] D19299: lower __builtin_expect() directly to prof metadata instead of LLVM intrinsic

2016-04-21 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D19299



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


[clang-tools-extra] r267009 - [clang-tidy] Add new checker for comparison with runtime string functions.

2016-04-21 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr 21 12:19:36 2016
New Revision: 267009

URL: http://llvm.org/viewvc/llvm-project?rev=267009&view=rev
Log:
[clang-tidy] Add new checker for comparison with runtime string functions.

Summary:
This checker is validating suspicious usage of string compare functions.

Example:
```
  if (strcmp(...))   // Implicitly compare to zero
  if (!strcmp(...))  // Won't warn
  if (strcmp(...) != 0)  // Won't warn
```

This patch was checked over large amount of code.
There is three checks:
  [*] Implicit comparator to zero (coding-style, many warnings found),
  [*] Suspicious implicit cast to non-integral (bugs!?, almost none found),
  [*] Comparison to suspicious constant (bugs!?, found two cases),

Example:
[[https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c
 |
https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c]]

```
  else if(strcmp(id, "select") == 0)
  {
 array->array[i].key1 = 25;
  }
  else if(strcmp(id, "sk") == 28)  // BUG!?
  {
 array->array[i].key1 = 20;
  }
```

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-string-compare.rst
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.c
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.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=267009&r1=267008&r2=267009&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Apr 21 12:19:36 
2016
@@ -29,6 +29,7 @@ add_clang_library(clangTidyMiscModule
   StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp
+  SuspiciousStringCompareCheck.cpp
   SwappedArgumentsCheck.cpp
   ThrowByValueCatchByReferenceCheck.cpp
   UndelegatedConstructor.cpp

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=267009&r1=267008&r2=267009&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Thu Apr 21 
12:19:36 2016
@@ -37,6 +37,7 @@
 #include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
+#include "SuspiciousStringCompareCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "ThrowByValueCatchByReferenceCheck.h"
 #include "UndelegatedConstructor.h"
@@ -106,6 +107,8 @@ public:
 "misc-suspicious-missing-comma");
 CheckFactories.registerCheck(
 "misc-suspicious-semicolon");
+CheckFactories.registerCheck(
+"misc-suspicious-string-compare");
 CheckFactories.registerCheck(
 "misc-swapped-arguments");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp?rev=267009&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
Thu Apr 21 12:19:36 2016
@@ -0,0 +1,221 @@
+//===--- SuspiciousStringCompareCheck.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 "SuspiciousStringCompareCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+AST_MATCHER(BinaryOperator, isComparisonOperator) {
+  return Node.isComparisonOp();
+}
+
+constexpr char

Re: [PATCH] D19146: [clang-tidy] New checker to detect suspicious string constructor.

2016-04-21 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 54532.
etienneb added a comment.

rebased


http://reviews.llvm.org/D19146

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringConstructorCheck.cpp
  clang-tidy/misc/StringConstructorCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-constructor.rst
  test/clang-tidy/misc-string-constructor.cpp

Index: test/clang-tidy/misc-string-constructor.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-constructor.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s misc-string-constructor %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator >
+struct basic_string {
+  basic_string();
+  basic_string(const C*, unsigned int size);
+  basic_string(unsigned int size, C c);
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+const char* kText = "";
+const char kText2[] = "";
+extern const char kText3[];
+
+void Test() {
+  std::string str('x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
+  std::wstring wstr(L'x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
+  std::string s0(0, 'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
+  std::string s1(-4, 'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
+  std::string s2(0x100, 'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+  
+  std::string q0("test", 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
+  std::string q1(kText, -4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
+  std::string q2("test", 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+  std::string q3(kText, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+  std::string q4(kText2, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+  std::string q5(kText3,  0x100);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+}
+
+void Valid() {
+  std::string empty();
+  std::string str(4, 'x');
+  std::wstring wstr(4, L'x');
+  std::string s1("test", 4);
+  std::string s2("test", 3);
+}
Index: docs/clang-tidy/checks/misc-string-constructor.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-constructor.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - misc-string-constructor
+
+misc-string-constructor
+===
+
+Finds string constructors that are suspicious and probably errors.
+
+
+A common mistake is to swap parameters to the 'fill' string-constructor.
+
+Examples:
+
+.. code:: c++
+
+  std::string('x', 50) str; // should be std::string(50, 'x') 
+
+
+Calling the string-literal constructor with a length bigger than the literal is
+suspicious and adds extra random characters to the string.
+
+Examples:
+
+.. code:: c++
+
+  std::string("test", 200);   // Will include random characters after "test".
+
+
+Creating an empty string from constructors with parameters is considered
+suspicious. The programmer should use the empty constructor instead.
+
+Examples:
+
+.. code:: c++
+
+  std::string("test", 0);   // Creation of an empty string.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
+   misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
misc-suspicious-missing-comma
Index: clang-tidy/misc/StringConstructorCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringConstructorCheck.h
@@ -0,0 +1,39 @@
+//===--- StringConstructorCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds suspicious string constructor and check their parameters.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-st

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-21 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: lib/AST/ASTContext.cpp:1279
@@ -1282,1 +1278,3 @@
+const ASTContext::CXXMethodVector *
+ASTContext::overridden_methods(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos

It would be simpler to return `ArrayRef`.
That way the caller doesn't need to deal with a potential null pointer or with 
the custom vector type.


http://reviews.llvm.org/D19324



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


[clang-tools-extra] r267011 - [clang-tidy] New checker to detect suspicious string constructor.

2016-04-21 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr 21 12:28:08 2016
New Revision: 267011

URL: http://llvm.org/viewvc/llvm-project?rev=267011&view=rev
Log:
[clang-tidy] New checker to detect suspicious string constructor.

Summary:
Checker to validate string constructor parameters.

A common mistake is to swap parameter for the fill-constructor.
```
  std::string str('x', 4);
  std::string str('4', x);
```

Reviewers: alexfh

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst
clang-tools-extra/trunk/test/clang-tidy/misc-string-constructor.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=267011&r1=267010&r2=267011&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Apr 21 12:28:08 
2016
@@ -25,6 +25,7 @@ add_clang_library(clangTidyMiscModule
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp
   StaticAssertCheck.cpp
+  StringConstructorCheck.cpp
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousMissingCommaCheck.cpp

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=267011&r1=267010&r2=267011&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Thu Apr 21 
12:28:08 2016
@@ -33,6 +33,7 @@
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
 #include "StaticAssertCheck.h"
+#include "StringConstructorCheck.h"
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
@@ -99,6 +100,8 @@ public:
 "misc-sizeof-expression");
 CheckFactories.registerCheck(
 "misc-static-assert");
+CheckFactories.registerCheck(
+"misc-string-constructor");
 CheckFactories.registerCheck(
 "misc-string-integer-assignment");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.cpp?rev=267011&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.cpp Thu Apr 
21 12:28:08 2016
@@ -0,0 +1,126 @@
+//===--- StringConstructorCheck.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 "StringConstructorCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
+  return Node.getValue().getZExtValue() > N;
+}
+
+StringConstructorCheck::StringConstructorCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  WarnOnLargeLength(Options.get("WarnOnLargeLength", 1) != 0),
+  LargeLengthThreshold(Options.get("LargeLengthThreshold", 0x80)) {}
+
+void StringConstructorCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WarnOnLargeLength", WarnOnLargeLength);
+  Options.store(Opts, "LargeLengthThreshold", LargeLengthThreshold);
+}
+
+void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  const auto ZeroExpr = expr(ignoringParenImpCasts(integerLiteral(equals(0;
+  const auto CharExpr = expr(ignoringParenImpCasts(characterLiteral()));
+  const auto NegativeExpr = expr(ignoringParenImpCasts(
+  unaryOperator(hasOperatorName("-"),
+hasUnaryOperand(integerLiteral(unless(equals(0)));
+  const auto LargeLengthExpr = expr(ignoringParenImpCasts(
+  integerLiteral(isBig

Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-21 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Frontend/InitPreprocessor.cpp:418
@@ +417,3 @@
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __CLANG_OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.

CLANG_OPENCL_C_VERSION -> OPENCL_C_VERSION


Comment at: test/Frontend/stdlang.c:11
@@ -3,2 +10,3 @@
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 // expected-no-diagnostics
 

I still think that "// expected-no-diagnostics" is not needed here as we don't 
pass -verify.


http://reviews.llvm.org/D19071



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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-21 Thread Rong Xu via cfe-commits
I tried D17864 and D18624 with the latest trunk of r267006 on a clean
client.
The built compiler works fine with povray.

the meta data only has the files name.

How did you build povray?
can you show me your command line in building (for example, csg.cpp) for
both--fprofile-instr-use and -fprofile-instr-generate?


On Wed, Apr 20, 2016 at 4:41 PM, Adam Nemet  wrote:

> anemet added a comment.
>
> Rong, do you have full paths or just the filename?
>
>
> http://reviews.llvm.org/D18624
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-21 Thread Rong Xu via cfe-commits
xur added a comment.

I tried http://reviews.llvm.org/D17864 and http://reviews.llvm.org/D18624 with 
the latest trunk of r267006 on a clean
client.
The built compiler works fine with povray.

the meta data only has the files name.

How did you build povray?
can you show me your command line in building (for example, csg.cpp) for
both--fprofile-instr-use and -fprofile-instr-generate?


http://reviews.llvm.org/D18624



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


[PATCH] D19379: [clang-tidy] Fix broken build bot.

2016-04-21 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

There is a build bot that doesn't support 'constexpr'.

```
FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32 
/D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 
-wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 
-wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 
-wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi /Zc:rvalueCast /MD /O2 /Ob2 
-Itools\clang\tools\extra\clang-tidy\misc 
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc
 -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include 
-Itools\clang\include -Iinclude 
-ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR- 
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER 
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
/Fotools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\SuspiciousStringCompareCheck.cpp.obj
 /Fdtools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\ 
/FS -c 
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25)
 : error C2144: syntax error : 'char' should be preceded by ';'
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25)
 : error C4430: missing type specifier - int assumed. Note: C++ does not 
support default-int
ninja: build stopped: subcommand failed.
program finished with exit code 1
```

http://reviews.llvm.org/D19379

Files:
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp

Index: clang-tidy/misc/SuspiciousStringCompareCheck.cpp
===
--- clang-tidy/misc/SuspiciousStringCompareCheck.cpp
+++ clang-tidy/misc/SuspiciousStringCompareCheck.cpp
@@ -22,50 +22,50 @@
   return Node.isComparisonOp();
 }
 
-constexpr char KnownStringCompareFunctions[] = "__builtin_memcmp;"
-   "__builtin_strcasecmp;"
-   "__builtin_strcmp;"
-   "__builtin_strncasecmp;"
-   "__builtin_strncmp;"
-   "_mbscmp;"
-   "_mbscmp_l;"
-   "_mbsicmp;"
-   "_mbsicmp_l;"
-   "_mbsnbcmp;"
-   "_mbsnbcmp_l;"
-   "_mbsnbicmp;"
-   "_mbsnbicmp_l;"
-   "_mbsncmp;"
-   "_mbsncmp_l;"
-   "_mbsnicmp;"
-   "_mbsnicmp_l;"
-   "_memicmp;"
-   "_memicmp_l;"
-   "_stricmp;"
-   "_stricmp_l;"
-   "_strnicmp;"
-   "_strnicmp_l;"
-   "_wcsicmp;"
-   "_wcsicmp_l;"
-   "_wcsnicmp;"
-   "_wcsnicmp_l;"
-   "lstrcmp;"
-   "lstrcmpi;"
-   "memcmp;"
-   "memicmp;"
-   "strcasecmp;"
-   "strcmp;"
-   "strcmpi;"
-   "stricmp;"
-   "strncasecmp;"
-   "strncmp;"
-   "strnicmp;"
-   "wcscasecmp;"
-   "wcscmp;"
-  

[clang-tools-extra] r267026 - [Release Notes] Mention Clang-tidy misc-string-constructor and misc-suspicious-string-compare checks.

2016-04-21 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Apr 21 13:13:09 2016
New Revision: 267026

URL: http://llvm.org/viewvc/llvm-project?rev=267026&view=rev
Log:
[Release Notes] Mention Clang-tidy misc-string-constructor and 
misc-suspicious-string-compare checks.

Fix excessive line in misc-string-constructor documentation.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=267026&r1=267025&r2=267026&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Apr 21 13:13:09 2016
@@ -118,6 +118,11 @@ identified.  The improvements since the
 
   Warns about incorrect uses of ``sizeof`` operator.
 
+- New `misc-string-constructor
+  
`_ 
check
+
+  Finds string constructors that are suspicious and probably errors.
+
 - New `misc-string-literal-with-embedded-nul
   
`_
 check
 
@@ -135,6 +140,11 @@ identified.  The improvements since the
   Finds most instances of stray semicolons that unexpectedly alter the meaning
   of the code.
 
+- New `misc-suspicious-string-compare
+  
`_
 check
+
+  Find suspicious usage of runtime string comparison functions.
+
 - New `misc-unused-using-decls
   
`_ 
check
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst?rev=267026&r1=267025&r2=267026&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-constructor.rst 
Thu Apr 21 13:13:09 2016
@@ -5,7 +5,6 @@ misc-string-constructor
 
 Finds string constructors that are suspicious and probably errors.
 
-
 A common mistake is to swap parameters to the 'fill' string-constructor.
 
 Examples:


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


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-21 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 54552.
yaxunl added a comment.

Revised as Anastasia suggested.


http://reviews.llvm.org/D19071

Files:
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Frontend/std.cl
  test/Frontend/stdlang.c
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -146,3 +146,36 @@
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK-SYNC_CAS_MIPS32-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK-SYNC_CAS_MIPS64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// CHECK-CL10: #define CL_VERSION_1_0 100
+// CHECK-CL10: #define CL_VERSION_1_1 110
+// CHECK-CL10: #define CL_VERSION_1_2 120
+// CHECK-CL10: #define CL_VERSION_2_0 200
+// CHECK-CL10: #define __OPENCL_C_VERSION__ 100
+// CHECK-CL11: #define CL_VERSION_1_0 100
+// CHECK-CL11: #define CL_VERSION_1_1 110
+// CHECK-CL11: #define CL_VERSION_1_2 120
+// CHECK-CL11: #define CL_VERSION_2_0 200
+// CHECK-CL11: #define __OPENCL_C_VERSION__ 110
+// CHECK-CL12: #define CL_VERSION_1_0 100
+// CHECK-CL12: #define CL_VERSION_1_1 110
+// CHECK-CL12: #define CL_VERSION_1_2 120
+// CHECK-CL12: #define CL_VERSION_2_0 200
+// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
+// CHECK-CL20: #define CL_VERSION_1_0 100
+// CHECK-CL20: #define CL_VERSION_1_1 110
+// CHECK-CL20: #define CL_VERSION_1_2 120
+// CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+
Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
-// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
 #if defined(CUDA)
   __attribute__((device)) void f_device();
Index: test/Frontend/std.cl
===
--- test/Frontend/std.cl
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
-// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | FileCheck %s
-
-#ifdef INVALID 
-// CHECK: invalid value 'invalid' in '-cl-std=invalid'
-#endif
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -408,6 +408,39 @@
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VER

[clang-tools-extra] r267027 - [clang-tidy] Fix broken build bot.

2016-04-21 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr 21 13:15:35 2016
New Revision: 267027

URL: http://llvm.org/viewvc/llvm-project?rev=267027&view=rev
Log:
[clang-tidy] Fix broken build bot.

Summary:
There is a build bot that doesn't support 'constexpr'.

```
FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32 
/D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 
-wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 
-wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 
-wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi /Zc:rvalueCast /MD /O2 /Ob2 
-Itools\clang\tools\extra\clang-tidy\misc 
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc
 -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include 
-Itools\clang\include -Iinclude 
-ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR- 
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER 
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_DEBUG_POINTER_IMPL
 ="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE 
-D_SCL_SECURE_NO_WARNINGS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
/Fotools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\SuspiciousStringCompareCheck.cpp.obj
 /Fdtools\clang\tools\extra\clang-tidy\misc\CMakeFiles\clangTidyMiscModule.dir\ 
/FS -c 
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25)
 : error C2144: syntax error : 'char' should be preceded by ';'
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\misc\SuspiciousStringCompareCheck.cpp(25)
 : error C4430: missing type specifier - int assumed. Note: C++ does not 
support default-int
ninja: build stopped: subcommand failed.
program finished with exit code 1
```

Reviewers: alexfh, sbenza

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp?rev=267027&r1=267026&r2=267027&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
Thu Apr 21 13:15:35 2016
@@ -22,50 +22,50 @@ AST_MATCHER(BinaryOperator, isComparison
   return Node.isComparisonOp();
 }
 
-constexpr char KnownStringCompareFunctions[] = "__builtin_memcmp;"
-   "__builtin_strcasecmp;"
-   "__builtin_strcmp;"
-   "__builtin_strncasecmp;"
-   "__builtin_strncmp;"
-   "_mbscmp;"
-   "_mbscmp_l;"
-   "_mbsicmp;"
-   "_mbsicmp_l;"
-   "_mbsnbcmp;"
-   "_mbsnbcmp_l;"
-   "_mbsnbicmp;"
-   "_mbsnbicmp_l;"
-   "_mbsncmp;"
-   "_mbsncmp_l;"
-   "_mbsnicmp;"
-   "_mbsnicmp_l;"
-   "_memicmp;"
-   "_memicmp_l;"
-   "_stricmp;"
-   "_stricmp_l;"
-   "_strnicmp;"
-   "_strnicmp_l;"
-   "_wcsicmp;"
-   "_wcsicmp_l;"
-   "_wcsnicmp;"
-   "_wcsnicmp_l;"
-   "lstrcmp;"
-   "lstrcmpi;"
-   "memcmp;"
-   "memicmp;"
-  

Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-21 Thread Adam Nemet via cfe-commits
anemet added a comment.

> How did you build povray?

>  can you show me your command line in building (for example, csg.cpp) for

>  both--fprofile-instr-use and -fprofile-instr-generate?


Sent it in an email.


http://reviews.llvm.org/D18624



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


Re: [PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2016-04-21 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Sorry about the long delay in reviewing this. @eugenis Are you still 
able/willing to proceed with this?


Repository:
  rL LLVM

http://reviews.llvm.org/D14411



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


[PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-21 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: caomhin, cfe-commits.

This patch adds logic to save the components of mappable expressions in the 
clause that uses it, so that they don't have to be recomputed during codegen. 
Given that the mappable components are (will be) used in several clauses a new 
geneneric implementation `OMPMappableExprListClause` is used that extends the 
existing `OMPVarListClause`.

This patch does not add new tests. The goal is to preserve the existing 
functionality while storing more info in the clauses.

http://reviews.llvm.org/D19382

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -2021,13 +2021,26 @@
 
 void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
   Record.push_back(C->varlist_size());
+  Record.push_back(C->getUniqueDeclarationsNum());
+  Record.push_back(C->getTotalComponentListNum());
+  Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
   Record.push_back(C->getMapTypeModifier());
   Record.push_back(C->getMapType());
   Record.AddSourceLocation(C->getMapLoc());
   Record.AddSourceLocation(C->getColonLoc());
-  for (auto *VE : C->varlists())
-Record.AddStmt(VE);
+  for (auto *E : C->varlists())
+Record.AddStmt(E);
+  for (auto *D : C->all_decls())
+Record.AddDeclRef(D);
+  for (auto N : C->all_num_lists())
+Record.push_back(N);
+  for (auto N : C->all_lists_sizes())
+Record.push_back(N);
+  for (auto &M : C->all_components()) {
+Record.AddStmt(M.getAssociatedExpression());
+Record.AddDeclRef(M.getAssociatedDeclaration());
+  }
 }
 
 void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1861,9 +1861,14 @@
   case OMPC_device:
 C = new (Context) OMPDeviceClause();
 break;
-  case OMPC_map:
-C = OMPMapClause::CreateEmpty(Context, Record[Idx++]);
-break;
+  case OMPC_map: {
+unsigned NumVars = Record[Idx++];
+unsigned NumDeclarations = Record[Idx++];
+unsigned NumLists = Record[Idx++];
+unsigned NumComponents = Record[Idx++];
+C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+  NumComponents);
+  } break;
   case OMPC_num_teams:
 C = new (Context) OMPNumTeamsClause();
 break;
@@ -2225,12 +2230,45 @@
   C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
   auto NumVars = C->varlist_size();
+  auto UniqueDecls = C->getUniqueDeclarationsNum();
+  auto TotalLists = C->getTotalComponentListNum();
+  auto TotalComponents = C->getTotalComponentsNum();
+
   SmallVector Vars;
   Vars.reserve(NumVars);
-  for (unsigned i = 0; i != NumVars; ++i) {
+  for (unsigned i = 0; i != NumVars; ++i)
 Vars.push_back(Reader->Reader.ReadSubExpr());
-  }
   C->setVarRefs(Vars);
+
+  SmallVector Decls;
+  Decls.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+Decls.push_back(
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx));
+  C->setUniqueDecls(Decls);
+
+  SmallVector ListsPerDecl;
+  ListsPerDecl.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+ListsPerDecl.push_back(Record[Idx++]);
+  C->setDeclNumLists(ListsPerDecl);
+
+  SmallVector ListSizes;
+  ListSizes.reserve(TotalLists);
+  for (unsigned i = 0; i < TotalLists; ++i)
+ListSizes.push_back(Record[Idx++]);
+  C->setComponentListSizes(ListSizes);
+
+  SmallVector Components;
+  Components.reserve(TotalComponents);
+  for (unsigned i = 0; i < TotalComponents; ++i) {
+Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
+ValueDecl *AssociatedDecl =
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx);
+Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+AssociatedExpr, AssociatedDecl));
+  }
+  C->setComponents(Components, ListSizes);
 }
 
 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -81,8 +81,6 @@
   };
 
 private:
-  typedef SmallVector MapInfo;
-
   struct DSAInfo {
 OpenMPClauseKind Attributes;
 Expr *RefExpr;
@@ -92,14 +90,16 @@
   typedef llvm::DenseMap AlignedMapTy;
   typedef std::pair LCDeclInfo;
   typedef llvm::DenseMap LoopControlVariablesMapTy;
-  typedef llvm::DenseMap MappedD

Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-21 Thread Rong Xu via cfe-commits
I was using spec-run where the command line has the pathless filename.

The source in Atam's command-line has the absolute path.
In meta-data creation, we used Module's getSourceFileName() which has the
source name appeared in the command line (in this case, a full patch name).

While in Clang's setFuncName, it uses CGM.getCodeGenOpts().MainFileName.
This string strips the path from the source.

I can expand function createPGOFuncNameMetadata() to handle this (I mean
using the stripped name).

But I need to point out that stripping the patch may not a good idea as it
greatly increases the change name conflicts:
If we have
static bar() in dir1/foo.c
and
static bar() in dir2/foo.c

if the user compiler with:
> clang ... dir1/foo.c
> clang ... dir2/foo.c
With Clang's scheme, both functions would have PGOFuncName of foo.c:bar().
In IR instrumentation, we will have different name in this case:
dir1/foo.c:bar(), and dir2/foo.c:bar()

Of course, if the user compiles the code the following way:
> cd dir1; clang foo.c
>cd ../dir2; clang foo.c
we will have conflict for both instrumentation.
In this case, we can suggestion the user to have the relative path in the
build line.



On Thu, Apr 21, 2016 at 11:23 AM, Adam Nemet  wrote:

> anemet added a comment.
>
> > How did you build povray?
>
> >  can you show me your command line in building (for example, csg.cpp) for
>
> >  both--fprofile-instr-use and -fprofile-instr-generate?
>
>
> Sent it in an email.
>
>
> http://reviews.llvm.org/D18624
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-21 Thread Rong Xu via cfe-commits
xur added a comment.

I was using spec-run where the command line has the pathless filename.

The source in Atam's command-line has the absolute path.
In meta-data creation, we used Module's getSourceFileName() which has the
source name appeared in the command line (in this case, a full patch name).

While in Clang's setFuncName, it uses CGM.getCodeGenOpts().MainFileName.
This string strips the path from the source.

I can expand function createPGOFuncNameMetadata() to handle this (I mean
using the stripped name).

But I need to point out that stripping the patch may not a good idea as it
greatly increases the change name conflicts:
If we have
static bar() in dir1/foo.c
and
static bar() in dir2/foo.c

if the user compiler with:

> clang ... dir1/foo.c

>  clang ... dir2/foo.c


With Clang's scheme, both functions would have PGOFuncName of foo.c:bar().
In IR instrumentation, we will have different name in this case:
dir1/foo.c:bar(), and dir2/foo.c:bar()

Of course, if the user compiles the code the following way:

> cd dir1; clang foo.c

> cd ../dir2; clang foo.c


we will have conflict for both instrumentation.
In this case, we can suggestion the user to have the relative path in the
build line.


http://reviews.llvm.org/D18624



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-04-21 Thread Steven Wu via cfe-commits
steven_wu updated this revision to Diff 54559.
steven_wu added a comment.

Ping.

Rebase the patch over trunk and tweak the testcase.


http://reviews.llvm.org/D17392

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/embed-bitcode.c
  test/Frontend/embed-bitcode.ll

Index: test/Frontend/embed-bitcode.ll
===
--- /dev/null
+++ test/Frontend/embed-bitcode.ll
@@ -0,0 +1,59 @@
+; REQUIRES: arm-registered-target
+; REQUIRES: aarch64-registered-target
+; check .ll input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+; RUN: %clang_cc1 -triple aarch64-unknown-linux-gnueabi -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ELF
+
+; check .bc input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-x ir %s -o %t.bc
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %t.bc -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=bitcode -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ONLY-BITCODE
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+
+; run through -fembed-bitcode twice and make sure it doesn't crash
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir - -o /dev/null
+
+; check the magic number of bitcode at the beginning of the string
+; CHECK: @llvm.embedded.module
+; CHECK: c"\DE\C0\17\0B
+; CHECK: section "__LLVM,__bitcode"
+; CHECK: @llvm.cmdline
+; CHECK: section "__LLVM,__cmdline"
+
+; CHECK-ELF: @llvm.embedded.module
+; CHECK-ELF: section ".llvmbc"
+; CHECK-ELF: @llvm.cmdline
+; CHECK-ELF: section ".llvmcmd"
+
+; CHECK-ONLY-BITCODE: @llvm.embedded.module
+; CHECK-ONLY-BITCODE: c"\DE\C0\17\0B
+; CHECK-ONLY-BITCODE: section "__LLVM,__bitcode"
+; CHECK-ONLY-BITCODE-NOT: @llvm.cmdline
+; CHECK-ONLY-BITCODE-NOT: section "__LLVM,__cmdline"
+
+; CHECK-MARKER: @llvm.embedded.module
+; CHECK-MARKER: constant [0 x i8] zeroinitializer
+; CHECK-MARKER: section "__LLVM,__bitcode"
+; CHECK-MARKER: @llvm.cmdline
+; CHECK-MARKER: section "__LLVM,__cmdline"
+
+define i32 @f0() {
+  ret i32 0
+}
Index: test/Driver/embed-bitcode.c
===
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -7,28 +7,35 @@
 // CHECK-CC: -emit-llvm-bc
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-obj
-// CHECK-CC: -fembed-bitcode
+// CHECK-CC: -fembed-bitcode=all
 
+// RUN: %clang %s -c -fembed-bitcode=bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-BITCODE
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-llvm-bc
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-obj
+// CHECK-BITCODE: -fembed-bitcode=bitcode
+//
 // RUN: %clang %s -c -save-temps -fembed-bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-SAVE-TEMP
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -E
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -emit-llvm-bc
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -S
-// CHECK-SAVE-TEMP: -fembed-bitcode
+// CHECK-SAVE-TEMP: -fembed-bitcode=all
 // CHECK-SAVE-TEMP: -cc1as
 
 // RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
 // CHECK-LTO: -cc1
 // CHECK-LTO: -emit-llvm-bc
 // CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
 // CHECK-LTO-NOT: -cc1
-// CHECK-LTO-NOT: -fembed-bitcode
+// CHECK-LTO-NOT: -fembed-bitcode=all
 
 // RUN: %clang -c %s -fembed-bitcode-marker -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-MARKER
 // CHECK-MARKER: -cc1
 // CHECK-MARKER: -emit-obj
-// CHECK-MARKER: -fembed-bitcode-marker
+// CHECK-MARKER: -fembed-bitcode=marker
 // CHECK-MARKER-NOT: -cc1
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -635,6 +635,47 @@
   }
 }
   }
+	// Handle -fembed-bitcode option.
+  if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
+StringRef Name = A->getValue();
+unsigned Model = llvm::StringSwitc

Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-04-21 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4393-4431
@@ +4392,41 @@
+/// retrieved from the provided map clause expression.
+DeclarationMapInfoEntry(const Expr *MCE, OpenMPMapClauseKind MapType,
+OpenMPMapClauseKind MapTypeModifier)
+: MapType(MapType), MapTypeModifier(MapTypeModifier) {
+  assert(MCE && "Invalid expression??");
+  while (true) {
+MCE = MCE->IgnoreParenImpCasts();
+
+if (auto *CurE = dyn_cast(MCE)) {
+  Components.push_back(
+  ComponentTy(CurE, cast(CurE->getDecl(;
+  break;
+}
+
+if (auto *CurE = dyn_cast(MCE)) {
+  auto *BaseE = CurE->getBase()->IgnoreParenImpCasts();
+
+  Components.push_back(
+  ComponentTy(CurE, cast(CurE->getMemberDecl(;
+  if (isa(BaseE))
+break;
+
+  MCE = BaseE;
+  continue;
+}
+
+if (auto *CurE = dyn_cast(MCE)) {
+  Components.push_back(ComponentTy(CurE, nullptr));
+  MCE = CurE->getBase()->IgnoreParenImpCasts();
+  continue;
+}
+
+if (auto *CurE = dyn_cast(MCE)) {
+  Components.push_back(ComponentTy(CurE, nullptr));
+  MCE = CurE->getBase()->IgnoreParenImpCasts();
+  continue;
+}
+
+llvm_unreachable("Invalid map clause expression!");
+  }
+}

ABataev wrote:
> I do recall that similar code already exists in Sema. Maybe you'd better to 
> store info about top-level bases in map clause in Sema rather than copy the 
> code between modules?
Yes, Sema does something similar. In the last diff I use what Sema produces and 
store it in the clause. The implementation is in the dependence diff.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4462
@@ +4461,3 @@
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy = OMPArraySectionExpr::getBaseOriginalType(
+OAE->getBase()->IgnoreParenImpCasts())

ABataev wrote:
> Replace 'auto' by 'QualType'. Also, I think all such deep digging into 
> structure of expressions must reside in Sema rather than in codegen and info 
> must be stored within OMPMapClause
Done. The information is now stored in the map clause.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4493-4498
@@ +4492,8 @@
+
+  /// \brief Generate the address of the lower bound of the section defined by
+  /// expression \a E.
+  llvm::Value *getLowerBoundOfElement(const Expr *E) const {
+return CGF.EmitLValue(E).getPointer();
+  }
+
+  /// \brief Return the corresponding bits for a given map clause modifier. Add

ABataev wrote:
> Do we really need this? It is quite simple and has nothing to do with the 
> name of the function
Ok, I removed this.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4681-4684
@@ +4680,6 @@
+if (I->second->getType()->isAnyPointerType() && std::next(I) != CE) {
+  auto PtrAddr =
+  CGF.MakeNaturalAlignAddrLValue(BP, I->second->getType());
+  BP = CGF.EmitLoadOfLValue(PtrAddr, SourceLocation()).getScalarVal();
+
+  // We do not need to generate individual map information for the

ABataev wrote:
> CGF has EmitLoadOfPointer() function
Ok, using `EmitLoadOfPointerLValue` now.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4699-4735
@@ +4698,39 @@
+
+// A final array section, is one whose length can't be proved to be 
one.
+auto IsFinalArraySection = [this](const Expr *E) -> bool {
+  auto *OASE = dyn_cast(E);
+
+  // It is not an array section and therefore not a unity-size one.
+  if (!OASE)
+return false;
+
+  // An array section with no colon always refer to a single element.
+  if (OASE->getColonLoc().isInvalid())
+return false;
+
+  auto *Length = OASE->getLength();
+
+  // If we don't have a length we have to check if the array has size 1
+  // for this dimension. Also, we should always expect a length if the
+  // base type is pointer.
+  if (!Length) {
+auto BaseQTy = OMPArraySectionExpr::getBaseOriginalType(
+   OASE->getBase()->IgnoreParenImpCasts())
+   .getCanonicalType();
+if (auto *ATy = dyn_cast(BaseQTy.getTypePtr()))
+  return ATy->getSize().getSExtValue() != 1;
+// If we don't have a constant dimension length, we have to 
consider
+// the current section as having any size, so it is not necessarily
+// unitary. If it happen to be unity size, that's user fault.
+return true;
+  }
+
+  // Check if the length evaluates to 1.
+  llvm::APSInt ConstLength;
+  if (!Length->EvaluateAsInt(ConstLeng

Re: [PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2016-04-21 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Yes, I'd like to try.
I think this is blocked on the changes that move visibility attributes to the 
first declaration, right?
Also, re: cfi-commits thread for r255177, it appears that on Mac we can neither 
hide nor expose existing methods (i.e. if something was hidden, it can not be 
exported and vice versa; basically, the set of exports must stay exactly the 
same).


Repository:
  rL LLVM

http://reviews.llvm.org/D14411



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


Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

2016-04-21 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

So you pointed out that my changes to the streams is not ABI compatible. 
Obviously that cannot be a part of this patch then.


Repository:
  rL LLVM

http://reviews.llvm.org/D15404



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


Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

2016-04-21 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 54562.
eugenis added a comment.

Updates with Eric's patch from
https://gist.github.com/EricWF/487e5b1de2bb320e93fbb3c9c758b013
without the iostream changes.


Repository:
  rL LLVM

http://reviews.llvm.org/D15404

Files:
  include/complex
  include/experimental/any
  include/experimental/dynarray
  include/ext/hash_map
  include/ext/hash_set
  include/forward_list
  include/fstream
  include/list
  include/queue
  include/unordered_map
  include/unordered_set

Index: include/unordered_set
===
--- include/unordered_set
+++ include/unordered_set
@@ -404,10 +404,12 @@
   size_type __n, const hasher& __hf, const allocator_type& __a)
 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
 #endif
+_LIBCPP_INLINE_VISIBILITY
 explicit unordered_set(const allocator_type& __a);
 unordered_set(const unordered_set& __u);
 unordered_set(const unordered_set& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 unordered_set(unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
 unordered_set(unordered_set&& __u, const allocator_type& __a);
@@ -439,10 +441,12 @@
 return *this;
 }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 unordered_set& operator=(unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+_LIBCPP_INLINE_VISIBILITY
 unordered_set& operator=(initializer_list __il);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
@@ -527,6 +531,7 @@
 #endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template 
+_LIBCPP_INLINE_VISIBILITY
 void insert(_InputIterator __first, _InputIterator __last);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 _LIBCPP_INLINE_VISIBILITY
@@ -678,7 +683,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
 const allocator_type& __a)
 : __table_(__a)
@@ -715,7 +720,7 @@
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
 unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
@@ -792,7 +797,7 @@
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>&
 unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
@@ -806,7 +811,7 @@
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_set<_Value, _Hash, _Pred, _Alloc>&
 unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
 initializer_list __il)
@@ -819,7 +824,7 @@
 
 template 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 void
 unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
 _InputIterator __last)
@@ -940,10 +945,12 @@
size_type __n, const hasher& __hf, const allocator_type& __a)
 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
 #endif
+_LIBCPP_INLINE_VISIBILITY
 explicit unordered_multiset(const allocator_type& __a);
 unordered_multiset(const unordered_multiset& __u);
 unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 unordered_multiset(unordered_multiset&& __u)
 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
 unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
@@ -973,6 +980,7 @@
 return *this;
 }
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 unordered_multiset& operator=(unordered_multiset&& __u)
 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
 #endif
@@ -1029,6 +1037,7 @@
 {return __table_.__insert_multi(__p, _VSTD::move(__x));}
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template 
+_LIBCPP_INLINE_VISIBILITY
 void insert(_InputIterator __first, _InputIterator __last);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 _LIBCPP_INLINE_VISIBILITY
@@ -1181,7 +1190,7 @@
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
 const allocator_type& __a)
 : __table_(__a)
@@ -1218,7 +1227,7 @@
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
 unordered_multiset&& __u)
 

Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

2016-04-21 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This change does not affect libc++.so on Linux in any way.


Repository:
  rL LLVM

http://reviews.llvm.org/D15404



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


[PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-21 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added reviewers: rjmccall, zaks.anna, rsmith.
apelete added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Fixing another set of "Logic error" warnings of the type "Called c++
object pointer is null" reported by Clang Static Analyzer on the
following files:

- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
- lib/Sema/SemaLookup.cpp,
- lib/Sema/SemaExprCXX.cpp,
- lib/Frontend/CompilerInstance.cpp,
- lib/Format/Format.cpp,
- lib/AST/DeclObjC.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19385

Files:
  lib/AST/DeclObjC.cpp
  lib/Format/Format.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = &Diags.front()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool AnyVisibleDecls = !NewDecls.empty();
 
   for (/**/; DI != DE; ++DI) {
+assert(*DI && "TypoCorrection iterator cannot be NULL");
 NamedDecl *VisibleDecl = *DI;
 if (!LookupResult::isVisible(SemaRef, *DI))
   VisibleDecl = findAcceptableDecl(SemaRef, *DI);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -398,8 +398,10 @@
 SourceLocation TypeidLoc,
 Expr *E,
 SourceLocation RParenLoc) {
+  assert(E && "expression operand is NULL, cannot build C++ typeid expression");
+
   bool WasEvaluated = false;
-  if (E && !E->isTypeDependent()) {
+  if (!E->isTypeDependent()) {
 if (E->getType()->isPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector, 16>
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1646,12 +1646,16 @@
   // Returns \c true if line or one if its children is affected.
   bool nonPPLineAffected(AnnotatedLine *Line,
  const AnnotatedLine *PreviousLine) {
+assert(Line && "line is NULL, cannot determine if affected by input SourceRanges");
+
 bool SomeLineAffected = false;
 Line->ChildrenAffected =
 computeAffectedLines(Line->Children.begin(), Line->Children.end());
 if (Line->ChildrenAffected)
   SomeLineAffected = true;
 
+assert(Line->First && "cannot process line with a NULL first token");
+
 // Stores whether one of the line's tokens is directly affected.
 bool SomeTokenAffected = false;
 // Stores whether we need to look at the leading newlines of the next token
Index: lib/AST/DeclObjC.cpp

Re: [PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope

2016-04-21 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

Ping


http://reviews.llvm.org/D15031



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


r267040 - clang-cl: Don't assert on using /Yc with non-source files, PR27450

2016-04-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr 21 14:59:10 2016
New Revision: 267040

URL: http://llvm.org/viewvc/llvm-project?rev=267040&view=rev
Log:
clang-cl: Don't assert on using /Yc with non-source files, PR27450

Move phase handling after input type validation.

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-pch.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267040&r1=267039&r2=267040&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 14:59:10 2016
@@ -1563,25 +1563,6 @@ void Driver::BuildActions(Compilation &C
 PL.clear();
 types::getCompilationPhases(InputType, PL);
 
-if (YcArg) {
-  // Add a separate precompile phase for the compile phase.
-  if (FinalPhase >= phases::Compile) {
-llvm::SmallVector PCHPL;
-types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
-Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
-
-// Build the pipeline for the pch file.
-Action *ClangClPch = C.MakeAction(*PchInputArg, 
InputType);
-for (phases::ID Phase : PCHPL)
-  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
-assert(ClangClPch);
-Actions.push_back(ClangClPch);
-// The driver currently exits after the first failed command.  This
-// relies on that behavior, to make sure if the pch generation fails,
-// the main compilation won't run.
-  }
-}
-
 // If the first step comes after the final phase we are doing as part of
 // this compilation, warn the user about it.
 phases::ID InitialPhase = PL[0];
@@ -1614,6 +1595,25 @@ void Driver::BuildActions(Compilation &C
   continue;
 }
 
+if (YcArg) {
+  // Add a separate precompile phase for the compile phase.
+  if (FinalPhase >= phases::Compile) {
+llvm::SmallVector PCHPL;
+types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
+Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
+
+// Build the pipeline for the pch file.
+Action *ClangClPch = C.MakeAction(*PchInputArg, 
InputType);
+for (phases::ID Phase : PCHPL)
+  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
+assert(ClangClPch);
+Actions.push_back(ClangClPch);
+// The driver currently exits after the first failed command.  This
+// relies on that behavior, to make sure if the pch generation fails,
+// the main compilation won't run.
+  }
+}
+
 phases::ID CudaInjectionPhase =
 (phases::Compile < FinalPhase &&
  llvm::find(PL, phases::Compile) != PL.end())

Modified: cfe/trunk/test/Driver/cl-pch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.cpp?rev=267040&r1=267039&r2=267040&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch.cpp Thu Apr 21 14:59:10 2016
@@ -296,7 +296,7 @@
 // CHECK-YCTC: -o
 // CHECK-YCTC: pchfile.pch
 // CHECK-YCTC: -x
-// CHECK-YCTP: "c"
+// CHECK-YCTC: "c"
 
 // Also check lower-case /Tc variant.
 // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
@@ -307,3 +307,18 @@
 // CHECK-YCTc: pchfile.pch
 // CHECK-YCTc: -x
 // CHECK-YCTc: "c"
+
+// Don't crash when a non-source file is passed.
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### 
%S/Inputs/file.prof 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NoSource %s
+// CHECK-NoSource: file.prof:{{.*}}input unused
+
+// ...but if an explicit file turns the file into a source file, handle it:
+// RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### 
%S/Inputs/file.prof 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NoSourceTP %s
+// CHECK-NoSourceTP: cc1
+// CHECK-NoSourceTP: -emit-pch
+// CHECK-NoSourceTP: -o
+// CHECK-NoSourceTP: pchfile.pch
+// CHECK-NoSourceTP: -x
+// CHECK-NoSourceTP: "c++"


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


Re: r267040 - clang-cl: Don't assert on using /Yc with non-source files, PR27450

2016-04-21 Thread Vedant Kumar via cfe-commits
Hi Nico,

This seems to be causing a test failure on one of our bots:

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/17279/testReport/junit/Clang/Driver/cl_pch_cpp/

Command Output (stderr):
--
/Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/cl-pch.cpp:314:20:
 error: expected string not found in input
// CHECK-NoSource: file.prof:{{.*}}input unused
:5:7: note: possible intended match here
clang-3.8: error: argument unused during compilation: '-Werror'

I'm not sure what exactly is causing the problem, but if -Werror is being 
ignored, the "input unused" warning may be suppressed somehow.

I'd appreciate any help looking into this.

thanks,
vedant

> On Apr 21, 2016, at 12:59 PM, Nico Weber via cfe-commits 
>  wrote:
> 
> Author: nico
> Date: Thu Apr 21 14:59:10 2016
> New Revision: 267040
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=267040&view=rev
> Log:
> clang-cl: Don't assert on using /Yc with non-source files, PR27450
> 
> Move phase handling after input type validation.
> 
> Modified:
>cfe/trunk/lib/Driver/Driver.cpp
>cfe/trunk/test/Driver/cl-pch.cpp
> 
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267040&r1=267039&r2=267040&view=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 14:59:10 2016
> @@ -1563,25 +1563,6 @@ void Driver::BuildActions(Compilation &C
> PL.clear();
> types::getCompilationPhases(InputType, PL);
> 
> -if (YcArg) {
> -  // Add a separate precompile phase for the compile phase.
> -  if (FinalPhase >= phases::Compile) {
> -llvm::SmallVector PCHPL;
> -types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> -Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> -
> -// Build the pipeline for the pch file.
> -Action *ClangClPch = C.MakeAction(*PchInputArg, 
> InputType);
> -for (phases::ID Phase : PCHPL)
> -  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> -assert(ClangClPch);
> -Actions.push_back(ClangClPch);
> -// The driver currently exits after the first failed command.  This
> -// relies on that behavior, to make sure if the pch generation fails,
> -// the main compilation won't run.
> -  }
> -}
> -
> // If the first step comes after the final phase we are doing as part of
> // this compilation, warn the user about it.
> phases::ID InitialPhase = PL[0];
> @@ -1614,6 +1595,25 @@ void Driver::BuildActions(Compilation &C
>   continue;
> }
> 
> +if (YcArg) {
> +  // Add a separate precompile phase for the compile phase.
> +  if (FinalPhase >= phases::Compile) {
> +llvm::SmallVector PCHPL;
> +types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> +Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> +
> +// Build the pipeline for the pch file.
> +Action *ClangClPch = C.MakeAction(*PchInputArg, 
> InputType);
> +for (phases::ID Phase : PCHPL)
> +  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> +assert(ClangClPch);
> +Actions.push_back(ClangClPch);
> +// The driver currently exits after the first failed command.  This
> +// relies on that behavior, to make sure if the pch generation fails,
> +// the main compilation won't run.
> +  }
> +}
> +
> phases::ID CudaInjectionPhase =
> (phases::Compile < FinalPhase &&
>  llvm::find(PL, phases::Compile) != PL.end())
> 
> Modified: cfe/trunk/test/Driver/cl-pch.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.cpp?rev=267040&r1=267039&r2=267040&view=diff
> ==
> --- cfe/trunk/test/Driver/cl-pch.cpp (original)
> +++ cfe/trunk/test/Driver/cl-pch.cpp Thu Apr 21 14:59:10 2016
> @@ -296,7 +296,7 @@
> // CHECK-YCTC: -o
> // CHECK-YCTC: pchfile.pch
> // CHECK-YCTC: -x
> -// CHECK-YCTP: "c"
> +// CHECK-YCTC: "c"
> 
> // Also check lower-case /Tc variant.
> // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
> @@ -307,3 +307,18 @@
> // CHECK-YCTc: pchfile.pch
> // CHECK-YCTc: -x
> // CHECK-YCTc: "c"
> +
> +// Don't crash when a non-source file is passed.
> +// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### 
> %S/Inputs/file.prof 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NoSource %s
> +// CHECK-NoSource: file.prof:{{.*}}input unused
> +
> +// ...but if an explicit file turns the file into a source file, handle it:
> +// RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### 
> %S/Inputs/file.prof 2>&1 \
> +// RUN:   | FileCheck -check-prefix=CHECK-NoSourceTP %s
> +// CHECK-NoSourceTP: cc1
> +// CHE

Re: r267040 - clang-cl: Don't assert on using /Yc with non-source files, PR27450

2016-04-21 Thread Nico Weber via cfe-commits
Does removing -Werror help? All the bots on http://lab.llvm.org:8011/console
look happy.

On Thu, Apr 21, 2016 at 4:58 PM, Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Nico,
>
> This seems to be causing a test failure on one of our bots:
>
>
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/17279/testReport/junit/Clang/Driver/cl_pch_cpp/
>
> Command Output (stderr):
> --
> /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/cl-pch.cpp:314:20:
> error: expected string not found in input
> // CHECK-NoSource: file.prof:{{.*}}input unused
> :5:7: note: possible intended match here
> clang-3.8: error: argument unused during compilation: '-Werror'
>
> I'm not sure what exactly is causing the problem, but if -Werror is being
> ignored, the "input unused" warning may be suppressed somehow.
>
> I'd appreciate any help looking into this.
>
> thanks,
> vedant
>
> > On Apr 21, 2016, at 12:59 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: nico
> > Date: Thu Apr 21 14:59:10 2016
> > New Revision: 267040
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=267040&view=rev
> > Log:
> > clang-cl: Don't assert on using /Yc with non-source files, PR27450
> >
> > Move phase handling after input type validation.
> >
> > Modified:
> >cfe/trunk/lib/Driver/Driver.cpp
> >cfe/trunk/test/Driver/cl-pch.cpp
> >
> > Modified: cfe/trunk/lib/Driver/Driver.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267040&r1=267039&r2=267040&view=diff
> >
> ==
> > --- cfe/trunk/lib/Driver/Driver.cpp (original)
> > +++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 14:59:10 2016
> > @@ -1563,25 +1563,6 @@ void Driver::BuildActions(Compilation &C
> > PL.clear();
> > types::getCompilationPhases(InputType, PL);
> >
> > -if (YcArg) {
> > -  // Add a separate precompile phase for the compile phase.
> > -  if (FinalPhase >= phases::Compile) {
> > -llvm::SmallVector PCHPL;
> > -types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> > -Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> > -
> > -// Build the pipeline for the pch file.
> > -Action *ClangClPch = C.MakeAction(*PchInputArg,
> InputType);
> > -for (phases::ID Phase : PCHPL)
> > -  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> > -assert(ClangClPch);
> > -Actions.push_back(ClangClPch);
> > -// The driver currently exits after the first failed command.
> This
> > -// relies on that behavior, to make sure if the pch generation
> fails,
> > -// the main compilation won't run.
> > -  }
> > -}
> > -
> > // If the first step comes after the final phase we are doing as
> part of
> > // this compilation, warn the user about it.
> > phases::ID InitialPhase = PL[0];
> > @@ -1614,6 +1595,25 @@ void Driver::BuildActions(Compilation &C
> >   continue;
> > }
> >
> > +if (YcArg) {
> > +  // Add a separate precompile phase for the compile phase.
> > +  if (FinalPhase >= phases::Compile) {
> > +llvm::SmallVector PCHPL;
> > +types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> > +Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> > +
> > +// Build the pipeline for the pch file.
> > +Action *ClangClPch = C.MakeAction(*PchInputArg,
> InputType);
> > +for (phases::ID Phase : PCHPL)
> > +  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> > +assert(ClangClPch);
> > +Actions.push_back(ClangClPch);
> > +// The driver currently exits after the first failed command.
> This
> > +// relies on that behavior, to make sure if the pch generation
> fails,
> > +// the main compilation won't run.
> > +  }
> > +}
> > +
> > phases::ID CudaInjectionPhase =
> > (phases::Compile < FinalPhase &&
> >  llvm::find(PL, phases::Compile) != PL.end())
> >
> > Modified: cfe/trunk/test/Driver/cl-pch.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.cpp?rev=267040&r1=267039&r2=267040&view=diff
> >
> ==
> > --- cfe/trunk/test/Driver/cl-pch.cpp (original)
> > +++ cfe/trunk/test/Driver/cl-pch.cpp Thu Apr 21 14:59:10 2016
> > @@ -296,7 +296,7 @@
> > // CHECK-YCTC: -o
> > // CHECK-YCTC: pchfile.pch
> > // CHECK-YCTC: -x
> > -// CHECK-YCTP: "c"
> > +// CHECK-YCTC: "c"
> >
> > // Also check lower-case /Tc variant.
> > // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
> > @@ -307,3 +307,18 @@
> > // CHECK-YCTc: pchfile.pch
> > // CHECK-YCTc: -x
> > // CHECK-YCTc: "c"
> > +
> > +// Don't crash when a non-source file is passed.
> > +// RUN: %clang_cl -Werror /Ycp

r267054 - Split interesting warnings off from -Wfloat-conversion

2016-04-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Apr 21 16:04:55 2016
New Revision: 267054

URL: http://llvm.org/viewvc/llvm-project?rev=267054&view=rev
Log:
Split interesting warnings off from -Wfloat-conversion

Restructure the implict floating point to integer conversions so that
interesting sub-groups are under different flags.  Breakdown of warnings:

No warning:
Exact conversions from floating point to integer:
int x = 10.0;
int x = 1e10;

-Wliteral-conversion - Floating point literal to integer with rounding:
int x = 5.5;
int x = -3.4;

-Wfloat-conversion - All conversions not covered by the above two:
int x = GetFloat();
int x = 5.5 + 3.5;

-Wfloat-zero-conversion - The expression converted has a non-zero floating
point value that gets converted to a zero integer value, excluded the cases
falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
int x = 1.0 / 2.0;

-Wfloat-overflow-conversion - The floating point value is outside the range
of the integer type, exluding cases from -Wliteral conversion.  Subset of
-Wfloat-conversion.
char x = 500;
char x = -1000;

-Wfloat-bool-conversion - Any conversion of a floating point type to bool.
Subset of -Wfloat-conversion.
if (GetFloat()) {}
bool x = 5.0;

-Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable
floating point value to bool.  Subset of -Wfloat-bool-conversion.
bool x = 1.0;
bool x = 4.0 / 20.0;

Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but for
floating point values.


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=267054&r1=267053&r2=267054&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 21 16:04:55 2016
@@ -594,6 +594,13 @@ public:
   bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
  SideEffectsKind AllowSideEffects = SE_NoSideEffects) 
const;
 
+  /// EvaluateAsFloat - Return true if this is a constant which we can fold and
+  /// convert to a floating point value, using any crazy technique that we
+  /// want to.
+  bool
+  EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
+  SideEffectsKind AllowSideEffects = SE_NoSideEffects) const;
+
   /// isEvaluatable - Call EvaluateAsRValue to see if this expression can be
   /// constant folded without side-effects, but discard the result.
   bool isEvaluatable(const ASTContext &Ctx,

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267054&r1=267053&r2=267054&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 21 16:04:55 2016
@@ -46,7 +46,17 @@ def BoolConversion : DiagGroup<"bool-con
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
-def FloatConversion : DiagGroup<"float-conversion">;
+
+def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
+def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
+def FloatBoolConstantConversion : DiagGroup<"float-bool-constant-conversion">;
+def FloatBoolConversion :
+  DiagGroup<"float-bool-conversion", [FloatBoolConstantConversion]>;
+def FloatConversion :
+  DiagGroup<"float-conversion", [FloatBoolConversion,
+ FloatOverflowConversion,
+ FloatZeroConversion]>;
+
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267054&r1=267053&r2=267054&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 21 16:04:55 
2016
@@ -2742,9 +2742,6 @@ def warn_impcast_float_precision : Warni
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
-def warn_impcast_float_i

Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-21 Thread Richard Trieu via cfe-commits
rtrieu added a subscriber: rtrieu.
rtrieu added a comment.

Have you looked at http://reviews.llvm.org/D6561 which was a previous attempt 
at this warning?


http://reviews.llvm.org/D19312



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


Re: [PATCH] D18073: Add memory allocating functions

2016-04-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

This looks reasonable to me, but you should wait for @zaks.anna to sign off.


http://reviews.llvm.org/D18073



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


Re: r267040 - clang-cl: Don't assert on using /Yc with non-source files, PR27450

2016-04-21 Thread Vedant Kumar via cfe-commits
No, removing -Werror doesn't help.

What's strange is that this doesn't reproduce on my machine -- just on the bots.

I'll poke around a bit more.

vedant

> On Apr 21, 2016, at 2:08 PM, Nico Weber  wrote:
> 
> Does removing -Werror help? All the bots on http://lab.llvm.org:8011/console 
> look happy.
> 
> On Thu, Apr 21, 2016 at 4:58 PM, Vedant Kumar via cfe-commits 
>  wrote:
> Hi Nico,
> 
> This seems to be causing a test failure on one of our bots:
> 
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/17279/testReport/junit/Clang/Driver/cl_pch_cpp/
> 
> Command Output (stderr):
> --
> /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/cl-pch.cpp:314:20:
>  error: expected string not found in input
> // CHECK-NoSource: file.prof:{{.*}}input unused
> :5:7: note: possible intended match here
> clang-3.8: error: argument unused during compilation: '-Werror'
> 
> I'm not sure what exactly is causing the problem, but if -Werror is being 
> ignored, the "input unused" warning may be suppressed somehow.
> 
> I'd appreciate any help looking into this.
> 
> thanks,
> vedant
> 
> > On Apr 21, 2016, at 12:59 PM, Nico Weber via cfe-commits 
> >  wrote:
> >
> > Author: nico
> > Date: Thu Apr 21 14:59:10 2016
> > New Revision: 267040
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=267040&view=rev
> > Log:
> > clang-cl: Don't assert on using /Yc with non-source files, PR27450
> >
> > Move phase handling after input type validation.
> >
> > Modified:
> >cfe/trunk/lib/Driver/Driver.cpp
> >cfe/trunk/test/Driver/cl-pch.cpp
> >
> > Modified: cfe/trunk/lib/Driver/Driver.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267040&r1=267039&r2=267040&view=diff
> > ==
> > --- cfe/trunk/lib/Driver/Driver.cpp (original)
> > +++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 14:59:10 2016
> > @@ -1563,25 +1563,6 @@ void Driver::BuildActions(Compilation &C
> > PL.clear();
> > types::getCompilationPhases(InputType, PL);
> >
> > -if (YcArg) {
> > -  // Add a separate precompile phase for the compile phase.
> > -  if (FinalPhase >= phases::Compile) {
> > -llvm::SmallVector PCHPL;
> > -types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> > -Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> > -
> > -// Build the pipeline for the pch file.
> > -Action *ClangClPch = C.MakeAction(*PchInputArg, 
> > InputType);
> > -for (phases::ID Phase : PCHPL)
> > -  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> > -assert(ClangClPch);
> > -Actions.push_back(ClangClPch);
> > -// The driver currently exits after the first failed command.  This
> > -// relies on that behavior, to make sure if the pch generation 
> > fails,
> > -// the main compilation won't run.
> > -  }
> > -}
> > -
> > // If the first step comes after the final phase we are doing as part of
> > // this compilation, warn the user about it.
> > phases::ID InitialPhase = PL[0];
> > @@ -1614,6 +1595,25 @@ void Driver::BuildActions(Compilation &C
> >   continue;
> > }
> >
> > +if (YcArg) {
> > +  // Add a separate precompile phase for the compile phase.
> > +  if (FinalPhase >= phases::Compile) {
> > +llvm::SmallVector PCHPL;
> > +types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
> > +Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
> > +
> > +// Build the pipeline for the pch file.
> > +Action *ClangClPch = C.MakeAction(*PchInputArg, 
> > InputType);
> > +for (phases::ID Phase : PCHPL)
> > +  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
> > +assert(ClangClPch);
> > +Actions.push_back(ClangClPch);
> > +// The driver currently exits after the first failed command.  This
> > +// relies on that behavior, to make sure if the pch generation 
> > fails,
> > +// the main compilation won't run.
> > +  }
> > +}
> > +
> > phases::ID CudaInjectionPhase =
> > (phases::Compile < FinalPhase &&
> >  llvm::find(PL, phases::Compile) != PL.end())
> >
> > Modified: cfe/trunk/test/Driver/cl-pch.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.cpp?rev=267040&r1=267039&r2=267040&view=diff
> > ==
> > --- cfe/trunk/test/Driver/cl-pch.cpp (original)
> > +++ cfe/trunk/test/Driver/cl-pch.cpp Thu Apr 21 14:59:10 2016
> > @@ -296,7 +296,7 @@
> > // CHECK-YCTC: -o
> > // CHECK-YCTC: pchfile.pch
> > // CHECK-YCTC: -x
> > -// CHECK-YCTP: "c"
> > +// CHECK-YCTC: "c"
> >
> > // Also check lower-case /Tc variant.
> > // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
> > @@ -307,3 

r267059 - [esan] EfficiencySanitizer driver flags

2016-04-21 Thread Derek Bruening via cfe-commits
Author: bruening
Date: Thu Apr 21 16:32:04 2016
New Revision: 267059

URL: http://llvm.org/viewvc/llvm-project?rev=267059&view=rev
Log:
[esan] EfficiencySanitizer driver flags

Summary:
Adds a framework to enable the instrumentation pass for the new
EfficiencySanitizer ("esan") family of tools.  Adds a flag for esan's
cache fragmentation tool via -fsanitize=efficiency-cache-frag.
Adds appropriate tests for the new flag.

Reviewers: eugenis, vitalybuka, aizatsky, filcab

Subscribers: filcab, kubabrecka, llvm-commits, zhaoqin, kcc

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

Added:
cfe/trunk/test/Driver/esan.c
cfe/trunk/test/Lexer/has_feature_efficiency_sanitizer.cpp
Modified:
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitize_unwind_tables.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=267059&r1=267058&r2=267059&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Apr 21 16:32:04 2016
@@ -114,6 +114,11 @@ SANITIZER_GROUP("integer", Integer,
 SANITIZER("local-bounds", LocalBounds)
 SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
 
+// EfficiencySanitizer
+SANITIZER("efficiency-cache-frag", EfficiencyCacheFrag)
+// Meta-group only used internally.
+SANITIZER_GROUP("efficiency-all", Efficiency, EfficiencyCacheFrag)
+
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
 SANITIZER_GROUP("all", All, ~0ULL)

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=267059&r1=267058&r2=267059&view=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Thu Apr 21 16:32:04 2016
@@ -58,6 +58,9 @@ class SanitizerArgs {
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
+  bool needsEsanRt() const {
+return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
+  }
 
   bool requiresPIE() const;
   bool needsUnwindTables() const;

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=267059&r1=267058&r2=267059&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Apr 21 16:32:04 2016
@@ -248,6 +248,17 @@ static void addDataFlowSanitizerPass(con
   PM.add(createDataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
 }
 
+static void addEfficiencySanitizerPass(const PassManagerBuilder &Builder,
+   legacy::PassManagerBase &PM) {
+  const PassManagerBuilderWrapper &BuilderWrapper =
+  static_cast(Builder);
+  const LangOptions &LangOpts = BuilderWrapper.getLangOpts();
+  EfficiencySanitizerOptions Opts;
+  if (LangOpts.Sanitize.has(SanitizerKind::EfficiencyCacheFrag))
+Opts.ToolType = EfficiencySanitizerOptions::ESAN_CacheFrag;
+  PM.add(createEfficiencySanitizerPass(Opts));
+}
+
 static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
  const CodeGenOptions &CodeGenOpts) {
   TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
@@ -407,6 +418,13 @@ void EmitAssemblyHelper::CreatePasses(Mo
addDataFlowSanitizerPass);
   }
 
+  if (LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency)) {
+PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
+   addEfficiencySanitizerPass);
+PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+   addEfficiencySanitizerPass);
+  }
+
   // Set up the per-function pass manager.
   legacy::FunctionPassManager *FPM = getPerFunctionPasses();
   if (CodeGenOpts.VerifyModule)

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=267059&r1=267058&r2=267059&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Apr 21 16:32:04 2016
@@ -311,7 +311,12 @@ SanitizerArgs::Saniti

r267062 - [CUDA] removed unneeded __nvvm_reflect_anchor()

2016-04-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Apr 21 16:40:27 2016
New Revision: 267062

URL: http://llvm.org/viewvc/llvm-project?rev=267062&view=rev
Log:
[CUDA] removed unneeded __nvvm_reflect_anchor()

Since r265060 LLVM infers correct __nvvm_reflect attributes, so
explicit declaration of __nvvm_reflect() is no longer needed.

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=267062&r1=267061&r2=267062&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Thu Apr 21 16:40:27 
2016
@@ -216,16 +216,6 @@ static inline __device__ void __brkpt(in
 #undef __CUDABE__
 #define __CUDACC__
 
-#if defined(__CUDA_ARCH__)
-// We need to emit IR declaration for non-existing __nvvm_reflect() to
-// let backend know that it should be treated as const nothrow
-// function which is what NVVMReflect pass expects to see.
-extern "C" __device__ __attribute__((const)) int __nvvm_reflect(const void *);
-static __device__ __attribute__((used)) int __nvvm_reflect_anchor() {
-  return __nvvm_reflect("NONE");
-}
-#endif
-
 extern "C" {
 // Device-side CUDA system calls.
 // 
http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#system-calls


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


Re: [PATCH] D19074: [CUDA] removed unneeded __nvvm_reflect_anchor()

2016-04-21 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267062: [CUDA] removed unneeded __nvvm_reflect_anchor() 
(authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D19074?vs=53618&id=54585#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19074

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -216,16 +216,6 @@
 #undef __CUDABE__
 #define __CUDACC__
 
-#if defined(__CUDA_ARCH__)
-// We need to emit IR declaration for non-existing __nvvm_reflect() to
-// let backend know that it should be treated as const nothrow
-// function which is what NVVMReflect pass expects to see.
-extern "C" __device__ __attribute__((const)) int __nvvm_reflect(const void *);
-static __device__ __attribute__((used)) int __nvvm_reflect_anchor() {
-  return __nvvm_reflect("NONE");
-}
-#endif
-
 extern "C" {
 // Device-side CUDA system calls.
 // 
http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#system-calls


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -216,16 +216,6 @@
 #undef __CUDABE__
 #define __CUDACC__
 
-#if defined(__CUDA_ARCH__)
-// We need to emit IR declaration for non-existing __nvvm_reflect() to
-// let backend know that it should be treated as const nothrow
-// function which is what NVVMReflect pass expects to see.
-extern "C" __device__ __attribute__((const)) int __nvvm_reflect(const void *);
-static __device__ __attribute__((used)) int __nvvm_reflect_anchor() {
-  return __nvvm_reflect("NONE");
-}
-#endif
-
 extern "C" {
 // Device-side CUDA system calls.
 // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#system-calls
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r267040 - clang-cl: Don't assert on using /Yc with non-source files, PR27450

2016-04-21 Thread Vedant Kumar via cfe-commits
Hm, here's something weird --

The test passes if I change this RUN line:

// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### 
%S/Inputs/file.prof

To this:

// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### 
/%S/Inputs/file.prof

The output I get with the original RUN line looks like this:

clang-3.9: error: argument unused during compilation: '-Werror'
clang-3.9: error: argument unused during compilation: '-include pchfile.h'
clang-3.9: error: argument unused during compilation: '-U 
sers/buildslave/jenkins/sharedspace/...' << !

vedant

> On Apr 21, 2016, at 2:42 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> No, removing -Werror doesn't help.
> 
> What's strange is that this doesn't reproduce on my machine -- just on the 
> bots.
> 
> I'll poke around a bit more.
> 
> vedant
> 
>> On Apr 21, 2016, at 2:08 PM, Nico Weber  wrote:
>> 
>> Does removing -Werror help? All the bots on http://lab.llvm.org:8011/console 
>> look happy.
>> 
>> On Thu, Apr 21, 2016 at 4:58 PM, Vedant Kumar via cfe-commits 
>>  wrote:
>> Hi Nico,
>> 
>> This seems to be causing a test failure on one of our bots:
>> 
>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/17279/testReport/junit/Clang/Driver/cl_pch_cpp/
>> 
>> Command Output (stderr):
>> --
>> /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/cl-pch.cpp:314:20:
>>  error: expected string not found in input
>> // CHECK-NoSource: file.prof:{{.*}}input unused
>> :5:7: note: possible intended match here
>> clang-3.8: error: argument unused during compilation: '-Werror'
>> 
>> I'm not sure what exactly is causing the problem, but if -Werror is being 
>> ignored, the "input unused" warning may be suppressed somehow.
>> 
>> I'd appreciate any help looking into this.
>> 
>> thanks,
>> vedant
>> 
>>> On Apr 21, 2016, at 12:59 PM, Nico Weber via cfe-commits 
>>>  wrote:
>>> 
>>> Author: nico
>>> Date: Thu Apr 21 14:59:10 2016
>>> New Revision: 267040
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267040&view=rev
>>> Log:
>>> clang-cl: Don't assert on using /Yc with non-source files, PR27450
>>> 
>>> Move phase handling after input type validation.
>>> 
>>> Modified:
>>>   cfe/trunk/lib/Driver/Driver.cpp
>>>   cfe/trunk/test/Driver/cl-pch.cpp
>>> 
>>> Modified: cfe/trunk/lib/Driver/Driver.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267040&r1=267039&r2=267040&view=diff
>>> ==
>>> --- cfe/trunk/lib/Driver/Driver.cpp (original)
>>> +++ cfe/trunk/lib/Driver/Driver.cpp Thu Apr 21 14:59:10 2016
>>> @@ -1563,25 +1563,6 @@ void Driver::BuildActions(Compilation &C
>>>PL.clear();
>>>types::getCompilationPhases(InputType, PL);
>>> 
>>> -if (YcArg) {
>>> -  // Add a separate precompile phase for the compile phase.
>>> -  if (FinalPhase >= phases::Compile) {
>>> -llvm::SmallVector PCHPL;
>>> -types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
>>> -Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
>>> -
>>> -// Build the pipeline for the pch file.
>>> -Action *ClangClPch = C.MakeAction(*PchInputArg, 
>>> InputType);
>>> -for (phases::ID Phase : PCHPL)
>>> -  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
>>> -assert(ClangClPch);
>>> -Actions.push_back(ClangClPch);
>>> -// The driver currently exits after the first failed command.  This
>>> -// relies on that behavior, to make sure if the pch generation 
>>> fails,
>>> -// the main compilation won't run.
>>> -  }
>>> -}
>>> -
>>>// If the first step comes after the final phase we are doing as part of
>>>// this compilation, warn the user about it.
>>>phases::ID InitialPhase = PL[0];
>>> @@ -1614,6 +1595,25 @@ void Driver::BuildActions(Compilation &C
>>>  continue;
>>>}
>>> 
>>> +if (YcArg) {
>>> +  // Add a separate precompile phase for the compile phase.
>>> +  if (FinalPhase >= phases::Compile) {
>>> +llvm::SmallVector PCHPL;
>>> +types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
>>> +Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
>>> +
>>> +// Build the pipeline for the pch file.
>>> +Action *ClangClPch = C.MakeAction(*PchInputArg, 
>>> InputType);
>>> +for (phases::ID Phase : PCHPL)
>>> +  ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
>>> +assert(ClangClPch);
>>> +Actions.push_back(ClangClPch);
>>> +// The driver currently exits after the first failed command.  This
>>> +// relies on that behavior, to make sure if the pch generation 
>>> fails,
>>> +// the main compilation won't run.
>>> +  }
>>> +}
>>> +
>>>phases::ID CudaInjectionPhase =
>>>(phases::Compile < FinalPhase &&
>>> llvm::find(PL, 

[PATCH] D19393: Move Checkers.inc to clang/include/.../Checkers

2016-04-21 Thread Chih-Hung Hsieh via cfe-commits
chh created this revision.
chh added reviewers: srhines, alexfh.
chh added a subscriber: cfe-commits.
Herald added subscribers: danalbert, tberghammer.

https://llvm.org/bugs/show_bug.cgi?id=27355
To compile with other binary output directory structures in build systems like 
Android.
Allow clang-tidy/ClangTidy.cpp and other files to include Checkers.inc like 
other .inc files,
with a relative path to clang/include.


http://reviews.llvm.org/D19393

Files:
  include/clang/CMakeLists.txt
  include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
  lib/StaticAnalyzer/Checkers/ClangSACheckers.h

Index: lib/StaticAnalyzer/Checkers/ClangSACheckers.h
===
--- lib/StaticAnalyzer/Checkers/ClangSACheckers.h
+++ lib/StaticAnalyzer/Checkers/ClangSACheckers.h
@@ -26,7 +26,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   void register##CLASS(CheckerManager &mgr);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 
Index: lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
===
--- lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
+++ lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
@@ -27,6 +27,6 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,DESCFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   registry.addChecker(register##CLASS, FULLNAME, HELPTEXT);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_CHECKERS
 }
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -1,8 +1,3 @@
-clang_tablegen(Checkers.inc -gen-clang-sa-checkers
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../include
-  SOURCE Checkers.td
-  TARGET ClangSACheckers)
-
 set(LLVM_LINK_COMPONENTS
   Support
   )
Index: include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
+++ include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -0,0 +1,4 @@
+clang_tablegen(Checkers.inc -gen-clang-sa-checkers
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../
+  SOURCE ../../../../lib/StaticAnalyzer/Checkers/Checkers.td
+  TARGET ClangSACheckers)
Index: include/clang/CMakeLists.txt
===
--- include/clang/CMakeLists.txt
+++ include/clang/CMakeLists.txt
@@ -4,3 +4,4 @@
 add_subdirectory(Parse)
 add_subdirectory(Sema)
 add_subdirectory(Serialization)
+add_subdirectory(StaticAnalyzer/Checkers)


Index: lib/StaticAnalyzer/Checkers/ClangSACheckers.h
===
--- lib/StaticAnalyzer/Checkers/ClangSACheckers.h
+++ lib/StaticAnalyzer/Checkers/ClangSACheckers.h
@@ -26,7 +26,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   void register##CLASS(CheckerManager &mgr);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 
Index: lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
===
--- lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
+++ lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
@@ -27,6 +27,6 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,DESCFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   registry.addChecker(register##CLASS, FULLNAME, HELPTEXT);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_CHECKERS
 }
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -1,8 +1,3 @@
-clang_tablegen(Checkers.inc -gen-clang-sa-checkers
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../include
-  SOURCE Checkers.td
-  TARGET ClangSACheckers)
-
 set(LLVM_LINK_COMPONENTS
   Support
   )
Index: include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
+++ include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -0,0 +1,4 @@
+clang_tablegen(Checkers.inc -gen-clang-sa-checkers
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../
+  SOURCE ../../../../lib/StaticAnalyzer/Checkers/Checkers.td
+  TARGET ClangSACheckers)
Index: include/clang/CMakeLists.txt
===
--- include/clang/CMakeLists.txt
+++ include/clang/CMakeLists.txt
@@ -4,3 +4,4 @@
 add_subdirectory(Parse)
 add_subdirectory(Sema)
 add_subdirectory(Serializatio

Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-21 Thread Chih-Hung Hsieh via cfe-commits
chh updated this revision to Diff 54587.

http://reviews.llvm.org/D19249

Files:
  clang-tidy/ClangTidy.cpp

Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   
\
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   \
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-21 Thread Chih-Hung Hsieh via cfe-commits
chh added a comment.

This change depends on http://reviews.llvm.org/D19393.


http://reviews.llvm.org/D19249



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


Re: [PATCH] D19393: Move Checkers.inc to clang/include/.../Checkers

2016-04-21 Thread Chih-Hung Hsieh via cfe-commits
chh added a comment.

See dependent change of ClangTidy.cpp in http://reviews.llvm.org/D19393.


http://reviews.llvm.org/D19393



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


[libcxx] r267074 - Fix most GCC attribute ignored warnings

2016-04-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 21 17:54:21 2016
New Revision: 267074

URL: http://llvm.org/viewvc/llvm-project?rev=267074&view=rev
Log:
Fix most GCC attribute ignored warnings

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__functional_base
libcxx/trunk/include/bitset
libcxx/trunk/include/memory
libcxx/trunk/include/stdexcept
libcxx/trunk/include/string
libcxx/trunk/include/thread
libcxx/trunk/include/type_traits
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=267074&r1=267073&r2=267074&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Apr 21 17:54:21 2016
@@ -319,8 +319,6 @@ typedef __char32_t char32_t;
 #  define _LIBCPP_NORETURN __attribute__ ((noreturn))
 #endif
 
-#define _LIBCPP_UNUSED __attribute__((__unused__))
-
 #if !(__has_feature(cxx_default_function_template_args))
 #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #endif
@@ -459,8 +457,6 @@ namespace std {
 
 #define _LIBCPP_NORETURN __attribute__((noreturn))
 
-#define _LIBCPP_UNUSED __attribute__((__unused__))
-
 #if _GNUC_VER >= 407
 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
 #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
@@ -566,7 +562,6 @@ using namespace _LIBCPP_NAMESPACE __attr
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
-#define _LIBCPP_UNUSED
 #define _ALIGNAS(x) __declspec(align(x))
 #define _LIBCPP_HAS_NO_VARIADICS
 
@@ -588,7 +583,6 @@ namespace std {
 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x
 #define _ATTRIBUTE(x) __attribute__((x))
 #define _LIBCPP_NORETURN __attribute__((noreturn))
-#define _LIBCPP_UNUSED
 
 #define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=267074&r1=267073&r2=267074&view=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Thu Apr 21 17:54:21 2016
@@ -38,8 +38,6 @@ struct _LIBCPP_TYPE_VIS_ONLY binary_func
 typedef _Result result_type;
 };
 
-template  struct _LIBCPP_TYPE_VIS_ONLY hash;
-
 template 
 struct __has_result_type
 {

Modified: libcxx/trunk/include/bitset
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=267074&r1=267073&r2=267074&view=diff
==
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Thu Apr 21 17:54:21 2016
@@ -656,7 +656,7 @@ __bitset<0, 0>::__bitset(unsigned long l
 }
 
 template  class _LIBCPP_TYPE_VIS_ONLY bitset;
-template  struct _LIBCPP_TYPE_VIS_ONLY hash >;
+template  struct hash >;
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY bitset

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=267074&r1=267073&r2=267074&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Apr 21 17:54:21 2016
@@ -3166,8 +3166,6 @@ template
 
 #endif  // _LIBCPP_STD_VER > 11
 
-template  struct hash;
-
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _Size
@@ -3978,23 +3976,23 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 operator=(shared_ptr<_Yp>&& __r);
 template
+_LIBCPP_INLINE_VISIBILITY
 typename enable_if
 <
 !is_array<_Yp>::value &&
 is_convertible<_Yp*, element_type*>::value,
 shared_ptr
 >::type&
-_LIBCPP_INLINE_VISIBILITY
 operator=(auto_ptr<_Yp>&& __r);
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template
+_LIBCPP_INLINE_VISIBILITY
 typename enable_if
 <
 !is_array<_Yp>::value &&
 is_convertible<_Yp*, element_type*>::value,
 shared_ptr&
 >::type
-_LIBCPP_INLINE_VISIBILITY
 operator=(auto_ptr<_Yp> __r);
 #endif
 template 
@@ -5622,7 +5620,7 @@ _LIBCPP_FUNC_VIS void* align(size_t __al
 
 // --- Helper for container swap --
 template 
-_LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY
 void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
 #if _LIBCPP_STD_VER >= 14
 _NOEXCEPT
@@ -5648,7 +5646,7 @@ void __swap_allocator(_Alloc & __a1, _Al
 }
 
 template 
-_LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY
 void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
 
 template  >

Modified: libcxx/trunk/include/stdexcept
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdexcept?rev=267074&r1=267073&r2

[libcxx] r267076 - Make ios_base::failure visibility specified consistent

2016-04-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 21 18:00:33 2016
New Revision: 267076

URL: http://llvm.org/viewvc/llvm-project?rev=267076&view=rev
Log:
Make ios_base::failure visibility specified consistent

Modified:
libcxx/trunk/include/ios

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=267076&r1=267075&r2=267076&view=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Thu Apr 21 18:00:33 2016
@@ -231,7 +231,7 @@ typedef ptrdiff_t streamsize;
 class _LIBCPP_TYPE_VIS ios_base
 {
 public:
-class _LIBCPP_TYPE_VIS failure;
+class _LIBCPP_EXCEPTION_ABI failure;
 
 typedef unsigned int fmtflags;
 static const fmtflags boolalpha   = 0x0001;


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


[libcxx] r267079 - Add is_swappable/is_nothrow_swappable traits

2016-04-21 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 21 18:38:59 2016
New Revision: 267079

URL: http://llvm.org/viewvc/llvm-project?rev=267079&view=rev
Log:
Add is_swappable/is_nothrow_swappable traits

Added:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable_with.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_with.pass.cpp
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/array
libcxx/trunk/include/map
libcxx/trunk/include/memory
libcxx/trunk/include/queue
libcxx/trunk/include/stack
libcxx/trunk/include/type_traits
libcxx/trunk/include/utility
libcxx/trunk/test/std/containers/sequences/array/array.special/swap.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
libcxx/trunk/test/std/utilities/utility/utility.swap/swap.pass.cpp
libcxx/trunk/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=267079&r1=267078&r2=267079&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Thu Apr 21 18:38:59 2016
@@ -630,7 +630,7 @@ template 
 #include 
 #include 
-#include 
+#include  // needed to provide swap_ranges.
 #include 
 #include 
 #include 

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=267079&r1=267078&r2=267079&view=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Thu Apr 21 18:38:59 2016
@@ -34,7 +34,7 @@ struct array
 
 // No explicit construct/copy/destroy for aggregate type
 void fill(const T& u);
-void swap(array& a) noexcept(noexcept(swap(declval(), declval(;
+void swap(array& a) noexcept(is_nothrow_swappable_v);
 
 // iterators:
 iterator begin() noexcept;
@@ -141,8 +141,15 @@ struct _LIBCPP_TYPE_VIS_ONLY array
 _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
 {_VSTD::fill_n(__elems_, _Size, __u);}
 _LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
-{_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(_Size == 0 || 
__is_nothrow_swappable<_Tp>::value)
+{ __swap_dispatch((std::integral_constant()), __a); }
+
+_LIBCPP_INLINE_VISIBILITY
+void __swap_dispatch(std::true_type, array&) {}
+
+_LIBCPP_INLINE_VISIBILITY
+void __swap_dispatch(std::false_type, array& __a)
+{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY
@@ -276,11 +283,12 @@ template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if
 <
+_Size == 0 ||
 __is_swappable<_Tp>::value,
 void
 >::type
 swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
-  
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+  _NOEXCEPT_(noexcept(__x.swap(__y)))
 {
 __x.swap(__y);
 }

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=267079&r1=267078&r2=267079&view=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Thu Apr 21 18:38:59 2016
@@ -162,7 +162,7 @@ public:
 
 void swap(map& m)
 noexcept(allocator_traits::is_always_equal::value &&
-__is_nothrow_swappable::value); // C++17
+is_nothrow_swappable::value); // C++17
 
 // observers:
 allocator_type get_allocator() const noexcept;
@@ -357,7 +357,7 @@ public:
 
 void swap(multimap& m)
 noexcept(allocator_traits::is_always_equal::value &&
-__is_nothrow_swappable::value); // C++17
+is_nothrow_swappable::value); // C++17
 
 // observers:
 allocator_type get_allocator() const noexcept;

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=267079&r1=267078&r2=267079&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Apr 21 18:38:59 2016
@@ -2974,7 +2974,10 @@ private:
 
 template 
 inline _LIBCPP_INLINE_

  1   2   >