[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-04-29 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, rsmith.

If a variable has initializer, codegen tries to build its value. It
causes strange behavior from user viewpoint: compilation of huge zero
initialized arrays like:

  int char data_1[2147483648u] = { 0 };

consumes enormous amount of time and memory.

With this change compiler recognizes more patterns when variable is
initialized with zeros and elementwise treatment can be avoided.


Repository:
  rC Clang

https://reviews.llvm.org/D46241

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/cxx11-initializer-aggregate.cpp


Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -51,3 +51,15 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1392,20 +1392,36 @@
   return type;
 }
 
+static bool isZeroInitializer(ConstantEmitter , const Expr *Init) {
+  QualType InitTy = Init->getType().getCanonicalType();
+  QualType BaseTy = CE.CGM.getContext().getBaseElementType(InitTy);
+  if (BaseTy->isRecordType()) {
+if (auto *E = dyn_cast_or_null(Init)) {
+CXXConstructorDecl *CD = E->getConstructor();
+if (CD->isDefaultConstructor() && CD->isTrivial())
+return true;
+}
+  } else if (InitTy->isIntegerType()) {
+llvm::APSInt Value;
+if (Init->isIntegerConstantExpr(Value, CE.CGM.getContext()))
+  return Value.isNullValue();
+  } else if (InitTy->isConstantArrayType()) {
+if (auto *IL = dyn_cast_or_null(Init)) {
+  for (auto I : IL->inits())
+if (!isZeroInitializer(CE, I))
+  return false;
+  return true;
+}
+  }
+  return false;
+}
+
 llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl ) {
   // Make a quick check if variable can be default NULL initialized
   // and avoid going through rest of code which may do, for c++11,
   // initialization of memory to all NULLs.
-  if (!D.hasLocalStorage()) {
-QualType Ty = CGM.getContext().getBaseElementType(D.getType());
-if (Ty->isRecordType())
-  if (const CXXConstructExpr *E =
-  dyn_cast_or_null(D.getInit())) {
-const CXXConstructorDecl *CD = E->getConstructor();
-if (CD->isTrivial() && CD->isDefaultConstructor())
-  return CGM.EmitNullConstant(D.getType());
-  }
-  }
+  if (!D.hasLocalStorage() && isZeroInitializer(*this, D.getInit()))
+return CGM.EmitNullConstant(D.getType());
 
   QualType destType = D.getType();
 


Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -51,3 +51,15 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1392,20 +1392,36 @@
   return type;
 }
 
+static bool isZeroInitializer(ConstantEmitter , const Expr *Init) {
+  QualType InitTy = Init->getType().getCanonicalType();
+  QualType BaseTy = CE.CGM.getContext().getBaseElementType(InitTy);
+  if (BaseTy->isRecordType()) {
+if (auto *E = dyn_cast_or_null(Init)) {
+CXXConstructorDecl *CD = E->getConstructor();
+if (CD->isDefaultConstructor() && CD->isTrivial())
+return true;
+}
+  } else if (InitTy->isIntegerType()) {
+llvm::APSInt Value;
+if (Init->isIntegerConstantExpr(Value, CE.CGM.getContext()))
+  return Value.isNullValue();
+  } else if (InitTy->isConstantArrayType()) {
+if (auto *IL = dyn_cast_or_null(Init)) {
+  for (auto I : IL->inits())
+if (!isZeroInitializer(CE, I))
+  return false;
+  return true;
+}
+  }
+  return false;
+}
+
 llvm::Constant 

[clang-tools-extra] r331156 - Fix up after clang r331155.

2018-04-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Apr 29 22:26:07 2018
New Revision: 331156

URL: http://llvm.org/viewvc/llvm-project?rev=331156=rev
Log:
Fix up after clang r331155.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/clangd/AST.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=331156=331155=331156=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Sun Apr 29 22:26:07 2018
@@ -280,7 +280,10 @@ SourceLocation
 getLocForEndOfDecl(const clang::Decl *D,
const LangOptions  = clang::LangOptions()) {
   const auto  = D->getASTContext().getSourceManager();
-  auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).second;
+  // If the expansion range is a character range, this is the location of
+  // the first character past the end. Otherwise it's the location of the
+  // first character in the final token in the range.
+  auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).getEnd();
   std::pair LocInfo = SM.getDecomposedLoc(EndExpansionLoc);
   // Try to load the file buffer.
   bool InvalidTemp = false;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=331156=331155=331156=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Sun Apr 
29 22:26:07 2018
@@ -374,7 +374,7 @@ static bool LineIsMarkedWithNOLINTinMacr
   return true;
 if (!Loc.isMacroID())
   return false;
-Loc = SM.getImmediateExpansionRange(Loc).first;
+Loc = SM.getImmediateExpansionRange(Loc).getBegin();
   }
   return false;
 }

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp?rev=331156=331155=331156=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp Sun 
Apr 29 22:26:07 2018
@@ -81,7 +81,7 @@ void LambdaFunctionNameCheck::check(cons
   if (E->getLocation().isMacroID()) {
 auto ER =
 Result.SourceManager->getImmediateExpansionRange(E->getLocation());
-if (SuppressMacroExpansions.find(SourceRange(ER.first, ER.second)) !=
+if (SuppressMacroExpansions.find(ER.getAsRange()) !=
 SuppressMacroExpansions.end()) {
   // This is a macro expansion for which we should not warn.
   return;

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp?rev=331156=331155=331156=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp 
Sun Apr 29 22:26:07 2018
@@ -38,7 +38,7 @@ const Stmt *nextStmt(const MatchFinder::
   return nextStmt(Result, Parent);
 }
 
-using ExpansionRanges = std::vector>;
+using ExpansionRanges = std::vector;
 
 /// \bried Get all the macro expansion ranges related to `Loc`.
 ///
@@ -47,8 +47,9 @@ ExpansionRanges getExpansionRanges(Sourc
const MatchFinder::MatchResult ) {
   ExpansionRanges Locs;
   while (Loc.isMacroID()) {
-Locs.push_back(Result.SourceManager->getImmediateExpansionRange(Loc));
-Loc = Locs.back().first;
+Locs.push_back(
+Result.SourceManager->getImmediateExpansionRange(Loc).getAsRange());
+Loc = Locs.back().getBegin();
   }
   return Locs;
 }
@@ -96,9 +97,9 @@ void MultipleStatementMacroCheck::check(
   InnerRanges.back() != NextRanges.back())
 return;
 
-  diag(InnerRanges.back().first, "multiple statement macro used without "
- "braces; some statements will be "
- "unconditionally executed");
+  diag(InnerRanges.back().getBegin(), "multiple statement macro used without "

r331155 - PR37189 Fix incorrect end source location and spelling for a split '>>' token.

2018-04-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Apr 29 22:25:48 2018
New Revision: 331155

URL: http://llvm.org/viewvc/llvm-project?rev=331155=rev
Log:
PR37189 Fix incorrect end source location and spelling for a split '>>' token.

When a '>>' token is split into two '>' tokens (in C++11 onwards), or (as an
extension) when we do the same for other tokens starting with a '>', we can't
just use a location pointing to the first '>' as the location of the split
token, because that would result in our miscomputing the length and spelling
for the token. As a consequence, for example, a refactoring replacing 'A'
with something else would sometimes replace one character too many, and
similarly diagnostics highlighting a template-id source range would highlight
one character too many.

Fix this by creating an expansion range covering the first character of the
'>>' token, whose spelling is '>'. For this to work, we generalize the
expansion range of a macro FileID to be either a token range (the common case)
or a character range (used in this new case).

Added:
cfe/trunk/test/Misc/diag-greatergreater.cpp
Modified:
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Rewrite/Core/HTMLRewrite.h
cfe/trunk/lib/ARCMigrate/PlistReporter.cpp
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/ARCMigrate/TransUnbridgedCasts.cpp
cfe/trunk/lib/ARCMigrate/TransformActions.cpp
cfe/trunk/lib/Basic/SourceLocation.cpp
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/lib/Edit/EditedSource.cpp
cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Parser/cxx0x-decl.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=331155=331154=331155=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Sun Apr 29 22:25:48 2018
@@ -265,6 +265,7 @@ public:
  
   void setBegin(SourceLocation b) { Range.setBegin(b); }
   void setEnd(SourceLocation e) { Range.setEnd(e); }
+  void setTokenRange(bool TR) { IsTokenRange = TR; }
   
   bool isValid() const { return Range.isValid(); }
   bool isInvalid() const { return !isValid(); }
@@ -359,7 +360,6 @@ public:
   FullSourceLoc getExpansionLoc() const;
   FullSourceLoc getSpellingLoc() const;
   FullSourceLoc getFileLoc() const;
-  std::pair getImmediateExpansionRange() const;
   PresumedLoc getPresumedLoc(bool UseLineDirectives = true) const;
   bool isMacroArgExpansion(FullSourceLoc *StartLoc = nullptr) const;
   FullSourceLoc getImmediateMacroCallerLoc() const;
@@ -377,8 +377,6 @@ public:
   unsigned getLineNumber(bool *Invalid = nullptr) const;
   unsigned getColumnNumber(bool *Invalid = nullptr) const;
 
-  std::pair getExpansionRange() const;
-
   const FileEntry *getFileEntry() const;
 
   /// \brief Return a StringRef to the source buffer data for the

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=331155=331154=331155=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Sun Apr 29 22:25:48 2018
@@ -317,9 +317,13 @@ namespace SrcMgr {
 /// invalid location.
 unsigned ExpansionLocStart, ExpansionLocEnd;
 
+/// Whether the expansion range is a token range.
+bool ExpansionIsTokenRange;
+
   public:
 SourceLocation getSpellingLoc() const {
-  return SourceLocation::getFromRawEncoding(SpellingLoc);
+  SourceLocation SpellLoc = 
SourceLocation::getFromRawEncoding(SpellingLoc);
+  return SpellLoc.isInvalid() ? getExpansionLocStart() : SpellLoc;
 }
 
 SourceLocation getExpansionLocStart() const {
@@ -332,8 

[PATCH] D46056: Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-04-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Apologies for misspelling your last name :-(


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D46056



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


Re: [libcxxabi] r331150 - Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-04-29 Thread Nico Weber via cfe-commits
This should have said "Patch from Taiju Tsuiki ",
apologies.

On Sun, Apr 29, 2018 at 7:05 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Sun Apr 29 16:05:11 2018
> New Revision: 331150
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331150=rev
> Log:
> Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build
> system
>
> _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is currently used to
> bring back std::unexpected, which is removed in C++17, but still needed
> for libc++abi for backward compatibility.
>
> This macro used to define in cxa_exception.cpp only, but actually
> needed for all sources that touches exceptions.
> So, a build-system-level macro is better fit to define this macro.
>
> https://reviews.llvm.org/D46056
> Patch from Taiju Tsuiku !
>
> Modified:
> libcxxabi/trunk/CMakeLists.txt
> libcxxabi/trunk/src/cxa_exception.cpp
> libcxxabi/trunk/test/test_exception_storage.pass.cpp
>
> Modified: libcxxabi/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/
> CMakeLists.txt?rev=331150=331149=331150=diff
> 
> ==
> --- libcxxabi/trunk/CMakeLists.txt (original)
> +++ libcxxabi/trunk/CMakeLists.txt Sun Apr 29 16:05:11 2018
> @@ -387,6 +387,10 @@ endif()
>  # Prevent libc++abi from having library dependencies on libc++
>  add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE)
>
> +# Bring back `std::unexpected`, which is removed in C++17, to support
> +# pre-C++17.
> +add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
> +
>  if (MSVC)
>add_definitions(-D_CRT_SECURE_NO_WARNINGS)
>  endif()
>
> Modified: libcxxabi/trunk/src/cxa_exception.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> cxa_exception.cpp?rev=331150=331149=331150=diff
> 
> ==
> --- libcxxabi/trunk/src/cxa_exception.cpp (original)
> +++ libcxxabi/trunk/src/cxa_exception.cpp Sun Apr 29 16:05:11 2018
> @@ -11,8 +11,6 @@
>  //
>  //===---
> ---===//
>
> -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
> -
>  #include "cxxabi.h"
>
>  #include // for std::terminate
>
> Modified: libcxxabi/trunk/test/test_exception_storage.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/
> test_exception_storage.pass.cpp?rev=331150=331149=331150=diff
> 
> ==
> --- libcxxabi/trunk/test/test_exception_storage.pass.cpp (original)
> +++ libcxxabi/trunk/test/test_exception_storage.pass.cpp Sun Apr 29
> 16:05:11 2018
> @@ -7,11 +7,6 @@
>  //
>  //===---
> ---===//
>
> -// FIXME: cxa_exception.hpp directly references `std::unexpected` and
> friends.
> -// This breaks this test when compiled in C++17. For now fix this by
> manually
> -// re-enabling the STL functions.
> -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
> -
>  #include 
>  #include 
>  #include 
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46056: Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-04-29 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

Landed in r331150: 
http://llvm.org/viewvc/llvm-project?view=revision=331150


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D46056



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


[libcxxabi] r331150 - Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-04-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Sun Apr 29 16:05:11 2018
New Revision: 331150

URL: http://llvm.org/viewvc/llvm-project?rev=331150=rev
Log:
Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is currently used to
bring back std::unexpected, which is removed in C++17, but still needed
for libc++abi for backward compatibility.

This macro used to define in cxa_exception.cpp only, but actually
needed for all sources that touches exceptions.
So, a build-system-level macro is better fit to define this macro.

https://reviews.llvm.org/D46056
Patch from Taiju Tsuiku !

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/test/test_exception_storage.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=331150=331149=331150=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Sun Apr 29 16:05:11 2018
@@ -387,6 +387,10 @@ endif()
 # Prevent libc++abi from having library dependencies on libc++
 add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE)
 
+# Bring back `std::unexpected`, which is removed in C++17, to support
+# pre-C++17.
+add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
+
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif()

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=331150=331149=331150=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Sun Apr 29 16:05:11 2018
@@ -11,8 +11,6 @@
 //  
 
//===--===//
 
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-
 #include "cxxabi.h"
 
 #include // for std::terminate

Modified: libcxxabi/trunk/test/test_exception_storage.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage.pass.cpp?rev=331150=331149=331150=diff
==
--- libcxxabi/trunk/test/test_exception_storage.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_storage.pass.cpp Sun Apr 29 16:05:11 
2018
@@ -7,11 +7,6 @@
 //
 
//===--===//
 
-// FIXME: cxa_exception.hpp directly references `std::unexpected` and friends.
-// This breaks this test when compiled in C++17. For now fix this by manually
-// re-enabling the STL functions.
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-
 #include 
 #include 
 #include 


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


[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2018-04-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46234#1082332, @xazax.hun wrote:

> In https://reviews.llvm.org/D46234#1082307, @rsmith wrote:
>
> > Perhaps we should just use a null pointer for the not-instantiated arm of 
> > an `if constexpr` instead, rather than tracking a flag on an empty 
> > statement that is meaningless for real empty statements.
>
>
> I will look into that, thanks. I wonder if any of the code assumes that the 
> than branch always present.


I expect some code does. But this is fundamentally a special property of an `if 
constexpr` statement, not of an empty statement, so I think it makes most sense 
that whatever special handling we choose to use for this should live in the 
`IfStmt`.


Repository:
  rC Clang

https://reviews.llvm.org/D46234



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


[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2018-04-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D46234#1082307, @rsmith wrote:

> Can you say something about why you want to track this?


The original motivation was to fix this false positive in clang tidy: 
https://reviews.llvm.org/D46027

> Perhaps we should just use a null pointer for the not-instantiated arm of an 
> `if constexpr` instead, rather than tracking a flag on an empty statement 
> that is meaningless for real empty statements.

I will look into that, thanks. I wonder if any of the code assumes that the 
than branch always present.


Repository:
  rC Clang

https://reviews.llvm.org/D46234



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


[PATCH] D46236: [Driver, CodeGen] rename options to disable an FP cast optimization

2018-04-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: docs/ReleaseNotes.rst:96
+   type, the code has undefined behavior according to the language standard.
+   Clang will not guarantee any particular result in that case. With the
+   'no-strict' option, Clang attempts to match the overflowing behavior of

Add "By default" to the start of this sentence.


https://reviews.llvm.org/D46236



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


[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2018-04-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Can you say something about why you want to track this?

Perhaps we should just use a null pointer for the not-instantiated arm of an 
`if constexpr` instead, rather than tracking a flag on an empty statement that 
is meaningless for real empty statements.


Repository:
  rC Clang

https://reviews.llvm.org/D46234



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


[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-29 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 144490.
shuaiwang marked 11 inline comments as done.
shuaiwang added a comment.

Added an isMutated overload for Decl.
A few more test cases.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679

Files:
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/ExprMutationAnalyzer.cpp
  clang-tidy/utils/ExprMutationAnalyzer.h
  unittests/clang-tidy/CMakeLists.txt
  unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- /dev/null
+++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -0,0 +1,554 @@
+//===-- ExprMutationAnalyzerTest.cpp - clang-tidy -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../clang-tidy/utils/ExprMutationAnalyzer.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+using namespace clang::ast_matchers;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::ResultOf;
+using ::testing::StartsWith;
+using ::testing::Values;
+
+namespace {
+
+using ExprMatcher = internal::Matcher;
+using StmtMatcher = internal::Matcher;
+
+ExprMatcher declRefTo(StringRef Name) {
+  return declRefExpr(to(namedDecl(hasName(Name;
+}
+
+StmtMatcher withEnclosingCompound(ExprMatcher Matcher) {
+  return expr(Matcher, hasAncestor(compoundStmt().bind("stmt"))).bind("expr");
+}
+
+bool isMutated(const SmallVectorImpl , ASTUnit *AST) {
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  return utils::ExprMutationAnalyzer(S, >getASTContext()).isMutated(E);
+}
+
+SmallVector
+mutatedBy(const SmallVectorImpl , ASTUnit *AST) {
+  const auto *const S = selectFirst("stmt", Results);
+  SmallVector Chain;
+  utils::ExprMutationAnalyzer Analyzer(S, >getASTContext());
+  for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
+const Stmt *By = Analyzer.findMutation(E);
+std::string buffer;
+llvm::raw_string_ostream stream(buffer);
+By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
+Chain.push_back(StringRef(stream.str()).trim().str());
+E = dyn_cast(By);
+  }
+  return Chain;
+}
+
+std::string removeSpace(std::string s) {
+  s.erase(std::remove_if(s.begin(), s.end(),
+ [](char c) { return std::isspace(c); }),
+  s.end());
+  return s;
+}
+
+} // namespace
+
+TEST(ExprMutationAnalyzerTest, Trivial) {
+  const auto AST = tooling::buildASTFromCode("void f() { int x; x; }");
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+class AssignmentTest : public ::testing::TestWithParam {};
+
+TEST_P(AssignmentTest, AssignmentModifies) {
+  const std::string ModExpr = "x " + GetParam() + " 10";
+  const auto AST =
+  tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }");
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+}
+
+INSTANTIATE_TEST_CASE_P(AllAssignmentOperators, AssignmentTest,
+Values("=", "+=", "-=", "*=", "/=", "%=", "&=", "|=",
+   "^=", "<<=", ">>="), );
+
+class IncDecTest : public ::testing::TestWithParam {};
+
+TEST_P(IncDecTest, IncDecModifies) {
+  const std::string ModExpr = GetParam();
+  const auto AST =
+  tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }");
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+}
+
+INSTANTIATE_TEST_CASE_P(AllIncDecOperators, IncDecTest,
+Values("++x", "--x", "x++", "x--"), );
+
+TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) {
+  const auto AST = tooling::buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }");
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+}
+
+TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
+  const auto AST = tooling::buildASTFromCode(
+  "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, 

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-29 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:229-237
+  const auto *UseExpr = selectFirst("use", Usage);
+
+  // The declared variables was used in non-const conserving way and can not
+  // be declared as const.
+  if (UseExpr && Scopes[Scope]->isMutated(UseExpr)) {
+// diag(UseExpr->getLocStart(), "Investigating starting with this use",
+// DiagnosticIDs::Note);

I think we need to loop over usages instead of just checking the first, i.e.:
```
for (const auto  : Usage) {
  const auto* UseExpr = Nodes.getNodeAs("use");
  if (UseExpr && isMutated(UseExpr)) return true;
}
```

I'll add a helper function in the MutationAnalyzer for checking varDecl 
directly as well per your comment there, which you'll be able to use directly 
in this check. Before that's ready (and if you have time of course) could you 
help check how many false positives are left with this change?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D46236: [Driver, CodeGen] rename options to disable an FP cast optimization

2018-04-29 Thread Sanjay Patel via Phabricator via cfe-commits
spatel updated this revision to Diff 144487.
spatel marked 6 inline comments as done.
spatel added a comment.

Patch updated:

1. Improved language in docs.
2. Added help text for clang options.
3. Added driver test with -fstrict-float-cast-overflow specified explicitly.

I'll leave this up for further review in case there are other suggestions.


https://reviews.llvm.org/D46236

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/no-junk-ftrunc.c
  test/Driver/fast-math.c

Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -289,25 +289,25 @@
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
 
 // This isn't fast-math, but the option is handled in the same place as other FP params.
-// Last option wins, and the flag is *not* passed by default. 
+// Last option wins, and strict behavior is assumed by default. 
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND %s
 // CHECK-FPOV-WORKAROUND: "-cc1"
-// CHECK-FPOV-WORKAROUND: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND: "-fno-strict-float-cast-overflow"
 
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND-DEFAULT %s
 // CHECK-FPOV-WORKAROUND-DEFAULT: "-cc1"
-// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND %s
 // CHECK-NO-FPOV-WORKAROUND: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND-OVERRIDE %s
 // CHECK-NO-FPOV-WORKAROUND-OVERRIDE: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "strict-float-cast-overflow"
 
Index: test/CodeGen/no-junk-ftrunc.c
===
--- test/CodeGen/no-junk-ftrunc.c
+++ test/CodeGen/no-junk-ftrunc.c
@@ -1,12 +1,16 @@
-// RUN: %clang_cc1 -S -ffp-cast-overflow-workaround %s -emit-llvm -o - | FileCheck %s
-// CHECK-LABEL: main
-// CHECK: attributes #0 = {{.*}}"fp-cast-overflow-workaround"="true"{{.*}}
+// RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | FileCheck %s --check-prefix=NOSTRICT
+// NOSTRICT-LABEL: main
+// NOSTRICT: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
 
 // The workaround attribute is not applied by default.
 
+// RUN: %clang_cc1 -S %s -fstrict-float-cast-overflow -emit-llvm -o - | FileCheck %s --check-prefix=STRICT
+// STRICT-LABEL: main
+// STRICT-NOT: strict-float-cast-overflow
+
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
 // DEFAULT-LABEL: main
-// DEFAULT-NOT: fp-cast-overflow-workaround
+// DEFAULT-NOT: strict-float-cast-overflow
 
 int main() {
   return 0;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -699,7 +699,8 @@
   Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
-  Opts.FPCastOverflowWorkaround = Args.hasArg(OPT_ffp_cast_overflow_workaround);
+  Opts.StrictFloatCastOverflow =
+  !Args.hasArg(OPT_fno_strict_float_cast_overflow);
 
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2242,9 +2242,9 @@
   }
 
   // Disable a codegen optimization for floating-point casts.
-  if (Args.hasFlag(options::OPT_ffp_cast_overflow_workaround,
-   options::OPT_fno_fp_cast_overflow_workaround, false))
-CmdArgs.push_back("-ffp-cast-overflow-workaround");
+  if (Args.hasFlag(options::OPT_fno_strict_float_cast_overflow,
+   options::OPT_fstrict_float_cast_overflow, false))
+

[PATCH] D46236: [Driver, CodeGen] rename options to disable an FP cast optimization

2018-04-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Overall makes sense to me.




Comment at: docs/ReleaseNotes.rst:94
+  :option:`-fno-strict-float-cast-overflow` -
+   When a floating-point value is not representable in a casted-to integer
+   type, the code has undefined behavior according to the language standard.

```
- in a casted-to integer type
+ in destination integer type
```
?




Comment at: docs/ReleaseNotes.rst:96
+   type, the code has undefined behavior according to the language standard.
+   Clang will not guarantee any particular result in that event. With the
+   'no-strict' option, Clang attempts to match the overflowing behavior of

s/event/case/ ?



Comment at: docs/UsersManual.rst:1260
 
-   Enable a workaround for code that casts floating-point values to 
-   integers and back to floating-point. If the floating-point value 
-   is not representable in the intermediate integer type, the code is
-   incorrect according to the language standard. This flag will attempt 
-   to generate code as if the result of an overflowing conversion matches
-   the overflowing behavior of a target's native float-to-int conversion
-   instructions.
+   When a floating-point value is not representable in a casted-to integer 
+   type, the code has undefined behavior according to the language standard.

same



Comment at: docs/UsersManual.rst:1262
+   type, the code has undefined behavior according to the language standard.
+   Clang will not guarantee any particular result in that event. With the
+   'no-strict' option, Clang attempts to match the overflowing behavior of 

same



Comment at: include/clang/Driver/Options.td:1033
+def fstrict_float_cast_overflow : Flag<["-"],
+  "fstrict-float-cast-overflow">, Group, Flags<[CC1Option]>;
+def fno_strict_float_cast_overflow : Flag<["-"],

Maybe add `HelpText<"">` to both of them, just to explain what they are,
specify that the first is the default, and the second relaxes language rules to 
help broken code.



Comment at: test/CodeGen/no-junk-ftrunc.c:7
 
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
 // DEFAULT-LABEL: main

It wouldn't hurt to duplicate this run-line, and explicitly pass 
`-fno-strict-float-cast-overflow`.


https://reviews.llvm.org/D46236



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


Re: r331056 - [docs] add -ffp-cast-overflow-workaround to the release notes

2018-04-29 Thread Sanjay Patel via cfe-commits
Patches to improve the language posted for review:
https://reviews.llvm.org/D46236
https://reviews.llvm.org/D46237

On Fri, Apr 27, 2018 at 7:41 PM, Chandler Carruth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, Apr 27, 2018 at 5:13 PM Richard Smith 
> wrote:
>
>> On 27 April 2018 at 17:09, Chandler Carruth via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Fri, Apr 27, 2018 at 4:36 PM Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 On 27 April 2018 at 16:07, Sanjay Patel via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Missing dash corrected at r331057. I can improve the doc wording, but
> let's settle on the flag name first, and I'll try to get it all fixed up 
> in
> one shot.
>
> So far we have these candidates:
> 1. -ffp-cast-overflow-workaround
> 2. -fstrict-fp-trunc-semantics
> 3. -fstrict-fp-cast-overflow
>
> I don't have a strong opinion here, but on 2nd reading, it does seem
> like a 'strict' flag fits better with existing options.
>

 The corresponding UBSan check is called -fsanitize=float-cast-overflow,
 so maybe -fno-strict-float-cast-overflow would be the most consistent
 name?

>>>
>>> On this topic: we were hit by this on a *lot* of code. All of that code
>>> builds and passes tests with -fsanitize=float-cast-overflow. So I think
>>> we've been mistaken in assuming that this sanitizer catches all of the
>>> failure modes of the optimization. That at least impacts the sanitizer
>>> suggestion in the release notes. And probably impacts the flag name /
>>> attribuet name.
>>>
>>
>> That's interesting, and definitely sounds like a bug (either the
>> sanitizer or LLVM is presumably getting the range check wrong). Can you
>> point me at an example?
>>
>
> It appears that the code that hit this has cleverly dodged *EVERY* build
> configuration we have deployed this sanitizer in... despite our best
> efforts. Sorry for the noise.
>
>
>>
>>
>>> On Fri, Apr 27, 2018 at 4:41 PM, Richard Smith 
> wrote:
>
>> On 27 April 2018 at 09:21, Sanjay Patel via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: spatel
>>> Date: Fri Apr 27 09:21:22 2018
>>> New Revision: 331056
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=331056=rev
>>> Log:
>>> [docs] add -ffp-cast-overflow-workaround to the release notes
>>>
>>> This option was added with:
>>> D46135
>>> rL331041
>>> ...copying the text from UsersManual.rst for more exposure.
>>>
>>>
>>> Modified:
>>> cfe/trunk/docs/ReleaseNotes.rst
>>>
>>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
>>> ReleaseNotes.rst?rev=331056=331055=331056=diff
>>> 
>>> ==
>>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>>> +++ cfe/trunk/docs/ReleaseNotes.rst Fri Apr 27 09:21:22 2018
>>> @@ -83,6 +83,15 @@ Non-comprehensive list of changes in thi
>>>  New Compiler Flags
>>>  --
>>>
>>> +- :option:`-ffp-cast-overflow-workaround` and
>>> +  :option:`-fnofp-cast-overflow-workaround`
>>>
>>
>> Shouldn't this be -fno-fp-cast-overflow-workaround?
>>
>> Also, our convention for flags that define undefined behavior is
>> `-fno-strict-*`, so perhaps this should be `-fno-strict-fp-cast-overflow`
>> ?
>>
>>
>>> +  enable (disable) a workaround for code that casts floating-point
>>> values to
>>> +  integers and back to floating-point. If the floating-point value
>>> is not
>>> +  representable in the intermediate integer type, the code is
>>> incorrect
>>> +  according to the language standard.
>>
>>
>> I find this hard to read: I initially misread "the code is incorrect
>> according to the language standard" as meaning "Clang will generate code
>> that is incorrect according to the language standard". I think what you
>> mean here is "the code has undefined behavior according to the language
>> standard, and Clang will not guarantee any particular result. This flag
>> causes the behavior to be defined to match the overflowing behavior of 
>> the
>> target's native float-to-int conversion instructions."
>>
>>
>>> This flag will attempt to generate code
>>> +  as if the result of an overflowing conversion matches the
>>> overflowing behavior
>>> +  of a target's native float-to-int conversion instructions.
>>> +
>>>  - ...
>>>
>>>  Deprecated Compiler Flags
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> 

[PATCH] D46236: [Driver, CodeGen] rename options to disable an FP cast optimization

2018-04-29 Thread Sanjay Patel via Phabricator via cfe-commits
spatel updated this revision to Diff 144481.
spatel added a comment.

Patch updated:
I missed a spot in the release notes - forgot to delete 'workaround' when 
listing the new options.


https://reviews.llvm.org/D46236

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/no-junk-ftrunc.c
  test/Driver/fast-math.c

Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -289,25 +289,25 @@
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
 
 // This isn't fast-math, but the option is handled in the same place as other FP params.
-// Last option wins, and the flag is *not* passed by default. 
+// Last option wins, and strict behavior is assumed by default. 
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND %s
 // CHECK-FPOV-WORKAROUND: "-cc1"
-// CHECK-FPOV-WORKAROUND: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND: "-fno-strict-float-cast-overflow"
 
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND-DEFAULT %s
 // CHECK-FPOV-WORKAROUND-DEFAULT: "-cc1"
-// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND %s
 // CHECK-NO-FPOV-WORKAROUND: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND-OVERRIDE %s
 // CHECK-NO-FPOV-WORKAROUND-OVERRIDE: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "strict-float-cast-overflow"
 
Index: test/CodeGen/no-junk-ftrunc.c
===
--- test/CodeGen/no-junk-ftrunc.c
+++ test/CodeGen/no-junk-ftrunc.c
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -S -ffp-cast-overflow-workaround %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | FileCheck %s
 // CHECK-LABEL: main
-// CHECK: attributes #0 = {{.*}}"fp-cast-overflow-workaround"="true"{{.*}}
+// CHECK: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
 
 // The workaround attribute is not applied by default.
 
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
 // DEFAULT-LABEL: main
-// DEFAULT-NOT: fp-cast-overflow-workaround
+// DEFAULT-NOT: strict-float-cast-overflow
 
 int main() {
   return 0;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -699,7 +699,8 @@
   Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
-  Opts.FPCastOverflowWorkaround = Args.hasArg(OPT_ffp_cast_overflow_workaround);
+  Opts.StrictFloatCastOverflow =
+  !Args.hasArg(OPT_fno_strict_float_cast_overflow);
 
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2242,9 +2242,9 @@
   }
 
   // Disable a codegen optimization for floating-point casts.
-  if (Args.hasFlag(options::OPT_ffp_cast_overflow_workaround,
-   options::OPT_fno_fp_cast_overflow_workaround, false))
-CmdArgs.push_back("-ffp-cast-overflow-workaround");
+  if (Args.hasFlag(options::OPT_fno_strict_float_cast_overflow,
+   options::OPT_fstrict_float_cast_overflow, false))
+CmdArgs.push_back("-fno-strict-float-cast-overflow");
 }
 
 static void RenderAnalyzerOptions(const ArgList , ArgStringList ,
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1727,8 +1727,10 @@
 FuncAttrs.addAttribute("no-trapping-math",

[PATCH] D46236: [Driver, CodeGen] rename options to disable an FP cast optimization

2018-04-29 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
spatel added reviewers: rsmith, chandlerc, scanon, hans, echristo, jgorbe, 
lebedev.ri.
Herald added a subscriber: mcrosier.

As suggested in the post-commit thread for https://reviews.llvm.org/rL331056, 
we should match these clang options with the established vocabulary of the 
corresponding sanitizer option. Also, the use of 'strict' is well-known for 
these kinds of knobs, and we can improve the descriptive text in the docs.

So this intends to match the logic of https://reviews.llvm.org/D46135 but only 
change the words. I'll post the matching LLVM patch next and link it to this.


https://reviews.llvm.org/D46236

Files:
  docs/ReleaseNotes.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/no-junk-ftrunc.c
  test/Driver/fast-math.c

Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -289,25 +289,25 @@
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
 
 // This isn't fast-math, but the option is handled in the same place as other FP params.
-// Last option wins, and the flag is *not* passed by default. 
+// Last option wins, and strict behavior is assumed by default. 
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND %s
 // CHECK-FPOV-WORKAROUND: "-cc1"
-// CHECK-FPOV-WORKAROUND: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND: "-fno-strict-float-cast-overflow"
 
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPOV-WORKAROUND-DEFAULT %s
 // CHECK-FPOV-WORKAROUND-DEFAULT: "-cc1"
-// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-FPOV-WORKAROUND-DEFAULT-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND %s
 // CHECK-NO-FPOV-WORKAROUND: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-NOT: "strict-float-cast-overflow"
 
-// RUN: %clang -### -ffp-cast-overflow-workaround -fno-fp-cast-overflow-workaround -c %s 2>&1 \
+// RUN: %clang -### -fno-strict-float-cast-overflow -fstrict-float-cast-overflow -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FPOV-WORKAROUND-OVERRIDE %s
 // CHECK-NO-FPOV-WORKAROUND-OVERRIDE: "-cc1"
-// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "-ffp-cast-overflow-workaround"
+// CHECK-NO-FPOV-WORKAROUND-OVERRIDE-NOT: "strict-float-cast-overflow"
 
Index: test/CodeGen/no-junk-ftrunc.c
===
--- test/CodeGen/no-junk-ftrunc.c
+++ test/CodeGen/no-junk-ftrunc.c
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -S -ffp-cast-overflow-workaround %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | FileCheck %s
 // CHECK-LABEL: main
-// CHECK: attributes #0 = {{.*}}"fp-cast-overflow-workaround"="true"{{.*}}
+// CHECK: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
 
 // The workaround attribute is not applied by default.
 
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
 // DEFAULT-LABEL: main
-// DEFAULT-NOT: fp-cast-overflow-workaround
+// DEFAULT-NOT: strict-float-cast-overflow
 
 int main() {
   return 0;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -699,7 +699,8 @@
   Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
-  Opts.FPCastOverflowWorkaround = Args.hasArg(OPT_ffp_cast_overflow_workaround);
+  Opts.StrictFloatCastOverflow =
+  !Args.hasArg(OPT_fno_strict_float_cast_overflow);
 
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2242,9 +2242,9 @@
   }
 
   // Disable a codegen optimization for floating-point casts.
-  if (Args.hasFlag(options::OPT_ffp_cast_overflow_workaround,
-   options::OPT_fno_fp_cast_overflow_workaround, false))
-CmdArgs.push_back("-ffp-cast-overflow-workaround");
+  if (Args.hasFlag(options::OPT_fno_strict_float_cast_overflow,
+   

[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2018-04-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added a reviewer: aaron.ballman.
Herald added subscribers: dkrupp, rnkovacs.

I did not add tests yet because first I wanted to be sure whether this approach 
is OK.


Repository:
  rC Clang

https://reviews.llvm.org/D46234

Files:
  include/clang/AST/Stmt.h
  lib/Sema/TreeTransform.h


Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6605,7 +6605,9 @@
 if (Then.isInvalid())
   return StmtError();
   } else {
-Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart());
+Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart(),
+/*hasLeadingEmptyMacro=*/false,
+/*resultOfConstexprFolding=*/true);
   }
 
   // Transform the "else" branch.
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -577,21 +577,33 @@
   /// @endcode
   bool HasLeadingEmptyMacro = false;
 
+  /// \brief True if the null statement was produced by folding a part of the
+  ///code away, e.g:
+  /// @code
+  ///   if constexpr(0 > 1) { willBeFoldedAway(); }
+  ///   // After constexpr evaluation:
+  ///   if constexpr(0 > 1) ;
+  /// @endcode
+  bool ResultOfConstexprFolding = false;
+
 public:
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 
-  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
+  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false,
+   bool resultOfConstexprFolding = false)
   : Stmt(NullStmtClass), SemiLoc(L),
-HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
+HasLeadingEmptyMacro(hasLeadingEmptyMacro),
+ResultOfConstexprFolding(resultOfConstexprFolding) {}
 
   /// \brief Build an empty null statement.
   explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
 
   SourceLocation getSemiLoc() const { return SemiLoc; }
   void setSemiLoc(SourceLocation L) { SemiLoc = L; }
 
   bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
+  bool resultOfConstexprFolding() const { return ResultOfConstexprFolding; }
 
   SourceLocation getLocStart() const LLVM_READONLY { return SemiLoc; }
   SourceLocation getLocEnd() const LLVM_READONLY { return SemiLoc; }


Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6605,7 +6605,9 @@
 if (Then.isInvalid())
   return StmtError();
   } else {
-Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart());
+Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart(),
+/*hasLeadingEmptyMacro=*/false,
+/*resultOfConstexprFolding=*/true);
   }
 
   // Transform the "else" branch.
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -577,21 +577,33 @@
   /// @endcode
   bool HasLeadingEmptyMacro = false;
 
+  /// \brief True if the null statement was produced by folding a part of the
+  ///code away, e.g:
+  /// @code
+  ///   if constexpr(0 > 1) { willBeFoldedAway(); }
+  ///   // After constexpr evaluation:
+  ///   if constexpr(0 > 1) ;
+  /// @endcode
+  bool ResultOfConstexprFolding = false;
+
 public:
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 
-  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
+  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false,
+   bool resultOfConstexprFolding = false)
   : Stmt(NullStmtClass), SemiLoc(L),
-HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
+HasLeadingEmptyMacro(hasLeadingEmptyMacro),
+ResultOfConstexprFolding(resultOfConstexprFolding) {}
 
   /// \brief Build an empty null statement.
   explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
 
   SourceLocation getSemiLoc() const { return SemiLoc; }
   void setSemiLoc(SourceLocation L) { SemiLoc = L; }
 
   bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
+  bool resultOfConstexprFolding() const { return ResultOfConstexprFolding; }
 
   SourceLocation getLocStart() const LLVM_READONLY { return SemiLoc; }
   SourceLocation getLocEnd() const LLVM_READONLY { return SemiLoc; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46233: [ASTMatchers] Overload isConstexpr for ifStmts

2018-04-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: alexfh, aaron.ballman.
Herald added subscribers: dkrupp, rnkovacs, klimek.

The HTML is the result of running the `dump_ast_matchers.py` script. There are 
more changes than I expected, looks like some link disappeared. I do not know 
if that is intentional.


Repository:
  rC Clang

https://reviews.llvm.org/D46233

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -894,6 +894,10 @@
   varDecl(hasName("foo"), isConstexpr(;
   EXPECT_TRUE(matches("constexpr int bar();",
   functionDecl(hasName("bar"), isConstexpr(;
+  EXPECT_TRUE(matchesConditionally("void baz() { if constexpr(1 > 0) {} }",
+   ifStmt(isConstexpr()), true, "-std=c++17"));
+  EXPECT_TRUE(matchesConditionally("void baz() { if (1 > 0) {} }",
+   ifStmt(isConstexpr()), false, "-std=c++17"));
 }
 
 TEST(TemplateArgumentCountIs, Matches) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3763,20 +3763,25 @@
   return FnTy->isNothrow(Finder->getASTContext());
 }
 
-/// \brief Matches constexpr variable and function declarations.
+/// \brief Matches constexpr variable and function declarations,
+///and if constexpr.
 ///
 /// Given:
 /// \code
 ///   constexpr int foo = 42;
 ///   constexpr int bar();
+///   void baz() { if constexpr(1 > 0) {} }
 /// \endcode
 /// varDecl(isConstexpr())
 ///   matches the declaration of foo.
 /// functionDecl(isConstexpr())
 ///   matches the declaration of bar.
+/// ifStmt(isConstexpr())
+///   matches the if statement in baz.
 AST_POLYMORPHIC_MATCHER(isConstexpr,
 AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl,
-FunctionDecl)) {
+FunctionDecl,
+IfStmt)) {
   return Node.isConstexpr();
 }
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -176,7 +176,7 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclcxxMethodDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html;>CXXMethodDecl...
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclcxxMethodDeclMatcherCXXMethodDecl...
 Matches method declarations.
 
 Example matches y
@@ -650,7 +650,7 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtbinaryConditionalOperatorMatcherhttp://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html;>BinaryConditionalOperator...
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtbinaryConditionalOperatorMatcherBinaryConditionalOperator...
 Matches binary conditional operator expressions (GNU extension).
 
 Example matches a ?: b
@@ -975,7 +975,7 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcxxThrowExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html;>CXXThrowExpr...
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcxxThrowExprMatcherCXXThrowExpr...
 Matches throw expressions.
 
   try { throw 5; } catch(int i) {}
@@ -1926,15 +1926,16 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html;>BinaryOperatorisAssignmentOperator
-Matches all kinds of assignment operators.
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html;>BinaryOperatorisAssignmentOperator
+Matches on all kinds of assignment operators.
 
 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
   if (a == b)
 a += b;
 
-Example 2: matches s1 = s2 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
-  struct S { S& operator=(const S&); };
+Example 2: matches s1 = s2
+   (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
+  struct S { S operator=(const S); };
   void x() { S s1, s2; s1 = s2; })
 
 
@@ -2159,7 +2160,7 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html;>CXXMethodDeclisConst
+MatcherCXXMethodDeclisConst
 Matches if the given method declaration is const.
 
 Given
@@ -2172,7 +2173,7 @@
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html;>CXXMethodDeclisCopyAssignmentOperator
+MatcherCXXMethodDeclisCopyAssignmentOperator
 Matches if the given method declaration declares a 

[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-29 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Two minor comments.

With regards to the function naming, the problem with incremental counts is 
that they get out of sync, like they did with `fXpY` and such, and if someone 
wants to keep the count incremental down the file, adding any new test will 
result in an unnecessarily large patch. Perhaps you could use `void T_()` for 
the test that calls `T::T()`?




Comment at: test/Analysis/cxx-uninitialized-object.cpp:660
+}
+#endif // PEDANTIC
+class MultiPointerTest3 {

A newline between `#endif` and the next token is missing here.



Comment at: test/Analysis/cxx-uninitialized-object.cpp:1412
+  struct RecordType;
+  // no-crash
+  RecordType *recptr; // expected-note{{uninitialized pointer 'this->recptr}}

What is this comment symbolising? Is this actually something the test 
infrastructure picks up?


https://reviews.llvm.org/D45532



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


[PATCH] D46056: Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

2018-04-29 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a comment.

rsmith: Thanks! I don't have the commit access to the repository. Could you 
submit this for me?


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D46056



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