Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 72441.

https://reviews.llvm.org/D24903

Files:
  include/inttypes.h
  include/stdint.h

Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#	define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#	define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#	define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In https://reviews.llvm.org/D24903#551890, @rmaprath wrote:

> When the `` headers where split into `` and `` headers in 
> https://reviews.llvm.org/D12747, we have left out `` and ``. 
> I was going to put up a patch to fix this but couldn't get to it. It's good 
> that you are adding ``, perhaps you can follow what was done in 
> https://reviews.llvm.org/D12747 and repeat the same for ``?
>
> You will also need a test for the new header, https://reviews.llvm.org/D12747 
> has examples.


I see that libcxx already has a pretty complete test for stdint.h.

After consulting the standard, I've shamelessly copied the C part of synopsis 
to my stdint.h.


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added inline comments.


Comment at: include/stdint.h:25
@@ +24,3 @@
+INT8_MAX
+INT16_MAX
+INT32_MAX

Are you referring to the way __STDC_LIMIT_MACROS etc. is handled there? Or 
something more?


https://reviews.llvm.org/D24903



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


[clang-tools-extra] r282386 - [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions

2016-09-26 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 26 02:22:37 2016
New Revision: 282386

URL: http://llvm.org/viewvc/llvm-project?rev=282386&view=rev
Log:
[clang-tidy] make readability-redundant-smartptr-get report get() usage in 
conditions

This patch extends clang-tidy's readability-redundant-smartptr-get to produce
warnings for previously unsupported cases:

```
std::unique_ptr ptr;
if (ptr.get())
if (ptr.get() == NULL)
if (ptr.get() != NULL)
```

This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug
report opened by @Eugene.Zelenko.

However, there still are cases not detected by the check. They can be found in
`void Negative()` function defined in
test/clang-tidy/readability-redundant-smartptr-get.cpp.

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=282386&r1=282385&r2=282386&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
Mon Sep 26 02:22:37 2016
@@ -60,21 +60,27 @@ void registerMatchersForGetEquals(MatchF
   // might be on global namespace or found by ADL, might be a template, etc.
   // For now, lets keep a list of known standard types.
 
-  const auto IsAKnownSmartptr = recordDecl(
-  anyOf(hasName("::std::unique_ptr"), hasName("::std::shared_ptr")));
+  const auto IsAKnownSmartptr =
+  recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
 
   // Matches against nullptr.
   Finder->addMatcher(
-  binaryOperator(
-  anyOf(hasOperatorName("=="), hasOperatorName("!=")),
-  hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())),
-  hasEitherOperand(callToGet(IsAKnownSmartptr))),
+  binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+ hasEitherOperand(ignoringImpCasts(
+ anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(),
+   integerLiteral(equals(0),
+ hasEitherOperand(callToGet(IsAKnownSmartptr))),
+  Callback);
+
+  // Matches against if(ptr.get())
+  Finder->addMatcher(
+  ifStmt(hasCondition(ignoringImpCasts(callToGet(IsAKnownSmartptr,
   Callback);
-  // TODO: Catch ptr.get() == other_ptr.get()
-}
 
+  // FIXME: Match and fix if (l.get() == r.get()).
+}
 
-}  // namespace
+} // namespace
 
 void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
@@ -102,10 +108,11 @@ bool allReturnTypesMatch(const MatchFind
   Result.Nodes.getNodeAs("getType")->getUnqualifiedDesugaredType();
   return OpArrowType == OpStarType && OpArrowType == GetType;
 }
-}  // namespace
+} // namespace
 
 void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) {
-  if (!allReturnTypesMatch(Result)) return;
+  if (!allReturnTypesMatch(Result))
+return;
 
   bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr;
   bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=282386&r1=282385&r2=282386&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp 
Mon Sep 26 02:22:37 2016
@@ -113,6 +113,37 @@ void Positive() {
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
   // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get();
   // CHECK-FIXES: i = *PointerWithOverloadedGet();
+
+  bb = std::unique_ptr().get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL;
+  // CHECK-FIXES: bb = std::unique_ptr() == NULL;
+  bb = ss->get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = ss->get() == NULL;
+  // CHECK-FIXES: bb = *ss == NULL;
+
+  std::unique_ptr x, y;
+  if (x.get() == nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == nullptr);
+  // CHECK-FIXES: if (x == nullptr);
+  if (nullptr == y.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warnin

Re: [PATCH] D24893: [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions

2016-09-26 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282386: [clang-tidy] make readability-redundant-smartptr-get 
report get() usage in… (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D24893?vs=72422&id=72442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24893

Files:
  clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -60,21 +60,27 @@
   // might be on global namespace or found by ADL, might be a template, etc.
   // For now, lets keep a list of known standard types.
 
-  const auto IsAKnownSmartptr = recordDecl(
-  anyOf(hasName("::std::unique_ptr"), hasName("::std::shared_ptr")));
+  const auto IsAKnownSmartptr =
+  recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
 
   // Matches against nullptr.
   Finder->addMatcher(
-  binaryOperator(
-  anyOf(hasOperatorName("=="), hasOperatorName("!=")),
-  hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())),
-  hasEitherOperand(callToGet(IsAKnownSmartptr))),
+  binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+ hasEitherOperand(ignoringImpCasts(
+ anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(),
+   integerLiteral(equals(0),
+ hasEitherOperand(callToGet(IsAKnownSmartptr))),
+  Callback);
+
+  // Matches against if(ptr.get())
+  Finder->addMatcher(
+  ifStmt(hasCondition(ignoringImpCasts(callToGet(IsAKnownSmartptr,
   Callback);
-  // TODO: Catch ptr.get() == other_ptr.get()
-}
 
+  // FIXME: Match and fix if (l.get() == r.get()).
+}
 
-}  // namespace
+} // namespace
 
 void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
@@ -102,10 +108,11 @@
   Result.Nodes.getNodeAs("getType")->getUnqualifiedDesugaredType();
   return OpArrowType == OpStarType && OpArrowType == GetType;
 }
-}  // namespace
+} // namespace
 
 void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) {
-  if (!allReturnTypesMatch(Result)) return;
+  if (!allReturnTypesMatch(Result))
+return;
 
   bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr;
   bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr;
Index: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
@@ -113,6 +113,37 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
   // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get();
   // CHECK-FIXES: i = *PointerWithOverloadedGet();
+
+  bb = std::unique_ptr().get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL;
+  // CHECK-FIXES: bb = std::unique_ptr() == NULL;
+  bb = ss->get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = ss->get() == NULL;
+  // CHECK-FIXES: bb = *ss == NULL;
+
+  std::unique_ptr x, y;
+  if (x.get() == nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == nullptr);
+  // CHECK-FIXES: if (x == nullptr);
+  if (nullptr == y.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call
+  // CHECK-MESSAGES: if (nullptr == y.get());
+  // CHECK-FIXES: if (nullptr == y);
+  if (x.get() == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == NULL);
+  // CHECK-FIXES: if (x == NULL);
+  if (NULL == x.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call
+  // CHECK-MESSAGES: if (NULL == x.get());
+  // CHECK-FIXES: if (NULL == x);
+  if (x.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get());
+  // CHECK-FIXES: if (x);
 }
 
 void Negative() {
@@ -137,7 +168,5 @@
   (*Fail2().get()).Do();
 
   int_ptr ip;
-  bool bb = std::unique_ptr().get() == NULL;
-  bb = ip.get() == nullptr;
-  bb = u->get() == NULL;
+  bool bb = ip.get() == nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r282388 - [clang-rename] Use checktime when reloading vim buffer after applying clang-rename

2016-09-26 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 26 02:26:32 2016
New Revision: 282388

URL: http://llvm.org/viewvc/llvm-project?rev=282388&view=rev
Log:
[clang-rename] Use checktime when reloading vim buffer after applying 
clang-rename

After applying `clang-rename` to a vim buffer (using `clang-rename.py` as part
of the vim integration) the buffer gets reloaded using `bufdo`. This solution is
suboptimal, since syntax highlighting is turned off for performance reasons and
never turned on, after all changes to the source file have been applied.

A better solution to this is using `checktime`. It is exactly designed for this
kind of task and doesn't have the syntax highlighting issue.

Patch by Kai Wolf!

Reviewers: omtcyfz

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

Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.py

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.py?rev=282388&r1=282387&r2=282388&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py Mon Sep 26 
02:26:32 2016
@@ -54,7 +54,7 @@ def main():
 print stderr
 
 # Reload all buffers in Vim.
-vim.command("bufdo edit")
+vim.command("checktime")
 
 
 if __name__ == '__main__':


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


Re: [PATCH] D24791: Use checktime when reloading vim buffer after applying clang-rename

2016-09-26 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282388: [clang-rename] Use checktime when reloading vim 
buffer after applying clang… (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D24791?vs=72011&id=72443#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24791

Files:
  clang-tools-extra/trunk/clang-rename/tool/clang-rename.py

Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -54,7 +54,7 @@
 print stderr
 
 # Reload all buffers in Vim.
-vim.command("bufdo edit")
+vim.command("checktime")
 
 
 if __name__ == '__main__':


Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -54,7 +54,7 @@
 print stderr
 
 # Reload all buffers in Vim.
-vim.command("bufdo edit")
+vim.command("checktime")
 
 
 if __name__ == '__main__':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-09-26 Thread Ben Harper via cfe-commits
bmharper updated this revision to Diff 72444.
bmharper added a comment.

This revision merges NestingLevel and IndentLevel into an std::pair, as 
suggested by @djasper.
IMO this makes the code slightly harder to read, because you lose the unique 
variable names "IndentLevel" and "NestingLevel". Those are now replaced by 
.first and .second, respectively. In addition, NestingLevel is no longer equal 
to the original NestingLevel that gets passed in, because it needs to be 
tweaked slightly to better work with the recursive technique we use for 
alignment scope.
However, the approach presented here certainly does work, and it's actually not 
too much of a code change from the previous patch.


https://reviews.llvm.org/D21279

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9250,12 +9250,11 @@
"};",
Alignment);
 
-  // FIXME: Should align all three assignments
   verifyFormat(
   "int i  = 1;\n"
   "SomeType a = SomeFunction(looongParameterA,\n"
   "  loongParameterB);\n"
-  "int j = 2;",
+  "int j  = 2;",
   Alignment);
 
   verifyFormat("template . Note that the value stored here is slightly different
+// to the NestingLevel passed in. See propagateIndentLevels() for details.
+// The second element in the pair, the indent level, is used to add tabs
 // only for the indentation, and not for alignment, when
 // UseTab = US_ForIndentation.
-unsigned IndentLevel;
+std::pair NestingAndIndentLevel;
 
 // The number of spaces in front of the token or broken part of the token.
 // This will be adapted when aligning tokens.
@@ -170,6 +176,10 @@
   /// \c EscapedNewlineColumn for the first tokens or token parts in a line.
   void calculateLineBreakInformation();
 
+  /// \brief Propagate IndentLevel from the first token on a line, to all of
+  /// the tokens on that line.
+  void propagateIndentLevels();
+
   /// \brief Align consecutive assignments over all \c Changes.
   void alignConsecutiveAssignments();
 
@@ -202,6 +212,10 @@
   void appendIndentText(std::string &Text, unsigned IndentLevel,
 unsigned Spaces, unsigned WhitespaceStartColumn);
 
+  /// \brief Determine whether this token is considered as the start of a
+  /// declaration name.
+  static bool IsStartOfDeclName(const FormatToken &Tok);
+
   SmallVector Changes;
   const SourceManager &SourceMgr;
   tooling::Replacements Replaces;
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -27,19 +27,21 @@
 
 WhitespaceManager::Change::Change(
 bool CreateReplacement, SourceRange OriginalWhitespaceRange,
-unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
-unsigned NewlinesBefore, StringRef PreviousLinePostfix,
-StringRef CurrentLinePrefix, tok::TokenKind Kind, bool ContinuesPPDirective,
+unsigned IndentLevel, unsigned NestingLevel, int Spaces,
+unsigned StartOfTokenColumn, unsigned NewlinesBefore,
+StringRef PreviousLinePostfix, StringRef CurrentLinePrefix,
+tok::TokenKind Kind, TokenType Type, bool ContinuesPPDirective,
 bool IsStartOfDeclName, bool IsInsideToken)
 : CreateReplacement(CreateReplacement),
   OriginalWhitespaceRange(OriginalWhitespaceRange),
   StartOfTokenColumn(StartOfTokenColumn), NewlinesBefore(NewlinesBefore),
   PreviousLinePostfix(PreviousLinePostfix),
-  CurrentLinePrefix(CurrentLinePrefix), Kind(Kind),
+  CurrentLinePrefix(CurrentLinePrefix), Kind(Kind), Type(Type),
   ContinuesPPDirective(ContinuesPPDirective),
-  IsStartOfDeclName(IsStartOfDeclName), IndentLevel(IndentLevel),
-  Spaces(Spaces), IsInsideToken(IsInsideToken), IsTrailingComment(false),
-  TokenLength(0), PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
+  IsStartOfDeclName(IsStartOfDeclName),
+  NestingAndIndentLevel(NestingLevel, IndentLevel), Spaces(Spaces),
+  IsInsideToken(IsInsideToken), IsTrailingComment(false), TokenLength(0),
+  PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
   StartOfBlockComment(nullptr), IndentationOffset(0) {}
 
 void WhitespaceManager::reset() {
@@ -56,22 +58,21 @@
   Tok.Decision = (Newlines > 0) ? FD_Break : FD_Continue;
   Changes.push_back(
   Change(/*CreateReplacement=*/true, Tok.WhitespaceRange, IndentLevel,
- Spaces, StartOfTokenColumn, Newlines, "", "", Tok.Tok.getKind(),
- InPPDirective && !Tok.IsFirst,
- Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
- /*IsInsideToken=*/false));
+ 

Re: [PATCH] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-26 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: migrate-tool/AffectedFilesFinder.h:24-25
@@ +23,4 @@
+public:
+  // Get all files that need to be updated when a symbol is renamed and/or
+  // moved.
+  virtual llvm::Expected>

Comment a bit on what the contract here is: will these be absolute or relative 
paths?


Comment at: migrate-tool/BuildManager.h:28
@@ +27,3 @@
+
+  // Adds a new dependency to the build target.
+  virtual bool addDependency(llvm::StringRef BuildTarget,

I think this needs more comments explaining what BuildTarget / Dependency will 
be. Similarly for Name above.


Comment at: migrate-tool/DummyMigrationEnvironment.h:18-20
@@ +17,5 @@
+
+// Creates a dummy migration environment whose components do not perform actual
+// work and only print messages.
+std::unique_ptr createDummyMigrationEnvironment();
+

Do we perhaps want to create fakes here, where we can later query the libraries 
/ dependencies that exist?


https://reviews.llvm.org/D24380



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


[PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-26 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, NoQ, zaks.anna, a.sidorin, 
xazax.hun.
danielmarjamaki set the repository for this revision to rL LLVM.

This patch fixes false positives for vardecls that are technically unreachable 
but they are needed.
```
  switch (x) {
int a;  // <- This is unreachable but needed
  case 1:
a = ...
```


For this code there will be Wunused-variable:
```
  if (1+2==45) {
int x;
  }
```

For this code there is 'unreachable code' warning on the 'if (1)':
```
  if (1+2==45) {
int x;
if (1) {}
  }  
```


Repository:
  rL LLVM

https://reviews.llvm.org/D24905

Files:
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  test/Analysis/unreachable-code-path.c

Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,16 @@
 }
   }
 }
+
+// don't warn about unreachable vardecl
+void varDecl() {
+  switch (x) {
+int a; // No warning here.
+  case 1:
+a=1;
+break;
+  case 2:
+a=2;
+break;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,16 @@
 }
   }
 }
+
+// don't warn about unreachable vardecl
+void varDecl() {
+  switch (x) {
+int a; // No warning here.
+  case 1:
+a=1;
+break;
+  case 2:
+a=2;
+break;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24903#551926, @mgorny wrote:

> I'm sorry but could you be a little more specific, please? I've looked into 
> that diff, and it seems that the cstdint resembles e.g. cinttypes already -- 
> i.e. there's only the include, and 'using' lines there. Or do you mean that I 
> should copy/update the synopsis over to stdint.h?


My bad, I hadn't actually looked at the current status of ``, it 
doesn't seem to need any more work.

/ Asiri


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24903#551938, @mgorny wrote:

> I see that libcxx already has a pretty complete test for stdint.h.


Hmm, now I see that too :)

Thanks for the patch.

/ Asiri


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-26 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


Comment at: lib/Driver/Tools.cpp:4777-4780
@@ +4776,6 @@
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;

Wouldn't something like this work better:

  D.Diag(...) << XRayInstrumentOption << " on " << Triple.getArchName();


https://reviews.llvm.org/D24799



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:372
@@ +371,3 @@
+
+struct Bug30487
+{

There's already this test:

```
struct NegativeInClassInitialized {
int F = 0;  
NegativeInClassInitialized() {}
};
```

I'd call your test NegativeInClassInitializedImplicit, and also add this:

```
struct NegativeInClassInitializedDefaulted {
int F = 0;
NegativeInClassInitializedDefaulted() = default;
};
```


https://reviews.llvm.org/D24848



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


Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-26 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 72455.
danielmarjamaki added a comment.

Minor updates of testcase


Repository:
  rL LLVM

https://reviews.llvm.org/D24905

Files:
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  test/Analysis/unreachable-code-path.c

Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,17 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,17 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24907: NFC: separate file for fp denormal regression tests

2016-09-26 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: rengolin, jmolloy, olista01.
SjoerdMeijer added a subscriber: cfe-commits.

For clarity, this moves checks for -fdenormal-fp-math values from fast-math.c 
to a new separate file.

https://reviews.llvm.org/D24907

Files:
  test/Driver/denormalfpmode.c
  test/Driver/fast-math.c

Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -234,13 +234,4 @@
 //
 // RUN: %clang -### -ftrapping-math -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-TRAPPING-MATH %s
-// RUN: %clang -### -fdenormal-fp-math=ieee -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-IEEE %s
-// RUN: %clang -### -fdenormal-fp-math=preserve-sign -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PS %s
-// RUN: %clang -### -fdenormal-fp-math=positive-zero -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PZ %s
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
-// CHECK-FP-DENORMAL-IEEE: "-fdenormal-fp-math=ieee"
-// CHECK-FP-DENORMAL-PS: "-fdenormal-fp-math=preserve-sign"
-// CHECK-FP-DENORMAL-PZ: "-fdenormal-fp-math=positive-zero"
Index: test/Driver/denormalfpmode.c
===
--- /dev/null
+++ test/Driver/denormalfpmode.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo 
-v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+
+// CHECK-IEEE: "-fdenormal-fp-math=ieee"
+// CHECK-PS: "-fdenormal-fp-math=preserve-sign"
+// CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'


Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -234,13 +234,4 @@
 //
 // RUN: %clang -### -ftrapping-math -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-TRAPPING-MATH %s
-// RUN: %clang -### -fdenormal-fp-math=ieee -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-IEEE %s
-// RUN: %clang -### -fdenormal-fp-math=preserve-sign -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PS %s
-// RUN: %clang -### -fdenormal-fp-math=positive-zero -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PZ %s
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
-// CHECK-FP-DENORMAL-IEEE: "-fdenormal-fp-math=ieee"
-// CHECK-FP-DENORMAL-PS: "-fdenormal-fp-math=preserve-sign"
-// CHECK-FP-DENORMAL-PZ: "-fdenormal-fp-math=positive-zero"
Index: test/Driver/denormalfpmode.c
===
--- /dev/null
+++ test/Driver/denormalfpmode.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+
+// CHECK-IEEE: "-fdenormal-fp-math=ieee"
+// CHECK-PS: "-fdenormal-fp-math=preserve-sign"
+// CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-09-26 Thread Igor Kudrin via cfe-commits

Hi Eric,

Ping...

On 19-Sep-16 13:57, Eric Fiselier wrote:


I'll look at these first thing next week. If you remember please ping 
me. (It's Cppcon this week)


Sorry I haven't reviewed this already. Thank you for working on this.


On Sep 18, 2016 11:55 PM, "Igor Kudrin" > wrote:


ikudrin added a comment.

Hi,

Ping.

The patch is under review for a long time and the described
problem is still here. As we've seen the issue in practice, I'm
sure that others may also run into it, and I do believe it should
be fixed, one way or another.

@EricWF, can I improve the patch somehow to pass the review? Or
maybe you prefer it to be fixed in some other way?


https://reviews.llvm.org/D17815 





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


Re: [PATCH] D24759: [RFC][StaticAnalyser] fix unreachable code false positives when block numbers mismatch

2016-09-26 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: lib/Analysis/CFG.cpp:2986
@@ -2985,3 +2985,1 @@
 
-if (!KnownVal.isFalse()) {
-  // Add an intermediate block between the BodyBlock and the

dcoughlin wrote:
> You need to keep this check so that the optimized CFG still removes edges 
> that are trivially known to be false.
Thanks


Comment at: lib/Analysis/CFG.cpp:2994
@@ -2993,3 @@
-  Succ = BodyBlock;
-  CFGBlock *LoopBackBlock = createBlock();
-  LoopBackBlock->setLoopTarget(D);

dcoughlin wrote:
> To keep the unoptimized and optimized blocks in sync, this block creation 
> needs to be done regardless of whether the branch condition is known to be 
> false. My advice would be to hoist the creation (and the FIXME comments)  to 
> above the check for whether KnownVal is false.
Thanks


https://reviews.llvm.org/D24759



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


Re: [PATCH] D24759: [RFC][StaticAnalyser] fix unreachable code false positives when block numbers mismatch

2016-09-26 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 72461.
danielmarjamaki marked 2 inline comments as done.
danielmarjamaki added a comment.

Fixed review comments by Devin. It works better now!


https://reviews.llvm.org/D24759

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/unreachable-code-path.c

Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,14 @@
 }
   }
 }
+
+// Ensure that ExplodedGraph and unoptimized CFG match.
+void test12(int x) {
+  switch (x) {
+  case 1:
+break; // not unreachable
+  case 2:
+do { } while (0);
+break;
+  }
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -2983,20 +2983,19 @@
 return nullptr;
 }
 
-if (!KnownVal.isFalse()) {
-  // Add an intermediate block between the BodyBlock and the
-  // ExitConditionBlock to represent the "loop back" transition.  Create an
-  // empty block to represent the transition block for looping back to the
-  // head of the loop.
-  // FIXME: Can we do this more efficiently without adding another block?
-  Block = nullptr;
-  Succ = BodyBlock;
-  CFGBlock *LoopBackBlock = createBlock();
-  LoopBackBlock->setLoopTarget(D);
+// Add an intermediate block between the BodyBlock and the
+// ExitConditionBlock to represent the "loop back" transition.  Create an
+// empty block to represent the transition block for looping back to the
+// head of the loop.
+// FIXME: Can we do this more efficiently without adding another block?
+Block = nullptr;
+Succ = BodyBlock;
+CFGBlock *LoopBackBlock = createBlock();
+LoopBackBlock->setLoopTarget(D);
 
+if (!KnownVal.isFalse())
   // Add the loop body entry as a successor to the condition.
   addSuccessor(ExitConditionBlock, LoopBackBlock);
-}
 else
   addSuccessor(ExitConditionBlock, nullptr);
   }


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,14 @@
 }
   }
 }
+
+// Ensure that ExplodedGraph and unoptimized CFG match.
+void test12(int x) {
+  switch (x) {
+  case 1:
+break; // not unreachable
+  case 2:
+do { } while (0);
+break;
+  }
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -2983,20 +2983,19 @@
 return nullptr;
 }
 
-if (!KnownVal.isFalse()) {
-  // Add an intermediate block between the BodyBlock and the
-  // ExitConditionBlock to represent the "loop back" transition.  Create an
-  // empty block to represent the transition block for looping back to the
-  // head of the loop.
-  // FIXME: Can we do this more efficiently without adding another block?
-  Block = nullptr;
-  Succ = BodyBlock;
-  CFGBlock *LoopBackBlock = createBlock();
-  LoopBackBlock->setLoopTarget(D);
+// Add an intermediate block between the BodyBlock and the
+// ExitConditionBlock to represent the "loop back" transition.  Create an
+// empty block to represent the transition block for looping back to the
+// head of the loop.
+// FIXME: Can we do this more efficiently without adding another block?
+Block = nullptr;
+Succ = BodyBlock;
+CFGBlock *LoopBackBlock = createBlock();
+LoopBackBlock->setLoopTarget(D);
 
+if (!KnownVal.isFalse())
   // Add the loop body entry as a successor to the condition.
   addSuccessor(ExitConditionBlock, LoopBackBlock);
-}
 else
   addSuccessor(ExitConditionBlock, nullptr);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24909: fix for not copying fp denormal and trapping options.

2016-09-26 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: rengolin, jmolloy, olista01.
SjoerdMeijer added a subscriber: cfe-commits.

This is a fix for not copying fp denormal and trapping options, and depends on 
the nfc cleanups in D24906 and D24907.

https://reviews.llvm.org/D24909

Files:
  lib/CodeGen/BackendUtil.cpp

Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -537,6 +537,13 @@
   .Case("posix", llvm::ThreadModel::POSIX)
   .Case("single", llvm::ThreadModel::Single);
 
+  Options.FPDenormalMode =
+
llvm::StringSwitch(CodeGenOpts.FPDenormalMode)
+  .Case("ieee", llvm::FPDenormal::IEEE)
+  .Case("preserve-sign", llvm::FPDenormal::PreserveSign)
+  .Case("positive-zero", llvm::FPDenormal::PositiveZero)
+  .Default(llvm::FPDenormal::IEEE);
+
   // Set float ABI type.
   assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
   CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
@@ -579,6 +586,7 @@
   Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
+  Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath;
   Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
   Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
   Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -537,6 +537,13 @@
   .Case("posix", llvm::ThreadModel::POSIX)
   .Case("single", llvm::ThreadModel::Single);
 
+  Options.FPDenormalMode =
+llvm::StringSwitch(CodeGenOpts.FPDenormalMode)
+  .Case("ieee", llvm::FPDenormal::IEEE)
+  .Case("preserve-sign", llvm::FPDenormal::PreserveSign)
+  .Case("positive-zero", llvm::FPDenormal::PositiveZero)
+  .Default(llvm::FPDenormal::IEEE);
+
   // Set float ABI type.
   assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
   CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
@@ -579,6 +586,7 @@
   Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
+  Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath;
   Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
   Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
   Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282400 - update the link to the code coverage

2016-09-26 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Sep 26 07:53:53 2016
New Revision: 282400

URL: http://llvm.org/viewvc/llvm-project?rev=282400&view=rev
Log:
update the link to the code coverage

Modified:
cfe/trunk/www/menu.html.incl

Modified: cfe/trunk/www/menu.html.incl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/menu.html.incl?rev=282400&r1=282399&r2=282400&view=diff
==
--- cfe/trunk/www/menu.html.incl (original)
+++ cfe/trunk/www/menu.html.incl Mon Sep 26 07:53:53 2016
@@ -51,7 +51,7 @@
 
   
 Quick Links
-http://buildd-clang.debian.net/coverage/";>Testing Coverage
+http://llvm.org/reports/coverage/";>Testing Coverage
   
 
   


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


r282402 - In the get started page, also explain how to start the testsuite

2016-09-26 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Sep 26 08:22:34 2016
New Revision: 282402

URL: http://llvm.org/viewvc/llvm-project?rev=282402&view=rev
Log:
In the get started page, also explain how to start the testsuite

Modified:
cfe/trunk/www/get_started.html

Modified: cfe/trunk/www/get_started.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=282402&r1=282401&r2=282402&view=diff
==
--- cfe/trunk/www/get_started.html (original)
+++ cfe/trunk/www/get_started.html Mon Sep 26 08:22:34 2016
@@ -118,6 +118,11 @@ follows:
 clang file.c -S -O3 -o - (output native machine code)
   
   
+  Run the testsuite:
+  
+make check-clang
+  
+  
 
 
 If you encounter problems while building Clang, make sure that your LLVM


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


Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 72476.
malcolm.parsons added a comment.

Expand code comment


https://reviews.llvm.org/D24652

Files:
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -36,7 +36,12 @@
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but they
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(),
+   // Class template instantiations have a non-definition
+   // CXXMethodDecl for methods that aren't used in this
+   // translation unit. Ignore those, as the template will have
+   // already been checked.
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
+   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);


Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -53,6 +53,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
 // CHECK-FIXES: void F12(bool b = true);
 
+template
+int F13(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b'
+// CHECK-FIXES: int F13(bool b = true);
+int f13 = F13();
+
 struct Foo {
   Foo(const int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
@@ -63,6 +69,18 @@
   // CHECK-FIXES: void operator()(int i);
 };
 
+template 
+struct FooT {
+  FooT(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i'
+  // CHECK-FIXES: FooT(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+FooT f(1);
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -72,6 +90,25 @@
 void NF6(const int *const) {}
 void NF7(int, const int) {}
 void NF8(const int, const int) {}
+template 
+int NF9(const int, const int) { return 0; }
+int nf9 = NF9(1, 2);
+
+// Do not match on inline member functions
+struct Bar {
+  Bar(const int i) {}
+
+  void operator()(const int i) {}
+};
+
+// Do not match on inline member functions of a templated class
+template 
+struct BarT {
+  BarT(const int i) {}
+
+  void operator()(const int i) {}
+};
+BarT b(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -36,7 +36,12 @@
   functionDecl(unless(isDefinition()),
// Lambdas are always their own definition, but th

Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.


Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:39
@@ -38,2 +38,3 @@
// generate a non-definition FunctionDecl too. Ignore those.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(),
+   // Ignore template instantiations too.
+   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(

alexfh wrote:
> Would be helpful to expand on why we're ignoring only member function of 
> class instantiations (and not instantiations of member or free standing 
> functions, for example).
AFAICT, template instantiations of member and free standing functions are 
definitions when the template is a definition.


https://reviews.llvm.org/D24652



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


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-26 Thread Serge Rogatch via cfe-commits
rSerge added inline comments.


Comment at: lib/Driver/Tools.cpp:4777-4780
@@ +4776,6 @@
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;

dberris wrote:
> Wouldn't something like this work better:
> 
>   D.Diag(...) << XRayInstrumentOption << " on " << Triple.getArchName();
No, it doesn't work this way.  Although `D.Diag` looks like a C++ stream 
because of overloaded `<<` operator, it works like C `printf` and 
`diag::err_drv_clang_unsupported` is like a format specifier. The latter 
specifies that only the first argument added via `operator<<` is included in 
the final message. So we have to pass in one string everything we want to say. 
And LLVM coding guidelines forbid C++ streams.


https://reviews.llvm.org/D24799



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


Re: [PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D24669#548984, @vbyakovlcl wrote:

> Clang 3.8 balances vector shift operand erroneous using CheckVectorOperands 
> which converts one of operand to the type of another. In 
> https://reviews.llvm.org/D21678 it was fixed by using checkVectorShift 
> instead. As result clang does not emit error if shift operands have different 
> element sizes (bat gcc does).


Ah, thank you for the explanation!



Comment at: llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td:522
@@ -521,2 +521,3 @@
 def GNUZeroVariadicMacroArguments : 
DiagGroup<"gnu-zero-variadic-macro-arguments">;
+def GNUVecElemSize : DiagGroup<"gnu-vec-elem-size">;
 def Fallback : DiagGroup<"fallback">;

Is this the same warning flag GCC uses?


Comment at: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td:2306
@@ -2304,1 +2305,3 @@
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup, DefaultIgnore;
 def err_ext_vector_component_exceeds_length : Error<

Why is this off by default?


Repository:
  rL LLVM

https://reviews.llvm.org/D24669



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


Re: [PATCH] D24444: [clang-tidy] modernize-use-default default constructor bugfix

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

ping


https://reviews.llvm.org/D2



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


Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-26 Thread Eric Liu via cfe-commits
ioeric added a comment.

Friendly ping :)


https://reviews.llvm.org/D24800



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


Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.

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

LGTM, thank you!



Comment at: change-namespace/ChangeNamespace.cpp:279-281
@@ -276,3 +278,5 @@
   Finder->addMatcher(
-  usingDecl(hasAnyUsingShadowDecl(IsInMovedNs)).bind("using_decl"), this);
+  usingDecl(IsInMovedNs, hasAnyUsingShadowDecl(decl())).bind("using_decl"),
+  this);
+
   // Handle types in nested name specifier.

I had originally thought that this was changing behavior, but I am starting to 
think this is actually fine.


https://reviews.llvm.org/D24862



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


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-26 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 72478.
rmaprath added a comment.

Use `__internal_linkage__` attribute to control visibility following 
https://reviews.llvm.org/D24642.


https://reviews.llvm.org/D24864

Files:
  include/__cxxabi_config.h
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,82 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_HAS_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)(void *)) {
+  return pthread_key_create(key, destructor);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+void *__libcxxabi_tls_get(__libcxxabi_tls_key key) {
+  return pthread_getspecific(key);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_set(__libcxxabi_tls_key key, void *value) {
+  return pthread_setspecific(key, value);
+}
+#endif // _LIBCXXABI_HAS_THREAD_API_PTHREAD
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+#endif // _LIBCXXABI_THREADING_SUPPORT_H
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -27,25 +27,25 @@
 
 // When POSIX threads are not available, make the mutex operations a nop
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
 #else
 static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
-~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); }
+~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); }
 #else
 mutexor ( void * ) {}
 ~mutexor () {}
 #endif
 private:
 mutexor ( const mutexor &rhs );
 mutexor & operator = ( const mutexor &rhs );
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-pthread_mutex_t *mtx_;
+__libcxxabi_mutex_t *mtx_;
 #endif
 };
 
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -11,20 +11,18 @@
 
 #include "abort_message.h"
 #include "config.h"
+#include "threading_support.h"
 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
 #include 
 
 /*
 This implementation must be careful to not call code external to this file
 which will turn around and try to call __cxa_guard_acquire reentrantly.
 For this reas

Re: [PATCH] D24444: [clang-tidy] modernize-use-default default constructor bugfix

2016-09-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a reviewer: alexfh.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


https://reviews.llvm.org/D2



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


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 72480.
NoQ added a comment.

This diff is a part of the original diff that contains core changes without 
checker changes (in particular, without tests). No changes were made, no 
comments addressed, just removed checker stuff. Uploading it separately so that 
it was easier to track changes in phabricator.

Actually improved diff coming soon.
Separate reviews for the checkers coming soon.


https://reviews.llvm.org/D24278

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -113,13 +113,27 @@
   Diag.Report(WarnLoc, WarnID) << PD->getShortDescription()
<< PD->path.back()->getRanges();
 
+  // First, add extra notes, even if paths should not be included.
+  for (PathPieces::const_iterator PI = PD->path.begin(),
+  PE = PD->path.end(); PI != PE; ++PI) {
+if (!isa(PI->get()))
+  continue;
+
+SourceLocation NoteLoc = (*PI)->getLocation().asLocation();
+Diag.Report(NoteLoc, NoteID) << (*PI)->getString()
+ << (*PI)->getRanges();
+  }
+
   if (!IncludePath)
 continue;
 
+  // Then, add the path notes if necessary.
   PathPieces FlatPath = PD->path.flatten(/*ShouldFlattenMacros=*/true);
   for (PathPieces::const_iterator PI = FlatPath.begin(),
-  PE = FlatPath.end();
-   PI != PE; ++PI) {
+  PE = FlatPath.end(); PI != PE; ++PI) {
+if (isa(PI->get()))
+  continue;
+
 SourceLocation NoteLoc = (*PI)->getLocation().asLocation();
 Diag.Report(NoteLoc, NoteID) << (*PI)->getString()
  << (*PI)->getRanges();
Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -281,6 +281,9 @@
   ReportMacro(o, cast(P), FM, SM, LangOpts,
   indent, depth);
   break;
+case PathDiagnosticPiece::ExtraNote:
+  // FIXME: Extend the plist format to support those.
+  break;
   }
 }
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -60,6 +60,7 @@
 PathDiagnosticCallPiece::~PathDiagnosticCallPiece() {}
 PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {}
 PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {}
