[PATCH] D55698: [MinGW] Produce a vtable and RTTI for dllexported classes without a key function

2018-12-15 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349256: [MinGW] Produce a vtable and RTTI for dllexported 
classes without a key function (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55698?vs=178275&id=178343#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55698/new/

https://reviews.llvm.org/D55698

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -5528,6 +5528,9 @@
 // declaration.
 return;
 
+  if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+S.MarkVTableUsed(Class->getLocation(), Class, true);
+
   for (Decl *Member : Class->decls()) {
 // Defined static variables that are members of an exported base
 // class must be marked export too.
Index: cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
+++ cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix=GNU %s
+
+class __declspec(dllexport) QAbstractLayoutStyleInfo {
+public:
+  QAbstractLayoutStyleInfo() : m_isWindow(false) {}
+  virtual ~QAbstractLayoutStyleInfo() {}
+
+  virtual bool hasChangedCore() const { return false; }
+
+  virtual void invalidate() {}
+
+  virtual double windowMargin(bool orientation) const = 0;
+
+  bool isWindow() const { return m_isWindow; }
+
+protected:
+  bool m_isWindow;
+};
+
+// GNU-DAG: @_ZTV24QAbstractLayoutStyleInfo = weak_odr dso_local dllexport
+// GNU-DAG: @_ZTS24QAbstractLayoutStyleInfo = linkonce_odr
+// GNU-DAG: @_ZTI24QAbstractLayoutStyleInfo = linkonce_odr


Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -5528,6 +5528,9 @@
 // declaration.
 return;
 
+  if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+S.MarkVTableUsed(Class->getLocation(), Class, true);
+
   for (Decl *Member : Class->decls()) {
 // Defined static variables that are members of an exported base
 // class must be marked export too.
Index: cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
+++ cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
+
+class __declspec(dllexport) QAbstractLayoutStyleInfo {
+public:
+  QAbstractLayoutStyleInfo() : m_isWindow(false) {}
+  virtual ~QAbstractLayoutStyleInfo() {}
+
+  virtual bool hasChangedCore() const { return false; }
+
+  virtual void invalidate() {}
+
+  virtual double windowMargin(bool orientation) const = 0;
+
+  bool isWindow() const { return m_isWindow; }
+
+protected:
+  bool m_isWindow;
+};
+
+// GNU-DAG: @_ZTV24QAbstractLayoutStyleInfo = weak_odr dso_local dllexport
+// GNU-DAG: @_ZTS24QAbstractLayoutStyleInfo = linkonce_odr
+// GNU-DAG: @_ZTI24QAbstractLayoutStyleInfo = linkonce_odr
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349256 - [MinGW] Produce a vtable and RTTI for dllexported classes without a key function

2018-12-15 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Sat Dec 15 00:08:11 2018
New Revision: 349256

URL: http://llvm.org/viewvc/llvm-project?rev=349256&view=rev
Log:
[MinGW] Produce a vtable and RTTI for dllexported classes without a key function

This matches what GCC does in these situations.

This fixes compiling Qt in debug mode. In release mode, references to
the vtable of this particular class ends up optimized away, but in debug
mode, the compiler creates references to the vtable, which is expected
to be dllexported from a different DLL. Make sure the dllexported
version actually ends up emitted.

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

Added:
cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=349256&r1=349255&r2=349256&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Dec 15 00:08:11 2018
@@ -5528,6 +5528,9 @@ static void ReferenceDllExportedMembers(
 // declaration.
 return;
 
+  if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+S.MarkVTableUsed(Class->getLocation(), Class, true);
+
   for (Decl *Member : Class->decls()) {
 // Defined static variables that are members of an exported base
 // class must be marked export too.

Added: cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp?rev=349256&view=auto
==
--- cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/dllexport-missing-key.cpp Sat Dec 15 00:08:11 2018
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix=GNU %s
+
+class __declspec(dllexport) QAbstractLayoutStyleInfo {
+public:
+  QAbstractLayoutStyleInfo() : m_isWindow(false) {}
+  virtual ~QAbstractLayoutStyleInfo() {}
+
+  virtual bool hasChangedCore() const { return false; }
+
+  virtual void invalidate() {}
+
+  virtual double windowMargin(bool orientation) const = 0;
+
+  bool isWindow() const { return m_isWindow; }
+
+protected:
+  bool m_isWindow;
+};
+
+// GNU-DAG: @_ZTV24QAbstractLayoutStyleInfo = weak_odr dso_local dllexport
+// GNU-DAG: @_ZTS24QAbstractLayoutStyleInfo = linkonce_odr
+// GNU-DAG: @_ZTI24QAbstractLayoutStyleInfo = linkonce_odr


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


r349259 - [libclang] Add dependency on clangSerialization to unbreak -DBUILD_SHARED_LIBS=1 build after rC349237

2018-12-15 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sat Dec 15 00:54:06 2018
New Revision: 349259

URL: http://llvm.org/viewvc/llvm-project?rev=349259&view=rev
Log:
[libclang] Add dependency on clangSerialization to unbreak 
-DBUILD_SHARED_LIBS=1 build after rC349237

Frontend headers have undefined reference on the symbol 
`clang::PCHContainerOperations::PCHContainerOperations()` through some 
shared_ptr usage. Any dependents will get the undefined reference which can 
only be resolved by explicit dependency on clangSerialization (due to -z defs).

Modified:
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=349259&r1=349258&r2=349259&view=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Sat Dec 15 00:54:06 2018
@@ -40,6 +40,7 @@ set(LIBS
   clangIndex
   clangLex
   clangSema
+  clangSerialization
   clangTooling
 )
 


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


[PATCH] D55734: Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 created this revision.
boga95 added reviewers: gerazo, xazax.hun, Szelethus, a_sidorin, dcoughlin, 
george.karpenkov.
Herald added subscribers: cfe-commits, rnkovacs.

Use a more optimal data structure to represent taint propagation rules.


Repository:
  rC Clang

https://reviews.llvm.org/D55734

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -23,6 +23,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -69,8 +71,8 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(const CallExpr *,
-   CheckerContext &C) const;
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
+  const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postRetTaint(const CallExpr *CE, CheckerContext &C) const;
@@ -100,7 +102,7 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -112,30 +114,27 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it mark all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
@@ -144,9 +143,12 @@
   CheckerContext &C);
 
 inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A)  { DstArgs.push_back(A); }
+inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+inline bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
 inline bool isDestinationArgument(unsigned ArgNum) const {
   return (std::find(DstArgs.begin(),
@@ -169,7 +171,6 @@
 /// Pre-process a function which propagates taint according to the
 /// taint rule.
 ProgramStateRef process(const CallExpr *CE, CheckerContext &C) const;
-
   };
 };
 
@@ -206,26 +207,27 @@
   // value as tainted even if it's just a pointer, pointing to tainted data.
 
   // Check for exact name match for functions without builtin substitutes.
-  TaintPropagationRule Rule = llvm::StringSwitch(Name)
-.Case("atoi", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atol", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atoll", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("fgetc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc_unlocked", TaintPropagationRule(0, ReturnValueI

[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

If you don't mind, please submit diffs with full context (`diff -U9` or 
something alike depending on what you use). It makes it much easier to review 
patches. Also the formatting looks really off in some places where 4 spaces are 
used. Also another nitpick, nested statement ifs should have the statements 
within them aligned without adding another indentation level for every line 
break within the statement, also in case below `dyn_cast_or_null` may eliminate 
a need for an additional check in which case you can just use `&&` instead.

  if ((D->getName().find("stdin") != StringRef::npos) && D->isExternC())
if (const PointerType *PtrTy =
dyn_cast(D->getType().getTypePtr()))
  if (PtrTy->getPointeeType().getCanonicalType() ==
  C.getASTContext().getFILEType().getCanonicalType())
return true;

Also, is there a reason for pulling in `` here?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Could you please reupload with full context? :)
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


[PATCH] D54918: [analyzer] Apply clang-format to GenericTaintChecker.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Please don't mind me intruding.
If you create a patch for the Clang Static Analyzer, please add "[analyzer]" in 
the revision title, because many of us are automatically subscribed to those 
patches. Also, upload patches with full context.
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

I see the point here, and I think it'd be worth to just clang-format most of 
the files we work with, as the benefits would outweigh the drawbacks (at least 
eventually...), but I vaguely remember @george.karpenkov having many great 
points against it -- please don't commit until he can take a look :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54918/new/

https://reviews.llvm.org/D54918



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


[PATCH] D55683: [analyzer] Tests for scan-build?

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

I don't really use `scan-build`, so I can't barrage you with suggestions, but 
the patch looks great.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55683/new/

https://reviews.llvm.org/D55683



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


[PATCH] D55730: [analyzer] MoveChecker Pt.9: Add a "peaceful" mode in which it finds only 100% authentic bugs.

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:29
 namespace {
-
 struct RegionState {

Somewhat unrelated, but the size of this anonymous namespace is far too great.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:188-195
+  void setAggressiveness(StringRef Str) {
+Aggressiveness =
+llvm::StringSwitch(Str)
+.Case("KnownsOnly", AK_KnownsOnly)
+.Case("KnownsAndLocals", AK_KnownsAndLocals)
+.Case("All", AK_All)
+.Default(AK_KnownsAndLocals); // A sane default.

You can acquire a `DiagnosticsEngine` through `ASTContext`, which can be 
acquired from `CheckerManager`. I think it'd prefer to see an error if I messed 
up the input.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55730/new/

https://reviews.llvm.org/D55730



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


[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 178351.
boga95 added a comment.

Upload diff with full context.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -23,6 +23,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -69,8 +71,8 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(const CallExpr *,
-   CheckerContext &C) const;
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
+  const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postRetTaint(const CallExpr *CE, CheckerContext &C) const;
@@ -100,7 +102,7 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -112,30 +114,27 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it mark all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
@@ -144,9 +143,12 @@
   CheckerContext &C);
 
 inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A)  { DstArgs.push_back(A); }
+inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+inline bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
 inline bool isDestinationArgument(unsigned ArgNum) const {
   return (std::find(DstArgs.begin(),
@@ -169,7 +171,6 @@
 /// Pre-process a function which propagates taint according to the
 /// taint rule.
 ProgramStateRef process(const CallExpr *CE, CheckerContext &C) const;
-
   };
 };
 
@@ -206,26 +207,27 @@
   // value as tainted even if it's just a pointer, pointing to tainted data.
 
   // Check for exact name match for functions without builtin substitutes.
-  TaintPropagationRule Rule = llvm::StringSwitch(Name)
-.Case("atoi", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atol", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atoll", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("fgetc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc_unlocked", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getw", TaintPropagationRule(0, ReturnValueIndex))
-.Case("toupper", TaintPropagat

[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:210-230
+  TaintPropagationRule Rule =
+  llvm::StringSwitch(Name)
+  .Case("atoi", TaintPropagationRule({0}, {ReturnValueIndex}))
+  .Case("atol", TaintPropagationRule({0}, {ReturnValueIndex}))
+  .Case("atoll", TaintPropagationRule({0}, {ReturnValueIndex}))
+  .Case("getc", TaintPropagationRule({0}, {ReturnValueIndex}))
+  .Case("fgetc", TaintPropagationRule({0}, {ReturnValueIndex}))

Hmmm, the formatting part change already is in your other revision, D54918. Can 
you please rebase this patch on top of it, and add it as a dependency (that can 
be done on the right side, "Edit related revisions...").


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 added a comment.

I use std::move which is in the ``.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


[PATCH] D54429: [analyzer] Creating standard Sphinx documentation

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

That I think sounds great! Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54429/new/

https://reviews.llvm.org/D54429



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


[PATCH] D54918: [analyzer] Apply clang-format to GenericTaintChecker.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.

Hmm, actually, if you're doing changes all over the file in the followup 
patches, it shouldn't matter much. Let's just wait a couple days for ppl to 
object, now that they are subscribed.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54918/new/

https://reviews.llvm.org/D54918



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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 178355.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

- Rebase
- Reduce false-positives by not adding [[nodiscard]] to functions if the class 
has mutable fields (removed as known issues) and add tests


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp

Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,238 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17 \
+
+#include 
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
+#define BOOLEAN_FUNC bool f23() const
+
+typedef unsigned my_unsigned;
+typedef unsigned& my_unsigned_reference;
+typedef const unsigned& my_unsigned_const_reference;
+
+class Foo
+{
+public:
+using size_type = unsigned;
+
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f6();
+// CHECK-MESSAGES-NOT: warning:
+
+bool f7(int &);
+// CHECK-MESSAGES-NOT: warning:
+
+bool f8(int &) const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f9(int *) const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f10(const int &,int &) const;
+// CHECK-MESSAGES-NOT: warning:
+
+NO_DISCARD bool f12() const;
+// CHECK-MESSAGES-NOT: warning:
+
+MUST_USE_RESULT bool f13() const;
+// CHECK-MESSAGES-NOT: warning:
+   
+[[nodiscard]] bool f11() const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool _f20() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool _f20() const;
+
+NO_RETURN bool f21() const;
+// CHECK-MESSAGES-NOT: warning:
+
+~Foo();
+// CHECK-MESSAGES-NOT: warning:
+
+bool operator +=(int) const;
+// CHECK-MESSAGES-NOT: warning:
+   
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD const bool f15() const;
+
+inline const bool f16() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const bool f16() const;
+
+inline virtual const bool f17() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
+
+// inline with body
+bool f18() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f18' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f18() const {
+return true;
+}
+
+bool f19() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f19' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f19() const;
+
+BOOLEAN_FUNC;
+// CHECK-MESSAGES-NOT: warning

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: docs/clang-tidy/checks/modernize-use-nodiscard.rst:23
+Such functions have no means of altering any state or passing values other than
+via the return type. Unless the member functions are altering state via some 
external call (e.g. I/O).
+

noted > 80 char line will correct next patch


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433



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


[PATCH] D55697: [analyzer] Assume that we always have a SubEngine available

2018-12-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC349266: [analyzer] Assume that we always have a SubEngine 
available (authored by xazax, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55697?vs=178204&id=178357#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55697/new/

https://reviews.llvm.org/D55697

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -454,7 +454,7 @@
   QualType SingleTy;
 
   auto &Opts =
-StateMgr.getOwningEngine()->getAnalysisManager().getAnalyzerOptions();
+StateMgr.getOwningEngine().getAnalysisManager().getAnalyzerOptions();
 
   // FIXME: After putting complexity threshold to the symbols we can always
   //rearrange additive operations but rearrange comparisons only if
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -550,15 +550,15 @@
 return RuntimeDefinition(Decl);
   }
 
-  SubEngine *Engine = getState()->getStateManager().getOwningEngine();
-  AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
+  SubEngine &Engine = getState()->getStateManager().getOwningEngine();
+  AnalyzerOptions &Opts = Engine.getAnalysisManager().options;
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.IsNaiveCTUEnabled)
 return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
-  *Engine->getCrossTranslationUnitContext();
+  *Engine.getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
   CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
   Opts.DisplayCTUProgress);
@@ -1087,7 +1087,7 @@
  Selector Sel) const {
   assert(IDecl);
   AnalysisManager &AMgr =
-  getState()->getStateManager().getOwningEngine()->getAnalysisManager();
+  getState()->getStateManager().getOwningEngine().getAnalysisManager();
   // If the class interface is declared inside the main file, assume it is not
   // subcassed.
   // TODO: It could actually be subclassed if the subclass is private as well.
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -384,7 +384,7 @@
   // TODO: When the Max Complexity is reached, we should conjure a symbol
   // instead of generating an Unknown value and propagate the taint info to it.
   const unsigned MaxComp = StateMgr.getOwningEngine()
-   ->getAnalysisManager()
+   .getAnalysisManager()
.options.MaxSymbolComplexity;
 
   if (symLHS && symRHS &&
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -125,8 +125,8 @@
   ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(),
  LV, V));
   const MemRegion *MR = LV.getAsRegion();
-  if (MR && Mgr.getOwningEngine() && notifyChanges)
-return Mgr.getOwningEngine()->processRegionChange(newState, MR, LCtx);
+  if (MR && notifyChanges)
+return Mgr.getOwningEngine().processRegionChange(newState, MR, LCtx);
 
   return newState;
 }
@@ -138,9 +138,7 @@
   const MemRegion *R = loc.castAs().getRegion();
   const StoreRef &newStore = Mgr.StoreMgr->BindDefaultInitial(getStore(), R, V);
   ProgramStateRef new_state = makeWithStore(newStore);
-  return Mgr.getOwningEngine()
- ? Mgr.getOwningEngine()->processRegionChange(new_state, R, LCtx)
- : new_state;
+  return Mgr.getOwningEngine().processRegionChange(new_state, R, LCtx);
 }
 
 ProgramStateRef
@@ -149,9 +147,7 @@
   const MemRegion *R = loc.castAs().getRegion();
   const StoreRef &newStore = Mgr.StoreMgr->BindDefaultZero(getStore(), R);
   ProgramStateRef new_state = makeWithStore(newStore);
-  return Mgr.getOwningEngine()
- ? Mgr.getOwningEngine()->processRegionChange(new_state, R, LCtx)
- : new_state;
+  return Mgr.getOwningEngine().processRegionChange(new_state, R, LCtx);
 }
 
 typedef ArrayRef Region

r349266 - [analyzer] Assume that we always have a SubEngine available

2018-12-15 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Sat Dec 15 05:20:33 2018
New Revision: 349266

URL: http://llvm.org/viewvc/llvm-project?rev=349266&view=rev
Log:
[analyzer] Assume that we always have a SubEngine available

The removed codepath was dead.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=349266&r1=349265&r2=349266&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Sat Dec 15 05:20:33 2018
@@ -555,15 +555,15 @@ public:
   MemRegionManager& getRegionManager() {
 return svalBuilder->getRegionManager();
   }
-  const MemRegionManager& getRegionManager() const {
+  const MemRegionManager &getRegionManager() const {
 return svalBuilder->getRegionManager();
   }
 
   CallEventManager &getCallEventManager() { return *CallEventMgr; }
 
-  StoreManager& getStoreManager() { return *StoreMgr; }
-  ConstraintManager& getConstraintManager() { return *ConstraintMgr; }
-  SubEngine* getOwningEngine() { return Eng; }
+  StoreManager &getStoreManager() { return *StoreMgr; }
+  ConstraintManager &getConstraintManager() { return *ConstraintMgr; }
+  SubEngine &getOwningEngine() { return *Eng; }
 
   ProgramStateRef removeDeadBindings(ProgramStateRef St,
 const StackFrameContext *LCtx,

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp?rev=349266&r1=349265&r2=349266&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp Sat Dec 15 
05:20:33 2018
@@ -56,7 +56,7 @@ class AnalysisOrderChecker
 
   bool isCallbackEnabled(ProgramStateRef State, StringRef CallbackName) const {
 AnalyzerOptions &Opts = State->getStateManager().getOwningEngine()
- ->getAnalysisManager().getAnalyzerOptions();
+ .getAnalysisManager().getAnalyzerOptions();
 return isCallbackEnabled(Opts, CallbackName);
   }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=349266&r1=349265&r2=349266&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Sat Dec 15 05:20:33 2018
@@ -550,15 +550,15 @@ RuntimeDefinition AnyFunctionCall::getRu
 return RuntimeDefinition(Decl);
   }
 
-  SubEngine *Engine = getState()->getStateManager().getOwningEngine();
-  AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
+  SubEngine &Engine = getState()->getStateManager().getOwningEngine();
+  AnalyzerOptions &Opts = Engine.getAnalysisManager().options;
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.IsNaiveCTUEnabled)
 return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
-  *Engine->getCrossTranslationUnitContext();
+  *Engine.getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
   CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
   Opts.DisplayCTUProgress);
@@ -1087,7 +1087,7 @@ bool ObjCMethodCall::canBeOverridenInSub
  Selector Sel) const {
   assert(IDecl);
   AnalysisManager &AMgr =
-  getState()->getStateManager().getOwningEngine()->getAnalysisManager();
+  getState()->getStateManager().getOwningEngine().getAnalysisManager();
   // If the class interface is declared inside the main file, assume it is not
   // subcassed.
   // TODO: It could actually be subclassed if the subclass is private as well.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=349266&r1=349265&r2=349266&view=diff
==
--- c

[PATCH] D55737: [Utils] Attempt to fix clang.natvis following "[AST] Various optimizations in DeclarationName(Table)"

2018-12-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: aaron.ballman.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

`[AST] Various optimizations in DeclarationName(Table)` changed how 
`DeclarationName`s
are represented. Therefore `clang.natvis` needs to be updated to reflect these 
changes.

This is completely untested since I actually don't have access to a windows 
machine.
However it should be close enough to a working fix.


Repository:
  rC Clang

https://reviews.llvm.org/D55737

Files:
  utils/ClangVisualizers/clang.natvis


Index: utils/ClangVisualizers/clang.natvis
===
--- utils/ClangVisualizers/clang.natvis
+++ utils/ClangVisualizers/clang.natvis
@@ -392,25 +392,32 @@
 
 Empty
 {*(clang::IdentifierInfo *)(Ptr & 
~PtrMask)}
-{{Identifier ({*(clang::IdentifierInfo *)(Ptr & 
~PtrMask)})}}
-{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo 
*)(Ptr & ~PtrMask)})}}
-{{ObjC One Arg Selector (*{(clang::IdentifierInfo 
*)(Ptr & ~PtrMask)})}}
+Identifier {*(clang::IdentifierInfo *)(Ptr & 
~PtrMask)}
+ObjC Zero Arg Selector {*(clang::IdentifierInfo 
*)(Ptr & ~PtrMask)}
+ObjC One Arg Selector {*(clang::IdentifierInfo *)(Ptr 
& ~PtrMask)}
+C++ Constructor {*(clang::detail::CXXSpecialNameExtra 
*)(Ptr & ~PtrMask)}
+C++ Destructor {*(clang::detail::CXXSpecialNameExtra 
*)(Ptr & ~PtrMask)}
+C++ Conversion function 
{*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}
+C++ Operator {*(clang::detail::CXXOperatorIdName *)(Ptr 
& ~PtrMask)}
 {*(clang::DeclarationNameExtra *)(Ptr 
& ~PtrMask),view(cpp)}
-{{Extra ({*(clang::DeclarationNameExtra *)(Ptr 
& ~PtrMask)})}}
+Extra {*(clang::detail::DeclarationNameExtra *)(Ptr 
& ~PtrMask)}
 
   *(clang::IdentifierInfo *)(Ptr & ~PtrMask)
   *(clang::IdentifierInfo *)(Ptr & 
~PtrMask)
   *(clang::IdentifierInfo *)(Ptr & 
~PtrMask)
-  (clang::DeclarationNameExtra *)(Ptr & ~PtrMask)
-
-  
-  
-{((clang::CXXSpecialName 
*)this)->Type,view(cpp)}
-
{(clang::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{"
  ",sb}{*this,view(cpp)}
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr & 
~PtrMask)
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr & 
~PtrMask)
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr 
& ~PtrMask)
+  *(clang::detail::CXXOperatorIdName *)(Ptr & 
~PtrMask)
+  *(clang::detail::DeclarationNameExtra *)(Ptr & 
~PtrMask)
+
+  
+  
+C++ 
Deduction guide
+C++ Literal operator
+C++ 
Using directive
+
{(clang::detail::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{"
  ",sb}{*this,view(cpp)}
   
   
 {(clang::tok::TokenKind)Kind,en}


Index: utils/ClangVisualizers/clang.natvis
===
--- utils/ClangVisualizers/clang.natvis
+++ utils/ClangVisualizers/clang.natvis
@@ -392,25 +392,32 @@
 
 Empty
 {*(clang::IdentifierInfo *)(Ptr & ~PtrMask)}
-{{Identifier ({*(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
-{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
-{{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}}
+Identifier {*(clang::IdentifierInfo *)(Ptr & ~PtrMask)}
+ObjC Zero Arg Selector {*(clang::IdentifierInfo *)(Ptr & ~PtrMask)}
+ObjC One Arg Selector {*(clang::IdentifierInfo *)(Ptr & ~PtrMask)}
+C++ Constructor {*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}
+C++ Destructor {*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}
+C++ Conversion function {*(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)}
+C++ Operator {*(clang::detail::CXXOperatorIdName *)(Ptr & ~PtrMask)}
 {*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask),view(cpp)}
-{{Extra ({*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask)})}}
+Extra {*(clang::detail::DeclarationNameExtra *)(Ptr & ~PtrMask)}
 
   *(clang::IdentifierInfo *)(Ptr & ~PtrMask)
   *(clang::IdentifierInfo *)(Ptr & ~PtrMask)
   *(clang::IdentifierInfo *)(Ptr & ~PtrMask)
-  (clang::DeclarationNameExtra *)(Ptr & ~PtrMask)
-
-  
-  
-{((clang::CXXSpecialName *)this)->Type,view(cpp)}
-{(clang::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{"  ",sb}{*this,view(cpp)}
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr & ~PtrMask)
+  *(clang::detail::CXXOperatorIdName *)(Ptr & ~PtrMask)
+  *(clang::detail::DeclarationNameExtra *)(Ptr & ~PtrMask)
+
+  
+  
+C++ Deduction guide
+C++ Literal operator
+C++ Using directive
+{(clang::detail::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{"  ",sb}{*this,view(cpp)}
   
   
 {(clang::tok::TokenKind)Kind,en}
___
cfe-commits mailing list

r349274 - [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 07:44:05 2018
New Revision: 349274

URL: http://llvm.org/viewvc/llvm-project?rev=349274&view=rev
Log:
[analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

Renaming collectCheckers to getEnabledCheckers
Changing the functionality to acquire all enabled checkers, rather then collect
checkers for a specific CheckerOptInfo (for example, collecting all checkers for
{ "core", true }, which meant enabling all checkers from the core package, which
was an unnecessary complication).
Removing CheckerOptInfo, instead of storing whether the option was claimed via a
field, we handle errors immediately, as getEnabledCheckers can now access a
DiagnosticsEngine. Realize that the remaining information it stored is directly
accessible through AnalyzerOptions.CheckerControlList.
Fix a test with -analyzer-disable-checker -verify accidentally left in.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
cfe/trunk/test/Analysis/disable-all-checks.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h?rev=349274&r1=349273&r2=349274&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h Sat Dec 15 
07:44:05 2018
@@ -95,6 +95,7 @@ public:
   };
 
   using CheckerInfoList = std::vector;
+  using CheckerInfoSet = llvm::SetVector;
 
 private:
   template 
@@ -131,9 +132,13 @@ public:
   /// Prints the name and description of all checkers in this registry.
   /// This output is not intended to be machine-parseable.
   void printHelp(raw_ostream &out, size_t maxNameChars = 30) const;
-  void printList(raw_ostream &out, const AnalyzerOptions &opts) const;
+  void printList(raw_ostream &out, const AnalyzerOptions &opts,
+ DiagnosticsEngine &diags) const;
 
 private:
+  CheckerInfoSet getEnabledCheckers(const AnalyzerOptions &Opts,
+DiagnosticsEngine &diags) const;
+
   mutable CheckerInfoList Checkers;
   mutable llvm::StringMap Packages;
 };

Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h?rev=349274&r1=349273&r2=349274&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h Sat Dec 
15 07:44:05 2018
@@ -54,7 +54,8 @@ private:
 
 void printCheckerHelp(raw_ostream &OS, ArrayRef plugins);
 void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins,
- const AnalyzerOptions &opts);
+ const AnalyzerOptions &opts,
+ DiagnosticsEngine &diags);
 void printAnalyzerConfigList(raw_ostream &OS);
 
 } // end GR namespace

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=349274&r1=349273&r2=349274&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Sat Dec 15 
07:44:05 2018
@@ -246,7 +246,8 @@ bool ExecuteCompilerInvocation(CompilerI
   if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) {
 ento::printEnabledCheckerList(llvm::outs(),
   Clang->getFrontendOpts().Plugins,
-  *Clang->getAnalyzerOpts());
+  *Clang->getAnalyzerOpts(),
+  Clang->getDiagnostics());
   }
 
   // Honor -analyzer-config-help.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=349274&r1=349273&r2=349274&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Sat Dec 15 07:44:05 
2018
@@ -18,50 +18,11 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
-#include 
-#include 
 
 using namespace clang;
 using namespace ento;
 
-static const char PackageSeparator = '.';
-
-using CheckerInf

[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 178368.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -23,6 +23,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -69,8 +71,8 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(const CallExpr *,
-   CheckerContext &C) const;
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
+  const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postRetTaint(const CallExpr *CE, CheckerContext &C) const;
@@ -100,7 +102,7 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -112,30 +114,27 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it mark all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
@@ -144,9 +143,12 @@
   CheckerContext &C);
 
 inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A)  { DstArgs.push_back(A); }
+inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+inline bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
 inline bool isDestinationArgument(unsigned ArgNum) const {
   return (std::find(DstArgs.begin(),
@@ -169,7 +171,6 @@
 /// Pre-process a function which propagates taint according to the
 /// taint rule.
 ProgramStateRef process(const CallExpr *CE, CheckerContext &C) const;
-
   };
 };
 
@@ -206,26 +207,27 @@
   // value as tainted even if it's just a pointer, pointing to tainted data.
 
   // Check for exact name match for functions without builtin substitutes.
-  TaintPropagationRule Rule = llvm::StringSwitch(Name)
-.Case("atoi", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atol", TaintPropagationRule(0, ReturnValueIndex))
-.Case("atoll", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("fgetc", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getc_unlocked", TaintPropagationRule(0, ReturnValueIndex))
-.Case("getw", TaintPropagationRule(0, ReturnValueIndex))
-.Case("toupper", TaintPropagationRule(0, ReturnValueIndex))
-.Case("tolower", Taint

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2018-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 178367.
MyDeveloperDay added a comment.

-Refactor the checker to remove the llvm::any_of by using a QualType 
ast-matcher with hasAnyParameter(hasType(x))

- i.e. ...unless(hasAnyParameter(hasType(isNonConstReferenceOrPointer(...

-Reduce the SNR ratio of using a macro as the ReplacementString option (e.g. 
LLVM_NODISCARD), when that macro is not define in-scope

- This was seen when performing clang-tidy on LLVM itself, some of the very low 
level classes did not have the LLVM_NODISCARD macro (from 
include/llvm/Support/Compiler.h) defined in scope.
- In these cases the fix-it caused too many additional changes to be needed of 
including the additional header file in order to build.
- Instead emit a warning to say that it could not be marked as LLVM_NODISCARD 
and don't apply the fix-it
- Add documentation and unit tests to document and validate the above


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp
  test/clang-tidy/modernize-use-nodiscard.h

Index: test/clang-tidy/modernize-use-nodiscard.h
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.h
@@ -0,0 +1,5 @@
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,244 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17 \
+
+#include 
+
+#include "modernize-use-nodiscard.h"
+
+#define BOOLEAN_FUNC bool f23() const
+
+typedef unsigned my_unsigned;
+typedef unsigned& my_unsigned_reference;
+typedef const unsigned& my_unsigned_const_reference;
+
+class Foo
+{
+public:
+using size_type = unsigned;
+
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f6();
+// CHECK-MESSAGES-NOT: warning:
+
+bool f7(int &);
+// CHECK-MESSAGES-NOT: warning:
+
+bool f8(int &) const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f9(int *) const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool f10(const int &,int &) const;
+// CHECK-MESSAGES-NOT: warning:
+
+NO_DISCARD bool f12() const;
+// CHECK-MESSAGES-NOT: warning:
+
+MUST_USE_RESULT bool f13() const;
+// CHECK-MESSAGES-NOT: warning:
+   
+[[nodiscard]] bool f11() const;
+// CHECK-MESSAGES-NOT: warning:
+
+bool _f20() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool _f20() const;
+
+NO_RETURN bool f21() const;
+// CHECK-MESSAGES-NOT: warning:
+
+~Foo();
+// CHECK-MESSAGES-NOT: warning:
+
+bool operator +=(int) const;
+// CHECK-MESSAGES-NOT: warning:
+   
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD cons

[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus closed this revision.
Szelethus added a comment.

Commited in rC349274 .


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54401/new/

https://reviews.llvm.org/D54401



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


r349275 - [analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 08:23:51 2018
New Revision: 349275

URL: http://llvm.org/viewvc/llvm-project?rev=349275&view=rev
Log:
[analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

ClangCheckerRegistry is a very non-obvious, poorly documented, weird concept.
It derives from CheckerRegistry, and is placed in lib/StaticAnalyzer/Frontend,
whereas it's base is located in lib/StaticAnalyzer/Core. It was, from what I can
imagine, used to circumvent the problem that the registry functions of the
checkers are located in the clangStaticAnalyzerCheckers library, but that
library depends on clangStaticAnalyzerCore. However, clangStaticAnalyzerFrontend
depends on both of those libraries.

One can make the observation however, that CheckerRegistry has no place in Core,
it isn't used there at all! The only place where it is used is Frontend, which
is where it ultimately belongs.

This move implies that since
include/clang/StaticAnalyzer/Checkers/ClangCheckers.h only contained a single 
function:

class CheckerRegistry;

void registerBuiltinCheckers(CheckerRegistry ®istry);

it had to re purposed, as CheckerRegistry is no longer available to
clangStaticAnalyzerCheckers. It was renamed to BuiltinCheckerRegistration.h,
which actually describes it a lot better -- it does not contain the registration
functions for checkers, but only those generated by the tblgen files.

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

Added:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  - copied unchanged from r349274, 
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  - copied unchanged from r349274, 
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  - copied, changed from r349274, 
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
Removed:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/ClangCheckers.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvali

[PATCH] D54436: [analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349275: [analyzer][NFC] Move CheckerRegistry from the Core 
directory to Frontend (authored by Szelethus, committed by ).
Herald added subscribers: llvm-commits, mgrang.

Changed prior to commit:
  https://reviews.llvm.org/D54436?vs=173718&id=178369#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54436/new/

https://reviews.llvm.org/D54436

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/ClangCheckers.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
  cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  cfe/trunk/lib/StaticAnalyze

r349278 - Fix a compilation error in examples/

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 09:12:38 2018
New Revision: 349278

URL: http://llvm.org/viewvc/llvm-project?rev=349278&view=rev
Log:
Fix a compilation error in examples/

Modified:
cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp

Modified: cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp?rev=349278&r1=349277&r2=349278&view=diff
==
--- cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp (original)
+++ cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp Sat Dec 15 09:12:38 
2018
@@ -1,6 +1,6 @@
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 
 using namespace clang;


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


r349279 - Link examples/clang-interpreter against clangSerialization

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 10:03:15 2018
New Revision: 349279

URL: http://llvm.org/viewvc/llvm-project?rev=349279&view=rev
Log:
Link examples/clang-interpreter against clangSerialization

Modified:
cfe/trunk/examples/clang-interpreter/CMakeLists.txt

Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/CMakeLists.txt?rev=349279&r1=349278&r2=349279&view=diff
==
--- cfe/trunk/examples/clang-interpreter/CMakeLists.txt (original)
+++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt Sat Dec 15 10:03:15 2018
@@ -25,6 +25,7 @@ target_link_libraries(clang-interpreter
   clangCodeGen
   clangDriver
   clangFrontend
+  clangSerialization
   )
 
 export_executable_symbols(clang-interpreter)


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


r349280 - [analyzer][NFC] Merge ClangCheckerRegistry to CheckerRegistry

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 10:11:49 2018
New Revision: 349280

URL: http://llvm.org/viewvc/llvm-project?rev=349280&view=rev
Log:
[analyzer][NFC] Merge ClangCheckerRegistry to CheckerRegistry

Now that CheckerRegistry lies in Frontend, we can finally eliminate
ClangCheckerRegistry. Fortunately, this also provides us with a
DiagnosticsEngine, so I went ahead and removed some parameters from it's
methods.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h?rev=349280&r1=349279&r2=349280&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h Sat Dec 
15 10:11:49 2018
@@ -81,6 +81,8 @@ namespace ento {
 /// "core.builtin", or the full name "core.builtin.NoReturnFunctionChecker".
 class CheckerRegistry {
 public:
+  CheckerRegistry(ArrayRef plugins, DiagnosticsEngine &diags);
+
   /// Initialization functions perform any necessary setup for a checker.
   /// They should include a call to CheckerManager::registerChecker.
   using InitializationFunction = void (*)(CheckerManager &);
@@ -122,25 +124,23 @@ public:
   /// all checkers specified by the given CheckerOptInfo list. The order of 
this
   /// list is significant; later options can be used to reverse earlier ones.
   /// This can be used to exclude certain checkers in an included package.
-  void initializeManager(CheckerManager &mgr, const AnalyzerOptions &Opts,
- DiagnosticsEngine &diags) const;
+  void initializeManager(CheckerManager &mgr,
+ const AnalyzerOptions &Opts) const;
 
   /// Check if every option corresponds to a specific checker or package.
-  void validateCheckerOptions(const AnalyzerOptions &opts,
-  DiagnosticsEngine &diags) const;
+  void validateCheckerOptions(const AnalyzerOptions &opts) const;
 
   /// Prints the name and description of all checkers in this registry.
   /// This output is not intended to be machine-parseable.
   void printHelp(raw_ostream &out, size_t maxNameChars = 30) const;
-  void printList(raw_ostream &out, const AnalyzerOptions &opts,
- DiagnosticsEngine &diags) const;
+  void printList(raw_ostream &out, const AnalyzerOptions &opts) const;
 
 private:
-  CheckerInfoSet getEnabledCheckers(const AnalyzerOptions &Opts,
-DiagnosticsEngine &diags) const;
+  CheckerInfoSet getEnabledCheckers(const AnalyzerOptions &Opts) const;
 
   mutable CheckerInfoList Checkers;
   mutable llvm::StringMap Packages;
+  DiagnosticsEngine &Diags;
 };
 
 } // namespace ento

Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h?rev=349280&r1=349279&r2=349280&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h Sat Dec 
15 10:11:49 2018
@@ -52,7 +52,8 @@ private:
   llvm::StringMap &Bodies;
 };
 
-void printCheckerHelp(raw_ostream &OS, ArrayRef plugins);
+void printCheckerHelp(raw_ostream &OS, ArrayRef plugins,
+  DiagnosticsEngine &diags);
 void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins,
  const AnalyzerOptions &opts,
  DiagnosticsEngine &diags);

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=349280&r1=349279&r2=349280&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Sat Dec 15 
10:11:49 2018
@@ -238,7 +238,8 @@ bool ExecuteCompilerInvocation(CompilerI
   // Honor -analyzer-checker-help.
   // This should happen AFTER plugins have been loaded!
   if (Clang->getAnalyzerOpts()->ShowCheckerHelp) {
-ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins);
+ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins,
+   Clang->getDiagnostics());
 return 

[PATCH] D54437: [analyzer][NFC] Merge ClangCheckerRegistry to CheckerRegistry

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349280: [analyzer][NFC] Merge ClangCheckerRegistry to 
CheckerRegistry (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54437?vs=173724&id=178370#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54437/new/

https://reviews.llvm.org/D54437

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
@@ -52,7 +52,8 @@
   llvm::StringMap &Bodies;
 };
 
-void printCheckerHelp(raw_ostream &OS, ArrayRef plugins);
+void printCheckerHelp(raw_ostream &OS, ArrayRef plugins,
+  DiagnosticsEngine &diags);
 void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins,
  const AnalyzerOptions &opts,
  DiagnosticsEngine &diags);
Index: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -81,6 +81,8 @@
 /// "core.builtin", or the full name "core.builtin.NoReturnFunctionChecker".
 class CheckerRegistry {
 public:
+  CheckerRegistry(ArrayRef plugins, DiagnosticsEngine &diags);
+
   /// Initialization functions perform any necessary setup for a checker.
   /// They should include a call to CheckerManager::registerChecker.
   using InitializationFunction = void (*)(CheckerManager &);
@@ -122,25 +124,23 @@
   /// all checkers specified by the given CheckerOptInfo list. The order of this
   /// list is significant; later options can be used to reverse earlier ones.
   /// This can be used to exclude certain checkers in an included package.
-  void initializeManager(CheckerManager &mgr, const AnalyzerOptions &Opts,
- DiagnosticsEngine &diags) const;
+  void initializeManager(CheckerManager &mgr,
+ const AnalyzerOptions &Opts) const;
 
   /// Check if every option corresponds to a specific checker or package.
-  void validateCheckerOptions(const AnalyzerOptions &opts,
-  DiagnosticsEngine &diags) const;
+  void validateCheckerOptions(const AnalyzerOptions &opts) const;
 
   /// Prints the name and description of all checkers in this registry.
   /// This output is not intended to be machine-parseable.
   void printHelp(raw_ostream &out, size_t maxNameChars = 30) const;
-  void printList(raw_ostream &out, const AnalyzerOptions &opts,
- DiagnosticsEngine &diags) const;
+  void printList(raw_ostream &out, const AnalyzerOptions &opts) const;
 
 private:
-  CheckerInfoSet getEnabledCheckers(const AnalyzerOptions &Opts,
-DiagnosticsEngine &diags) const;
+  CheckerInfoSet getEnabledCheckers(const AnalyzerOptions &Opts) const;
 
   mutable CheckerInfoList Checkers;
   mutable llvm::StringMap Packages;
+  DiagnosticsEngine &Diags;
 };
 
 } // namespace ento
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -16,95 +16,15 @@
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
 using namespace clang;
 using namespace ento;
-using llvm::sys::DynamicLibrary;
-
-namespace {
-class ClangCheckerRegistry : public CheckerRegistry {
-  typedef void (*RegisterCheckersFn)(CheckerRegistry &);
-
-  static bool isCompatibleAPIVersion(const char *versionString);
-  static void warnIncompatible(DiagnosticsEngine *diags, StringRef pluginPath,
-   const char *pluginAPIVersion);
-
-public:
-  ClangCheckerRegistry(ArrayRef plugins,
-  

[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Hmm, I find the revision title and summary a little vague -- I'd expect a 
revision called "Refactoring" not to feature any funcitonal change, yet you 
changed how variadic functions are handled. Please

- Keep purely formatting changes to your earlier revision, and rebase this 
patch on that
- Edit the revision title and/or summary about what your patch does,
- If it features any change in the checker's behavior, include tests.




Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:125
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it mark all
+/// of them as source or destination.

typo: marks



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:132-137
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}

I like this //a lot//! Call sites look very nice.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:145-158
 inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A)  { DstArgs.push_back(A); }
+inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+inline bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}

In-class method definitions are implicitly `inline` -- could you please remove 
them while we're cleaning up anyways? :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


[PATCH] D55658: Avoid Decl::getASTContext in hot paths where possible, Part 1

2018-12-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for working on this :). It’d be interesting to see some pre/post patch 
compile time numbers on CTMark.

Naive/strawman alternative here, but: what’s the impact on peak RSS and compile 
time of just storing an ASTContext pointer in Decl/DeclContext? If it’s not out 
of the question to grow Decl etc. and it gives a nice speed up, that might be a 
simpler approach.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55658/new/

https://reviews.llvm.org/D55658



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


[PATCH] D54823: [analyzer][MallocChecker][NFC] Document and reorganize some functions

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349281: [analyzer][MallocChecker][NFC] Document and 
reorganize some functions (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54823?vs=177057&id=178371#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54823/new/

https://reviews.llvm.org/D54823

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/malloc-annotations.c
  cfe/trunk/test/Analysis/malloc.c

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -7,8 +7,41 @@
 //
 //===--===//
 //
-// This file defines malloc/free checker, which checks for potential memory
-// leaks, double free, and use-after-free problems.
+// This file defines a variety of memory management related checkers, such as
+// leak, double free, and use-after-free.
+//
+// The following checkers are defined here:
+//
+//   * MallocChecker
+//   Despite its name, it models all sorts of memory allocations and
+//   de- or reallocation, including but not limited to malloc, free,
+//   relloc, new, delete. It also reports on a variety of memory misuse
+//   errors.
+//   Many other checkers interact very closely with this checker, in fact,
+//   most are merely options to this one. Other checkers may register
+//   MallocChecker, but do not enable MallocChecker's reports (more details
+//   to follow around its field, ChecksEnabled).
+//   It also has a boolean "Optimistic" checker option, which if set to true
+//   will cause the checker to model user defined memory management related
+//   functions annotated via the attribute ownership_takes, ownership_holds
+//   and ownership_returns.
+//
+//   * NewDeleteChecker
+//   Enables the modeling of new, new[], delete, delete[] in MallocChecker,
+//   and checks for related double-free and use-after-free errors.
+//
+//   * NewDeleteLeaksChecker
+//   Checks for leaks related to new, new[], delete, delete[].
+//   Depends on NewDeleteChecker.
+//
+//   * MismatchedDeallocatorChecker
+//   Enables checking whether memory is deallocated with the correspending
+//   allocation function in MallocChecker, such as malloc() allocated
+//   regions are only freed by free(), new by delete, new[] by delete[].
+//
+//  InnerPointerChecker interacts very closely with MallocChecker, but unlike
+//  the above checkers, it has it's own file, hence the many InnerPointerChecker
+//  related headers and non-static functions.
 //
 //===--===//
 
@@ -37,6 +70,10 @@
 using namespace clang;
 using namespace ento;
 
+//===--===//
+// The types of allocation we're modeling.
+//===--===//
+
 namespace {
 
 // Used to check correspondence between allocators and deallocators.
@@ -50,28 +87,59 @@
   AF_InnerBuffer
 };
 
+struct MemFunctionInfoTy;
+
+} // end of anonymous namespace
+
+/// Determine family of a deallocation expression.
+static AllocationFamily getAllocationFamily(
+const MemFunctionInfoTy &MemFunctionInfo, CheckerContext &C, const Stmt *S);
+
+/// Print names of allocators and deallocators.
+///
+/// \returns true on success.
+static bool printAllocDeallocName(raw_ostream &os, CheckerContext &C,
+  const Expr *E);
+
+/// Print expected name of an allocator based on the deallocator's
+/// family derived from the DeallocExpr.
+static void printExpectedAllocName(raw_ostream &os,
+   const MemFunctionInfoTy  &MemFunctionInfo,
+   CheckerContext &C, const Expr *E);
+
+/// Print expected name of a deallocator based on the allocator's
+/// family.
+static void printExpectedDeallocName(raw_ostream &os, AllocationFamily Family);
+
+//===--===//
+// The state of a symbol, in terms of memory management.
+//===--===//
+
+namespace {
+
 class RefState {
-  enum Kind { // Reference to allocated memory.
-  Allocated,
-  // Reference to zero-allocated memory.
-  AllocatedOfSizeZero,
-  // Reference to released/freed memory.
-  Released,
-  // The responsibility for freeing resources has transferred from
-  // this reference. A relinquished symbol should not be freed.
-

r349281 - [analyzer][MallocChecker][NFC] Document and reorganize some functions

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 10:34:00 2018
New Revision: 349281

URL: http://llvm.org/viewvc/llvm-project?rev=349281&view=rev
Log:
[analyzer][MallocChecker][NFC] Document and reorganize some functions

This patch merely reorganizes some things, and features no functional change.

In detail:

* Provided documentation, or moved existing documentation in more obvious
places.
* Added dividers. (the //===--===// thing).
* Moved getAllocationFamily, printAllocDeallocName, printExpectedAllocName and
printExpectedDeallocName in the global namespace on top of the file where
AllocationFamily is declared, as they are very strongly related.
* Moved isReleased and MallocUpdateRefState near RefState's definition for the
same reason.
* Realloc modeling was very poor in terms of variable and structure naming, as
well as documentation, so I renamed some of them and added much needed docs.
* Moved function IdentifierInfos to a separate struct, and moved isMemFunction,
isCMemFunction adn isStandardNewDelete inside it. This makes the patch affect
quite a lot of lines, should I extract it to a separate one?
* Moved MallocBugVisitor out of MallocChecker.
* Preferred switches to long else-if branches in some places.
* Neatly organized some RUN: lines.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/Analysis/malloc-annotations.c
cfe/trunk/test/Analysis/malloc.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=349281&r1=349280&r2=349281&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sat Dec 15 10:34:00 
2018
@@ -7,8 +7,41 @@
 //
 
//===--===//
 //
-// This file defines malloc/free checker, which checks for potential memory
-// leaks, double free, and use-after-free problems.
+// This file defines a variety of memory management related checkers, such as
+// leak, double free, and use-after-free.
+//
+// The following checkers are defined here:
+//
+//   * MallocChecker
+//   Despite its name, it models all sorts of memory allocations and
+//   de- or reallocation, including but not limited to malloc, free,
+//   relloc, new, delete. It also reports on a variety of memory misuse
+//   errors.
+//   Many other checkers interact very closely with this checker, in fact,
+//   most are merely options to this one. Other checkers may register
+//   MallocChecker, but do not enable MallocChecker's reports (more details
+//   to follow around its field, ChecksEnabled).
+//   It also has a boolean "Optimistic" checker option, which if set to 
true
+//   will cause the checker to model user defined memory management related
+//   functions annotated via the attribute ownership_takes, ownership_holds
+//   and ownership_returns.
+//
+//   * NewDeleteChecker
+//   Enables the modeling of new, new[], delete, delete[] in MallocChecker,
+//   and checks for related double-free and use-after-free errors.
+//
+//   * NewDeleteLeaksChecker
+//   Checks for leaks related to new, new[], delete, delete[].
+//   Depends on NewDeleteChecker.
+//
+//   * MismatchedDeallocatorChecker
+//   Enables checking whether memory is deallocated with the correspending
+//   allocation function in MallocChecker, such as malloc() allocated
+//   regions are only freed by free(), new by delete, new[] by delete[].
+//
+//  InnerPointerChecker interacts very closely with MallocChecker, but unlike
+//  the above checkers, it has it's own file, hence the many 
InnerPointerChecker
+//  related headers and non-static functions.
 //
 
//===--===//
 
@@ -37,6 +70,10 @@
 using namespace clang;
 using namespace ento;
 
+//===--===//
+// The types of allocation we're modeling.
+//===--===//
+
 namespace {
 
 // Used to check correspondence between allocators and deallocators.
@@ -50,28 +87,59 @@ enum AllocationFamily {
   AF_InnerBuffer
 };
 
+struct MemFunctionInfoTy;
+
+} // end of anonymous namespace
+
+/// Determine family of a deallocation expression.
+static AllocationFamily getAllocationFamily(
+const MemFunctionInfoTy &MemFunctionInfo, CheckerContext &C, const Stmt 
*S);
+
+/// Print names of allocators and deallocators.
+///
+/// \returns true on success.
+static bool printAllocDeallocName(raw_ostream &os, CheckerContext &C,
+  const Expr *E);
+
+/// Print expected name of an allocator based on

[PATCH] D54834: [analyzer][MallocChecker] Improve warning messages on double-delete errors

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D54834#1315475 , @NoQ wrote:

> Thanks, nice catch!
>
> It seems that the `ReportDoubleDelete()` thing was never used for reporting 
> double-delete, but it was used for some strange check when a destructor is 
> called.


It was used for reporting, there actually is a test case for it in 
`test/Analysis/NewDelete-checker-test.cpp` on line 380.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54834/new/

https://reviews.llvm.org/D54834



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


[PATCH] D54834: [analyzer][MallocChecker] Improve warning messages on double-delete errors

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: test/Analysis/NewDelete-checker-test.cpp:380
   delete foo;
   delete foo; // expected-warning {{Attempt to delete released memory}}
 }

Right here.



Comment at: test/Analysis/NewDelete-checker-test.cpp:392
   delete foo;
   delete foo;  // expected-warning {{Attempt to delete released memory}}
 }

And here.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54834/new/

https://reviews.llvm.org/D54834



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


r349283 - [analyzer][MallocChecker] Improve warning messages on double-delete errors

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 10:41:37 2018
New Revision: 349283

URL: http://llvm.org/viewvc/llvm-project?rev=349283&view=rev
Log:
[analyzer][MallocChecker] Improve warning messages on double-delete errors

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
cfe/trunk/test/Analysis/NewDelete-checker-test.cpp
cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
cfe/trunk/test/Analysis/dtor.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=349283&r1=349282&r2=349283&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sat Dec 15 10:41:37 
2018
@@ -1431,7 +1431,8 @@ ProgramStateRef MallocChecker::addExtent
 
 void MallocChecker::checkPreStmt(const CXXDeleteExpr *DE,
  CheckerContext &C) const {
-
+  // This will regard deleting freed() regions as a use-after-free, rather then
+  // a double-free or double-delete error.
   if (!ChecksEnabled[CK_NewDeleteChecker])
 if (SymbolRef Sym = C.getSVal(DE->getArgument()).getAsSymbol())
   checkUseAfterFree(Sym, C, DE->getArgument());
@@ -1628,7 +1629,8 @@ ProgramStateRef MallocChecker::FreeMemAu
 }
 
 /// Checks if the previous call to free on the given symbol failed - if free
-/// failed, returns true. Also, returns the corresponding return value symbol.
+/// failed, returns true. Also, stores the corresponding return value symbol in
+/// \p RetStatusSymbol.
 static bool didPreviousFreeFail(ProgramStateRef State,
 SymbolRef Sym, SymbolRef &RetStatusSymbol) {
   const SymbolRef *Ret = State->get(Sym);
@@ -2289,6 +2291,12 @@ void MallocChecker::ReportDoubleFree(Che
   if (!CheckKind.hasValue())
 return;
 
+  // If this is a double delete error, print the appropiate warning message.
+  if (CheckKind == CK_NewDeleteChecker) {
+ReportDoubleDelete(C, Sym);
+return;
+  }
+
   if (ExplodedNode *N = C.generateErrorNode()) {
 if (!BT_DoubleFree[*CheckKind])
   BT_DoubleFree[*CheckKind].reset(new BugType(

Modified: 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist?rev=349283&r1=349282&r2=349283&view=diff
==
--- 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist 
(original)
+++ 
cfe/trunk/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist 
Sat Dec 15 10:41:37 2018
@@ -194,17 +194,17 @@
  
  depth0
  extended_message
- Attempt to free released memory
+ Attempt to delete released memory
  message
- Attempt to free released memory
+ Attempt to delete released memory
 

-   descriptionAttempt to free released memory
+   descriptionAttempt to delete released memory
categoryMemory error
-   typeDouble free
+   typeDouble delete
check_namecplusplus.NewDelete

-   
issue_hash_content_of_line_in_contextbd8e324d09c70b9e2be6f824a4942e5a
+   
issue_hash_content_of_line_in_context593b185245106bed5175ccf2753039b2
   issue_context_kindfunction
   issue_contexttest
   issue_hash_function_offset8
@@ -423,17 +423,17 @@
  
  depth0
  extended_message
- Attempt to free released memory
+ Attempt to delete released memory
  message
- Attempt to free released memory
+ Attempt to delete released memory
 

-   descriptionAttempt to free released memory
+   descriptionAttempt to delete released memory
categoryMemory error
-   typeDouble free
+   typeDouble delete
check_namecplusplus.NewDelete

-   
issue_hash_content_of_line_in_context8bf1a5b9fdae9d86780aa6c4cdce2605
+   
issue_hash_content_of_line_in_context6484e9b006ede7362edef2187ba6eb37
   issue_context_kindfunction
   issue_contexttest
   issue_hash_function_offset3

Modified: cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Malloc%2BMismatchedDeallocator%2BNewDelete.cpp?rev=349283&r1=349282&r2=349283&view=diff
==
--- cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp 
(original)
+++ cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp Sat Dec 
15 10:41:37 2018
@@ -46,7 +46,7 @@ void testMismatchedDeallocator() {
 void testNewDoubleFree() {
   int *p = new int;
   delete p;
-  delete 

[PATCH] D55658: Avoid Decl::getASTContext in hot paths where possible, Part 1

2018-12-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D55658#1332240 , @vsk wrote:

> Thanks for working on this :). It’d be interesting to see some pre/post patch 
> compile time numbers on CTMark.
>
> Naive/strawman alternative here, but: what’s the impact on peak RSS and 
> compile time of just storing an ASTContext pointer in Decl/DeclContext? If 
> it’s not out of the question to grow Decl etc. and it gives a nice speed up, 
> that might be a simpler approach.


I will try to get some numbers from CTMark.

I don't think that storing a ref/pointer to the `ASTContext` in each 
`DeclContext` (no point in storing it in `Decl`) is a great idea.
I experimented with this and the speedup from avoiding the lookup of the 
`ASTContext` are almost completely offset by
the slowdown from the increased memory usage.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55658/new/

https://reviews.llvm.org/D55658



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


[PATCH] D54834: [analyzer][MallocChecker] Improve warning messages on double-delete errors

2018-12-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC349283: [analyzer][MallocChecker] Improve warning messages 
on double-delete errors (authored by Szelethus, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54834/new/

https://reviews.llvm.org/D54834

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/NewDelete-path-notes.cpp
  test/Analysis/dtor.cpp

Index: test/Analysis/NewDelete-checker-test.cpp
===
--- test/Analysis/NewDelete-checker-test.cpp
+++ test/Analysis/NewDelete-checker-test.cpp
@@ -182,7 +182,7 @@
 void testDoubleDelete() {
   int *p = new int;
   delete p;
-  delete p; // expected-warning{{Attempt to free released memory}}
+  delete p; // expected-warning{{Attempt to delete released memory}}
 }
 
 void testExprDeleteArg() {
Index: test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
===
--- test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
+++ test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
@@ -194,17 +194,17 @@
  
  depth0
  extended_message
- Attempt to free released memory
+ Attempt to delete released memory
  message
- Attempt to free released memory
+ Attempt to delete released memory
 

-   descriptionAttempt to free released memory
+   descriptionAttempt to delete released memory
categoryMemory error
-   typeDouble free
+   typeDouble delete
check_namecplusplus.NewDelete

-   issue_hash_content_of_line_in_contextbd8e324d09c70b9e2be6f824a4942e5a
+   issue_hash_content_of_line_in_context593b185245106bed5175ccf2753039b2
   issue_context_kindfunction
   issue_contexttest
   issue_hash_function_offset8
@@ -423,17 +423,17 @@
  
  depth0
  extended_message
- Attempt to free released memory
+ Attempt to delete released memory
  message
- Attempt to free released memory
+ Attempt to delete released memory
 

-   descriptionAttempt to free released memory
+   descriptionAttempt to delete released memory
categoryMemory error
-   typeDouble free
+   typeDouble delete
check_namecplusplus.NewDelete

-   issue_hash_content_of_line_in_context8bf1a5b9fdae9d86780aa6c4cdce2605
+   issue_hash_content_of_line_in_context6484e9b006ede7362edef2187ba6eb37
   issue_context_kindfunction
   issue_contexttest
   issue_hash_function_offset3
Index: test/Analysis/dtor.cpp
===
--- test/Analysis/dtor.cpp
+++ test/Analysis/dtor.cpp
@@ -528,7 +528,7 @@
 return *this;
   }
   ~NonTrivial() {
-delete[] p; // expected-warning {{free released memory}}
+delete[] p; // expected-warning {{delete released memory}}
   }
 };
 
Index: test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
===
--- test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
+++ test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
@@ -46,7 +46,7 @@
 void testNewDoubleFree() {
   int *p = new int;
   delete p;
-  delete p; // expected-warning{{Attempt to free released memory}}
+  delete p; // expected-warning{{Attempt to delete released memory}}
 }
 
 void testNewLeak() {
Index: test/Analysis/NewDelete-path-notes.cpp
===
--- test/Analysis/NewDelete-path-notes.cpp
+++ test/Analysis/NewDelete-path-notes.cpp
@@ -11,8 +11,8 @@
 delete p;
 // expected-note@-1 {{Memory is released}}
 
-  delete p; // expected-warning {{Attempt to free released memory}}
-  // expected-note@-1 {{Attempt to free released memory}}
+  delete p; // expected-warning {{Attempt to delete released memory}}
+  // expected-note@-1 {{Attempt to delete released memory}}
 }
 
 struct Odd {
@@ -24,7 +24,7 @@
 void test(Odd *odd) {
 	odd->kill(); // expected-note{{Calling 'Odd::kill'}}
// expected-note@-1 {{Returning; memory was released}}
-	delete odd; // expected-warning {{Attempt to free released memory}}
-  // expected-note@-1 {{Attempt to free released memory}}
+	delete odd; // expected-warning {{Attempt to delete released memory}}
+  // expected-note@-1 {{Attempt to delete released memory}}
 }
 
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1431,7 +1431,8 @@
 
 void MallocChecker::checkPreStmt(const CXXDeleteExpr *DE,
  CheckerContext &C) const {
-
+  // This will regard de

[PATCH] D55658: Avoid Decl::getASTContext in hot paths where possible, Part 1

2018-12-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In D55658#1332249 , @riccibruno wrote:

> In D55658#1332240 , @vsk wrote:
>
> > Thanks for working on this :). It’d be interesting to see some pre/post 
> > patch compile time numbers on CTMark.
> >
> > Naive/strawman alternative here, but: what’s the impact on peak RSS and 
> > compile time of just storing an ASTContext pointer in Decl/DeclContext? If 
> > it’s not out of the question to grow Decl etc. and it gives a nice speed 
> > up, that might be a simpler approach.
>
>
> I will try to get some numbers from CTMark.
>
> I don't think that storing a ref/pointer to the `ASTContext` in each 
> `DeclContext` (no point in storing it in `Decl`) is a great idea.
>  I experimented with this and the speedup from avoiding the lookup of the 
> `ASTContext` is almost completely offset by
>  the slowdown from the increased memory usage.


Good to know, thanks for trying it out!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55658/new/

https://reviews.llvm.org/D55658



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


Clang-format - always break after colon

2018-12-15 Thread Денис Сенькин via cfe-commits
Hi all,

Recently we have started using clang-format in our project. However, the it
clang-format does not support breaking after colon in constructor init
list, which we find very useful.
When we always break after colon, it is pretty clear - you always know the
arguments are placed below the constructor and you have not to look at the
previous line.

Also I have attached patch.

Regards,
Denys


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


[PATCH] D55734: [analyzer] Refactoring GenericTaintChecker.cpp

2018-12-15 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 178373.
boga95 added a comment.

Rebase patch on the earlier version. Remove unnecessary inline specifiers. Fix 
typo.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -23,15 +23,20 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
 
 namespace {
-class GenericTaintChecker : public Checker< check::PostStmt,
-check::PreStmt > {
+class GenericTaintChecker
+: public Checker, check::PreStmt> {
 public:
-  static void *getTag() { static int Tag; return &Tag; }
+  static void *getTag() {
+static int Tag;
+return &Tag;
+  }
 
   void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
 
@@ -43,7 +48,7 @@
   static const unsigned ReturnValueIndex = UINT_MAX - 1;
 
   mutable std::unique_ptr BT;
-  inline void initBugType() const {
+  void initBugType() const {
 if (!BT)
   BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data"));
   }
@@ -69,8 +74,8 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(const CallExpr *,
-   CheckerContext &C) const;
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
+  const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postRetTaint(const CallExpr *CE, CheckerContext &C) const;
@@ -100,7 +105,7 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -112,50 +117,48 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2,
- unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it marks all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
-  getTaintPropagationRule(const FunctionDecl *FDecl,
-  StringRef Name,
-  CheckerContext &C);
+getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
+CheckerContext &C);
 
-inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A)  { DstArgs.push_back(A); }
+void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
+void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
-inline bool isDes

[clang-tools-extra] r349288 - Fix a lit test failure after MallocChecker changes

2018-12-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Dec 15 16:00:18 2018
New Revision: 349288

URL: http://llvm.org/viewvc/llvm-project?rev=349288&view=rev
Log:
Fix a lit test failure after MallocChecker changes

Modified:
clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp?rev=349288&r1=349287&r2=349288&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp Sat Dec 15 
16:00:18 2018
@@ -7,7 +7,7 @@ void f() {
   int *p = new int(42);
   delete p;
   delete p;
-  // CHECK: warning: Attempt to free released memory 
[clang-analyzer-cplusplus.NewDelete]
+  // CHECK: warning: Attempt to delete released memory 
[clang-analyzer-cplusplus.NewDelete]
 }
 
 void g() {


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


[PATCH] D55730: [analyzer] MoveChecker Pt.9: Add a "peaceful" mode in which it finds only 100% authentic bugs.

2018-12-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:188-195
+  void setAggressiveness(StringRef Str) {
+Aggressiveness =
+llvm::StringSwitch(Str)
+.Case("KnownsOnly", AK_KnownsOnly)
+.Case("KnownsAndLocals", AK_KnownsAndLocals)
+.Case("All", AK_All)
+.Default(AK_KnownsAndLocals); // A sane default.

Szelethus wrote:
> You can acquire a `DiagnosticsEngine` through `ASTContext`, which can be 
> acquired from `CheckerManager`. I think it'd prefer to see an error if I 
> messed up the input.
Hmm. I should probably also honor the compatibility mode then.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55730/new/

https://reviews.llvm.org/D55730



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


[PATCH] D55741: Implementation Feature Test Macros for P0722R3

2018-12-15 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly created this revision.
ckennelly added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

P1353R0, adopted in San Diego, specified an implementation feature test macro 
for destroying delete (P0722R3).

The implementation of the feature (https://reviews.llvm.org/rL315662) is not 
guarded behind a flag, so the macro is not conditional on language version.


Repository:
  rC Clang

https://reviews.llvm.org/D55741

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Lexer/cxx-features.cpp


Index: test/Lexer/cxx-features.cpp
===
--- test/Lexer/cxx-features.cpp
+++ test/Lexer/cxx-features.cpp
@@ -34,6 +34,10 @@
 #error "wrong value for __cpp_char8_t"
 #endif
 
+#if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806)
+#error "wrong value for __cpp_impl_destroying_delete"
+#endif
+
 // --- C++17 features ---
 
 #if check(hex_float, 0, 0, 0, 201603, 201603)
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -543,6 +543,7 @@
   // C++20 features.
   if (LangOpts.Char8)
 Builder.defineMacro("__cpp_char8_t", "201811L");
+  Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");
 
   // TS features.
   if (LangOpts.ConceptsTS)


Index: test/Lexer/cxx-features.cpp
===
--- test/Lexer/cxx-features.cpp
+++ test/Lexer/cxx-features.cpp
@@ -34,6 +34,10 @@
 #error "wrong value for __cpp_char8_t"
 #endif
 
+#if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806)
+#error "wrong value for __cpp_impl_destroying_delete"
+#endif
+
 // --- C++17 features ---
 
 #if check(hex_float, 0, 0, 0, 201603, 201603)
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -543,6 +543,7 @@
   // C++20 features.
   if (LangOpts.Char8)
 Builder.defineMacro("__cpp_char8_t", "201811L");
+  Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");
 
   // TS features.
   if (LangOpts.ConceptsTS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits