[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-19 Thread wangxin via Phabricator via cfe-commits
wangxindsb updated this revision to Diff 111806.
wangxindsb added a comment.

+enum class ObjectState : bool { CtorCalled, DtorCalled };
+} // end namespace

Add namespace closing comment.


https://reviews.llvm.org/D34275

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp

Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,79 +1,43 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
 
-/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
-   from a constructor or destructor. If it is not set, we expect diagnostics
-   only in the constructor or destructor.
-
-   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
-   functions not to non-pure virtual functions.
-*/
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
 
 class A {
 public:
   A();
-  A(int i);
 
   ~A() {};
   
-  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
-  virtual void bar() = 0;
+  virtual int foo()=0;
+  virtual void bar()=0;
   void f() {
 foo();
-#if INTERPROCEDURAL
-// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
-#endif
+// expected-warning:Call to virtual function during construction
   }
 };
 
 class B : public A {
 public:
   B() {
 foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
-
+// expected-warning:Call to virtual function during construction
   }
   ~B();
   
   virtual int foo();
   virtual void bar() { foo(); }
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
-#endif
+  // expected-warning:Call to virtual function during destruction
 };
 
 A::A() {
   f();
 }
 
-A::A(int i) {
-  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
-#else
-  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
-#endif
-}
-
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
   this->foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
-#endif
-#endif
-
+  // expected-warning:Call to virtual function during destruction
 }
 
 class C : public B {
@@ -87,13 +51,7 @@
 
 C::C() {
   f(foo());
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
+  // expected-warning:Call to virtual function during construction
 }
 
 class D : public B {
@@ -103,7 +61,8 @@
   }
   ~D() { bar(); }
   int foo() final;
-  void bar() final { foo(); } // no-warning
+  void bar() final { foo(); } 
+  // no-warning
 };
 
 class E final : public B {
@@ -115,7 +74,6 @@
   int foo() override;
 };
 