+PathDiagnosticExtraNotePiece::~PathDiagnosticExtraNotePiece() {}
 
 void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current,
bool ShouldFlattenMacros) const {
@@ -95,6 +96,7 @@
 }
 case PathDiagnosticPiece::Event:
 case PathDiagnosticPiece::ControlFlow:
+case PathDiagnosticPiece::ExtraNote:
   Current.push_back(Piece);
   break;
 }
@@ -342,15 +344,16 @@
   }
 
   switch (X.getKind()) {
-case clang::ento::PathDiagnosticPiece::ControlFlow:
+case PathDiagnosticPiece::ControlFlow:
   return compareControlFlow(cast(X),
 cast(Y));
-case clang::ento::PathDiagnosticPiece::Event:
+case PathDiagnosticPiece::Event:
+case PathDiagnosticPiece::ExtraNote:
   return None;
-case clang::ento::PathDiagnosticPiece::Macro:
+case PathDiagnosticPiece::Macro:
   return compareMacro(cast(X),
   cast(Y));
-case clang::ento::PathDiagnosticPiece::Call:
+case PathDiagnosticPiece::Call:
   return compareCall(cast(X),
  cast(Y));
   }
@@ -1098,6 +1101,10 @@
 ID.Add(**I);
 }
 
+void PathDiagnosticExtraNotePiece::Profile(llvm::FoldingSetNodeID &ID) const {
+  PathDiagnosticSpotPiece::Profile(ID);
+}
+
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.AddString(BugType);
Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -152,13 +152,29 @@
   }
 
   // Process t

Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix

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

LG


https://reviews.llvm.org/D24652



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


[PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-26 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added a reviewer: alexfh.
omtcyfz added a subscriber: cfe-commits.

`clang-rename` might sometimes have multiple replacements at one 
SourceLocation, both trying to perform the same renaming. While this issue 
should be addressed properly at some point, for now it's fine to prevent 
`clang-rename` from printing out the error message to prevent confusion as it 
works just fine even if the error happens.



https://reviews.llvm.org/D24914

Files:
  clang-rename/RenamingAction.cpp

Index: clang-rename/RenamingAction.cpp
===
--- clang-rename/RenamingAction.cpp
+++ clang-rename/RenamingAction.cpp
@@ -68,12 +68,14 @@
<< ":" << FullLoc.getSpellingLineNumber() << ":"
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
-  // FIXME: better error handling.
   tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
   llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  // FIXME: As for clang-rename, replacement fails IFF either the AST node
+  // has been matched multiple times (which shouldn't happen in reality,
+  // need to fix that) or when it's a specific header. For now, just ingore
+  // there error that happened as it doesn't mean a failure.
   if (Err)
-llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
- << llvm::toString(std::move(Err)) << "\n";
+llvm::consumeError(std::move(Err));
 }
   }
 


Index: clang-rename/RenamingAction.cpp
===
--- clang-rename/RenamingAction.cpp
+++ clang-rename/RenamingAction.cpp
@@ -68,12 +68,14 @@
<< ":" << FullLoc.getSpellingLineNumber() << ":"
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
-  // FIXME: better error handling.
   tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
   llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  // FIXME: As for clang-rename, replacement fails IFF either the AST node
+  // has been matched multiple times (which shouldn't happen in reality,
+  // need to fix that) or when it's a specific header. For now, just ingore
+  // there error that happened as it doesn't mean a failure.
   if (Err)
-llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
- << llvm::toString(std::move(Err)) << "\n";
+llvm::consumeError(std::move(Err));
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24887: [clang-tidy] cert-err58-cpp should not apply to function scope objects

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

LGTM!

Good catch, I will fix up the CERT rule to match the check accordingly. Thank 
you for this!


https://reviews.llvm.org/D24887



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


[PATCH] D24915: [analyzer] Extend bug reports with extra notes - ObjCDeallocChecker

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

This patch applies the bug reporting technique that is being introduced in 
D24278 to ObjCDeallocChecker. Extra notes highlight instance variable or 
property declarations that are of relevance to the bug report. Extra notes are 
separate from bug reports.

Originally D24278 contained this patch, but then it was decided to make a 
separate review. The original diff is an exact copy of the relevant section of 
the original diff in D24278, with no review comments addressed.

https://reviews.llvm.org/D24915

Files:
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  test/Analysis/DeallocMissingRelease.m
  test/Analysis/PR2978.m
  test/Analysis/properties.m

Index: test/Analysis/properties.m
===
--- test/Analysis/properties.m
+++ test/Analysis/properties.m
@@ -134,11 +134,17 @@
   NSString *_name;
 }
 @property (retain) NSString * name;
+#if !__has_feature(objc_arc)
+// expected-note@-2 {{The property is declared here}}
+#endif
 @property (assign) id friend;
 @end
 
 @implementation Person
 @synthesize name = _name;
+#if !__has_feature(objc_arc)
+// expected-note@-2 {{The property is synthesized here}}
+#endif
 
 -(void)dealloc {
 #if !__has_feature(objc_arc)
Index: test/Analysis/PR2978.m
===
--- test/Analysis/PR2978.m
+++ test/Analysis/PR2978.m
@@ -29,22 +29,22 @@
   id _nonPropertyIvar;
 }
 @property(retain) id X;
-@property(retain) id Y;
-@property(assign) id Z;
+@property(retain) id Y; // expected-note{{The property is declared here}}
+@property(assign) id Z; // expected-note{{The property is declared here}}
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
 @property(weak) id P;
-@property(weak) id Q;
+@property(weak) id Q; // expected-note{{The property is declared here}}
 @property(retain) id R;
-@property(weak, readonly) id S;
+@property(weak, readonly) id S; // expected-note{{The property is declared here}}
 
 @property(assign, readonly) id T; // Shadowed in class extension
 @property(assign) id U;
 
 @property(retain) id V;
-@property(retain) id W;
+@property(retain) id W; // expected-note{{The property is declared here}}
 -(id) O;
 -(void) setO: (id) arg;
 @end
@@ -56,16 +56,16 @@
 
 @implementation MyClass
 @synthesize X = _X;
-@synthesize Y = _Y;
-@synthesize Z = _Z;
+@synthesize Y = _Y; // expected-note{{The property is synthesized here}}
+@synthesize Z = _Z; // expected-note{{The property is synthesized here}}
 @synthesize K = _K;
 @synthesize L = _L;
 @synthesize N = _N;
 @synthesize M = _M;
-@synthesize Q = _Q;
+@synthesize Q = _Q; // expected-note{{The property is synthesized here}}
 @synthesize R = _R;
 @synthesize V = _V;
-@synthesize W = _W;
+@synthesize W = _W; // expected-note{{The property is synthesized here}}
 
 -(id) O{ return 0; }
 -(void) setO:(id)arg { }
Index: test/Analysis/DeallocMissingRelease.m
===
--- test/Analysis/DeallocMissingRelease.m
+++ test/Analysis/DeallocMissingRelease.m
@@ -80,6 +80,9 @@
 
 @interface MyPropertyClass1 : NSObject
 @property (copy) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass1
@@ -93,6 +96,9 @@
 
 @interface MyPropertyClass2 : NSObject
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass2
@@ -108,10 +114,16 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass3
 @synthesize ivar = _ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is synthesized here}}
+#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -125,13 +137,19 @@
   void (^_blockPropertyIvar)(void);
 }
 @property (copy) void (^blockProperty)(void);
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}
+#endif
 @property (copy) void (^blockProperty2)(void);
 @property (copy) void (^blockProperty3)(void);
 
 @end
 
 @implementation MyPropertyClass4
 @synthesize blockProperty = _blockPropertyIvar;
+#if NON_ARC
+// expected-note@-2 {{The property is synthesized here}}
+#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -163,10 +181,16 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClassWithReturnInDealloc
 @synthesize ivar = _ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is synthesized here}}
+#endif
 - (void)dealloc
 {
   return;
@@ -182,12 +206,18 @@
   MyPropertyClassWithReleaseInOtherInstance *_other;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{The property is declared here}}

[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin, v.g.vassilev, teemperor.
NoQ added a subscriber: cfe-commits.

This patch applies the bug reporting technique that is being introduced in 
D24278 to CloneChecker. Extra notes highlight cloned code sections.

Examples of HTML reports: {F2409277} {F2409279}

Originally D24278 contained this patch, but then it was decided to make a 
separate review. The original diff is an exact copy of the relevant section of 
the original diff in D24278, with no review comments addressed.

https://reviews.llvm.org/D24916

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/function-try-block.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/macro-complexity.cpp
  test/Analysis/copypaste/macros.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/plist-diagnostics-extra-notes-as-events.cpp
  test/Analysis/copypaste/plist-diagnostics.cpp
  test/Analysis/copypaste/sub-sequences.cpp
  test/Analysis/copypaste/suspicious-clones.cpp
  test/Analysis/copypaste/text-diagnostics.cpp

Index: test/Analysis/copypaste/text-diagnostics.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/text-diagnostics.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-output=text -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone}} // expected-note{{Detected code clone}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
Index: test/Analysis/copypaste/suspicious-clones.cpp
===
--- test/Analysis/copypaste/suspicious-clones.cpp
+++ test/Analysis/copypaste/suspicious-clones.cpp
@@ -8,14 +8,14 @@
   log();
   if (a > b)
 return a;
-  return b; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  return b; // expected-note{{Suggestion is based on the usage of this variable in a similar piece of code}}
 }
 
 int maxClone(int x, int y, int z) {
   log();
   if (x > y)
 return x;
-  return z; // expected-warning{{suspicious code clone detected; did you mean to use 'y'?}}
+  return z; // expected-warning{{Suspicious code clone detected; did you mean to use 'y'?}}
 }
 
 // Tests finding a suspicious clone that references global variables.
@@ -33,7 +33,7 @@
   while (true) {
 if (m1.try_lock()) {
   ++i;
-  m1.unlock(); // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  m1.unlock(); // expected-note{{Suggestion is based on the usage of this variable in a similar piece of code}}
   if (i > 1000) {
 return;
   }
@@ -45,7 +45,7 @@
   while (true) {
 if (m1.try_lock()) {
   ++i;
-  m2.unlock();  // expected-warning{{suspicious code clone detected; did you mean to use 'm1'?}}
+  m2.unlock();  // expected-warning{{Suspicious code clone detected; did you mean to use 'm1'?}}
   if (i > 1000) {
 return;
   }
@@ -58,14 +58,14 @@
 int foo(int a, int b, int c) {
   a += b + c;
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Suspicious code clone detected; did you mean to use 'a'?}}
   return c;
 }
 
 int fooClone(int a, int b, int c) {
   a += b + c;
   b /= a + b;
-  c -= a * a; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}}
+  c -= a * a; // expected-note{{Suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}}
   return c;
 }
 
@@ -77,21 +77,21 @@
 long bar1(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = b * b - c; // expected-warning{{suspicious code clone detected; did you mean to use 'c'?}}
+  d = b * b - c; // expected-warning{{Suspicious code clone detected; did you mean to use 'c'?}}
   return d;
 }
 
 long bar2(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = c * b - c; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}} \
- // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  d = c * b - c; // expected-note{{Suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}} \
+ // expected-warning{{Suspicious code clone detected; did you mean to use 'a'?}}
   return d;
 }
 
 long bar3(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = a 

Re: [PATCH] D24444: [clang-tidy] modernize-use-default default constructor bugfix

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

I don't have commit access, so please commit this and 
https://reviews.llvm.org/D24652 for me.
Thanks.


https://reviews.llvm.org/D2



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


Re: [PATCH] D24887: [clang-tidy] cert-err58-cpp should not apply to function scope objects

2016-09-26 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

I don't have commit access, so please commit it for me.
Thanks.


https://reviews.llvm.org/D24887



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


[PATCH] D24917: Resolve response file names relative to including file

2016-09-26 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a reviewer: rnk.
sepavloff added a subscriber: cfe-commits.

If a response file included by construct @file itself includes a response file
and that file is specified by relative file name, resolve the name relative
to the including file.  With this behavior a set of related response files may
be kept together and reference each other with short position-independent names.
This is convenient for implementation of configuration files.

https://reviews.llvm.org/D24917

Files:
  lib/Support/CommandLine.cpp
  unittests/Support/CommandLineTest.cpp

Index: unittests/Support/CommandLineTest.cpp
===
--- unittests/Support/CommandLineTest.cpp
+++ unittests/Support/CommandLineTest.cpp
@@ -7,11 +7,15 @@
 //
 //===--===//
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 
@@ -476,4 +480,64 @@
   EXPECT_FALSE(cl::ParseCommandLineOptions(3, args2, nullptr, true));
 }
 
+TEST(CommandLineTest, ResponseFiles) {
+  llvm::SmallString<128> TestDir;
+  std::error_code EC =
+llvm::sys::fs::createUniqueDirectory("unittest", TestDir);
+  EXPECT_TRUE(!EC);
+
+  // Create included response file of first level.
+  llvm::SmallString<128> IncludedFileName;
+  llvm::sys::path::append(IncludedFileName, TestDir, "resp1");
+  std::ofstream IncludedFile(IncludedFileName.c_str());
+  EXPECT_TRUE(IncludedFile.is_open());
+  IncludedFile << "-option_1 -option_2\n"
+  "@incdir/resp2\n"
+  "-option_3=abcd\n";
+  IncludedFile.close();
+
+  // Directory for included file.
+  llvm::SmallString<128> IncDir;
+  llvm::sys::path::append(IncDir, TestDir, "incdir");
+  EC = llvm::sys::fs::create_directory(IncDir);
+  EXPECT_TRUE(!EC);
+
+  // Create included response file of second level.
+  llvm::SmallString<128> IncludedFileName2;
+  llvm::sys::path::append(IncludedFileName2, IncDir, "resp2");
+  std::ofstream IncludedFile2(IncludedFileName2.c_str());
+  EXPECT_TRUE(IncludedFile2.is_open());
+  IncludedFile2 << "-option_21 -option_22\n";
+  IncludedFile2 << "-option_23=abcd\n";
+  IncludedFile2.close();
+
+  // Prepare 'file' with reference to response file.
+  SmallString<128> IncRef;
+  IncRef.append(1, '@');
+  IncRef.append(IncludedFileName.c_str());
+  llvm::SmallVector Argv =
+{ "test/test", "-flag_1", IncRef.c_str(), "-flag_2" };
+
+  // Expand response files.
+  llvm::BumpPtrAllocator A;
+  llvm::StringSaver Saver(A);
+  bool Res = llvm::cl::ExpandResponseFiles(
+ Saver, llvm::cl::TokenizeGNUCommandLine, Argv);
+  EXPECT_TRUE(Res);
+  EXPECT_EQ(Argv.size(), 9);
+  EXPECT_STREQ(Argv[0], "test/test");
+  EXPECT_STREQ(Argv[1], "-flag_1");
+  EXPECT_STREQ(Argv[2], "-option_1");
+  EXPECT_STREQ(Argv[3], "-option_2");
+  EXPECT_STREQ(Argv[4], "-option_21");
+  EXPECT_STREQ(Argv[5], "-option_22");
+  EXPECT_STREQ(Argv[6], "-option_23=abcd");
+  EXPECT_STREQ(Argv[7], "-option_3=abcd");
+  EXPECT_STREQ(Argv[8], "-flag_2");
+
+  llvm::sys::fs::remove(IncludedFileName2);
+  llvm::sys::fs::remove(IncDir);
+  llvm::sys::fs::remove(IncludedFileName);
+}
+
 }  // anonymous namespace
Index: lib/Support/CommandLine.cpp
===
--- lib/Support/CommandLine.cpp
+++ lib/Support/CommandLine.cpp
@@ -865,7 +865,7 @@
   return (S.size() >= 3 && S[0] == '\xef' && S[1] == '\xbb' && S[2] == '\xbf');
 }
 