-// Regression test: don't crash when there's no direct callee.
 class F {
 public:
   F() {
@@ -125,17 +83,103 @@
   void foo();
 };
 
-int main() {
-  A *a;
-  B *b;
-  C *c;
-  D *d;
-  E *e;
-  F *f;
+class G {
+public:
+  G() {}
+  virtual void bar();
+  void foo() {
+bar();
+  // no warning
+  }
+};
+
+class H{
+public:
+  H() : initState(0) { init(); }
+  int initState;
+  virtual void f() const;
+  void init() {
+if (initState)
+  f();
+  // no warning
+  }
+
+  H(int i) {
+G g;
+g.foo();
+g.bar();
+ 

[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-08-19 Thread Boris Kolpackov via Phabricator via cfe-commits
boris marked 6 inline comments as done.
boris added a comment.

I've marked as "done" items that I have resolved in my local revision (not yet 
uploaded) and have added one comment for further feedback.




Comment at: lib/Frontend/CompilerInvocation.cpp:982
+StringRef Val = A->getValue();
+if (Val.find('=') == StringRef::npos)
+  Opts.ExtraDeps.push_back(Val);

rsmith wrote:
> There should be some way to specify a module file that contains a `=` in its 
> file name. Ideally, that way would be compatible with our currently-supported 
> form of `-fmodule-name=filename`. I don't see a way to support that other 
> than `stat`ing every value we're given and checking to see whether it exists 
> before attempting to split on a `=`... thoughts?
> 
> One somewhat hackish alternative would be to only recognize an `=` if there 
> is no preceding `/`. (So `-fmodule-file=foo=bar.pcm` specifies a mapping, and 
> `-fmodule-file=./foo=bar.pcm` specifies the file `./foo=bar.pcm`.)
> 
> (FWIW, we also support module names containing `=` characters.)
A couple of thoughts:

1. Using stat() is also not without issues: I may have an unrelated file with a 
name that matches the whole value -- this will be fun to debug.

2. GCC seems to have given up on trying to support paths with '=' since AFAIK, 
none of their key=value options (e.g., -fdebug-prefix-map) support any kind of 
escaping. I think the implicit assumption is that if you are using paths with 
'=' in them, then you've asked for it.

3. The '/' idea will work but will get a bit hairier if we also want to support 
Windows (will need to check for both slashes).

4. Another option is to reserve empty module name as a way to escape '=': 
-fmodule-file==foo=bar.pcm. Not backwards compatible (but neither is ./) and 
looks a bit weird but is the simplest to implement.

My preference order is (2), (4), (3), (1). Let me know which way you want to go.




https://reviews.llvm.org/D35020



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


[PATCH] D36180: [clang-diff] Add option to dump the AST, one node per line

2017-08-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311232: [clang-diff] Add option to dump the AST, one node 
per line (authored by krobelus).

Repository:
  rL LLVM

https://reviews.llvm.org/D36180

Files:
  cfe/trunk/test/Tooling/clang-diff-ast.cpp
  cfe/trunk/test/Tooling/clang-diff-json.cpp
  cfe/trunk/tools/clang-diff/ClangDiff.cpp

Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -25,9 +25,14 @@
 
 static cl::opt
 ASTDump("ast-dump",
-cl::desc("Print the internal representation of the AST as JSON."),
+cl::desc("Print the internal representation of the AST."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt ASTDumpJson(
+"ast-dump-json",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -166,6 +171,15 @@
   OS << "(" << Id << ")";
 }
 
+static void printTree(raw_ostream &OS, diff::SyntaxTree &Tree) {
+  for (diff::NodeId Id : Tree) {
+for (int I = 0; I < Tree.getNode(Id).Depth; ++I)
+  OS << " ";
+printNode(OS, Tree, Id);
+OS << "\n";
+  }
+}
+
 static void printDstChange(raw_ostream &OS, diff::ASTDiff &Diff,
diff::SyntaxTree &SrcTree, diff::SyntaxTree &DstTree,
diff::NodeId Dst) {
@@ -213,15 +227,19 @@
 
   addExtraArgs(CommonCompilations);
 
-  if (ASTDump) {
+  if (ASTDump || ASTDumpJson) {
 if (!DestinationPath.empty()) {
   llvm::errs() << "Error: Please specify exactly one filename.\n";
   return 1;
 }
 std::unique_ptr AST = getAST(CommonCompilations, SourcePath);
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
+if (ASTDump) {
+  printTree(llvm::outs(), Tree);
+  return 0;
+}
 llvm::outs() << R"({"filename":")";
 printJsonString(llvm::outs(), SourcePath);
 llvm::outs() << R"(","root":)";
Index: cfe/trunk/test/Tooling/clang-diff-json.cpp
===
--- cfe/trunk/test/Tooling/clang-diff-json.cpp
+++ cfe/trunk/test/Tooling/clang-diff-json.cpp
@@ -1,11 +1,11 @@
-// RUN: clang-diff -ast-dump %s -- \
+// RUN: clang-diff -ast-dump-json %s -- \
 // RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 294,
+// CHECK: "begin": 299,
 // CHECK: "type": "CXXRecordDecl",
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 314,
+// CHECK: "end": 319,
 class A {
   int x;
 };
Index: cfe/trunk/test/Tooling/clang-diff-ast.cpp
===
--- cfe/trunk/test/Tooling/clang-diff-ast.cpp
+++ cfe/trunk/test/Tooling/clang-diff-ast.cpp
@@ -0,0 +1,50 @@
+// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
+
+
+// CHECK: {{^}}TranslationUnitDecl(0)
+// CHECK: {{^}} NamespaceDecl: test;(
+namespace test {
+
+// CHECK: {{^}}  FunctionDecl: f(
+// CHECK: CompoundStmt(
+void f() {
+  // CHECK: VarDecl: i(int)(
+  // CHECK: IntegerLiteral: 1
+  auto i = 1;
+  // CHECK: CallExpr(
+  // CHECK: DeclRefExpr: f(
+  f();
+  // CHECK: BinaryOperator: =(
+  i = i;
+}
+
+} // end namespace test
+
+// CHECK: TypedefDecl: nat;unsigned int;(
+typedef unsigned nat;
+// CHECK: TypeAliasDecl: real;double;(
+using real = double;
+
+class Base {
+};
+
+// CHECK: CXXRecordDecl: X;class X;(
+class X : Base {
+  int m;
+  // CHECK: CXXMethodDecl: foo(const char *(int))(
+  // CHECK: ParmVarDecl: i(int)(
+  const char *foo(int i) {
+if (i == 0)
+  // CHECK: StringLiteral: foo(
+  return "foo";
+return 0;
+  }
+
+  // CHECK: AccessSpecDecl: public(
+public:
+  // CHECK: CXXConstructorDecl: X(void (char, int))(
+  X(char, int) : Base(), m(0) {
+// CHECK: MemberExpr(
+int x = m;
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311232 - [clang-diff] Add option to dump the AST, one node per line

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 02:36:14 2017
New Revision: 311232

URL: http://llvm.org/viewvc/llvm-project?rev=311232&view=rev
Log:
[clang-diff] Add option to dump the AST, one node per line

Summary:
This is done with -ast-dump; the JSON variant has been renamed to
-ast-dump-json.

Reviewers: arphaman

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

Added:
cfe/trunk/test/Tooling/clang-diff-ast.cpp
Modified:
cfe/trunk/test/Tooling/clang-diff-json.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Added: cfe/trunk/test/Tooling/clang-diff-ast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-ast.cpp?rev=311232&view=auto
==
--- cfe/trunk/test/Tooling/clang-diff-ast.cpp (added)
+++ cfe/trunk/test/Tooling/clang-diff-ast.cpp Sat Aug 19 02:36:14 2017
@@ -0,0 +1,50 @@
+// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
+
+
+// CHECK: {{^}}TranslationUnitDecl(0)
+// CHECK: {{^}} NamespaceDecl: test;(
+namespace test {
+
+// CHECK: {{^}}  FunctionDecl: f(
+// CHECK: CompoundStmt(
+void f() {
+  // CHECK: VarDecl: i(int)(
+  // CHECK: IntegerLiteral: 1
+  auto i = 1;
+  // CHECK: CallExpr(
+  // CHECK: DeclRefExpr: f(
+  f();
+  // CHECK: BinaryOperator: =(
+  i = i;
+}
+
+} // end namespace test
+
+// CHECK: TypedefDecl: nat;unsigned int;(
+typedef unsigned nat;
+// CHECK: TypeAliasDecl: real;double;(
+using real = double;
+
+class Base {
+};
+
+// CHECK: CXXRecordDecl: X;class X;(
+class X : Base {
+  int m;
+  // CHECK: CXXMethodDecl: foo(const char *(int))(
+  // CHECK: ParmVarDecl: i(int)(
+  const char *foo(int i) {
+if (i == 0)
+  // CHECK: StringLiteral: foo(
+  return "foo";
+return 0;
+  }
+
+  // CHECK: AccessSpecDecl: public(
+public:
+  // CHECK: CXXConstructorDecl: X(void (char, int))(
+  X(char, int) : Base(), m(0) {
+// CHECK: MemberExpr(
+int x = m;
+  }
+};

Modified: cfe/trunk/test/Tooling/clang-diff-json.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-json.cpp?rev=311232&r1=311231&r2=311232&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-json.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-json.cpp Sat Aug 19 02:36:14 2017
@@ -1,11 +1,11 @@
-// RUN: clang-diff -ast-dump %s -- \
+// RUN: clang-diff -ast-dump-json %s -- \
 // RUN: | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 294,
+// CHECK: "begin": 299,
 // CHECK: "type": "CXXRecordDecl",
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 314,
+// CHECK: "end": 319,
 class A {
   int x;
 };

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311232&r1=311231&r2=311232&view=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Sat Aug 19 02:36:14 2017
@@ -25,9 +25,14 @@ static cl::OptionCategory ClangDiffCateg
 
 static cl::opt
 ASTDump("ast-dump",
-cl::desc("Print the internal representation of the AST as JSON."),
+cl::desc("Print the internal representation of the AST."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt ASTDumpJson(
+"ast-dump-json",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -166,6 +171,15 @@ static void printNode(raw_ostream &OS, d
   OS << "(" << Id << ")";
 }
 
+static void printTree(raw_ostream &OS, diff::SyntaxTree &Tree) {
+  for (diff::NodeId Id : Tree) {
+for (int I = 0; I < Tree.getNode(Id).Depth; ++I)
+  OS << " ";
+printNode(OS, Tree, Id);
+OS << "\n";
+  }
+}
+
 static void printDstChange(raw_ostream &OS, diff::ASTDiff &Diff,
diff::SyntaxTree &SrcTree, diff::SyntaxTree 
&DstTree,
diff::NodeId Dst) {
@@ -213,7 +227,7 @@ int main(int argc, const char **argv) {
 
   addExtraArgs(CommonCompilations);
 
-  if (ASTDump) {
+  if (ASTDump || ASTDumpJson) {
 if (!DestinationPath.empty()) {
   llvm::errs() << "Error: Please specify exactly one filename.\n";
   return 1;
@@ -222,6 +236,10 @@ int main(int argc, const char **argv) {
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
+if (ASTDump) {
+  printTree(llvm::outs(), Tree);
+  return 0;
+}
 llvm::outs() << R"({"filename":")";
 printJsonString(llvm::outs(), SourcePath);
 llvm::outs() << R"(","root":)";


___

r311233 - [clang-diff] Fix test

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 03:05:24 2017
New Revision: 311233

URL: http://llvm.org/viewvc/llvm-project?rev=311233&view=rev
Log:
[clang-diff] Fix test

Modified:
cfe/trunk/test/Tooling/clang-diff-ast.cpp

Modified: cfe/trunk/test/Tooling/clang-diff-ast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-ast.cpp?rev=311233&r1=311232&r2=311233&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-ast.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-ast.cpp Sat Aug 19 03:05:24 2017
@@ -31,7 +31,7 @@ class Base {
 // CHECK: CXXRecordDecl: X;class X;(
 class X : Base {
   int m;
-  // CHECK: CXXMethodDecl: foo(const char *(int))(
+  // CHECK: CXXMethodDecl: foo(const char *(int)
   // CHECK: ParmVarDecl: i(int)(
   const char *foo(int i) {
 if (i == 0)


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


r311234 - [StaticAnalyzer] LoopUnrolling: Exclude cases where the counter is escaped before the loop

2017-08-19 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Sat Aug 19 03:24:52 2017
New Revision: 311234

URL: http://llvm.org/viewvc/llvm-project?rev=311234&view=rev
Log:
[StaticAnalyzer] LoopUnrolling: Exclude cases where the counter is escaped 
before the loop

Adding escape check for the counter variable of the loop.
It is achieved by jumping back on the ExplodedGraph to its declStmt.

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=311234&r1=311233&r2=311234&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
Sat Aug 19 03:24:52 2017
@@ -8,8 +8,7 @@
 
//===--===//
 ///
 /// This header contains the declarations of functions which are used to decide
-/// which loops should be completely unrolled and mark their corresponding
-/// CFGBlocks.
+/// which loops should be completely unrolled and mark them.
 ///
 
//===--===//
 
@@ -28,7 +27,8 @@ ProgramStateRef markLoopAsUnrolled(const
const FunctionDecl *FD);
 bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Pred,
  AnalysisManager &AMgr);
-bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx);
+bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
+ExplodedNode *Pred);
 
 } // end namespace ento
 } // end namespace clang

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=311234&r1=311233&r2=311234&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sat Aug 19 03:24:52 2017
@@ -1504,7 +1504,7 @@ void ExprEngine::processCFGBlockEntrance
   if (AMgr.options.shouldUnrollLoops()) {
 const CFGBlock *ActualBlock = nodeBuilder.getContext().getBlock();
 const Stmt *Term = ActualBlock->getTerminator();
-if (Term && shouldCompletelyUnroll(Term, AMgr.getASTContext())) {
+if (Term && shouldCompletelyUnroll(Term, AMgr.getASTContext(), Pred)) {
   ProgramStateRef UnrolledState = markLoopAsUnrolled(
   Term, Pred->getState(),
   cast(Pred->getStackFrame()->getDecl()));

Modified: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp?rev=311234&r1=311233&r2=311234&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Sat Aug 19 03:24:52 2017
@@ -8,8 +8,9 @@
 
//===--===//
 ///
 /// This file contains functions which are used to decide if a loop worth to be
-/// unrolled. Moreover contains function which mark the CFGBlocks which belongs
-/// to the unrolled loop and store them in ProgramState.
+/// unrolled. Moreover contains function which mark the loops which are 
unrolled
+/// and store them in ProgramState. During the analysis we check the analyzed
+/// blocks if they are part of an unrolled loop or reached from one.
 ///
 
//===--===//
 
@@ -51,47 +52,52 @@ static internal::Matcher simpleCon
   hasEitherOperand(ignoringParenImpCasts(integerLiteral(;
 }
 
-static internal::Matcher changeIntBoundNode(StringRef NodeName) {
-  return anyOf(hasDescendant(unaryOperator(
-   anyOf(hasOperatorName("--"), hasOperatorName("++")),
-   hasUnaryOperand(ignoringParenImpCasts(
-   declRefExpr(to(varDecl(equalsBoundNode(NodeName,
-   hasDescendant(binaryOperator(
-   anyOf(hasOperatorName("="), hasOperatorName("+="),
- hasOperatorName("/="), hasOperatorName("*="),
- hasOperatorName("-=")),
-   hasLHS(ignoringParenImpCasts(
-   
declRefExpr(to(varDecl(equalsBoundNode(NodeName);
-}
-
-static internal::Matcher callByRef(StringRef NodeName) {
-  retur

[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-19 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 111812.
hamzasood added a comment.

Changed a documentation comment to use \brief instead of stating the function 
name.
Only enter the template parameter scope if needed.
Changed the phrasing of the diagnostic when an empty template parameter list is 
encountered.

Since submitting this patch for review, a test 

 has been added which fails with this patch. The test has a FIXME comment about 
moving the test somewhere when template lambda syntax is supported, but I'm not 
sure what needs to be done. Any ideas?


https://reviews.llvm.org/D36527

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -822,7 +822,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: test/SemaCXX/cxx2a-template-lambdas.cpp
===
--- test/SemaCXX/cxx2a-template-lambdas.cpp
+++ test/SemaCXX/cxx2a-template-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+template
+constexpr bool is_same = false;
+
+template
+constexpr bool is_same = true;
+
+template
+struct DummyTemplate { };
+
+void func() {
+  auto L0 = [](T arg) {
+static_assert(is_same);
+  };
+  L0(0);
+
+  auto L1 = [] {
+static_assert(I == 5);
+  };
+  L1.operator()<5>();
+
+  auto L2 = [] class T, class U>(T &&arg) {
+static_assert(is_same, DummyTemplate>);
+  };
+  L2(DummyTemplate());
+}
+
+template // expected-note {{declared here}}
+struct ShadowMe {
+  void member_func() {
+auto L = [] { }; // expected-error {{'T' shadows template parameter}}
+  }
+};
Index: test/Parser/cxx2a-template-lambdas.cpp
===
--- test/Parser/cxx2a-template-lambdas.cpp
+++ test/Parser/cxx2a-template-lambdas.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+auto L0 = []<> { }; //expected-error {{cannot be empty}}
+
+auto L1 = [] { };
+auto L2 = [](T1 arg1, T2 arg2) -> T1 { };
+auto L3 = [](auto arg) { T t; };
+auto L4 = []() { };
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2789,8 +2789,8 @@
 // template parameter type.
 sema::LambdaScopeInfo *LSI = SemaRef.getCurLambda();
 assert(LSI && "No LambdaScopeInfo on the stack!");
-const unsigned TemplateParameterDepth = LSI->AutoTemplateParameterDepth;
-const unsigned AutoParameterPosition = LSI->AutoTemplateParams.size();
+const unsigned TemplateParameterDepth = LSI->TemplateParameterDepth;
+const unsigned AutoParameterPosition = LSI->TemplateParams.size();
 const bool IsParameterPack = D.hasEllipsis();
 
 // Create the TemplateTypeParmDecl here to retrieve the corresponding
@@ -2802,7 +2802,7 @@
 /*KeyLoc*/SourceLocation(), /*NameLoc*/D.getLocStart(),
 TemplateParameterDepth, AutoParameterPosition,
 /*Identifier*/nullptr, false, IsParameterPack);
-LSI->AutoTemplateParams.push_back(CorrespondingTemplateParam);
+LSI->TemplateParams.push_back(CorrespondingTemplateParam);
 // Replace the 'auto' in the function parameter with this invented 
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -229,15 +229,17 @@
   if (LSI->GLTemplateParameterList)
 return LSI->GLTemplateParameterList;
 
-  if (!LSI->AutoTemplateParams.empty()) {
-SourceRange IntroRange = LSI->IntroducerRange;
-SourceLocation LAngleLoc = IntroRange.getBegin();
-SourceLocation RAngleLoc = IntroRange.getEnd();
+  if (!LSI->TemplateParams.empty()) {
+SourceRange ListRange = LSI->ExplicitTemplateParamsRange.isValid()
+  ? LSI->ExplicitTemplateParamsRange
+  : LSI->IntroducerRange;
+SourceLocation LAngleLoc = ListRange.getBegin();
+SourceLocation RAngleLoc = ListRange.getEnd();
 LSI->GLTemplateParameterList = TemplateParameterList::Create(
 SemaRef.Context,
 /*Template kw loc*/ SourceLocation(), LAngleLoc,
-   

r311235 - [CFG] Add LoopExit information to CFG

2017-08-19 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Sat Aug 19 04:19:16 2017
New Revision: 311235

URL: http://llvm.org/viewvc/llvm-project?rev=311235&view=rev
Log:
[CFG] Add LoopExit information to CFG

This patch introduces a new CFG element CFGLoopExit that indicate when a loop
ends. It does not deal with returnStmts yet (left it as a TODO).
It hidden behind a new analyzer-config flag called cfg-loopexit (false by
default).
Test cases added.

The main purpose of this patch right know is to make loop unrolling and loop
widening easier and more efficient. However, this information can be useful for
future improvements in the StaticAnalyzer core too.

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


Added:
cfe/trunk/test/Analysis/loopexit-cfg-output.cpp
Modified:
cfe/trunk/include/clang/Analysis/AnalysisContext.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/Analysis/AnalysisContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisContext.h?rev=311235&r1=311234&r2=311235&view=diff
==
--- cfe/trunk/include/clang/Analysis/AnalysisContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisContext.h Sat Aug 19 04:19:16 2017
@@ -427,6 +427,7 @@ public:
  bool addInitializers = false,
  bool addTemporaryDtors = false,
  bool addLifetime = false,
+ bool addLoopExit = false,
  bool synthesizeBodies = false,
  bool addStaticInitBranches = false,
  bool addCXXNewAllocator = true,

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=311235&r1=311234&r2=311235&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Sat Aug 19 04:19:16 2017
@@ -59,6 +59,7 @@ public:
 Initializer,
 NewAllocator,
 LifetimeEnds,
+LoopExit,
 // dtor kind
 AutomaticObjectDtor,
 DeleteDtor,
@@ -168,6 +169,29 @@ private:
   }
 };
 
+/// Represents the point where a loop ends.
+/// This element is is only produced when building the CFG for the static
+/// analyzer and hidden behind the 'cfg-loopexit' analyzer config flag.
+///
+/// Note: a loop exit element can be reached even when the loop body was never
+/// entered.
+class CFGLoopExit : public CFGElement {
+public:
+explicit CFGLoopExit(const Stmt *stmt)
+: CFGElement(LoopExit, stmt) {}
+
+const Stmt *getLoopStmt() const {
+  return static_cast(Data1.getPointer());
+}
+
+private:
+friend class CFGElement;
+CFGLoopExit() {}
+static bool isKind(const CFGElement &elem) {
+  return elem.getKind() == LoopExit;
+}
+};
+
 /// Represents the point where the lifetime of an automatic object ends
 class CFGLifetimeEnds : public CFGElement {
 public:
@@ -728,6 +752,10 @@ public:
 Elements.push_back(CFGLifetimeEnds(VD, S), C);
   }
 
+  void appendLoopExit(const Stmt *LoopStmt, BumpVectorContext &C) {
+Elements.push_back(CFGLoopExit(LoopStmt), C);
+  }
+
   void appendDeleteDtor(CXXRecordDecl *RD, CXXDeleteExpr *DE, 
BumpVectorContext &C) {
 Elements.push_back(CFGDeleteDtor(RD, DE), C);
   }
@@ -794,6 +822,7 @@ public:
 bool AddInitializers;
 bool AddImplicitDtors;
 bool AddLifetime;
+bool AddLoopExit;
 bool AddTemporaryDtors;
 bool AddStaticInitBranches;
 bool AddCXXNewAllocator;
@@ -818,7 +847,7 @@ public:
 PruneTriviallyFalseEdges(true),
 AddEHEdges(false),
 AddInitializers(false), AddImplicitDtors(false),
-AddLifetime(false),
+AddLifetime(false), AddLoopExit(false),
 AddTemporaryDtors(false), AddStaticInitBranches(false),
 AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {}
   };

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=311235&r1=311234&r2=311235&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Sat Aug 1

r311237 - [clang-diff] Make printing of matches optional

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 05:04:04 2017
New Revision: 311237

URL: http://llvm.org/viewvc/llvm-project?rev=311237&view=rev
Log:
[clang-diff] Make printing of matches optional

Reviewers: arphaman

Subscribers: klimek

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

Modified:
cfe/trunk/test/Tooling/clang-diff-args.test
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/test/Tooling/clang-diff-args.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-args.test?rev=311237&r1=311236&r2=311237&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-args.test (original)
+++ cfe/trunk/test/Tooling/clang-diff-args.test Sat Aug 19 05:04:04 2017
@@ -6,3 +6,7 @@ check adding compiler cflags
 RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s
+
+NOMATCH-CHECK-NOT: {{.}}
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 
\
+RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s

Modified: cfe/trunk/test/Tooling/clang-diff-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-basic.cpp?rev=311237&r1=311236&r2=311237&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp Sat Aug 19 05:04:04 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311237&r1=311236&r2=311237&view=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Sat Aug 19 05:04:04 2017
@@ -33,6 +33,10 @@ static cl::opt ASTDumpJson(
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
+ cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -267,7 +271,7 @@ int main(int argc, const char **argv) {
 
   for (diff::NodeId Dst : DstTree) {
 diff::NodeId Src = Diff.getMapped(DstTree, Dst);
-if (Src.isValid()) {
+if (PrintMatches && Src.isValid()) {
   llvm::outs() << "Match ";
   printNode(llvm::outs(), SrcTree, Src);
   llvm::outs() << " to ";


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


[PATCH] D36181: [clang-diff] Make printing of matches optional

2017-08-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311237: [clang-diff] Make printing of matches optional 
(authored by krobelus).

Changed prior to commit:
  https://reviews.llvm.org/D36181?vs=109503&id=111815#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36181

Files:
  cfe/trunk/test/Tooling/clang-diff-args.test
  cfe/trunk/test/Tooling/clang-diff-basic.cpp
  cfe/trunk/tools/clang-diff/ClangDiff.cpp


Index: cfe/trunk/test/Tooling/clang-diff-args.test
===
--- cfe/trunk/test/Tooling/clang-diff-args.test
+++ cfe/trunk/test/Tooling/clang-diff-args.test
@@ -6,3 +6,7 @@
 RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s
+
+NOMATCH-CHECK-NOT: {{.}}
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 
\
+RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s
Index: cfe/trunk/test/Tooling/clang-diff-basic.cpp
===
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {
Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -33,6 +33,10 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
+ cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -267,7 +271,7 @@
 
   for (diff::NodeId Dst : DstTree) {
 diff::NodeId Src = Diff.getMapped(DstTree, Dst);
-if (Src.isValid()) {
+if (PrintMatches && Src.isValid()) {
   llvm::outs() << "Match ";
   printNode(llvm::outs(), SrcTree, Src);
   llvm::outs() << " to ";


Index: cfe/trunk/test/Tooling/clang-diff-args.test
===
--- cfe/trunk/test/Tooling/clang-diff-args.test
+++ cfe/trunk/test/Tooling/clang-diff-args.test
@@ -6,3 +6,7 @@
 RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
 RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s
+
+NOMATCH-CHECK-NOT: {{.}}
+RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 \
+RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s
Index: cfe/trunk/test/Tooling/clang-diff-basic.cpp
===
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {
Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -33,6 +33,10 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt
+PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
+ cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -267,7 +271,7 @@
 
   for (diff::NodeId Dst : DstTree) {
 diff::NodeId Src = Diff.getMapped(DstTree, Dst);
-if (Src.isValid()) {
+if (PrintMatches && Src.isValid()) {
   llvm::outs() << "Match ";
   printNode(llvm::outs(), SrcTree, Src);
   llvm::outs() << " to ";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311240 - [clang-diff] Fix warning about useless comparison

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 06:29:44 2017
New Revision: 311240

URL: http://llvm.org/viewvc/llvm-project?rev=311240&view=rev
Log:
[clang-diff] Fix warning about useless comparison

Modified:
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311240&r1=311239&r2=311240&view=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Sat Aug 19 06:29:44 2017
@@ -106,7 +106,7 @@ getAST(const std::unique_ptrhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-08-19 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added inline comments.



Comment at: lib/Serialization/ASTReader.cpp:4145-4146
+// by-name lookup.
+if (Type == MK_PrebuiltModule || Type == MK_ExplicitModule)
+  ModuleMgr.registerPrebuilt(F);
 break;

rsmith wrote:
> I'm worried by this: the `Type` can be different for different imports of the 
> same .pcm file, and you'll only get here for the *first* import edge. So you 
> can fail to add the module to the "prebuilt modules" map here, and then later 
> attempt to look it up there (when processing the module offset map) and fail 
> to find it.
> 
> Instead of keeping a separate lookup structure on the module manager, could 
> you look up the `Module`, and then use its `ASTFile` to find the 
> corresponding `ModuleFile`?
> 
> (If you go that way, the changes to module lookup when reading the module 
> offset map could be generalized to apply to all `MK_*Module` types.)
Yes, I was not entirely happy with this register prebuilt business so thanks 
for the hint. I've implemented this and all tests pass (both Clang's and my 
own). Though I cannot say I fully understand all the possible scenarios (like 
when can ASTFile be NULL).



> (If you go that way, the changes to module lookup when reading the module 
> offset map could be generalized to apply to all MK_*Module types.)

Are you suggesting that we switch to storing module names instead of module 
files for all the module types in the offset map? If so, I think I've tried 
that at some point but it didn't go well (existing tests were failing if I 
remember correctly). I can try again if you think this should work. 




https://reviews.llvm.org/D35020



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


[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-08-19 Thread Boris Kolpackov via Phabricator via cfe-commits
boris updated this revision to Diff 111826.
boris added a comment.

New revision of the patch that I believe addresses all the issues except for 
the '=' escaping.


https://reviews.llvm.org/D35020

Files:
  docs/Modules.rst
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ModuleManager.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  lib/Serialization/ModuleManager.cpp
  test/CXX/modules-ts/basic/basic.search/module-import.cpp

Index: test/CXX/modules-ts/basic/basic.search/module-import.cpp
===
--- /dev/null
+++ test/CXX/modules-ts/basic/basic.search/module-import.cpp
@@ -0,0 +1,39 @@
+// Tests for imported module search.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: echo 'export module x; int a, b;' > %t/x.cppm
+// RUN: echo 'export module y; import x; int c;' > %t/y.cppm
+// RUN: echo 'export module z; import y; int d;' > %t/z.cppm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/x.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: mv %t/x.pcm %t/a.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=z
+//
+
+import MODULE_NAME;
+
+// expected-no-diagnostics
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -28,15 +28,23 @@
 using namespace clang;
 using namespace serialization;
 
-ModuleFile *ModuleManager::lookup(StringRef Name) const {
+ModuleFile *ModuleManager::lookupByFileName(StringRef Name) const {
   const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
/*cacheFailure=*/false);
   if (Entry)
 return lookup(Entry);
 
   return nullptr;
 }
 
+ModuleFile *ModuleManager::lookupByModuleName(StringRef Name) const {
+  if (const Module *Mod = HeaderSearchInfo.getModuleMap().findModule(Name))
+if (const FileEntry *File = Mod->getASTFile())
+  return lookup(File);
+
+  return nullptr;
+}
+
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
   auto Known = Modules.find(File);
   if (Known == Modules.end())
@@ -306,9 +314,11 @@
 }
 
 ModuleManager::ModuleManager(FileManager &FileMgr, MemoryBufferCache &PCMCache,
- const PCHContainerReader &PCHContainerRdr)
+ const PCHContainerReader &PCHContainerRdr,
+ const HeaderSearch& HeaderSearchInfo)
 : FileMgr(FileMgr), PCMCache(&PCMCache), PCHContainerRdr(PCHContainerRdr),
-  GlobalIndex(), FirstVisitState(nullptr) {}
+  HeaderSearchInfo (HeaderSearchInfo), GlobalIndex(),
+  FirstVisitState(nullptr) {}
 
 ModuleManager::~ModuleManager() { delete FirstVisitState; }
 
Index: lib/Serialization/GlobalModuleIndex.cpp
===
--- lib/Serialization/GlobalModuleIndex.cpp
+++ lib/Serialization/GlobalModuleIndex.cpp
@@ -619,6 +619,10 @@
   (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
   (uint32_t)Record[Idx++]}}};
 
+// Skip the module name (currently this is only used for prebuilt
+// modules while here we are only dealing with cached).
+Idx += Record[Idx] + 1;
+
 // Retrieve the imported file name.
 unsigned Length 

r311241 - [clang-diff] Add HTML side-by-side diff output

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 08:40:45 2017
New Revision: 311241

URL: http://llvm.org/viewvc/llvm-project?rev=311241&view=rev
Log:
[clang-diff] Add HTML side-by-side diff output

Reviewers: arphaman

Subscribers: mgorny

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

Added:
cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
cfe/trunk/test/Tooling/clang-diff-html.test
Modified:
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/CMakeLists.txt
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Added: cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp?rev=311241&view=auto
==
--- cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp (added)
+++ cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp Sat Aug 19 08:40:45 
2017
@@ -0,0 +1,31 @@
+namespace src {
+
+void foo() {
+  int x = 321;
+}
+
+void main() { foo(); };
+
+const char *a = "foo";
+
+typedef unsigned int nat;
+
+int p = 1 * 2 * 3 * 4;
+int squared = p * p;
+
+class X {
+  const char *foo(int i) {
+if (i == 0)
+  return "foo";
+return 0;
+  }
+
+public:
+  X(){};
+
+  int id(int i) { return i; }
+};
+}
+
+void m() { int x = 0 + 0 + 0; }
+int um = 1 + 2 + 3;

Modified: cfe/trunk/test/Tooling/clang-diff-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-basic.cpp?rev=311241&r1=311240&r2=311241&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp Sat Aug 19 08:40:45 2017
@@ -1,41 +1,5 @@
-// RUN: %clang_cc1 -E %s > %t.src.cpp
-// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %S/Inputs/clang-diff-basic-src.cpp %s -- | 
FileCheck %s
 
-#ifndef DEST
-namespace src {
-
-void foo() {
-  int x = 321;
-}
-
-void main() { foo(); };
-
-const char *a = "foo";
-
-typedef unsigned int nat;
-
-int p = 1 * 2 * 3 * 4;
-int squared = p * p;
-
-class X {
-  const char *foo(int i) {
-if (i == 0)
-  return "foo";
-return 0;
-  }
-
-public:
-  X(){};
-
-  int id(int i) { return i; }
-};
-}
-
-void m() { int x = 0 + 0 + 0; }
-int um = 1 + 2 + 3;
-
-#else
 // CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl
 // CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst
 namespace dst {
@@ -82,7 +46,6 @@ class X {
 void m() { { int x = 0 + 0 + 0; } }
 // CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: 
+({{.*}}) at 1
 int um = 1 + 7;
-#endif
 
 // CHECK: Delete AccessSpecDecl: public
 // CHECK: Delete CXXMethodDecl

Added: cfe/trunk/test/Tooling/clang-diff-html.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-html.test?rev=311241&view=auto
==
--- cfe/trunk/test/Tooling/clang-diff-html.test (added)
+++ cfe/trunk/test/Tooling/clang-diff-html.test Sat Aug 19 08:40:45 2017
@@ -0,0 +1,36 @@
+// RUN: clang-diff -html %S/Inputs/clang-diff-basic-src.cpp 
%S/clang-diff-basic.cpp -- | FileCheck %s
+
+// CHECK: 
+
+// match, update
+// CHECK: namespace src {
+
+// match, move
+// CHECK: void foo()
+
+// match
+// CHECK: void main()
+
+// deletion
+// CHECK: 4
+
+// update + move
+// CHECK: 2' class='u m'>2
+
+// insertion
+// CHECK: "Bar"
+
+// comments
+// CHECK: // CHECK: Insert IfStmt{{.*}} into IfStmt
+// CHECK: // CHECK: Delete AccessSpecDecl: public

Modified: cfe/trunk/tools/clang-diff/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/CMakeLists.txt?rev=311241&r1=311240&r2=311241&view=diff
==
--- cfe/trunk/tools/clang-diff/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-diff/CMakeLists.txt Sat Aug 19 08:40:45 2017
@@ -7,6 +7,7 @@ add_clang_executable(clang-diff
   )
 
 target_link_libraries(clang-diff
+  clangBasic
   clangFrontend
   clangTooling
   clangToolingASTDiff

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311241&r1=311240&r2=311241&view=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Sat Aug 19 08:40:45 2017
@@ -37,6 +37,10 @@ static cl::opt
 PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
  cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt HtmlDiff("html",
+  cl::desc("Output a side-by-side diff in HTML."),
+  cl::init(false), cl::cat(ClangDiffCategory));
+
 st

[PATCH] D36182: [clang-diff] Add HTML side-by-side diff output

2017-08-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311241: [clang-diff] Add HTML side-by-side diff output 
(authored by krobelus).

Changed prior to commit:
  https://reviews.llvm.org/D36182?vs=110553&id=111829#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36182

Files:
  cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
  cfe/trunk/test/Tooling/clang-diff-basic.cpp
  cfe/trunk/test/Tooling/clang-diff-html.test
  cfe/trunk/tools/clang-diff/CMakeLists.txt
  cfe/trunk/tools/clang-diff/ClangDiff.cpp

Index: cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
===
--- cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
+++ cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
@@ -0,0 +1,31 @@
+namespace src {
+
+void foo() {
+  int x = 321;
+}
+
+void main() { foo(); };
+
+const char *a = "foo";
+
+typedef unsigned int nat;
+
+int p = 1 * 2 * 3 * 4;
+int squared = p * p;
+
+class X {
+  const char *foo(int i) {
+if (i == 0)
+  return "foo";
+return 0;
+  }
+
+public:
+  X(){};
+
+  int id(int i) { return i; }
+};
+}
+
+void m() { int x = 0 + 0 + 0; }
+int um = 1 + 2 + 3;
Index: cfe/trunk/test/Tooling/clang-diff-html.test
===
--- cfe/trunk/test/Tooling/clang-diff-html.test
+++ cfe/trunk/test/Tooling/clang-diff-html.test
@@ -0,0 +1,36 @@
+// RUN: clang-diff -html %S/Inputs/clang-diff-basic-src.cpp %S/clang-diff-basic.cpp -- | FileCheck %s
+
+// CHECK: 
+
+// match, update
+// CHECK: namespace src {
+
+// match, move
+// CHECK: void foo()
+
+// match
+// CHECK: void main()
+
+// deletion
+// CHECK: 4
+
+// update + move
+// CHECK: 2' class='u m'>2
+
+// insertion
+// CHECK: "Bar"
+
+// comments
+// CHECK: // CHECK: Insert IfStmt{{.*}} into IfStmt
+// CHECK: // CHECK: Delete AccessSpecDecl: public
Index: cfe/trunk/test/Tooling/clang-diff-basic.cpp
===
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp
@@ -1,41 +1,5 @@
-// RUN: %clang_cc1 -E %s > %t.src.cpp
-// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %S/Inputs/clang-diff-basic-src.cpp %s -- | FileCheck %s
 
-#ifndef DEST
-namespace src {
-
-void foo() {
-  int x = 321;
-}
-
-void main() { foo(); };
-
-const char *a = "foo";
-
-typedef unsigned int nat;
-
-int p = 1 * 2 * 3 * 4;
-int squared = p * p;
-
-class X {
-  const char *foo(int i) {
-if (i == 0)
-  return "foo";
-return 0;
-  }
-
-public:
-  X(){};
-
-  int id(int i) { return i; }
-};
-}
-
-void m() { int x = 0 + 0 + 0; }
-int um = 1 + 2 + 3;
-
-#else
 // CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl
 // CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst
 namespace dst {
@@ -82,7 +46,6 @@
 void m() { { int x = 0 + 0 + 0; } }
 // CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 1
 int um = 1 + 7;
-#endif
 
 // CHECK: Delete AccessSpecDecl: public
 // CHECK: Delete CXXMethodDecl
Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -37,6 +37,10 @@
 PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
  cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt HtmlDiff("html",
+  cl::desc("Output a side-by-side diff in HTML."),
+  cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -105,6 +109,161 @@
 
 static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
 
+static const char HtmlDiffHeader[] = R"(
+
+
+
+
+span.d { color: red; }
+span.u { color: #cc00cc; }
+span.i { color: green; }
+span.m { font-weight: bold; }
+span   { font-weight: normal; color: black; }
+div.code {
+  width: 48%;
+  height: 98%;
+  overflow: scroll;
+  float: left;
+  padding: 0 0 0.5% 0.5%;
+  border: solid 2px LightGrey;
+  border-radius: 5px;
+}
+
+
+
+highlightStack = []
+function clearHighlight() {
+  while (highlightStack.length) {
+let [l, r] = highlightStack.pop()
+document.getElementById(l).style.backgroundColor = 'white'
+document.getElementById(r).style.backgroundColor = 'white'
+  }
+}
+function highlight(event) {
+  id = event.target['id']
+  doHighlight(id)
+}
+function doHighlight(id) {
+  clearHighlight()
+  source = document.getElementById(id)
+  if (!source.attributes['tid'])
+return
+  tid = source.attributes['tid'].value
+  target = document.getElementById(tid)
+  if (!target

[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

First of all, thanks everybody for working on this. I'd see what i can do.




Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:29
 namespace {
+enum class ObjectState : bool { CtorCalled, DtorCalled };
+} // end namespace

Please remind me what was wrong with ascending over `StackFrameContext`s to see 
if we're inside a constructor or destructor call? Why did we need a state trait 
here? Was it too hard to obtain this-values? (Not sure if there's time to fix 
this, but it might be worth it to leave a FIXME around).



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:56
+   CheckerContext &C) const;
+  void reportbug(StringRef Msg, bool PureError, const MemRegion *Reg,
+ CheckerContext &C) const;

I wish for camelCase.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:110
+  auto ThiSVal =
+  State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
+  const MemRegion *Reg = ThiSVal.getAsRegion();

I don't think this is working. CXXThisRegion is never a region of a C++ object; 
it's the segment of the stack where the pointer is passed, you need to 
dereference its value to get the actual object region.

Probably tests for the visitor might make things more clear.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:194
+if (IsPureOnly && MD->isPure())
+  reportbug("Call to pure function during construction", true, Reg, C);
+else

"Pure function" doesn't mean what we want to say here 
(https://en.wikipedia.org/wiki/Pure_function), i think we should stick with 
"pure virtual function" anyways.



Comment at: test/Analysis/virtualcall.cpp:15
 foo();
-#if INTERPROCEDURAL
-// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure 
virtual function during construction has undefined behavior}}
-#endif
+// expected-warning:Call to virtual function during construction
   }

Tests need fixing: `expected-warning` requires `{{` and needs to be on the 
correct line.


https://reviews.llvm.org/D34275



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


[PATCH] D36707: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation

2017-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36707



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


r311249 - [clang-diff] Fix compiler warning

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 10:12:25 2017
New Revision: 311249

URL: http://llvm.org/viewvc/llvm-project?rev=311249&view=rev
Log:
[clang-diff] Fix compiler warning

Modified:
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311249&r1=311248&r2=311249&view=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Sat Aug 19 10:12:25 2017
@@ -209,6 +209,7 @@ static std::string getChangeKindAbbr(dif
   case diff::UpdateMove:
 return "u m";
   }
+  llvm_unreachable("Invalid enumeration value.");
 }
 
 static unsigned printHtmlForNode(raw_ostream &OS, const diff::ASTDiff &Diff,


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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-19 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 111840.
Rakete marked 2 inline comments as done.
Rakete added a comment.

Update entry on the C++ status page.


https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
  www/cxx_status.html


Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -802,7 +802,7 @@
 
   const&-qualified pointers to members
   http://wg21.link/p0704r1";>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*&X::ref)(); // expected-error{{pointer-to-member function type 'void 
(X::*)() &' can only be called on an lvalue}}
+  (X{}.*&X::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? 
diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a 
extension">,
+  InGroup, SFINAEFailure;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "invoking a pointer to a 'const &' member function on an rvalue is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;


Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -802,7 +802,7 @@
 
   const&-qualified pointers to members
   http://wg21.link/p0704r1";>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*&X::ref)(); // expected-error{{pointer-to-member function type 'void (X::*)() &' can only be called on an lvalue}}
+  (X{}.*&X::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+  

r311250 - Add clang-diff to tool_patterns in test/lit.cfg

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 10:52:29 2017
New Revision: 311250

URL: http://llvm.org/viewvc/llvm-project?rev=311250&view=rev
Log:
Add clang-diff to tool_patterns in test/lit.cfg

Modified:
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=311250&r1=311249&r2=311250&view=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Sat Aug 19 10:52:29 2017
@@ -326,6 +326,7 @@ NoPostBar = r"(?!(/|\\))"
 tool_patterns = [r"\bFileCheck\b",
  r"\bc-index-test\b",
  NoPreHyphenDot + r"\bclang-check\b" + NoPostHyphenDot,
+ NoPreHyphenDot + r"\bclang-diff\b" + NoPostHyphenDot,
  NoPreHyphenDot + r"\bclang-format\b" + NoPostHyphenDot,
  # FIXME: Some clang test uses opt?
  NoPreHyphenDot + r"\bopt\b" + NoPostBar + NoPostHyphenDot,


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


r311251 - [clang-diff] Simplify mapping

2017-08-19 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Sat Aug 19 10:53:01 2017
New Revision: 311251

URL: http://llvm.org/viewvc/llvm-project?rev=311251&view=rev
Log:
[clang-diff] Simplify mapping

Summary:
Until we find a decent heuristic on how to choose between multiple
identical trees, there is no point in supporting multiple mappings.

This also enables matching of nodes with parents of different types,
because there are many instances where this is appropriate.  For
example for and foreach statements; functions in the global or
other namespaces.

Reviewers: arphaman

Subscribers: klimek

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

Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
cfe/trunk/test/Tooling/clang-diff-basic.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311251&r1=311250&r2=311251&view=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Sat Aug 19 10:53:01 2017
@@ -111,10 +111,6 @@ struct ComparisonOptions {
   /// mapping is computed, unless the size of either subtrees exceeds this.
   int MaxSize = 100;
 
-  /// If this is set to true, nodes that have parents that must not be matched
-  /// (see NodeComparison) will be allowed to be matched.
-  bool EnableMatchingWithUnmatchableParents = false;
-
   /// Returns false if the nodes should never be matched.
   bool isMatchingAllowed(const Node &N1, const Node &N2) const {
 return N1.getType().isSame(N2.getType());

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311251&r1=311250&r2=311251&view=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Sat Aug 19 10:53:01 2017
@@ -34,48 +34,23 @@ public:
   Mapping() = default;
   Mapping(Mapping &&Other) = default;
   Mapping &operator=(Mapping &&Other) = default;
-  Mapping(int Size1, int Size2) {
-// Maximum possible size after patching one tree.
-int Size = Size1 + Size2;
-SrcToDst = llvm::make_unique[]>(Size);
-DstToSrc = llvm::make_unique[]>(Size);
+
+  Mapping(size_t Size) {
+SrcToDst = llvm::make_unique(Size);
+DstToSrc = llvm::make_unique(Size);
   }
 
   void link(NodeId Src, NodeId Dst) {
-SrcToDst[Src].push_back(Dst);
-DstToSrc[Dst].push_back(Src);
+SrcToDst[Src] = Dst, DstToSrc[Dst] = Src;
   }
 
-  NodeId getDst(NodeId Src) const {
-if (hasSrc(Src))
-  return SrcToDst[Src][0];
-return NodeId();
-  }
-  NodeId getSrc(NodeId Dst) const {
-if (hasDst(Dst))
-  return DstToSrc[Dst][0];
-return NodeId();
-  }
-  const SmallVector &getAllDsts(NodeId Src) const {
-return SrcToDst[Src];
-  }
-  const SmallVector &getAllSrcs(NodeId Dst) const {
-return DstToSrc[Dst];
-  }
-  bool hasSrc(NodeId Src) const { return !SrcToDst[Src].empty(); }
-  bool hasDst(NodeId Dst) const { return !DstToSrc[Dst].empty(); }
-  bool hasSrcDst(NodeId Src, NodeId Dst) const {
-for (NodeId DstId : SrcToDst[Src])
-  if (DstId == Dst)
-return true;
-for (NodeId SrcId : DstToSrc[Dst])
-  if (SrcId == Src)
-return true;
-return false;
-  }
+  NodeId getDst(NodeId Src) const { return SrcToDst[Src]; }
+  NodeId getSrc(NodeId Dst) const { return DstToSrc[Dst]; }
+  bool hasSrc(NodeId Src) const { return getDst(Src).isValid(); }
+  bool hasDst(NodeId Dst) const { return getSrc(Dst).isValid(); }
 
 private:
-  std::unique_ptr[]> SrcToDst, DstToSrc;
+  std::unique_ptr SrcToDst, DstToSrc;
 };
 } // end anonymous namespace
 
@@ -105,8 +80,6 @@ private:
   // Returns true if the two subtrees are identical.
   bool identical(NodeId Id1, NodeId Id2) const;
 
-  bool canBeAddedToMapping(const Mapping &M, NodeId Id1, NodeId Id2) const;
-
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
@@ -712,23 +685,6 @@ bool ASTDiff::Impl::identical(NodeId Id1
   return true;
 }
 
-bool ASTDiff::Impl::canBeAddedToMapping(const Mapping &M, NodeId Id1,
-NodeId Id2) const {
-  assert(isMatchingPossible(Id1, Id2) &&
- "Matching must be possible in the first place.");
-  if (M.hasSrcDst(Id1, Id2))
-return false;
-  if (Options.EnableMatchingWithUnmatchableParents)
-return true;
-  const Node &N1 = T1.getNode(Id1);
-  const Node &N2 = T2.getNode(Id2);
-  NodeId P1 = N1.Parent;
-  NodeId P2 = N2.Parent;
-  // Only allow matching if parents can be matched.
-  return (P1.isInvalid() && P2.isInvalid()) ||
- (P1.isValid() && P2.isValid() && i

[PATCH] D36183: [clang-diff] Simplify mapping

2017-08-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311251: [clang-diff] Simplify mapping (authored by krobelus).

Repository:
  rL LLVM

https://reviews.llvm.org/D36183

Files:
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
  cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
  cfe/trunk/test/Tooling/Inputs/clang-diff-basic-src.cpp
  cfe/trunk/test/Tooling/clang-diff-basic.cpp

Index: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -34,48 +34,23 @@
   Mapping() = default;
   Mapping(Mapping &&Other) = default;
   Mapping &operator=(Mapping &&Other) = default;
-  Mapping(int Size1, int Size2) {
-// Maximum possible size after patching one tree.
-int Size = Size1 + Size2;
-SrcToDst = llvm::make_unique[]>(Size);
-DstToSrc = llvm::make_unique[]>(Size);
+
+  Mapping(size_t Size) {
+SrcToDst = llvm::make_unique(Size);
+DstToSrc = llvm::make_unique(Size);
   }
 
   void link(NodeId Src, NodeId Dst) {
-SrcToDst[Src].push_back(Dst);
-DstToSrc[Dst].push_back(Src);
+SrcToDst[Src] = Dst, DstToSrc[Dst] = Src;
   }
 
-  NodeId getDst(NodeId Src) const {
-if (hasSrc(Src))
-  return SrcToDst[Src][0];
-return NodeId();
-  }
-  NodeId getSrc(NodeId Dst) const {
-if (hasDst(Dst))
-  return DstToSrc[Dst][0];
-return NodeId();
-  }
-  const SmallVector &getAllDsts(NodeId Src) const {
-return SrcToDst[Src];
-  }
-  const SmallVector &getAllSrcs(NodeId Dst) const {
-return DstToSrc[Dst];
-  }
-  bool hasSrc(NodeId Src) const { return !SrcToDst[Src].empty(); }
-  bool hasDst(NodeId Dst) const { return !DstToSrc[Dst].empty(); }
-  bool hasSrcDst(NodeId Src, NodeId Dst) const {
-for (NodeId DstId : SrcToDst[Src])
-  if (DstId == Dst)
-return true;
-for (NodeId SrcId : DstToSrc[Dst])
-  if (SrcId == Src)
-return true;
-return false;
-  }
+  NodeId getDst(NodeId Src) const { return SrcToDst[Src]; }
+  NodeId getSrc(NodeId Dst) const { return DstToSrc[Dst]; }
+  bool hasSrc(NodeId Src) const { return getDst(Src).isValid(); }
+  bool hasDst(NodeId Dst) const { return getSrc(Dst).isValid(); }
 
 private:
-  std::unique_ptr[]> SrcToDst, DstToSrc;
+  std::unique_ptr SrcToDst, DstToSrc;
 };
 } // end anonymous namespace
 
@@ -105,8 +80,6 @@
   // Returns true if the two subtrees are identical.
   bool identical(NodeId Id1, NodeId Id2) const;
 
-  bool canBeAddedToMapping(const Mapping &M, NodeId Id1, NodeId Id2) const;
-
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
@@ -712,23 +685,6 @@
   return true;
 }
 
-bool ASTDiff::Impl::canBeAddedToMapping(const Mapping &M, NodeId Id1,
-NodeId Id2) const {
-  assert(isMatchingPossible(Id1, Id2) &&
- "Matching must be possible in the first place.");
-  if (M.hasSrcDst(Id1, Id2))
-return false;
-  if (Options.EnableMatchingWithUnmatchableParents)
-return true;
-  const Node &N1 = T1.getNode(Id1);
-  const Node &N2 = T2.getNode(Id2);
-  NodeId P1 = N1.Parent;
-  NodeId P2 = N2.Parent;
-  // Only allow matching if parents can be matched.
-  return (P1.isInvalid() && P2.isInvalid()) ||
- (P1.isValid() && P2.isValid() && isMatchingPossible(P1, P2));
-}
-
 bool ASTDiff::Impl::isMatchingPossible(NodeId Id1, NodeId Id2) const {
   return Options.isMatchingAllowed(T1.getNode(Id1), T2.getNode(Id2));
 }
@@ -751,7 +707,7 @@
   for (const auto Tuple : R) {
 NodeId Src = Tuple.first;
 NodeId Dst = Tuple.second;
-if (canBeAddedToMapping(M, Src, Dst))
+if (!M.hasSrc(Src) && !M.hasDst(Dst))
   M.link(Src, Dst);
   }
 }
@@ -804,7 +760,7 @@
 if (Matched || !MatchedChildren)
   continue;
 NodeId Id2 = findCandidate(M, Id1);
-if (Id2.isValid() && canBeAddedToMapping(M, Id1, Id2)) {
+if (Id2.isValid()) {
   M.link(Id1, Id2);
   addOptimalMapping(M, Id1, Id2);
 }
@@ -815,7 +771,7 @@
   PriorityList L1(T1);
   PriorityList L2(T2);
 
-  Mapping M(T1.getSize(), T2.getSize());
+  Mapping M(T1.getSize() + T2.getSize());
 
   L1.push(T1.getRootId());
   L2.push(T2.getRootId());
@@ -838,7 +794,7 @@
 H2 = L2.pop();
 for (NodeId Id1 : H1) {
   for (NodeId Id2 : H2) {
-if (identical(Id1, Id2) && canBeAddedToMapping(M, Id1, Id2)) {
+if (identical(Id1, Id2) && !M.hasSrc(Id1) && !M.hasDst(Id2)) {
   for (int I = 0, E = T1.getNumberOfDescendants(Id1); I < E; ++I)
 M.link(Id1 + I, Id2 + I);
 }
Index: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
===
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
@@ -111,10 +111,6 @@
   /// mapping is computed, unless the size of either subtrees exce

[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-19 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: include/clang/Sema/ScopeInfo.h:774
+  /// \brief The number of parameters in the template parameter list that were
+  /// explicitely specified by the user, as opposed to being invented by use
+  /// of an auto parameter.

typo: explicitly



Comment at: lib/Parse/ParseExprCXX.cpp:1090
+  TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
+  Actions.RecordParsingTemplateParameterDepth(TemplateParameterDepth);
+

Since you only really need to pass this information on for computing the depth 
of the 'auto' parameters - why not just leave the 
RecordParsingTEmplateParameterDepth call where it was, increment the template 
depth once we parse the TPL, and just pass in the right depth (minus one if 
ExplicitTemplateParameters) and increment the tracker if we getGenericLambda 
but no explicit TPL?

I wonder if that might be the safer way to do it - especially if you have 
generic lambdas in default arguments of generic lambdas - each of which have 
explicit template parameters also??

thoughts?




Comment at: lib/Parse/ParseExprCXX.cpp:1113
+  // FIXME: Consider allowing this as an extension for GCC compatibiblity.
+  bool HasExplicitTemplateParams = getLangOpts().CPlusPlus2a
+   && Tok.is(tok::less);

make this const pls.



Comment at: lib/Parse/ParseExprCXX.cpp:1305
 
+  TemplateParamScope.Exit();
+

Why do you exit the scope here, and then re-add the template parameters to the 
current scope?  What confusion (if any) occurs if you leave this scope on?



https://reviews.llvm.org/D36527



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-19 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

In regards to that failing test (that was added since review began) - could you 
fix that test pls (i.e. rename the nested ttp 'U' to something else) and move 
it into the function 'f' as requested by the author?
Might want to include a similar (but not same) example of matching complexity 
to your tests too.

Thanks!


https://reviews.llvm.org/D36527



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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-19 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added inline comments.



Comment at: include/clang/Lex/PreprocessorOptions.h:165
 public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  PreprocessorOptions() : PPTimer("preprocessor", "Preprocessing"),
+  UsePredefines(true),

eduardo-elizondo wrote:
> Should this be named "Lexing Time" or "Lexing" instead of "Preprocessing"?
Good idea! Now that the timer's being started up in the `Preprocessor::Lex` 
method, it probably should be named "Lexing". Alternatively, I could move this 
into, say,` Lexer::Lex`. I guess there's not much of a distinction in Clang 
between "lexing" and "preprocessing."

I had originally picked this name because that's what appears in `gcc 
-ftime-report`, but I guess we don't need to keep the names the same.


https://reviews.llvm.org/D36492



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


[PATCH] D36820: [Bash-autocompletion] Add support for -std=

2017-08-19 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36820



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


[PATCH] D36931: Update LLVM 5.0 release notes for ms_abi and __builtin_ms_va_list for aarch64

2017-08-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, rengolin, aemerson.

https://reviews.llvm.org/D36931

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -85,6 +85,8 @@
 -  The ``overloadable`` attribute now allows at most one function with a given
name to lack the ``overloadable`` attribute. This unmarked function will not
have its name mangled.
+-  The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and 
builtins
+   are now supported on AArch64.
 
 Windows Support
 ---


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -85,6 +85,8 @@
 -  The ``overloadable`` attribute now allows at most one function with a given
name to lack the ``overloadable`` attribute. This unmarked function will not
have its name mangled.
+-  The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins
+   are now supported on AArch64.
 
 Windows Support
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311270 - clang/test/Tooling/clang-diff-ast.cpp: Satisfy thiscall.

2017-08-19 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Aug 19 17:02:20 2017
New Revision: 311270

URL: http://llvm.org/viewvc/llvm-project?rev=311270&view=rev
Log:
clang/test/Tooling/clang-diff-ast.cpp: Satisfy thiscall.

  clang/test/Tooling/clang-diff-ast.cpp:45:12: error: expected string not found 
in input
   // CHECK: CXXConstructorDecl: X(void (char, int))
 ^
  :43:25: note: scanning from here
   AccessSpecDecl: public(42)
  ^
  :44:2: note: possible intended match here
   CXXConstructorDecl: X(void (char, int) __attribute__((thiscall)))(43)
   ^

Modified:
cfe/trunk/test/Tooling/clang-diff-ast.cpp

Modified: cfe/trunk/test/Tooling/clang-diff-ast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-ast.cpp?rev=311270&r1=311269&r2=311270&view=diff
==
--- cfe/trunk/test/Tooling/clang-diff-ast.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-ast.cpp Sat Aug 19 17:02:20 2017
@@ -42,7 +42,7 @@ class X : Base {
 
   // CHECK: AccessSpecDecl: public(
 public:
-  // CHECK: CXXConstructorDecl: X(void (char, int))(
+  // CHECK: CXXConstructorDecl: X(void (char, int){{( 
__attribute__\(\(thiscall\)\))?}})(
   X(char, int) : Base(), m(0) {
 // CHECK: MemberExpr(
 int x = m;


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


[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-19 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Update the README file please (with a text similar to this commit message)




Comment at: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:32
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)

[remark, feel free to ignore]
the "break;" here is redundant, and thus the {} too, i.e. you can keep the code 
shorter.
Whether it will make it more readable is debatable.  


Repository:
  rL LLVM

https://reviews.llvm.org/D36882



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


[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-19 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Please also write a lit test for test/DeepRecursionTest.cpp (e.g. 
test/deep-recursion.test)


Repository:
  rL LLVM

https://reviews.llvm.org/D36839



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


[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-19 Thread wangxin via Phabricator via cfe-commits
wangxindsb marked 3 inline comments as done.
wangxindsb added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:29
 namespace {
+enum class ObjectState : bool { CtorCalled, DtorCalled };
+} // end namespace

NoQ wrote:
> Please remind me what was wrong with ascending over `StackFrameContext`s to 
> see if we're inside a constructor or destructor call? Why did we need a state 
> trait here? Was it too hard to obtain this-values? (Not sure if there's time 
> to fix this, but it might be worth it to leave a FIXME around).
I have implement this method before, the code is on this link, [[ 
https://github.com/wangxindsb/VirtualCallChecker/blob/master/VirtualCallChecker-fullstack.cpp
 | virtualcallchecker using stackframe]]. I thought it was harder and slower 
than the state trait, so I gave up this method. Also, I thought this method 
maybe hard to add visitor. I will work on this soon.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:110
+  auto ThiSVal =
+  State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
+  const MemRegion *Reg = ThiSVal.getAsRegion();

NoQ wrote:
> I don't think this is working. CXXThisRegion is never a region of a C++ 
> object; it's the segment of the stack where the pointer is passed, you need 
> to dereference its value to get the actual object region.
> 
> Probably tests for the visitor might make things more clear.
```
class Y {
public:
  virtual void foobar();
  void fooY() {  
F f1;
foobar();
  }
  Y() {
fooY();
  }
};

```
I thought this test is for this situation. If the visitor is correct, it will 
issued "Called from this constructor 'Y'", else it will issued "Called from 
this constructor 'F'".



https://reviews.llvm.org/D34275



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


[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-19 Thread wangxin via Phabricator via cfe-commits
wangxindsb updated this revision to Diff 111862.
wangxindsb added a comment.

- Rename reportbug();
- Change message "Pure function" to "pure virtual function";
- Fixing: expected-warning;


https://reviews.llvm.org/D34275

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp

Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,99 +1,56 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
-
-/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
-   from a constructor or destructor. If it is not set, we expect diagnostics
-   only in the constructor or destructor.
-
-   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
-   functions not to non-pure virtual functions.
-*/
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall
+// -analyzer-store region -verify -std=c++11 %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall
+// -analyzer-store region -analyzer-config
+// optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
 
 class A {
 public:
   A();
-  A(int i);
 
-  ~A() {};
-  
-  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
+  ~A(){};
+
+  virtual int foo() = 0;
   virtual void bar() = 0;
   void f() {
-foo();
-#if INTERPROCEDURAL
-// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
-#endif
+foo(); // expected-warning{{Call to virtual function during construction}}
   }
 };
 
 class B : public A {
 public:
   B() {
-foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
-
+foo(); // expected-warning{{Call to virtual function during construction}}
   }
   ~B();
-  
+
   virtual int foo();
-  virtual void bar() { foo(); }
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
-#endif
+  virtual void bar() {
+foo();
+  } // expected-warning{{Call to virtual function during destruction}}
 };
 
-A::A() {
-  f();
-}
-
-A::A(int i) {
-  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
-#else
-  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
-#endif
-}
+A::A() { f(); }
 
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo();
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
-#endif
-#endif
-
+  this->foo(); // expected-warning{{Call to virtual function during
+   // destruction}}
 }
 
 class C : public B {
 public:
   C();
   ~C();
-  
+
   virtual int foo();
   void f(int i);
 };
 
 C::C() {
-  f(foo());
-#if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
-#endif
-#endif
+  f(foo()); // expected-warning{{Call to virtual function during construction}}
 }
 
 class D : public B {
@@ -115,27 +72,100 @@
   int foo() override;
 };
 
-// Regression test: don't crash when there's no direct callee.
 class F {
 public:
   F() {
-void (F::* ptr)() = &F::foo;
+void (F::*ptr)() = &F::foo;
 (this->*ptr)();
   }
   void foo();
 };
 
-int main() {
-  A *a;
-  B *b;
-  C *c;
-  D *d;
-  E *e;
-  F *f;
+class G {
+public:
+  G() {}
+  virtual void bar();
+  void foo() {
+bar(); // no warning
+  }
+};
+
+class H {
+public:
+  H() : initState(0) { init(); }
+  int initStat

[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-19 Thread wangxin via Phabricator via cfe-commits
wangxindsb added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:31
+} // end namespace
+  // FIXME: Ascending over StackFrameContext maybe another method.
+

Add the FIXME


https://reviews.llvm.org/D34275



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