-static bool ExpandResponseFile(const char *FName, StringSaver &Saver,
+static bool ExpandResponseFile(StringRef FName, StringSaver &Saver,
TokenizerCallback Tokenizer,
SmallVectorImpl &NewArgv,
bool MarkEOLs = false) {
@@ -893,6 +893,25 @@
   // Tokenize the contents into NewArgv.
   Tokenizer(Str, Saver, NewArgv, MarkEOLs);
 
+  // Scan expanded arguments. If any of them is itself an expansion of a
+  // response file and that file was specified by relative name, replace the
+  // response file name with the full path obtained by resolution of the
+  // specified name relative to the path of current file.
+  for (unsigned I = 0; I < NewArgv.size(); ++I)
+if (NewArgv[I]) {
+  StringRef Arg = NewArgv[I];
+  if (Arg.front() == '@') {
+StringRef FileName = Arg.drop_front();
+if (llvm::sys::path::is_relative(FileName)) {
+  SmallString<128> ResponseFile;
+  ResponseFile.append(1, '@');
+  llvm::sys::path::append(ResponseFile,
+  llvm::sys::path::parent_path(FName), FileName);
+  NewArgv[I] = Saver.save(R

[clang-tools-extra] r282409 - Silence a false positive with the cert-err58-cpp check; now allows objects with static or thread storage duration at function block scope.

2016-09-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Sep 26 10:00:45 2016
New Revision: 282409

URL: http://llvm.org/viewvc/llvm-project?rev=282409&view=rev
Log:
Silence a false positive with the cert-err58-cpp check; now allows objects with 
static or thread storage duration at function block scope.

Patch by Malcolm Parsons

Modified:
clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp?rev=282409&r1=282408&r2=282409&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp Mon 
Sep 26 10:00:45 2016
@@ -26,9 +26,9 @@ void StaticObjectExceptionCheck::registe
   // with a constructor that can throw.
   Finder->addMatcher(
   varDecl(anyOf(hasThreadStorageDuration(), hasStaticStorageDuration()),
+  unless(hasAncestor(functionDecl())),
   hasInitializer(cxxConstructExpr(hasDeclaration(
-  cxxConstructorDecl(unless(isNoThrow()))
-  .bind("ctor")
+  cxxConstructorDecl(unless(isNoThrow())).bind("ctor")
   .bind("var"),
   this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp?rev=282409&r1=282408&r2=282409&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-static-object-exception.cpp 
Mon Sep 26 10:00:45 2016
@@ -28,25 +28,89 @@ V v("v");
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static 
storage duration may throw an exception that cannot be caught
 // CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
 
+thread_local S s3;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with 
thread_local storage duration may throw an exception that cannot be caught
+thread_local T t3; // ok
+thread_local U u3;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'u3' with 
thread_local storage duration may throw an exception that cannot be caught
+thread_local V v3("v");
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'v3' with 
thread_local storage duration may throw an exception that cannot be caught
+
 void f(S s1, T t1, U u1, V v1) { // ok, ok, ok, ok
   S s2; // ok
   T t2; // ok
   U u2; // ok
   V v2("v"); // ok
 
-  thread_local S s3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 's3' with 
thread_local storage duration may throw an exception that cannot be caught
+  thread_local S s3; // ok
   thread_local T t3; // ok
-  thread_local U u3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'u3' with 
thread_local storage duration may throw an exception that cannot be caught
-  thread_local V v3("v");
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'v3' with 
thread_local storage duration may throw an exception that cannot be caught
+  thread_local U u3; // ok
+  thread_local V v3("v"); // ok
 
-  static S s4;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 's4' with 
static storage duration may throw an exception that cannot be caught
+  static S s4; // ok
   static T t4; // ok
-  static U u4;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'u4' with 
static storage duration may throw an exception that cannot be caught
-  static V v4("v");
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v4' with 
static storage duration may throw an exception that cannot be caught
+  static U u4; // ok
+  static V v4("v"); // ok
 }
+
+namespace {
+S s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static 
storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+T t; // ok
+U u;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static 
storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
+V v("v");
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static 
storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
+
+thread_local S s3;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with 
thread_local storage duration may throw an ex

Re: [PATCH] D24887: [clang-tidy] cert-err58-cpp should not apply to function scope objects

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

Commit in r282409


https://reviews.llvm.org/D24887



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


Re: [PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator

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

LGTM, but please wait for @dcoughlin or @ahatanak to chime in as well.


https://reviews.llvm.org/D23236



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


r282410 - clang-format: Only special-case top-level */& in multivar-declstmts.

2016-09-26 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Sep 26 10:14:24 2016
New Revision: 282410

URL: http://llvm.org/viewvc/llvm-project?rev=282410&view=rev
Log:
clang-format: Only special-case top-level */& in multivar-declstmts.

Before (even with PointerAlignment: Left):
  vector a, b;

After:
  vector a, b;

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=282410&r1=282409&r2=282410&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Sep 26 10:14:24 2016
@@ -2015,7 +2015,7 @@ bool TokenAnnotator::spaceRequiredBetwee
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||
-  Line.IsMultiVariableDeclStmt)));
+  (Line.IsMultiVariableDeclStmt && Left.NestingLevel == 0;
   if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
   (!Left.is(TT_PointerOrReference) ||
(Style.PointerAlignment != FormatStyle::PAS_Right &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=282410&r1=282409&r2=282410&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Sep 26 10:14:24 2016
@@ -4802,6 +4802,7 @@ TEST_F(FormatTest, DeclarationsOfMultipl
   verifyFormat("a *a = aaa, *b = 
bbb,\n"
"  *b = bbb, *d = ddd;",
Style);
+  verifyFormat("vector a, b;", Style);
 }
 
 TEST_F(FormatTest, ConditionalExpressionsInBrackets) {


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


r282411 - [analyzer] Improve CastToStruct checker so it can also detect widening casts of struct data

2016-09-26 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Mon Sep 26 10:17:18 2016
New Revision: 282411

URL: http://llvm.org/viewvc/llvm-project?rev=282411&view=rev
Log:
[analyzer] Improve CastToStruct checker so it can also detect widening casts of 
struct data

Example:

struct AB {
  int A;
  int B;
};

struct ABC {
  int A;
  int B;
  int C;
};

void f() {
  struct AB Data;
  struct ABC *P = (struct ABC *)&Data;
}

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


Added:
cfe/trunk/test/Analysis/cast-to-struct.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
cfe/trunk/test/Analysis/casts.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp?rev=282411&r1=282410&r2=282411&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp Mon Sep 26 
10:17:18 2016
@@ -1,4 +1,4 @@
-//=== CastToStructChecker.cpp - Fixed address usage checker *- C++ 
-*--===//
+//=== CastToStructChecker.cpp --*- C++ 
-*--===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,12 +8,13 @@
 
//===--===//
 //
 // This files defines CastToStructChecker, a builtin checker that checks for
-// cast from non-struct pointer to struct pointer.
+// cast from non-struct pointer to struct pointer and widening struct data 
cast.
 // This check corresponds to CWE-588.
 //
 
//===--===//
 
 #include "ClangSACheckers.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
@@ -23,18 +24,22 @@ using namespace clang;
 using namespace ento;
 
 namespace {
-class CastToStructChecker : public Checker< check::PreStmt > {
-  mutable std::unique_ptr BT;
+class CastToStructVisitor : public RecursiveASTVisitor {
+  BugReporter &BR;
+  const CheckerBase *Checker;
+  AnalysisDeclContext *AC;
 
 public:
-  void checkPreStmt(const CastExpr *CE, CheckerContext &C) const;
+  explicit CastToStructVisitor(BugReporter &B, const CheckerBase *Checker,
+   AnalysisDeclContext *A)
+  : BR(B), Checker(Checker), AC(A) {}
+  bool VisitCastExpr(const CastExpr *CE);
 };
 }
 
-void CastToStructChecker::checkPreStmt(const CastExpr *CE,
-   CheckerContext &C) const {
+bool CastToStructVisitor::VisitCastExpr(const CastExpr *CE) {
   const Expr *E = CE->getSubExpr();
-  ASTContext &Ctx = C.getASTContext();
+  ASTContext &Ctx = AC->getASTContext();
   QualType OrigTy = Ctx.getCanonicalType(E->getType());
   QualType ToTy = Ctx.getCanonicalType(CE->getType());
 
@@ -42,34 +47,72 @@ void CastToStructChecker::checkPreStmt(c
   const PointerType *ToPTy = dyn_cast(ToTy.getTypePtr());
 
   if (!ToPTy || !OrigPTy)
-return;
+return true;
 
   QualType OrigPointeeTy = OrigPTy->getPointeeType();
   QualType ToPointeeTy = ToPTy->getPointeeType();
 
   if (!ToPointeeTy->isStructureOrClassType())
-return;
+return true;
 
   // We allow cast from void*.
   if (OrigPointeeTy->isVoidType())
-return;
+return true;
 
   // Now the cast-to-type is struct pointer, the original type is not void*.
   if (!OrigPointeeTy->isRecordType()) {
-if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
-  if (!BT)
-BT.reset(
-new BuiltinBug(this, "Cast from non-struct type to struct type",
-   "Casting a non-structure type to a structure type "
-   "and accessing a field can lead to memory access "
-   "errors or data corruption."));
-  auto R = llvm::make_unique(*BT, BT->getDescription(), N);
-  R->addRange(CE->getSourceRange());
-  C.emitReport(std::move(R));
-}
+SourceRange Sr[1] = {CE->getSourceRange()};
+PathDiagnosticLocation Loc(CE, BR.getSourceManager(), AC);
+BR.EmitBasicReport(
+AC->getDecl(), Checker, "Cast from non-struct type to struct type",
+categories::LogicError, "Casting a non-structure type to a structure "
+"type and accessing a field can lead to memory 
"
+"access errors or data corruption.",
+Loc, Sr);
+  } else {
+// Don't warn when size of data is unknown.
+const auto *U = dyn_cast(E);
+if (!U || U->getOpcode() != UO_AddrOf)
+  return true;
+
+// Don't warn for references
+const ValueDecl *VD = nullptr;
+if (const auto *SE = dyn_cast(U->getSubExpr()))
+  VD = dyn_cast(SE->getDecl());
+else if (const aut

Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 72492.

https://reviews.llvm.org/D24903

Files:
  include/inttypes.h
  include/stdint.h

Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,132 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#   define __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#   define __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#endif
+
+#include_next 
+
+#ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_CONSTANT_MACROS
+#endif
+#ifdef __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_LIMIT_MACROS
+#endif
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,8 +237,21 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#   define __STDC_FORMAT_MACROS
+#   define __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#endif
+
 #include_next 
 
+#ifdef __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_FORMAT_MACROS
+#endif
+
 #ifdef __cplusplus
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

@EricWF, I've copied the additional unset logic from clang. Does this address 
all of your concerns?

By the way, I think clang misses __STDC_FORMAT_MACROS for inttypes.h. I'll 
write a patch for that as well, for consistency.


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

I'm generally in favor of this patch, but it's missing some pieces, like test 
cases. Also, I suspect we will want this attribute to also be written on types, 
but there are no changes to SemaType.cpp to handle this. Is that something you 
are planning to support as well?



Comment at: include/clang/Basic/Attr.td:1457
@@ +1456,3 @@
+  let Args = [VariadicStringArgument<"Rules">];
+  let Documentation = [Undocumented];
+}

No new undocumented attributes, please.


Comment at: lib/Sema/SemaDeclAttr.cpp:3851
@@ +3850,3 @@
+
+Rules.push_back(RuleName);
+  }

Should we diagnose if asked to suppress a diagnostic that we don't support? 
e.g., someone does `[[clang::suppress("this does not exist")]]`

On the one hand, we want to be forwards-compatible, but on the other hand, I 
can easily see typos in long string literals. So perhaps we may want to have a 
diagnostic based on some heuristic. e.g., we diagnose if the spelling is 
slightly off and we have viable options which we can use typo correction to 
issue a fixit, or if it's way off base, we silently eat it under the assumption 
it's a forwards compatibility thing?


Comment at: lib/Sema/SemaStmtAttr.cpp:72
@@ +71,3 @@
+A.getAttributeSpellingListIndex());
+  return ::new (S.Context) auto(Attr);
+}

Please construct this directly instead of relying on a copy constructor. Also, 
same comments about typos apply here as above.


https://reviews.llvm.org/D24886



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


[PATCH] D24921: [PATCH] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: rsmith.
mgorny added a subscriber: cfe-commits.

Define `__STDC_FORMAT_MACROS` in order to enable all macros defined by 
inttypes.h in C++ mode, as was required by the C99 standard and was enforced by 
multiple old glibc versions. This extends the fix from r179419 that covered 
only macros defined by stdint.h but not those in inttypes.h.


https://reviews.llvm.org/D24921

Files:
  lib/Headers/inttypes.h

Index: lib/Headers/inttypes.h
===
--- lib/Headers/inttypes.h
+++ lib/Headers/inttypes.h
@@ -27,8 +27,35 @@
 #error MSVC does not have inttypes.h prior to Visual Studio 2013
 #endif
 
+// C99 7.8.1 Macros for format specifiers
+//
+//  Footnote 191: C++ implementations should define these macros only when
+//  __STDC_FORMAT_MACROS is defined before  is included.
+//
+// C++11 [c.files]p3:
+//
+//  The macros defined by  are provided unconditionally.
+//  In particular, the symbol __STDC_FORMAT_MACROS (mentioned
+//  in footnote 182 of the C standard) plays no role in C++.
+//
+// C11 removed the problematic footnotes.
+//
+// Work around this inconsistency by always defining those macros in C++ mode,
+// so that a C library implementation which follows the C99 standard can be
+// used in C++.
+
+# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #include_next 
 
+# ifdef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_FORMAT_MACROS
+#  undef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #if defined(_MSC_VER) && _MSC_VER < 1900
 /* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x".
  * This triggers format warnings, so fix it up here. */


Index: lib/Headers/inttypes.h
===
--- lib/Headers/inttypes.h
+++ lib/Headers/inttypes.h
@@ -27,8 +27,35 @@
 #error MSVC does not have inttypes.h prior to Visual Studio 2013
 #endif
 
+// C99 7.8.1 Macros for format specifiers
+//
+//  Footnote 191: C++ implementations should define these macros only when
+//  __STDC_FORMAT_MACROS is defined before  is included.
+//
+// C++11 [c.files]p3:
+//
+//  The macros defined by  are provided unconditionally.
+//  In particular, the symbol __STDC_FORMAT_MACROS (mentioned
+//  in footnote 182 of the C standard) plays no role in C++.
+//
+// C11 removed the problematic footnotes.
+//
+// Work around this inconsistency by always defining those macros in C++ mode,
+// so that a C library implementation which follows the C99 standard can be
+// used in C++.
+
+# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #include_next 
 
+# ifdef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_FORMAT_MACROS
+#  undef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #if defined(_MSC_VER) && _MSC_VER < 1900
 /* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x".
  * This triggers format warnings, so fix it up here. */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24921: [PATCH] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

By the way, if anyone happens to have a 'more final' copy of the standards 
handy, feel free to provide a more consistent footnote numbers ;-).


https://reviews.llvm.org/D24921



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


Re: [PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:377
@@ +376,3 @@
+else if (type->isIntegerType())
+  Initializer = " = 0";
+else if (type->isFloatingType())

What about cases where a suffix is desired, like `U` or `LL`?


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:379
@@ +378,3 @@
+else if (type->isFloatingType())
+  Initializer = " = 0.0";
+else if (type->isPointerType())

Same here for `f`.


Comment at: 
test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp:14
@@ +13,3 @@
+  // CHECK-FIXES: float f = 0.0;
+  int* ptr;
+  // CHECK-FIXES: int* ptr = nullptr;

The `*` should bind to `ptr`.


https://reviews.llvm.org/D24892



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


Re: [PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
@@ -23,2 +24,3 @@
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

Hmm, it seems like this is boilerplate we are going to want for every rule, and 
that it's pretty easy to not get this right (for instance, if you change the 
way the check is spelled, you have to remember to update this as well). Could 
this actually be handled more transparently, by gathering this information when 
the check is registered and exposing it to the check?

The checks would still need to use `unless(isSuppressed(Rules))` in some form, 
but I am thinking that it would be more convenient if we could do: 
`Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
 this);`


Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
@@ +58,3 @@
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

Why is the check for `hasAttrs` required?

Also, this use of `hasAncestor()` makes this expensive to use, and that expense 
may be hidden from the caller. Is there a way to structure this so that we 
don't need to walk the entire ancestor tree?


https://reviews.llvm.org/D24888



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

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

LGTM with Malcom's test suggestions addressed.


https://reviews.llvm.org/D24848



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


Re: [PATCH] D24821: [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

2016-09-26 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282415: [ASTMatcher] Add isStaticStorageClass matcher for 
varDecl and functionDecl. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D24821?vs=72141&id=72502#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24821

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

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -2610,6 +2610,20 @@
 
 
 
+MatcherFunctionDecl>isStaticStorageClass
+Matches variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 MatcherFunctionDecl>isTemplateInstantiation
 Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -3473,6 +3487,20 @@
 
 
 
+MatcherVarDecl>isStaticStorageClass
+Matches variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 MatcherVarDecl>isTemplateInstantiation
 Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -4092,7 +4120,7 @@
 
 
 MatcherCXXMethodDecl>forEachOverriddenMatcherCXXMethodDecl> InnerMatcher
-Matches each method overridden by the given method. This matcher may
+Matches each method overriden by the given method. This matcher may
 produce multiple matches.
 
 Given
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -3387,6 +3387,24 @@
   return Node.isExternC();
 }
 
+/// \brief Matches variable/function declarations that have static storage class
+/// (with "static" key word) written in the source.
+///
+/// Given:
+/// \code
+///   static void f() {}
+///   static int i = 0;
+/// \endcode
+/// functionDecl(isStaticStorageClass())
+///   matches the function declaration f.
+/// varDecl(isStaticStorageClass())
+///   matches the variable declaration i.
+AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+VarDecl)) {
+  return Node.getStorageClass() == SC_Static;
+}
+
 /// \brief Matches deleted function declarations.
 ///
 /// Given:
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -848,6 +848,14 @@
   EXPECT_TRUE(notMatches("int i;", varDecl(isExternC(;
 }
 
+TEST(IsStaticStorageClass, MatchesStaticDeclarations) {
+  EXPECT_TRUE(
+  matches("static void f() {}", functionDecl(isStaticStorageClass(;
+  EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
+}
+
 TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
   EXPECT_TRUE(notMatches("class A { ~A(); };",
  functionDecl(hasName("~A"), isDefaulted(;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282415 - [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

2016-09-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Sep 26 11:01:52 2016
New Revision: 282415

URL: http://llvm.org/viewvc/llvm-project?rev=282415&view=rev
Log:
[ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

Reviewers: klimek

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=282415&r1=282414&r2=282415&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Sep 26 11:01:52 2016
@@ -2610,6 +2610,20 @@ functionDecl(isNoThrow()) and functionPr
 
 
 
+MatcherFunctionDecl>isStaticStorageClass
+Matches 
variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 MatcherFunctionDecl>isTemplateInstantiation
 Matches 
template instantiations of function, class, or static
 member variable template instantiations.
@@ -3473,6 +3487,20 @@ functionDecl(isExternC())
 
 
 
+MatcherVarDecl>isStaticStorageClass
+Matches 
variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 MatcherVarDecl>isTemplateInstantiation
 Matches 
template instantiations of function, class, or static
 member variable template instantiations.
@@ -4092,7 +4120,7 @@ matcher, or is a pointer to a type that
 
 
 MatcherCXXMethodDecl>forEachOverriddenMatcherCXXMethodDecl>
 InnerMatcher
-Matches each 
method overridden by the given method. This matcher may
+Matches each 
method overriden by the given method. This matcher may
 produce multiple matches.
 
 Given

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=282415&r1=282414&r2=282415&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Sep 26 11:01:52 2016
@@ -3387,6 +3387,24 @@ AST_POLYMORPHIC_MATCHER(isExternC, AST_P
   return Node.isExternC();
 }
 
+/// \brief Matches variable/function declarations that have static storage 
class
+/// (with "static" key word) written in the source.
+///
+/// Given:
+/// \code
+///   static void f() {}
+///   static int i = 0;
+/// \endcode
+/// functionDecl(isStaticStorageClass())
+///   matches the function declaration f.
+/// varDecl(isStaticStorageClass())
+///   matches the variable declaration i.
+AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+VarDecl)) {
+  return Node.getStorageClass() == SC_Static;
+}
+
 /// \brief Matches deleted function declarations.
 ///
 /// Given:

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=282415&r1=282414&r2=282415&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Mon Sep 26 
11:01:52 2016
@@ -848,6 +848,14 @@ TEST(IsExternC, MatchesExternCVariableDe
   EXPECT_TRUE(notMatches("int i;", varDecl(isExternC(;
 }
 
+TEST(IsStaticStorageClass, MatchesStaticDeclarations) {
+  EXPECT_TRUE(
+  matches("static void f() {}", functionDecl(isStaticStorageClass(;
+  EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
+}
+
 TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {

Re: [PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-26 Thread Alex Lorenz via cfe-commits
arphaman added a subscriber: arphaman.


Comment at: clang-rename/RenamingAction.cpp:75
@@ +74,3 @@
+  // has been matched multiple times (which shouldn't happen in reality,
+  // need to fix that) or when it's a specific header. For now, just ingore
+  // there error that happened as it doesn't mean a failure.

s/ingore/ignore/


Comment at: clang-rename/RenamingAction.cpp:76
@@ -74,1 +75,3 @@
+  // need to fix that) or when it's a specific header. For now, just ingore
+  // there error that happened as it doesn't mean a failure.
   if (Err)

Did you mean to use 'the' instead of 'there' here?


https://reviews.llvm.org/D24914



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


Re: [PATCH] D24821: [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h:3391
@@ +3390,3 @@
+/// \brief Matches variable/function declarations that have static storage 
class
+/// (with "static" key word) written in the source.
+///

It would be nice if you could clarify how this differs from the storage 
duration. This is a bit confusing because we already have 
`hasStaticStorageDuration()` for variables.


Repository:
  rL LLVM

https://reviews.llvm.org/D24821



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


[PATCH] D24922: [clang-move] Make it support both relative and absolute file path arguments.

2016-09-26 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D24922

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  test/clang-move/Inputs/database_template.json
  test/clang-move/Inputs/test.cpp
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -156,9 +156,12 @@
   CreateFiles(Spec.OldCC, TestCC);
 
   std::map FileToReplacements;
-  ClangMoveTool MoveTool(Spec, FileToReplacements);
+  llvm::SmallString<128> InitialDirectory;
+  std::error_code EC = llvm::sys::fs::current_path(InitialDirectory);
+  assert(!EC);
+  (void)EC;
   auto Factory = llvm::make_unique(
-  Spec, FileToReplacements);
+  Spec, FileToReplacements, InitialDirectory.str());
 
   tooling::runToolOnCodeWithArgs(
   Factory->create(), TestCC, {"-std=c++11"}, TestCCName, "clang-move",
Index: test/clang-move/move-class.cpp
===
--- /dev/null
+++ test/clang-move/move-class.cpp
@@ -0,0 +1,39 @@
+// RUN: mkdir -p %T/clang-move/build
+// RUN: sed 's|test_dir|%/T/clang-move|g' %S/Inputs/database_template.json > %T/clang-move/compile_commands.json
+// RUN: cp %S/Inputs/test*  %T/clang-move/
+// RUN: touch test2.h
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=../clang-move/test.cpp -old_header=../clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// RUN: cp %S/Inputs/test*  %T/clang-move/
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=%T/clang-move/test.cpp -old_header=%T/clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// CHECK-NEW-TEST-H: namespace a {
+// CHECK-NEW-TEST-H: class Foo {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace a
+//
+// CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
+// CHECK-NEW-TEST-CPP: #include "test2.h"
+// CHECK-NEW-TEST-CPP: namespace a {
+// CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace a
+//
+// CHECK-OLD-TEST-H: namespace a {
+// CHECK-OLD-TEST-H: } // namespace a
+//
+// CHECK-OLD-TEST-CPP: #include "test.h"
+// CHECK-OLD-TEST-CPP: #include "test2.h"
+// CHECK-OLD-TEST-CPP: namespace a {
+// CHECK-OLD-TEST-CPP: } // namespace a
Index: test/clang-move/Inputs/test.h
===
--- /dev/null
+++ test/clang-move/Inputs/test.h
@@ -0,0 +1,6 @@
+namespace a {
+class Foo {
+public:
+  int f();
+};
+} // namespace a
Index: test/clang-move/Inputs/test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/test.cpp
@@ -0,0 +1,8 @@
+#include "test.h"
+#include "test2.h"
+
+namespace a {
+int Foo::f() {
+  return 0;
+}
+} // namespace a
Index: test/clang-move/Inputs/database_template.json
===
--- /dev/null
+++ test/clang-move/Inputs/database_template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir/build",
+  "command": "clang++ -o test.o test_dir/test.cpp",
+  "file": "test_dir/test.cpp"
+}
+]
Index: clang-move/tool/ClangMoveMain.cpp
===
--- clang-move/tool/ClangMoveMain.cpp
+++ clang-move/tool/ClangMoveMain.cpp
@@ -17,13 +17,15 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 
 using namespace clang;
 using namespace llvm;
 
 namespace {
+
 std::error_code CreateNewFile(const llvm::Twine &path) {
   int fd = 0;
   if (std::error_code ec =
@@ -38,17 +40,23 @@
 cl::opt Name("name", cl::desc("The name of class being moved."),
   cl::cat(ClangMoveCategory));
 
-cl::opt OldHeader("old_header", cl:

Re: [PATCH] D24820: Add -stats-stats option

2016-09-26 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks Matthias

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



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


Re: [PATCH] D24821: [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

2016-09-26 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h:3391
@@ +3390,3 @@
+/// \brief Matches variable/function declarations that have static storage 
class
+/// (with "static" key word) written in the source.
+///

aaron.ballman wrote:
> It would be nice if you could clarify how this differs from the storage 
> duration. This is a bit confusing because we already have 
> `hasStaticStorageDuration()` for variables.
Good point! Will make a follow-up patch to do it.


Repository:
  rL LLVM

https://reviews.llvm.org/D24821



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


Re: [PATCH] D24516: [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-09-26 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping


https://reviews.llvm.org/D24516



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


Re: [PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType

2016-09-26 Thread Łukasz Anforowicz via cfe-commits
lukasza added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2119
@@ +2118,3 @@
+  "template \n"
+  "void Function(Namespace::Template param) {\n"
+  "  param.Method();\n"

klimek wrote:
> Given your use case: why do we need hasDeclaration here at all?
> I'd have expected this working with just matching on the nested name 
> specifier of the type instead of saying hasDeclaration on the template type.
> Btw, if you add a type alias for a class not in the namespace into the 
> namespace (typedef / using), do you wan that to rename or not? :)
> 
> I'd personally probably have expected (2), but I'm never sure in these cases 
> without playing around with more test cases...
> Given your use case: why do we need hasDeclaration here at all?
> I'd have expected this working with just matching on the nested name 
> specifier of the type instead of saying hasDeclaration on the template type.

Because I want "namespace-of-user-provided-declaration" matching to work both 
for ElaboratedType nodes (with explicit nested name specifier) and for other 
kinds of nodes (where there might be no nested name specifier).  I was hoping 
that I could do this with a single hasDeclaration matcher, rather than listing 
all possible type nodes myself (when building my own matcher) like I sort of do 
in a workaround.  In particular, after this CL a single, simple 
hasDeclaration-based matcher can be used in
//auto blink_qual_type_base_matcher =
//qualType(hasDeclaration(in_blink_namespace));
inside https://codereview.chromium.org/2256913002/patch/180001/190001.

> Btw, if you add a type alias for a class not in the namespace into the 
> namespace (typedef / using), do you wan that to rename or not? :)

Good question.  I want a rename to happen if I have 
::SomeOtherNamespace::Typedef resolving to 
::NamespaceWithRenamedMethods::Class, but I do not want rename to happen if I 
have ::NamespaceWithRenamtedMethods::Typedef resolving to 
::SomeOtherNamespace::Class.  I guess my current hasDeclaration-based matcher 
will match both cases :-(  One way to fix this would be to exclude typedefs in 
|decl_under_blink_namespace| at 
https://chromium.googlesource.com/chromium/src/+/14d095b4df6754fa4e6959220b2b332db0b4f504/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp#646

But... this question+answer should have no impact on the CL under review, right?

> I'd personally probably have expected (2), but I'm never sure in these cases 
> without playing around with more test cases...

Ok.  This (#2) is what the current patch results in.


https://reviews.llvm.org/D24361



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


[PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

2016-09-26 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: aaron.ballman.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D24928

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
@@ -669,7 +669,7 @@
 
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
-"void f() { int x; static int y; } int a;";
+"void f() { int x; static int y; } int a;static int b;extern int c;";
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration(;
   EXPECT_TRUE(
@@ -679,6 +679,8 @@
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration(;
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("b"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("c"), hasStaticStorageDuration(;
   EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasStaticStorageDuration(;
 
   // FIXME: It is really hard to test with thread_local itself because not all
@@ -853,6 +855,7 @@
   matches("static void f() {}", functionDecl(isStaticStorageClass(;
   EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2942,16 +2942,20 @@
 }
 
 /// \brief Matches a variable declaration that has static storage duration.
+/// It includes the variable declared at namespace scope and those declared
+/// with "static" and "extern" storage class specifiers.
 ///
-/// Example matches y and a, but not x or z.
-/// (matcher = varDecl(hasStaticStorageDuration())
 /// \code
 /// void f() {
 ///   int x;
 ///   static int y;
 ///   thread_local int z;
 /// }
 /// int a;
+/// static int b;
+/// extern int c;
+/// varDecl(isStaticStorageClass())
+///   matches the function declaration y, a, b and c.
 /// \endcode
 AST_MATCHER(VarDecl, hasStaticStorageDuration) {
   return Node.getStorageDuration() == SD_Static;
@@ -3387,13 +3391,15 @@
   return Node.isExternC();
 }
 
-/// \brief Matches variable/function declarations that have static storage class
-/// (with "static" key word) written in the source.
+/// \brief Matches variable/function declarations that have "static" storage
+/// class specifier ("static" key word) written in the source.
 ///
 /// Given:
 /// \code
 ///   static void f() {}
 ///   static int i = 0;
+///   extern int j;
+///   int k;
 /// \endcode
 /// functionDecl(isStaticStorageClass())
 ///   matches the function declaration f.
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2611,12 +2611,14 @@
 
 
 MatcherFunctionDecl>isStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" key word) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 functionDecl(isStaticStorageClass())
   matches the function declaration f.
 varDecl(isStaticStorageClass())
@@ -3394,15 +3396,19 @@
 
 MatcherVarDecl>hasStaticStorageDuration
 Matches a variable declaration that has static storage duration.
+It includes the variable declared at namespace scope and those declared
+with "static" and "extern" storage class specifiers.
 
-Example matches y and a, but not x or z.
-(matcher = varDecl(hasStaticStorageDuration())
 void f() {
   int x;
   static int y;
   thread_local int z;
 }
 int a;
+static int b;
+extern int c;
+varDecl(isStaticStorageClass())
+  matches the function declaration y, a, b and c.
 
 
 
@@ -3488,12 +3494,14 @@
 
 
 MatcherVarDecl>isStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" key word) written in the source.
 
 Given:
   static void f() {}
   static int

Re: [PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-26 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 72511.
omtcyfz marked 2 inline comments as done.
omtcyfz added a comment.

Address two comments.


https://reviews.llvm.org/D24914

Files:
  clang-rename/RenamingAction.cpp

Index: clang-rename/RenamingAction.cpp
===
--- clang-rename/RenamingAction.cpp
+++ clang-rename/RenamingAction.cpp
@@ -68,12 +68,14 @@
<< ":" << FullLoc.getSpellingLineNumber() << ":"
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
-  // FIXME: better error handling.
   tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
   llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  // FIXME: As for clang-rename, replacement fails IFF either the AST node
+  // has been matched multiple times (which shouldn't happen in reality,
+  // need to fix that) or when it's a specific header. For now, just 
ignore 
+  // the error that happened as it doesn't mean a failure.
   if (Err)
-llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
- << llvm::toString(std::move(Err)) << "\n";
+llvm::consumeError(std::move(Err));
 }
   }
 


Index: clang-rename/RenamingAction.cpp
===
--- clang-rename/RenamingAction.cpp
+++ clang-rename/RenamingAction.cpp
@@ -68,12 +68,14 @@
<< ":" << FullLoc.getSpellingLineNumber() << ":"
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
-  // FIXME: better error handling.
   tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
   llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  // FIXME: As for clang-rename, replacement fails IFF either the AST node
+  // has been matched multiple times (which shouldn't happen in reality,
+  // need to fix that) or when it's a specific header. For now, just ignore 
+  // the error that happened as it doesn't mean a failure.
   if (Err)
-llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
- << llvm::toString(std::move(Err)) << "\n";
+llvm::consumeError(std::move(Err));
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-26 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

@arphaman, thank you for the comments! Improved the wording.


https://reviews.llvm.org/D24914



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


Re: [PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-09-26 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.


Comment at: llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td:522
@@ -521,2 +521,3 @@
 def GNUZeroVariadicMacroArguments : 
DiagGroup<"gnu-zero-variadic-macro-arguments">;
+def GNUVecElemSize : DiagGroup<"gnu-vec-elem-size">;
 def Fallback : DiagGroup<"fallback">;

aaron.ballman wrote:
> Is this the same warning flag GCC uses?
Gcc prints error messages 

t.c:21:13: error: invalid operands to binary << (have vector_int8 and 
vector_short8)
   vi8 = vi8 << vs8;

I could not find a flag controlling this error.


Comment at: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td:2306
@@ -2304,1 +2305,3 @@
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup, DefaultIgnore;
 def err_ext_vector_component_exceeds_length : Error<

aaron.ballman wrote:
> Why is this off by default?
The question is: would we like to have the feature as a clang extension? 


Repository:
  rL LLVM

https://reviews.llvm.org/D24669



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


Re: [PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

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

LGTM, thank you for the clarifications!



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3395
@@ -3392,1 +3394,3 @@
+/// \brief Matches variable/function declarations that have "static" storage
+/// class specifier ("static" key word) written in the source.
 ///

Might as well correct "key word" to be "keyword" instead, as a drive-by fix.


https://reviews.llvm.org/D24928



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


r282417 - Complete support for the cxxCtorInitializer() AST matcher so that it can be used as a top-level matcher.

2016-09-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Sep 26 12:04:27 2016
New Revision: 282417

URL: http://llvm.org/viewvc/llvm-project?rev=282417&view=rev
Log:
Complete support for the cxxCtorInitializer() AST matcher so that it can be 
used as a top-level matcher.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h?rev=282417&r1=282416&r2=282417&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h Mon Sep 26 12:04:27 
2016
@@ -158,6 +158,8 @@ public:
   MatchCallback *Action);
   void addMatcher(const TypeLocMatcher &NodeMatch,
   MatchCallback *Action);
+  void addMatcher(const CXXCtorInitializerMatcher &NodeMatch,
+  MatchCallback *Action);
   /// @}
 
   /// \brief Adds a matcher to execute when running over the AST.
@@ -208,6 +210,7 @@ public:
 std::vector>
 NestedNameSpecifierLoc;
 std::vector> TypeLoc;
+std::vector> 
CtorInit;
 /// \brief All the callbacks in one container to simplify iteration.
 llvm::SmallPtrSet AllCallbacks;
   };

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=282417&r1=282416&r2=282417&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Sep 26 12:04:27 2016
@@ -125,6 +125,7 @@ typedef internal::Matcher Type
 typedef internal::Matcher TypeLocMatcher;
 typedef internal::Matcher NestedNameSpecifierMatcher;
 typedef internal::Matcher 
NestedNameSpecifierLocMatcher;
+typedef internal::Matcher CXXCtorInitializerMatcher;
 /// @}
 
 /// \brief Matches any node.

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=282417&r1=282416&r2=282417&view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Mon Sep 26 12:04:27 2016
@@ -126,6 +126,8 @@ public:
   traverse(*Q);
 else if (const TypeLoc *T = DynNode.get())
   traverse(*T);
+else if (const auto *C = DynNode.get())
+  traverse(*C);
 // FIXME: Add other base types after adding tests.
 
 // It's OK to always overwrite the bound nodes, as if there was
@@ -194,6 +196,12 @@ public:
   return false;
 return traverse(NNS);
   }
+  bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit) {
+if (!CtorInit)
+  return true;
+ScopedIncrement ScopedDepth(&CurrentDepth);
+return traverse(*CtorInit);
+  }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return true; }
@@ -235,6 +243,10 @@ private:
   bool baseTraverse(NestedNameSpecifierLoc NNS) {
 return VisitorBase::TraverseNestedNameSpecifierLoc(NNS);
   }
+  bool baseTraverse(const CXXCtorInitializer &CtorInit) {
+return VisitorBase::TraverseConstructorInitializer(
+const_cast(&CtorInit));
+  }
 
   // Sets 'Matched' to true if 'Matcher' matches 'Node' and:
   //   0 < CurrentDepth <= MaxDepth.
@@ -371,6 +383,7 @@ public:
   bool TraverseTypeLoc(TypeLoc TypeNode);
   bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS);
   bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
+  bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit);
 
   // Matches children or descendants of 'Node' with 'BaseMatcher'.
   bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode &Node,
@@ -472,6 +485,8 @@ public:
   match(*N);
 } else if (auto *N = Node.get()) {
   match(*N);
+} else if (auto *N = Node.get()) {
+  match(*N);
 }
   }
 
@@ -593,6 +608,9 @@ private:
   void matchDispatch(const NestedNameSpecifierLoc *Node) {
 matchWithoutFilter(*Node, Matchers->NestedNameSpecifierLoc);
   }
+  void matchDispatch(const CXXCtorInitializer *Node) {
+matchWithoutFilter(*Node, Matchers->CtorInit);
+  }
   void matchDispatch(const void *) { /* Do nothing. */ }
   /// @}
 
@@ -864,6 +882,17 @@ bool MatchASTVisitor::TraverseNestedName
   
RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(NNS);
 }
 
+bool MatchASTVisitor::TraverseConstructorInitializer(
+CXXCtorInitializer *CtorInit) {
+  if (!CtorInit)
+return true;
+
+  match(*CtorInit);
+
+  return RecursiveASTVisit

Re: [PATCH] D24874: Fully implement the matcher for CXXCtorInitializer

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

Thanks! Commit in r282417


https://reviews.llvm.org/D24874



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


Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 72519.
NoQ marked 10 inline comments as done.
NoQ added a comment.

Addressed inline comments. Renamed extra notes to notes.


https://reviews.llvm.org/D24278

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -113,16 +113,28 @@
   Diag.Report(WarnLoc, WarnID) << PD->getShortDescription()
<< PD->path.back()->getRanges();
 
+  // First, add extra notes, even if paths should not be included.
+  for (const auto &Piece : PD->path) {
+if (!isa(Piece.get()))
+  continue;
+
+SourceLocation NoteLoc = Piece->getLocation().asLocation();
+Diag.Report(NoteLoc, NoteID) << Piece->getString()
+ << Piece->getRanges();
+  }
+
   if (!IncludePath)
 continue;
 
+  // Then, add the path notes if necessary.
   PathPieces FlatPath = PD->path.flatten(/*ShouldFlattenMacros=*/true);
-  for (PathPieces::const_iterator PI = FlatPath.begin(),
-  PE = FlatPath.end();
-   PI != PE; ++PI) {
-SourceLocation NoteLoc = (*PI)->getLocation().asLocation();
-Diag.Report(NoteLoc, NoteID) << (*PI)->getString()
- << (*PI)->getRanges();
+  for (const auto &Piece : FlatPath) {
+if (isa(Piece.get()))
+  continue;
+
+SourceLocation NoteLoc = Piece->getLocation().asLocation();
+Diag.Report(NoteLoc, NoteID) << Piece->getString()
+ << Piece->getRanges();
   }
 }
   }
Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -281,6 +281,9 @@
   ReportMacro(o, cast(P), FM, SM, LangOpts,
   indent, depth);
   break;
+case PathDiagnosticPiece::Note:
+  // FIXME: Extend the plist format to support those.
+  break;
   }
 }
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -60,6 +60,7 @@
 PathDiagnosticCallPiece::~PathDiagnosticCallPiece() {}
 PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece() {}
 PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {}
+PathDiagnosticNotePiece::~PathDiagnosticNotePiece() {}
 
 void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current,
bool ShouldFlattenMacros) const {
@@ -95,6 +96,7 @@
 }
 case PathDiagnosticPiece::Event:
 case PathDiagnosticPiece::ControlFlow:
+case PathDiagnosticPiece::Note:
   Current.push_back(Piece);
   break;
 }
@@ -342,15 +344,16 @@
   }
 
   switch (X.getKind()) {
-case clang::ento::PathDiagnosticPiece::ControlFlow:
+case PathDiagnosticPiece::ControlFlow:
   return compareControlFlow(cast(X),
 cast(Y));
-case clang::ento::PathDiagnosticPiece::Event:
+case PathDiagnosticPiece::Event:
+case PathDiagnosticPiece::Note:
   return None;
-case clang::ento::PathDiagnosticPiece::Macro:
+case PathDiagnosticPiece::Macro:
   return compareMacro(cast(X),
   cast(Y));
-case clang::ento::PathDiagnosticPiece::Call:
+case PathDiagnosticPiece::Call:
   return compareCall(cast(X),
  cast(Y));
   }
@@ -1098,6 +1101,10 @@
 ID.Add(**I);
 }
 
+void PathDiagnosticNotePiece::Profile(llvm::FoldingSetNodeID &ID) const {
+  PathDiagnosticSpotPiece::Profile(ID);
+}
+
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.AddString(BugType);
Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -152,13 +152,30 @@
   }
 
   // Process the path.
-  unsigned n = path.size();
-  unsigned max = n;
-
-  for (PathPieces::const_reverse_iterator I = path.rbegin(),
-   E = path.rend();
-I != E; ++I, --n)
-HandlePiece(R, FID, **I, n, max)

Re: [PATCH] D24915: [analyzer] Extend bug reports with extra notes - ObjCDeallocChecker

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 72520.
NoQ added a comment.

Addressed two inline comments by Devin in the original review 
https://reviews.llvm.org/D24278. Rebased on top of the updated 
https://reviews.llvm.org/D24278.


https://reviews.llvm.org/D24915

Files:
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  test/Analysis/DeallocMissingRelease.m
  test/Analysis/PR2978.m
  test/Analysis/properties.m

Index: test/Analysis/properties.m
===
--- test/Analysis/properties.m
+++ test/Analysis/properties.m
@@ -134,11 +134,17 @@
   NSString *_name;
 }
 @property (retain) NSString * name;
+#if !__has_feature(objc_arc)
+// expected-note@-2 {{Property is declared here}}
+#endif
 @property (assign) id friend;
 @end
 
 @implementation Person
 @synthesize name = _name;
+#if !__has_feature(objc_arc)
+// expected-note@-2 {{Property is synthesized here}}
+#endif
 
 -(void)dealloc {
 #if !__has_feature(objc_arc)
Index: test/Analysis/PR2978.m
===
--- test/Analysis/PR2978.m
+++ test/Analysis/PR2978.m
@@ -29,22 +29,22 @@
   id _nonPropertyIvar;
 }
 @property(retain) id X;
-@property(retain) id Y;
-@property(assign) id Z;
+@property(retain) id Y; // expected-note{{Property is declared here}}
+@property(assign) id Z; // expected-note{{Property is declared here}}
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
 @property(weak) id P;
-@property(weak) id Q;
+@property(weak) id Q; // expected-note{{Property is declared here}}
 @property(retain) id R;
-@property(weak, readonly) id S;
+@property(weak, readonly) id S; // expected-note{{Property is declared here}}
 
 @property(assign, readonly) id T; // Shadowed in class extension
 @property(assign) id U;
 
 @property(retain) id V;
-@property(retain) id W;
+@property(retain) id W; // expected-note{{Property is declared here}}
 -(id) O;
 -(void) setO: (id) arg;
 @end
@@ -56,16 +56,16 @@
 
 @implementation MyClass
 @synthesize X = _X;
-@synthesize Y = _Y;
-@synthesize Z = _Z;
+@synthesize Y = _Y; // expected-note{{Property is synthesized here}}
+@synthesize Z = _Z; // expected-note{{Property is synthesized here}}
 @synthesize K = _K;
 @synthesize L = _L;
 @synthesize N = _N;
 @synthesize M = _M;
-@synthesize Q = _Q;
+@synthesize Q = _Q; // expected-note{{Property is synthesized here}}
 @synthesize R = _R;
 @synthesize V = _V;
-@synthesize W = _W;
+@synthesize W = _W; // expected-note{{Property is synthesized here}}
 
 -(id) O{ return 0; }
 -(void) setO:(id)arg { }
Index: test/Analysis/DeallocMissingRelease.m
===
--- test/Analysis/DeallocMissingRelease.m
+++ test/Analysis/DeallocMissingRelease.m
@@ -80,6 +80,9 @@
 
 @interface MyPropertyClass1 : NSObject
 @property (copy) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass1
@@ -93,6 +96,9 @@
 
 @interface MyPropertyClass2 : NSObject
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass2
@@ -108,10 +114,16 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClass3
 @synthesize ivar = _ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is synthesized here}}
+#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -125,13 +137,19 @@
   void (^_blockPropertyIvar)(void);
 }
 @property (copy) void (^blockProperty)(void);
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @property (copy) void (^blockProperty2)(void);
 @property (copy) void (^blockProperty3)(void);
 
 @end
 
 @implementation MyPropertyClass4
 @synthesize blockProperty = _blockPropertyIvar;
+#if NON_ARC
+// expected-note@-2 {{Property is synthesized here}}
+#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -163,10 +181,16 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClassWithReturnInDealloc
 @synthesize ivar = _ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is synthesized here}}
+#endif
 - (void)dealloc
 {
   return;
@@ -182,12 +206,18 @@
   MyPropertyClassWithReleaseInOtherInstance *_other;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 
 -(void)releaseIvars;
 @end
 
 @implementation MyPropertyClassWithReleaseInOtherInstance
 @synthesize ivar = _ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is synthesized here}}
+#endif
 
 -(void)releaseIvars; {
 #if NON_ARC
@@ -208,10 +238,16 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
+#if NON_ARC
+// expected-note@-2 {{Property is declared here}}
+#endif
 @end
 
 @implementation MyPropertyClassWithNei

Re: [PATCH] D24813: Driver: Add a test for triple with opencl environment

2016-09-26 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D24813



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


Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-26 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 72521.
NoQ added a comment.

Addressed inline comments on the original review 
https://reviews.llvm.org/D24278. Rebased on top of the updated 
https://reviews.llvm.org/D24278. Changed warning messages completely according 
to Anna's comments in https://reviews.llvm.org/D24278.


https://reviews.llvm.org/D24916

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/function-try-block.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/macro-complexity.cpp
  test/Analysis/copypaste/macros.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/plist-diagnostics.cpp
  test/Analysis/copypaste/sub-sequences.cpp
  test/Analysis/copypaste/suspicious-clones.cpp
  test/Analysis/copypaste/text-diagnostics.cpp
  test/Analysis/plist-diagnostics-notes-as-events.cpp

Index: test/Analysis/plist-diagnostics-notes-as-events.cpp
===
--- /dev/null
+++ test/Analysis/plist-diagnostics-notes-as-events.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -analyze -analyzer-output=plist -analyzer-config notes-as-events=true -o %t.plist -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+// RUN: FileCheck --input-file=%t.plist %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Clone of this code was detected}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // no-note (converted into event)
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// CHECK:  diagnostics
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line13
+// CHECK-NEXT:   col28
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line13
+// CHECK-NEXT:  col28
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line18
+// CHECK-NEXT:  col1
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Code clone here
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Code clone here
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line6
+// CHECK-NEXT:   col23
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line6
+// CHECK-NEXT:  col23
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line11
+// CHECK-NEXT:  col1
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Clone of this code was detected
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Clone of this code was detected
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:descriptionClone of this code was detected
+// CHECK-NEXT:categoryCode clone
+// CHECK-NEXT:typeExact code clone
+// CHECK-NEXT:check_namealpha.clone.CloneChecker
+// CHECK-NEXT:
+// CHECK-NEXT:issue_hash_content_of_line_in_context3d15184f38c5fa57e479b744fe3f5035
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:line6
+// CHECK-NEXT:col23
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:  
Index: test/Analysis/copypaste/text-diagnostics.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/text-diagnostics.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-output=text -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Clone of this code was detected}} // expected-note{{Clone of this code was detected}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Code clone here}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
Index: test/Analysis/copypaste/suspicious-clones.cpp
===
--- test/Analysis/copypaste/suspicious-clones.cpp
+++ test/Analysis/copypaste/suspicious-clones.cpp
@@ -8,14 +8,14 @@
   log();
   if (a > b)
 return a;
-  return b; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  return b; // expected-note{{Suggestion is ba

[PATCH] D24932: Fix PR 30440

2016-09-26 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: DmitryPolukhin.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes PR 30440 by initializing CXXNameMangler's FunctionTypeDepth in 
the two constructors added in r274222 (The commit that caused this regression).

Repository:
  rL LLVM

https://reviews.llvm.org/D24932

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp

Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- test/CodeGenCXX/mangle-abi-tag.cpp
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -219,3 +219,16 @@
 }
 // f19_test(N19::C, N19::F, N19::D)
 // CHECK-DAG: define void 
@_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
+
+namespace pr30440 {
+
+template void g(F);
+template auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
+}
+// CHECK-DAG: define {{.*}} 
@_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(
+
+void pr30440_test () {
+  h();
+}
+
+}
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -405,14 +405,14 @@
   CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {


Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- test/CodeGenCXX/mangle-abi-tag.cpp
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -219,3 +219,16 @@
 }
 // f19_test(N19::C, N19::F, N19::D)
 // CHECK-DAG: define void @_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DENS_1FES2_(
+
+namespace pr30440 {
+
+template void g(F);
+template auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
+}
+// CHECK-DAG: define {{.*}} @_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(
+
+void pr30440_test () {
+  h();
+}
+
+}
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -405,14 +405,14 @@
   CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
   : Context(Outer.Context), Out(Out_), NullOut(false),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
   CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
   : Context(Outer.Context), Out(Out_), NullOut(true),
 Structor(Outer.Structor), StructorType(Outer.StructorType),
-SeqID(Outer.SeqID), AbiTagsRoot(AbiTags),
-Substitutions(Outer.Substitutions) {}
+SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
+AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
 
 #if MANGLE_CHECKER
   ~CXXNameMangler() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24933: Enable configuration files in clang

2016-09-26 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rnk, ddunbar.
sepavloff added a subscriber: cfe-commits.

The implementation follows the discussion in mail list
(http://lists.llvm.org/pipermail/cfe-dev/2016-September/050776.html).
Main part of the config file support is implemented in llvm source tree,
in CommandLine library, see D24926 and D24917.

https://reviews.llvm.org/D24933

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/config-file.c
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -330,6 +330,14 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
+  // Try reading options from configuration file.
+  static const char * const SearchDirs[] = { "~/.llvm", "/etc/llvm" };
+  llvm::SmallString<128> ConfigFile;
+  auto SRes = llvm::cl::findConfigFile(ConfigFile, argv, SearchDirs, "clang");
+  llvm::cl::reportConfigFileSearchError(SRes, ConfigFile, SearchDirs, ProgName);
+  if (SRes == llvm::cl::CfgFileSearch::Successful)
+llvm::cl::readConfigFile(ConfigFile, Saver, argv);
+
   // Parse response files using the GNU syntax, unless we're in CL mode. There
   // are two ways to put clang in CL compatibility mode: argv[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
@@ -446,6 +454,8 @@
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
+  if (!ConfigFile.empty())
+TheDriver.setConfigFile(ConfigFile.str());
   SetInstallDir(argv, TheDriver, CanonicalPrefixes);
 
   insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv,
Index: test/Driver/config-file.c
===
--- /dev/null
+++ test/Driver/config-file.c
@@ -0,0 +1,30 @@
+// RUN: %clang --config %S/Inputs/config-1.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH
+// CHECK-HHH: Target: x86_64-apple-darwin
+// CHECK-HHH: Configuration file: {{.*}}/Inputs/config-1.cfg
+// CHECK-HHH: -Werror
+// CHECK-HHH: -std=c99
+
+// RUN: not %clang --config %S/Inputs/inexistent.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-INEX
+// CHECK-INEX: Configuration file {{.*}}/Inputs/inexistent.cfg' specified by option '--config' cannot be found
+
+// RUN: not %clang --config inexistent.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-INEX-NOSEARCH
+// CHECK-INEX-NOSEARCH: Configuration {{.*}}inexistent.cfg' specified by option '--config' cannot be found in directories:
+// CHECK-INEX-NOSEARCH: ~/.llvm
+// CHECK-INEX-NOSEARCH: /etc/llvm
+
+// RUN: %clang --config %S/Inputs/config-2.cfg -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH-NOFILE
+// CHECK-HHH-NOFILE: Target: x86_64-unknown-linux
+// CHECK-HHH-NOFILE: Configuration file: {{.*}}/Inputs/config-2.cfg
+
+// RUN: %clang --config %S/Inputs/config-1.cfg -c %s -v 2>&1 | FileCheck %s -check-prefix CHECK-V
+// CHECK-V: Target: x86_64-apple-darwin
+// CHECK-V: Configuration file: {{.*}}/Inputs/config-1.cfg
+// CHECK-V: -triple{{.*}}x86_64-apple-
+
+// RUN: env CLANGCFG=%S/Inputs/config-1.cfg %clang -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-ENV
+// CHECK-ENV: Target: x86_64-apple-darwin
+// CHECK-ENV: Configuration file: {{.*}}/Inputs/config-1.cfg
+// CHECK-ENV: -Werror
+
+// RUN: env CLANGCFG=inexistent.cfg not %clang -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-ENV-INEX
+// CHECK-ENV-INEX: Configuration file 'inexistent.cfg' specified by environment variable cannot be found
Index: test/Driver/Inputs/config-2.cfg
===
--- /dev/null
+++ test/Driver/Inputs/config-2.cfg
@@ -0,0 +1,2 @@
+# target
+-target x86_64-unknown-linux-gnu
Index: test/Driver/Inputs/config-1.cfg
===
--- /dev/null
+++ test/Driver/Inputs/config-1.cfg
@@ -0,0 +1,7 @@
+
+
+# Empty lines and line started with # are ignored
+-Werror -std=\
+c99
+# Target
+-target x86_64-apple-darwin
\ No newline at end of file
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -895,6 +895,10 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
+
+  // If configuration file was used, print its path.
+  if (!ConfigFile.empty())
+OS << "Configuration file: " << ConfigFile << '\n';
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -187,6 +187,9 @@
   /// Name to use when invoking gcc/g++.
   std::string

Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.

2016-09-26 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.

LGTM.


https://reviews.llvm.org/D24862



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


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-26 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: src/config.h:41
@@ +40,3 @@
+defined(__CloudABI__) || \
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD

Can you change this to `defined(__sun__) && defined(_POSIX_THREADS)` at the 
very least?  There is no reason to assume pthreads on Solaris.  Solaris Threads 
are a valid threading model.


Comment at: src/config.h:42
@@ +41,3 @@
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD
+# else

Can we use `_LIBCXXABI_USE_THREAD_API_PTHREAD` instead?  You can have more than 
one threading API on a platform, and wish to use a specific one.


Comment at: src/config.h:46
@@ +45,3 @@
+# endif
+#endif
+

I really think that we should use `_POSIX_THREADS` macro rather than this 
enumeration approach.


Comment at: test/test_fallback_malloc.pass.cpp:13
@@ -12,3 +12,3 @@
 
-#include 
+#include "../src/threading_support.h"
 

Can we add the include directory as a header search path for the tests?  Seems 
it may be nicer, but, obviously, we can do that later.


https://reviews.llvm.org/D24864



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


Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-26 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:102
@@ -95,5 +101,3 @@
 // as a note.
-DiagEngine.Report(Group.Sequences.front().getStartLoc(), WarnID);
-for (unsigned i = 1; i < Group.Sequences.size(); ++i) {
-  DiagEngine.Report(Group.Sequences[i].getStartLoc(), NoteID);
-}
+static const char *const MsgSingular = "Clone of this code was detected";
+static const char *const MsgPlural = "Clones of this code were detected";

I was thinking whether we shouldn't say `code snippet` or something that 
qualifies code, as it is too generic term.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:112
@@ +111,3 @@
+  R->addNote("Code clone here",
+  makeLocation(Group.Sequences[i], Mgr),
+  Group.Sequences[i].getSourceRange());

Is that missing an indent?


https://reviews.llvm.org/D24916



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


r282426 - CC1: Add -save-stats option

2016-09-26 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Sep 26 13:53:34 2016
New Revision: 282426

URL: http://llvm.org/viewvc/llvm-project?rev=282426&view=rev
Log:
CC1: Add -save-stats option

This option behaves in a similar spirit as -save-temps and writes
internal llvm statistics in json format to a file.

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

Added:
cfe/trunk/test/Driver/save-stats.c
cfe/trunk/test/Frontend/stats-file.c
Modified:
cfe/trunk/docs/CommandGuide/clang.rst
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282426&r1=282425&r2=282426&view=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Mon Sep 26 13:53:34 2016
@@ -408,6 +408,12 @@ Driver Options
 
   Save intermediate compilation results.
 
+.. option:: -save-stats, -save-stats=cwd, -save-stats=obj
+
+  Save internal code generation (LLVM) statistics to a file in the current
+  directory (:option:`-save-stats`/:option:`-save-stats=cwd`) or the directory
+  of the output file (:option:`-save-state=obj`).
+
 .. option:: -integrated-as, -no-integrated-as
 
   Used to enable and disable, respectively, the use of the integrated

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=282426&r1=282425&r2=282426&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Sep 26 
13:53:34 2016
@@ -107,6 +107,8 @@ def warn_fe_cc_print_header_failure : Wa
 "unable to open CC_PRINT_HEADERS file: %0 (using stderr)">;
 def warn_fe_cc_log_diagnostics_failure : Warning<
 "unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">;
+def warn_fe_unable_to_open_stats_file : Warning<
+"unable to open statistics output file '%0': '%1'">;
 def err_fe_no_pch_in_dir : Error<
 "no suitable precompiled header file found in directory '%0'">;
 def err_fe_action_not_available : Error<

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=282426&r1=282425&r2=282426&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Sep 26 13:53:34 2016
@@ -509,6 +509,8 @@ def arcmt_migrate : Flag<["-"], "arcmt-m
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;
+def stats_file : Joined<["-"], "stats-file=">,
+  HelpText<"Filename to write statistics to">;
 def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
   HelpText<"Dump record layout information">;
 def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=282426&r1=282425&r2=282426&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Sep 26 13:53:34 2016
@@ -1876,6 +1876,11 @@ def save_temps_EQ : Joined<["-", "--"],
 def save_temps : Flag<["-", "--"], "save-temps">, Flags<[DriverOption]>,
   Alias, AliasArgs<["cwd"]>,
   HelpText<"Save intermediate compilation results">;
+def save_stats_EQ : Joined<["-", "--"], "save-stats=">, Flags<[DriverOption]>,
+  HelpText<"Save llvm statistics.">;
+def save_stats : Flag<["-", "--"], "save-stats">, Flags<[DriverOption]>,
+  Alias, AliasArgs<["cwd"]>,
+  HelpText<"Save llvm statistics.">;
 def via_file_asm : Flag<["-", "--"], "via-file-asm">, InternalDebugOpt,
   HelpText<"Write assembly to file for input to assemble jobs">;
 def sectalign : MultiArg<["-"], "sectalign", 3>;

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=282426&r1=282425&r2=282426&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/Frontend

Re: [PATCH] D24820: Add -stats-stats option

2016-09-26 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282426: CC1: Add -save-stats option (authored by matze).

Changed prior to commit:
  https://reviews.llvm.org/D24820?vs=72376&id=72532#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24820

Files:
  cfe/trunk/docs/CommandGuide/clang.rst
  cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/FrontendOptions.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInstance.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Driver/save-stats.c
  cfe/trunk/test/Frontend/stats-file.c
  cfe/trunk/test/Misc/warning-flags.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1876,6 +1876,11 @@
 def save_temps : Flag<["-", "--"], "save-temps">, Flags<[DriverOption]>,
   Alias, AliasArgs<["cwd"]>,
   HelpText<"Save intermediate compilation results">;
+def save_stats_EQ : Joined<["-", "--"], "save-stats=">, Flags<[DriverOption]>,
+  HelpText<"Save llvm statistics.">;
+def save_stats : Flag<["-", "--"], "save-stats">, Flags<[DriverOption]>,
+  Alias, AliasArgs<["cwd"]>,
+  HelpText<"Save llvm statistics.">;
 def via_file_asm : Flag<["-", "--"], "via-file-asm">, InternalDebugOpt,
   HelpText<"Write assembly to file for input to assemble jobs">;
 def sectalign : MultiArg<["-"], "sectalign", 3>;
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -509,6 +509,8 @@
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;
+def stats_file : Joined<["-"], "stats-file=">,
+  HelpText<"Filename to write statistics to">;
 def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
   HelpText<"Dump record layout information">;
 def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
Index: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -107,6 +107,8 @@
 "unable to open CC_PRINT_HEADERS file: %0 (using stderr)">;
 def warn_fe_cc_log_diagnostics_failure : Warning<
 "unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">;
+def warn_fe_unable_to_open_stats_file : Warning<
+"unable to open statistics output file '%0': '%1'">;
 def err_fe_no_pch_in_dir : Error<
 "no suitable precompiled header file found in directory '%0'">;
 def err_fe_action_not_available : Error<
Index: cfe/trunk/include/clang/Frontend/FrontendOptions.h
===
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h
@@ -273,6 +273,9 @@
   // included by this file.
   std::string FindPchSource;
 
+  /// Filename to write statistics to.
+  std::string StatsFile;
+
 public:
   FrontendOptions() :
 DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: cfe/trunk/test/Misc/warning-flags.c
===
--- cfe/trunk/test/Misc/warning-flags.c
+++ cfe/trunk/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (84):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -66,6 +66,7 @@
 CHECK-NEXT:   warn_fe_cc_log_diagnostics_failure
 CHECK-NEXT:   warn_fe_cc_print_header_failure
 CHECK-NEXT:   warn_fe_macro_contains_embedded_newline
+CHECK-NEXT:   warn_fe_unable_to_open_stats_file
 CHECK-NEXT:   warn_file_asm_volatile
 CHECK-NEXT:   warn_ignoring_ftabstop_value
 CHECK-NEXT:   warn_implements_nscopying
Index: cfe/trunk/test/Driver/save-stats.c
===
--- cfe/trunk/test/Driver/save-stats.c
+++ cfe/trunk/test/Driver/save-stats.c
@@ -0,0 +1,20 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin -save-stats=cwd %s -### 2>&1 | FileCheck %s
+// CHECK: "-stats-file=save-stats.stats"
+// CHECK: "{{.*}}save-stats.c"
+
+// RUN: %clang -target x86_64-apple-darwin -S %s -### 2>&1 | FileCheck %s -check-prefix=NO-STATS
+// NO-STATS-NO: -stats-file
+// NO-STATS: "{{.*}}save-stats.c"
+// NO-STATS-NO: -stat

Re: r282426 - CC1: Add -save-stats option

2016-09-26 Thread Hal Finkel via cfe-commits
Nice!

 -Hal

- Original Message -
> From: "Matthias Braun via cfe-commits" 
> To: cfe-commits@lists.llvm.org
> Sent: Monday, September 26, 2016 1:53:34 PM
> Subject: r282426 - CC1: Add -save-stats option
> 
> Author: matze
> Date: Mon Sep 26 13:53:34 2016
> New Revision: 282426
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=282426&view=rev
> Log:
> CC1: Add -save-stats option
> 
> This option behaves in a similar spirit as -save-temps and writes
> internal llvm statistics in json format to a file.
> 
> Differential Revision: https://reviews.llvm.org/D24820
> 
> Added:
> cfe/trunk/test/Driver/save-stats.c
> cfe/trunk/test/Frontend/stats-file.c
> Modified:
> cfe/trunk/docs/CommandGuide/clang.rst
> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/FrontendOptions.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInstance.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
> cfe/trunk/test/Misc/warning-flags.c
> 
> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282426&r1=282425&r2=282426&view=diff
> ==
> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> +++ cfe/trunk/docs/CommandGuide/clang.rst Mon Sep 26 13:53:34 2016
> @@ -408,6 +408,12 @@ Driver Options
>  
>Save intermediate compilation results.
>  
> +.. option:: -save-stats, -save-stats=cwd, -save-stats=obj
> +
> +  Save internal code generation (LLVM) statistics to a file in the
> current
> +  directory (:option:`-save-stats`/:option:`-save-stats=cwd`) or the
> directory
> +  of the output file (:option:`-save-state=obj`).
> +
>  .. option:: -integrated-as, -no-integrated-as
>  
>Used to enable and disable, respectively, the use of the
>integrated
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=282426&r1=282425&r2=282426&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Sep
> 26 13:53:34 2016
> @@ -107,6 +107,8 @@ def warn_fe_cc_print_header_failure : Wa
>  "unable to open CC_PRINT_HEADERS file: %0 (using stderr)">;
>  def warn_fe_cc_log_diagnostics_failure : Warning<
>  "unable to open CC_LOG_DIAGNOSTICS file: %0 (using stderr)">;
> +def warn_fe_unable_to_open_stats_file : Warning<
> +"unable to open statistics output file '%0': '%1'">;
>  def err_fe_no_pch_in_dir : Error<
>  "no suitable precompiled header file found in directory '%0'">;
>  def err_fe_action_not_available : Error<
> 
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=282426&r1=282425&r2=282426&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Sep 26 13:53:34
> 2016
> @@ -509,6 +509,8 @@ def arcmt_migrate : Flag<["-"], "arcmt-m
>  
>  def print_stats : Flag<["-"], "print-stats">,
>HelpText<"Print performance metrics and statistics">;
> +def stats_file : Joined<["-"], "stats-file=">,
> +  HelpText<"Filename to write statistics to">;
>  def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
>HelpText<"Dump record layout information">;
>  def fdump_record_layouts_simple : Flag<["-"],
>  "fdump-record-layouts-simple">,
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=282426&r1=282425&r2=282426&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Sep 26 13:53:34
> 2016
> @@ -1876,6 +1876,11 @@ def save_temps_EQ : Joined<["-", "--"],
>  def save_temps : Flag<["-", "--"], "save-temps">,
>  Flags<[DriverOption]>,
>Alias, AliasArgs<["cwd"]>,
>HelpText<"Save intermediate compilation results">;
> +def save_stats_EQ : Joined<["-", "--"], "save-stats=">,
> Flags<[DriverOption]>,
> +  HelpText<"Save llvm statistics.">;
> +def save_stats : Flag<["-", "--"], "save-stats">,
> Flags<[DriverOption]>,
> +  Alias, AliasArgs<["cwd"]>,
> +  HelpText<"Save llvm statistics.">;
>  def via_file_asm : Flag<["-", "--"], "via-file-asm">,
>  InternalDebugOpt,
>HelpText<"Write assembly to file for input to assemble jobs">;
>

Re: [PATCH] D24933: Enable configuration files in clang

2016-09-26 Thread Daniel Dunbar via cfe-commits
ddunbar added a comment.

I am too out of the loop on Clang development to be able to comment on the 
specific direction, but I will just say that I am highly in favor of adding new 
features in this direction. Thank you!


https://reviews.llvm.org/D24933



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


Re: [PATCH] D24932: Fix PR 30440

2016-09-26 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

LGTM, added Richard in case he has something to add.


Repository:
  rL LLVM

https://reviews.llvm.org/D24932



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


Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics

2016-09-26 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

Ping, can someone commit this one now?


https://reviews.llvm.org/D24609



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-26 Thread Richard Smith via cfe-commits
rsmith added a comment.

Giving this the name `[[clang::suppress(...)]]` seems unhelpful. This attribute 
is specified by the C++ core guidelines, not by clang, and presumably we want 
code using this attribute to be portable across implementations of the C++ code 
guidelines. I'd suggest asking the editors of the core guidelines what 
attribute namespace they'd like used, and using that here rather than using 
`clang`.


https://reviews.llvm.org/D24886



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D24886#552859, @rsmith wrote:

> Giving this the name `[[clang::suppress(...)]]` seems unhelpful. This 
> attribute is specified by the C++ core guidelines, not by clang, and 
> presumably we want code using this attribute to be portable across 
> implementations of the C++ code guidelines. I'd suggest asking the editors of 
> the core guidelines what attribute namespace they'd like used, and using that 
> here rather than using `clang`.


I believe this attribute should be used to silence diagnostics for more than 
just the C++ Core Guidelines, so I don't think it makes sense to let them 
dictate what attribute namespace should be used. However, I would appreciate if 
they didn't suggest implementers stomp all over the attribute namespace used by 
standards-based attributes, either.


https://reviews.llvm.org/D24886



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

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

LGTM. Please remove the `LIBCXX` macros before committing.



Comment at: include/stdint.h:118
@@ +117,3 @@
+#   define __STDC_CONSTANT_MACROS
+#   define __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#endif

We don't actually need the `__STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX`. Please 
remove before commiting.


https://reviews.llvm.org/D24903



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


Re: [PATCH] D17979: [OPENMP] Add regression test for codegen of distribute pragma for NVPTX

2016-09-26 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Looks like patch was not committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D17979



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


Re: [PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2016-09-26 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Looks like patch was not committed.


https://reviews.llvm.org/D17890



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


Re: [PATCH] D17840: [OPENMP] Private, firstprivate, and lastprivate clauses for distribute, host code generation

2016-09-26 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Looks like patch was not committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D17840



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

Ok. Thanks for the review.


https://reviews.llvm.org/D24903



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


[libcxx] r282435 - [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Sep 26 15:20:00 2016
New Revision: 282435

URL: http://llvm.org/viewvc/llvm-project?rev=282435&view=rev
Log:
[include] Declare __STDC_*_MACROS for C++11 compat in old libc

Declare __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and
__STDC_CONSTANT_MACROS before including real inttypes.h/stdint.h when
the wrapper-header is included in C++11, in order to enable
the necessary macros in C99-compliant libc.

The C99 standard defined that the format macros in inttypes.h should be
defined by the C++ implementations only when __STDC_FORMAT_MACROS is
defined, and the limit and constant macros in stdint.h should be defined
only when __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined
appropriately. Following this specification, multiple old versions of
glibc up to 2.17 do not define those macros by default for C++,
rendering the libc++ headers non-compliant to the C++11 standard.

In order to achieve the necessary compliance, __STDC_FORMAT_MACROS is
defined in wrapped inttypes.h just before including the system
inttypes.h, when C++11 or newer is used. Both __STDC_LIMIT_MACROS
and __STDC_CONSTANT_MACROS are defined in newly-wrapped stdint.h. This
fixes the C++11 compliance while preserving the current behavior for
C++03.

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

Added:
libcxx/trunk/include/stdint.h
Modified:
libcxx/trunk/include/inttypes.h

Modified: libcxx/trunk/include/inttypes.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/inttypes.h?rev=282435&r1=282434&r2=282435&view=diff
==
--- libcxx/trunk/include/inttypes.h (original)
+++ libcxx/trunk/include/inttypes.h Mon Sep 26 15:20:00 2016
@@ -237,6 +237,13 @@ uintmax_t wcstoumax(const wchar_t* restr
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#   define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus

Added: libcxx/trunk/include/stdint.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdint.h?rev=282435&view=auto
==
--- libcxx/trunk/include/stdint.h (added)
+++ libcxx/trunk/include/stdint.h Mon Sep 26 15:20:00 2016
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//=== stdint.h 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H


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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282435: [include] Declare __STDC_*_MACROS for C++11 compat 
in old libc (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24903?vs=72492&id=72552#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24903

Files:
  libcxx/trunk/include/inttypes.h
  libcxx/trunk/include/stdint.h

Index: libcxx/trunk/include/stdint.h
===
--- libcxx/trunk/include/stdint.h
+++ libcxx/trunk/include/stdint.h
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: libcxx/trunk/include/inttypes.h
===
--- libcxx/trunk/include/inttypes.h
+++ libcxx/trunk/include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#   define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-26 Thread Andrii Grynenko via cfe-commits
andriigrynenko added inline comments.


Comment at: test/asan/TestCases/Linux/swapcontext_annotation.cc:176-199
@@ -164,7 +175,26 @@
 ret += Run(argc - 1, 0, stack);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: Main context from: [[CHILD_STACK]] 524288
 ret += Run(argc - 1, 1, stack);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: Main context from: [[CHILD_STACK]] 524288
 ret += Run(argc - 1, 2, stack);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: NextChild stack: [[NEXT_CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: NextChild from: [[CHILD_STACK]] 524288
+// CHECK: Main context from: [[NEXT_CHILD_STACK]] 524288
 ret += Run(argc - 1, 0, heap);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: Main context from: [[CHILD_STACK]] 524288
 ret += Run(argc - 1, 1, heap);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: Main context from: [[CHILD_STACK]] 524288
 ret += Run(argc - 1, 2, heap);
+// CHECK: Child stack: [[CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: NextChild stack: [[NEXT_CHILD_STACK:0x[0-9a-f]*]]
+// CHECK: NextChild from: [[CHILD_STACK]] 524288
+// CHECK: Main context from: [[NEXT_CHILD_STACK]] 524288
+
+// CHECK: Iteration 0 passed
+printf("Iteration %d passed\n", i);
   }

dvyukov wrote:
> andriigrynenko wrote:
> > This only checks the first iteration of the loop. Can I do it better with 
> > FileCheck ? 
> Yes, you can add CHECKs for the second iteration as well.
> 
@dvyukov: What I meant is that I didn't see a way to have some kind of loop in 
these CHECKs. I don't want to copy-paste these same CHECKs 30 times :)


https://reviews.llvm.org/D24628



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


Re: [PATCH] D17469: [libcxx] Add deployment knobs to tests (for Apple platforms)

2016-09-26 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Looks like patch was not committed.


https://reviews.llvm.org/D17469



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


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-26 Thread Serge Rogatch via cfe-commits
rSerge updated this revision to Diff 72554.
rSerge added a comment.

Implemented a workaround for XFAIL not differentiating between `x86` and 
`x86_64` because it searches for a substring in the triple string, thus `x86` 
matches both `x86-X-Y-Z` and `x86_64-X-Y-Z`.


https://reviews.llvm.org/D24799

Files:
  lib/Driver/Tools.cpp
  test/Driver/xray-instrument.c

Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4767,7 +4767,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char* const XRayInstrumentOption = "-fxray-instrument";
+switch(getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default:
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+} }
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4767,7 +4767,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char* const XRayInstrumentOption = "-fxray-instrument";
+switch(getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default:
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+} }
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24820: Add -stats-stats option

2016-09-26 Thread Matthias Braun via cfe-commits
MatzeB added inline comments.


Comment at: test/Driver/save-stats.c:12
@@ +11,3 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o 
obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats"
+// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o"

bruno wrote:
> aprantl wrote:
> > This is up to taste, but just accepting {{.}} as the path separator would 
> > be sufficient IMO and might be more readable.
> +1 to Adrian's suggestion
For the record: Switching to {{.}} in the final commit broke the windows bots, 
because they display an escaped slash here (= two backslash characters)...


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



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


r282438 - Fix test on windows

2016-09-26 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Sep 26 15:48:34 2016
New Revision: 282438

URL: http://llvm.org/viewvc/llvm-project?rev=282438&view=rev
Log:
Fix test on windows

Modified:
cfe/trunk/test/Driver/save-stats.c

Modified: cfe/trunk/test/Driver/save-stats.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-stats.c?rev=282438&r1=282437&r2=282438&view=diff
==
--- cfe/trunk/test/Driver/save-stats.c (original)
+++ cfe/trunk/test/Driver/save-stats.c Mon Sep 26 15:48:34 2016
@@ -9,8 +9,8 @@
 // NO-STATS-NO: -stats-file
 
 // RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o 
obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
-// CHECK-OBJ: "-stats-file=obj/dir{{.}}save-stats.stats"
-// CHECK-OBJ: "-o" "obj/dir{{.}}save-stats.o"
+// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats"
+// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o"
 
 // RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c %s -### 2>&1 | 
FileCheck %s -check-prefix=CHECK-OBJ-NOO
 // CHECK-OBJ-NOO: "-stats-file=save-stats.stats"


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


Re: [PATCH] D17469: [libcxx] Add deployment knobs to tests (for Apple platforms)

2016-09-26 Thread Duncan P. N. Exon Smith via cfe-commits
Correct.  I haven't had a chance to get back to this.  I'm aiming to pick it up 
again in the next week or two, but if this is specifically blocking you, feel 
free to rebase and commit on my behalf.

> On 2016-Sep-26, at 13:39, Eugene Zelenko  wrote:
> 
> Eugene.Zelenko added a subscriber: Eugene.Zelenko.
> Eugene.Zelenko added a comment.
> 
> Looks like patch was not committed.
> 
> 
> https://reviews.llvm.org/D17469
> 
> 
> 

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


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

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

LGTM after addressing the inline comments.



Comment at: src/fallback_malloc.cpp:58
@@ +57,3 @@
+
+#define HEAP_SIZE   512
+char heap [ HEAP_SIZE ];

A static const variable would be better here.


Comment at: src/fallback_malloc.cpp:59
@@ +58,3 @@
+#define HEAP_SIZE   512
+char heap [ HEAP_SIZE ];
+

This should have `__attribute__((aligned))` on it.


Comment at: src/fallback_malloc.h:20
@@ +19,3 @@
+// Allocate some memory from _somewhere_
+void * __cxa_malloc_with_fallback(size_t size);
+

Please don't use the `__cxa` prefix on these functions. It makes it seem like 
they are part of the Itanium spec but they're really internal details.


https://reviews.llvm.org/D17815



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


  1   2   >