[PATCH] D53239: [python] [tests] Disable python binding tests when building with LLVM_USE_SANITIZER=Address

2018-10-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.

WFM. Thanks for analyzing the problem.




Comment at: bindings/python/tests/CMakeLists.txt:27
+# with ASan.
+if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
 set_property(GLOBAL APPEND PROPERTY

Hmm, I don't think you need to parenthesize the `(NOT FOO)` thing (and it looks 
bit weird to me).


Repository:
  rC Clang

https://reviews.llvm.org/D53239



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


[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions

2018-10-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thanks. ... So anything else to be done? Or it is ok?


https://reviews.llvm.org/D52750



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


[clang-tools-extra] r344440 - [clang-tidy] add IgnoreMacros option to modernize-use-equals-delete

2018-10-13 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sat Oct 13 00:58:05 2018
New Revision: 30

URL: http://llvm.org/viewvc/llvm-project?rev=30&view=rev
Log:
[clang-tidy] add IgnoreMacros option to modernize-use-equals-delete

And also enable it by default to be consistent with e.g. modernize-use-using.
This improves consistency inside the check itself as well: both checks are now
disabled in macros by default.

This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.

Reviewed By: alexfh

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

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=30&r1=344439&r2=30&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Sat 
Oct 13 00:58:05 2018
@@ -21,6 +21,10 @@ namespace modernize {
 static const char SpecialFunction[] = "SpecialFunction";
 static const char DeletedNotPublic[] = "DeletedNotPublic";
 
+void UseEqualsDeleteCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -57,6 +61,8 @@ void UseEqualsDeleteCheck::check(const M
 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
 
+if (Func->getLocation().isMacroID() && IgnoreMacros)
+  return;
 // FIXME: Improve FixItHint to make the method public.
 diag(Func->getLocation(),
  "use '= delete' to prohibit calling of a special member function")
@@ -66,7 +72,7 @@ void UseEqualsDeleteCheck::check(const M
 // Ignore this warning in macros, since it's extremely noisy in code using
 // DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to
 // automatically fix the warning when macros are in play.
-if (Func->getLocation().isMacroID())
+if (Func->getLocation().isMacroID() && IgnoreMacros)
   return;
 // FIXME: Add FixItHint to make the method public.
 diag(Func->getLocation(), "deleted member function should be public");

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h?rev=30&r1=344439&r2=30&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h Sat Oct 
13 00:58:05 2018
@@ -38,9 +38,14 @@ namespace modernize {
 class UseEqualsDeleteCheck : public ClangTidyCheck {
 public:
   UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst?rev=30&r1=344439&r2=30&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst 
Sat Oct 13 00:58:05 2018
@@ -23,3 +23,8 @@ all other member functions implemented.
 A& operator=(const A&) = delete;
   };
 
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about functions declared inside macros.

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp?rev=30&vi

[PATCH] D53217: [clang-tidy] add IgnoreMacros option to modernize-use-equals-delete

2018-10-13 Thread Miklos Vajna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL30: [clang-tidy] add IgnoreMacros option to 
modernize-use-equals-delete (authored by vmiklos, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53217?vs=169490&id=169551#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53217

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
@@ -38,9 +38,14 @@
 class UseEqualsDeleteCheck : public ClangTidyCheck {
 public:
   UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -21,6 +21,10 @@
 static const char SpecialFunction[] = "SpecialFunction";
 static const char DeletedNotPublic[] = "DeletedNotPublic";
 
+void UseEqualsDeleteCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -57,6 +61,8 @@
 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
 
+if (Func->getLocation().isMacroID() && IgnoreMacros)
+  return;
 // FIXME: Improve FixItHint to make the method public.
 diag(Func->getLocation(),
  "use '= delete' to prohibit calling of a special member function")
@@ -66,7 +72,7 @@
 // Ignore this warning in macros, since it's extremely noisy in code using
 // DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to
 // automatically fix the warning when macros are in play.
-if (Func->getLocation().isMacroID())
+if (Func->getLocation().isMacroID() && IgnoreMacros)
   return;
 // FIXME: Add FixItHint to make the method public.
 diag(Func->getLocation(), "deleted member function should be public");
Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
@@ -23,3 +23,8 @@
 A& operator=(const A&) = delete;
   };
 
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about functions declared inside macros.
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
@@ -185,3 +185,9 @@
   DISALLOW_COPY_AND_ASSIGN(ProtectedDeletedMacro2);
 };
 
+// This resulted in a warning by default.
+#define MACRO(type) void operator=(type const &)
+class C {
+private:
+  MACRO(C);
+};
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s modernize-use-equals-delete %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
modernize-use-equals-delete.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -std=c++11
+
+#define MACRO(type) void operator=(type const &)
+class C {
+private:
+  MACRO(C);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function
+};


Index:

[PATCH] D53187: [clang-tidy] Optimize query in bugprone-exception-escape

2018-10-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 169552.
baloghadamsoftware added a comment.

Warning added to the docs.


https://reviews.llvm.org/D53187

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  docs/clang-tidy/checks/bugprone-exception-escape.rst
  test/clang-tidy/bugprone-exception-escape.cpp


Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- test/clang-tidy/bugprone-exception-escape.cpp
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -258,6 +258,31 @@
   throw ignored1();
 }
 
+void thrower(int n) {
+  throw n;
+}
+
+int directly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'directly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return directly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
functin 'indirectly_recursive' which should not throw exceptions
+
+int recursion_helper(int n) {
+  indirectly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'indirectly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return recursion_helper(n);
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'main' which should not throw exceptions
   throw 1;
Index: docs/clang-tidy/checks/bugprone-exception-escape.rst
===
--- docs/clang-tidy/checks/bugprone-exception-escape.rst
+++ docs/clang-tidy/checks/bugprone-exception-escape.rst
@@ -21,6 +21,8 @@
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This check may be expensive on large source files.
+
 Options
 ---
 
Index: clang-tidy/bugprone/ExceptionEscapeCheck.cpp
===
--- clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -190,12 +190,12 @@
 return;
 
   Finder->addMatcher(
-  functionDecl(allOf(throws(unless(isIgnored(IgnoredExceptions))),
- anyOf(isNoThrow(), cxxDestructorDecl(),
+  functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(),
cxxConstructorDecl(isMoveConstructor()),
cxxMethodDecl(isMoveAssignmentOperator()),
hasName("main"), hasName("swap"),
-   isEnabled(FunctionsThatShouldNotThrow
+   isEnabled(FunctionsThatShouldNotThrow)),
+ throws(unless(isIgnored(IgnoredExceptions)
   .bind("thrower"),
   this);
 }


Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- test/clang-tidy/bugprone-exception-escape.cpp
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -258,6 +258,31 @@
   throw ignored1();
 }
 
+void thrower(int n) {
+  throw n;
+}
+
+int directly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in funcion 'directly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return directly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in functin 'indirectly_recursive' which should not throw exceptions
+
+int recursion_helper(int n) {
+  indirectly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in funcion 'indirectly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return recursion_helper(n);
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'main' which should not throw exceptions
   throw 1;
Index: docs/clang-tidy/checks/bugprone-exception-escape.rst
===
--- docs/clang-tidy/checks/bugprone-exception-escape.rst
+++ docs/clang-tidy/checks/bugprone-exception-escape.rst
@@ -21,6 +21,8 @@
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This check may be expensive on large source files.
+
 Options
 ---
 
Index: clang-tidy/bugprone/ExceptionEscapeCheck.cpp
===
--- clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -190,12 +190,12 @@
 return;
 
   Finder->addMatcher(
-  functionDecl(allOf(throws(unless(isIgnored(IgnoredException

[PATCH] D53187: [clang-tidy] Optimize query in bugprone-exception-escape

2018-10-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I think further optimization steps should be done is separate patches. However, 
this is the biggest step.


https://reviews.llvm.org/D53187



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


[PATCH] D53187: [clang-tidy] Optimize query in bugprone-exception-escape

2018-10-13 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D53187#1264415, @baloghadamsoftware wrote:

> I think further optimization steps should be done is separate patches. 
> However, this is the biggest step.


Agreed.

LGTM.


https://reviews.llvm.org/D53187



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


[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-13 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: docs/ReleaseNotes.rst:113
+
+- New alias :doc:`cppcoreguidelines-non-private-member-variables-in-classes
+  
`

lebedev.ri wrote:
> Eugene.Zelenko wrote:
> > Please move new alias after new checks.
> You mean after all the new checks, at the very bottom?
> Because right now it is right after the check itself.
Yup, the aliases were mentioned last in the release notes (at least last 
release).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-13 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:64
+
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);

ymandel wrote:
> JonasToth wrote:
> > ymandel wrote:
> > > JonasToth wrote:
> > > > I feel that this comment doesn't add value. Could you please either 
> > > > make it more expressive or remove it?
> > > Agreed. I merged the comment below into this one, so one comment 
> > > describes the rest of the control flow in this block.
> > Did I tell you the "only one diagnostic in-flight" thing? :D
> > I told you wrong stuff as you already figured out in the code. Please 
> > adjust this comment and the additional scope is not necessary too.
> But, I think you are *correct* in this assertion.  When I tried multiple 
> in-flight diagnostics, it failed with error:
> 
> clang-tidy: 
> /usr/local/google/home/yitzhakm/Projects/llvm/llvm/tools/clang/include/clang/Basic/Diagnostic.h:1297:
>  clang::DiagnosticBuilder 
> clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int): 
> Assertion `CurDiagID == std::numeric_limits::max() && "Multiple 
> diagnostics in flight at once!"' failed.
> 
> Am I doing something wrong?
> 
> 
Then let me revert what I said and claim the first thing again :D 

I think, the issue is, that you have the `auto Diag = diag()` object not 
destroyed before the next one is created. So temporarily storing the locations 
for the problematic transformations might be necessary to close the scope of 
the `Diag` first and then emit the notes.

It would be a good idea, to make a function that returns you a list of FixIts 
and the list of problematic transformations.
Having these 2 lists (best is probably `llvm::SmallVector`, see 
https://llvm.org/docs/ProgrammersManual.html#dss-smallvector) simplifies 
creating the diagnostics a lot.
Then you have 2 scopes for emitting, one scope for the actual warning and 
replacement and the second scope for emitting the fail-notes.

These 2 scopes could even be methods (necessary to access `diag()`).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 169554.
lebedev.ri marked 8 inline comments as done.
lebedev.ri added a comment.

Hopefully address review notes:

- Support more (all?) obscure suffixes (complex, q, h, f16, i{8,16,32,64})
- Improve test coverage. There isn't coverage for every single 
combination/permuation of everything, but hopefully at least the basic coverage.
- Support a list of destination suffixes, thus the replacements can be finely 
controlled.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl16-c.rst
  docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  
test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
  
test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
  test/clang-tidy/readability-uppercase-literal-suffix.h

Index: test/clang-tidy/readability-uppercase-literal-suffix.h
===
--- /dev/null
+++ test/clang-tidy/readability-uppercase-literal-suffix.h
@@ -0,0 +1,16 @@
+template 
+struct integral_constant {
+  static constexpr T value = v;
+  typedef T value_type;
+  typedef integral_constant type; // using injected-class-name
+  constexpr operator value_type() const noexcept { return value; }
+};
+
+using false_type = integral_constant;
+using true_type = integral_constant;
+
+template 
+struct is_same : false_type {};
+
+template 
+struct is_same : true_type {};
Index: test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
@@ -0,0 +1,245 @@
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I %S
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S
+
+#include "readability-uppercase-literal-suffix.h"
+
+void integer_suffix() {
+  static constexpr auto v0 = __LINE__; // synthetic
+  static_assert(v0 == 9 || v0 == 5, "");
+
+  static constexpr auto v1 = __cplusplus; // synthetic, long
+
+  static constexpr auto v2 = 1; // no literal
+  static_assert(is_same::value, "");
+  static_assert(v2 == 1, "");
+
+  // Unsigned
+
+  static constexpr auto v3 = 1u;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'u', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1u;
+  // CHECK-MESSAGES-NEXT: ^~
+  // CHECK-MESSAGES-NEXT: {{^ *}}U{{$}}
+  // CHECK-FIXES: static constexpr auto v3 = 1U;
+  static_assert(is_same::value, "");
+  static_assert(v3 == 1, "");
+
+  static constexpr auto v4 = 1U; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v4 == 1, "");
+
+  // Long
+
+  static constexpr auto v5 = 1l;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l;
+  // CHECK-MESSAGES-NEXT: ^~
+  // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}}
+  // CHECK-FIXES: static constexpr auto v5 = 1L;
+  static_assert(is_same::value, "");
+  static_assert(v5 == 1, "");
+
+  static constexpr auto v6 = 1L; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v6 == 1, "");
+
+  // Long Long
+
+  static constexpr auto v7 = 1ll;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll;
+  // CHECK-MESSAGES-NEXT: ^~~
+  // CHECK-MESSAGES-NEXT: {{^ *}}LL{{$}}
+  // CHECK-FIXES: static constexpr auto v7 = 1LL;
+  static_assert(is_same::value, "");
+  static_assert(v7 == 1, "");
+
+  static constexpr auto v8 = 1LL; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v8 == 1, "");
+
+  // Unsigned Long
+
+  static constexpr auto v9 = 1ul;
+  //

[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 169555.
lebedev.ri added a comment.

Sort release notes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
  docs/ReleaseNotes.rst
  
docs/clang-tidy/checks/cppcoreguidelines-non-private-member-variables-in-classes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
  test/clang-tidy/misc-non-private-member-variables-in-classes.cpp

Index: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
@@ -0,0 +1,373 @@
+// RUN: %check_clang_tidy -check-suffixes=PUBLIC,NONPRIVATE,PROTECTED %s misc-non-private-member-variables-in-classes %t
+// RUN: %check_clang_tidy -check-suffixes=PUBLIC,NONPRIVATE,PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffixes=PUBLIC,PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+// RUN: %check_clang_tidy -check-suffixes=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffixes=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+
+////
+
+// Only data, do not warn
+
+struct S0 {
+  int S0_v0;
+
+public:
+  int S0_v1;
+
+protected:
+  int S0_v2;
+
+private:
+  int S0_v3;
+};
+
+class S1 {
+  int S1_v0;
+
+public:
+  int S1_v1;
+
+protected:
+  int S1_v2;
+
+private:
+  int S1_v3;
+};
+
+////
+
+// All functions are static, do not warn.
+
+struct S2 {
+  static void S2_m0();
+  int S2_v0;
+
+public:
+  static void S2_m1();
+  int S2_v1;
+
+protected:
+  static void S2_m3();
+  int S2_v2;
+
+private:
+  static void S2_m4();
+  int S2_v3;
+};
+
+class S3 {
+  static void S3_m0();
+  int S3_v0;
+
+public:
+  static void S3_m1();
+  int S3_v1;
+
+protected:
+  static void S3_m3();
+  int S3_v2;
+
+private:
+  static void S3_m4();
+  int S3_v3;
+};
+
+////
+
+// union != struct/class. do not diagnose.
+
+union U0 {
+  void U0_m0();
+  int U0_v0;
+
+public:
+  void U0_m1();
+  int U0_v1;
+
+protected:
+  void U0_m2();
+  int U0_v2;
+
+private:
+  void U0_m3();
+  int U0_v3;
+};
+
+////
+
+// Has non-static method with default visibility.
+
+struct S4 {
+  void S4_m0();
+
+  int S4_v0;
+  // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S4_v0' of struct 'S4' has public visibility
+public:
+  int S4_v1;
+  // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S4_v1' of struct 'S4' has public visibility
+protected:
+  int S4_v2;
+  // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S4_v2' of struct 'S4' has protected visibility
+private:
+  int S4_v3;
+};
+
+class S5 {
+  void S5_m0();
+
+  int S5_v0;
+
+public:
+  int S5_v1;
+  // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S5_v1' of class 'S5' has public visibility
+protected:
+  int S5_v2;
+  // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S5_v2' of class 'S5' has protected visibility
+private:
+  int S5_v3;
+};
+
+////
+
+// Has non-static method with public visibility.
+
+struct S6 {
+  int S6_v0;
+  // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S6_v0' of struct 'S6' has public visibility
+public:
+  void S6_m0();
+  int S6_v1;
+  // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: me

[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: docs/ReleaseNotes.rst:113
+
+- New alias :doc:`cppcoreguidelines-non-private-member-variables-in-classes
+  
`

JonasToth wrote:
> lebedev.ri wrote:
> > Eugene.Zelenko wrote:
> > > Please move new alias after new checks.
> > You mean after all the new checks, at the very bottom?
> > Because right now it is right after the check itself.
> Yup, the aliases were mentioned last in the release notes (at least last 
> release).
Seems rather arbitrarily and undocumented but whatever.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

2018-10-13 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Unfortunatly this check does not compile on some ARM platforms. It seems that a 
matcher exceeds the recursion limit in template instantations.

http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/4405/steps/build%20stage%201/logs/stdio

I will revert the check for now as I did not find an easy fix now.


https://reviews.llvm.org/D45050



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


[clang-tools-extra] r344441 - Revert "[doc] fix markup in clang-tidy bugprone-not-null-terminated-result"

2018-10-13 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Sat Oct 13 02:30:46 2018
New Revision: 31

URL: http://llvm.org/viewvc/llvm-project?rev=31&view=rev
Log:
Revert "[doc] fix markup in clang-tidy bugprone-not-null-terminated-result"

This reverts commit r344379.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst?rev=31&r1=30&r2=31&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
 Sat Oct 13 02:30:46 2018
@@ -55,11 +55,11 @@ Rewrite to a string handler function is
 
 Rewrite based on the destination array:
 
-- If copy to the destination array cannot overflow then the new function should
+- If copy to the destination array cannot *overflow then the new function 
should
   be the older copy function (ending with ``cpy``), because it is more
   efficient than the safe version.
 
-- If copy to the destination array can overflow and
+- If copy to the destination array can *overflow and
   ``AreSafeFunctionsAvailable`` is set to ``Yes``, ``y`` or non-zero and it is
   possible to obtain the capacity of the destination array then the new 
function
   could be the safe version (ending with ``cpy_s``).
@@ -67,7 +67,7 @@ Rewrite based on the destination array:
 - If the new function is could be safe version and C++ files are analysed then
   the length of the destination array can be omitted.
 
-- It is possible to overflow:
+- *It is possible to overflow:
   - Unknown the capacity of the destination array.
   - If the given length is equal to the destination capacity.
 
@@ -95,21 +95,17 @@ Memory handler functions
 :ref:`Transformation rules of 'memcpy()'` section.
 
 - ``memchr``:
-
   - Usually there is a C-style cast, and it is needed to be removed, because 
the
 new function ``strchr``'s return type is correct.
   - Also the given length is not needed in the new function.
 
 - ``memmove``:
-
   - If safe functions are available the new function is ``memmove_s``, it has
 four arguments:
-
 - destination array,
 - length of the destination array,
 - source string,
 - length of the source string which is incremented by one.
-
   - If safe functions are not available the given length is incremented by one.
 
 - ``memmove_s``: given length is incremented by one.


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


[clang-tools-extra] r344442 - Revert "[clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length"

2018-10-13 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Sat Oct 13 02:30:58 2018
New Revision: 32

URL: http://llvm.org/viewvc/llvm-project?rev=32&view=rev
Log:
Revert "[clang-tidy] New checker for not null-terminated result caused by 
strlen(), size() or equal length"

This reverts commit r344374.

Removed:
clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-in-initialization-strlen.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-before-safe.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-cxx.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-other.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-strlen.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-wcslen.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=32&r1=31&r2=32&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Sat Oct 
13 02:30:58 2018
@@ -30,7 +30,6 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
-#include "NotNullTerminatedResultCheck.h"
 #include "ParentVirtualCallCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
@@ -99,8 +98,6 @@ public:
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
-CheckFactories.registerCheck(
-"bugprone-not-null-terminated-result");
 CheckFactories.registerCheck(
 "bugprone-parent-virtual-call");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=32&r1=31&r2=32&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Sat Oct 13 
02:30:58 2018
@@ -21,7 +21,6 @@ add_clang_library(clangTidyBugproneModul
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
   MultipleStatementMacroCheck.cpp
-  NotNullTerminatedResultCheck.cpp
   ParentVirtualCallCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp

Removed: 
clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp?rev=31&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
(removed)
@@ -1,1024 +0,0 @@
-//===--- NotNullTerminatedResultCheck.cpp - clang-tidy --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "NotNullTerminatedResultCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/PPCallbacks.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace bugprone {
-
-static const char *const FuncExprName = "entire-called-function-expr";
-static const char *const CastExprName = "cast-expr";
-static const char *const UnknownDestName = "destination-length-is-unknown";
-static const char *const NotJustCharTyName = "unsigned-or-signed-char";
-static const char *const DestArrayTyName = "destination-is-arra

[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-13 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:94
+  // Else, find matching suffix, case-*insensitive*ly.
+  for (const auto &PotentialNewSuffix : NewSuffixes) {
+if (!OldSuffix.equals_lower(PotentialNewSuffix))

Is this `std::find_if`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670



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


[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 169556.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

Bloat with `llvm::find_if()`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl16-c.rst
  docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  
test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
  
test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
  test/clang-tidy/readability-uppercase-literal-suffix.h

Index: test/clang-tidy/readability-uppercase-literal-suffix.h
===
--- /dev/null
+++ test/clang-tidy/readability-uppercase-literal-suffix.h
@@ -0,0 +1,16 @@
+template 
+struct integral_constant {
+  static constexpr T value = v;
+  typedef T value_type;
+  typedef integral_constant type; // using injected-class-name
+  constexpr operator value_type() const noexcept { return value; }
+};
+
+using false_type = integral_constant;
+using true_type = integral_constant;
+
+template 
+struct is_same : false_type {};
+
+template 
+struct is_same : true_type {};
Index: test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
@@ -0,0 +1,245 @@
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I %S
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -fix -- -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S
+
+#include "readability-uppercase-literal-suffix.h"
+
+void integer_suffix() {
+  static constexpr auto v0 = __LINE__; // synthetic
+  static_assert(v0 == 9 || v0 == 5, "");
+
+  static constexpr auto v1 = __cplusplus; // synthetic, long
+
+  static constexpr auto v2 = 1; // no literal
+  static_assert(is_same::value, "");
+  static_assert(v2 == 1, "");
+
+  // Unsigned
+
+  static constexpr auto v3 = 1u;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'u', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v3 = 1u;
+  // CHECK-MESSAGES-NEXT: ^~
+  // CHECK-MESSAGES-NEXT: {{^ *}}U{{$}}
+  // CHECK-FIXES: static constexpr auto v3 = 1U;
+  static_assert(is_same::value, "");
+  static_assert(v3 == 1, "");
+
+  static constexpr auto v4 = 1U; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v4 == 1, "");
+
+  // Long
+
+  static constexpr auto v5 = 1l;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'l', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v5 = 1l;
+  // CHECK-MESSAGES-NEXT: ^~
+  // CHECK-MESSAGES-NEXT: {{^ *}}L{{$}}
+  // CHECK-FIXES: static constexpr auto v5 = 1L;
+  static_assert(is_same::value, "");
+  static_assert(v5 == 1, "");
+
+  static constexpr auto v6 = 1L; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v6 == 1, "");
+
+  // Long Long
+
+  static constexpr auto v7 = 1ll;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'll', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v7 = 1ll;
+  // CHECK-MESSAGES-NEXT: ^~~
+  // CHECK-MESSAGES-NEXT: {{^ *}}LL{{$}}
+  // CHECK-FIXES: static constexpr auto v7 = 1LL;
+  static_assert(is_same::value, "");
+  static_assert(v7 == 1, "");
+
+  static constexpr auto v8 = 1LL; // OK.
+  static_assert(is_same::value, "");
+  static_assert(v8 == 1, "");
+
+  // Unsigned Long
+
+  static constexpr auto v9 = 1ul;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: integer literal has suffix 'ul', which is not upper-case
+  // CHECK-MESSAGES-NEXT: static constexpr auto v9 = 1ul;
+  // CHECK-MESSAGES-NEXT: ^~~
+  // CHECK-MESSAGES-NEXT: {{^ *}}UL{{$}}
+  // CHECK-FIXES: static constexpr auto v9 = 1UL;
+  static_assert(is_same::value,

r344443 - [Analyzer] Iterator Checker - Part 10: Tests for iterators passed as parameter

2018-10-13 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Sat Oct 13 03:24:48 2018
New Revision: 33

URL: http://llvm.org/viewvc/llvm-project?rev=33&view=rev
Log:
[Analyzer] Iterator Checker - Part 10: Tests for iterators passed as parameter

In earlier Clang Static Analyzer versions `check::Bind() was not invoked for
parameter passing, so we needed a trick which is not needed anymore. However
add the tests to ensure its working.

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


Modified:
cfe/trunk/test/Analysis/iterator-range.cpp
cfe/trunk/test/Analysis/mismatched-iterator.cpp

Modified: cfe/trunk/test/Analysis/iterator-range.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/iterator-range.cpp?rev=33&r1=32&r2=33&view=diff
==
--- cfe/trunk/test/Analysis/iterator-range.cpp (original)
+++ cfe/trunk/test/Analysis/iterator-range.cpp Sat Oct 13 03:24:48 2018
@@ -97,6 +97,28 @@ void copy_and_increase3(const std::vecto
 *i2; // expected-warning{{Iterator accessed outside of its range}}
 }
 
+template 
+InputIterator nonStdFind(InputIterator first, InputIterator last,
+ const T &val) {
+  for (auto i = first; i != last; ++i) {
+if (*i == val) {
+  return i;
+}
+  }
+  return last;
+}
+
+void good_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());

Modified: cfe/trunk/test/Analysis/mismatched-iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/mismatched-iterator.cpp?rev=33&r1=32&r2=33&view=diff
==
--- cfe/trunk/test/Analysis/mismatched-iterator.cpp (original)
+++ cfe/trunk/test/Analysis/mismatched-iterator.cpp Sat Oct 13 03:24:48 2018
@@ -144,6 +144,19 @@ void bad_overwrite(std::vector &v1,
   v1.insert(i, n); // expected-warning{{Container accessed using foreign 
iterator argument}}
 }
 
+template
+bool is_cend(Container cont, Iterator it) {
+  return it == cont.cend();
+}
+
+void good_empty(std::vector &v) {
+  is_cend(v, v.cbegin()); // no-warning
+}
+
+void bad_empty(std::vector &v1, std::vector &v2) {
+  is_cend(v1, v2.cbegin()); // expected-warning@-8{{Iterators of different 
containers used where the same container is expected}}
+}
+
 void good_move(std::vector &v1, std::vector &v2) {
   const auto i0 = ++v2.cbegin();
   v1 = std::move(v2);


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


[PATCH] D53187: [clang-tidy] Optimize query in bugprone-exception-escape

2018-10-13 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL34: [clang-tidy] Optimize query in 
bugprone-exception-escape (authored by baloghadamsoftware, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53187?vs=169552&id=169557#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53187

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
  clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp


Index: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -190,12 +190,12 @@
 return;
 
   Finder->addMatcher(
-  functionDecl(allOf(throws(unless(isIgnored(IgnoredExceptions))),
- anyOf(isNoThrow(), cxxDestructorDecl(),
+  functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(),
cxxConstructorDecl(isMoveConstructor()),
cxxMethodDecl(isMoveAssignmentOperator()),
hasName("main"), hasName("swap"),
-   isEnabled(FunctionsThatShouldNotThrow
+   isEnabled(FunctionsThatShouldNotThrow)),
+ throws(unless(isIgnored(IgnoredExceptions)
   .bind("thrower"),
   this);
 }
Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
@@ -21,6 +21,8 @@
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This check may be expensive on large source files.
+
 Options
 ---
 
Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp
@@ -258,6 +258,31 @@
   throw ignored1();
 }
 
+void thrower(int n) {
+  throw n;
+}
+
+int directly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'directly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return directly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
functin 'indirectly_recursive' which should not throw exceptions
+
+int recursion_helper(int n) {
+  indirectly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'indirectly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return recursion_helper(n);
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'main' which should not throw exceptions
   throw 1;


Index: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -190,12 +190,12 @@
 return;
 
   Finder->addMatcher(
-  functionDecl(allOf(throws(unless(isIgnored(IgnoredExceptions))),
- anyOf(isNoThrow(), cxxDestructorDecl(),
+  functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(),
cxxConstructorDecl(isMoveConstructor()),
cxxMethodDecl(isMoveAssignmentOperator()),
hasName("main"), hasName("swap"),
-   isEnabled(FunctionsThatShouldNotThrow
+   isEnabled(FunctionsThatShouldNotThrow)),
+ throws(unless(isIgnored(IgnoredExceptions)
   .bind("thrower"),
   this);
 }
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
@@ -21,6 +21,8 @@
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This

[clang-tools-extra] r344444 - [clang-tidy] Optimize query in bugprone-exception-escape

2018-10-13 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Sat Oct 13 03:34:52 2018
New Revision: 34

URL: http://llvm.org/viewvc/llvm-project?rev=34&view=rev
Log:
[clang-tidy] Optimize query in bugprone-exception-escape

Checking whether a functions throws indirectly may be very expensive because it
needs to visit its whole call graph. Therefore we should first check whether the
function is forbidden to throw and only check whether it throws afterward. This
also seems to solve bug https://bugs.llvm.org/show_bug.cgi?id=39167 where the
execution time is so long that it seems to hang.

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


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=34&r1=33&r2=34&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp Sat 
Oct 13 03:34:52 2018
@@ -190,12 +190,12 @@ void ExceptionEscapeCheck::registerMatch
 return;
 
   Finder->addMatcher(
-  functionDecl(allOf(throws(unless(isIgnored(IgnoredExceptions))),
- anyOf(isNoThrow(), cxxDestructorDecl(),
+  functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(),
cxxConstructorDecl(isMoveConstructor()),
cxxMethodDecl(isMoveAssignmentOperator()),
hasName("main"), hasName("swap"),
-   isEnabled(FunctionsThatShouldNotThrow
+   isEnabled(FunctionsThatShouldNotThrow)),
+ throws(unless(isIgnored(IgnoredExceptions)
   .bind("thrower"),
   this);
 }

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst?rev=34&r1=33&r2=34&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-exception-escape.rst 
Sat Oct 13 03:34:52 2018
@@ -21,6 +21,8 @@ are always possible to implement in a no
 operations are also used to create move operations. A throwing ``main()``
 function also results in unexpected termination.
 
+WARNING! This check may be expensive on large source files.
+
 Options
 ---
 

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp?rev=34&r1=33&r2=34&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp Sat 
Oct 13 03:34:52 2018
@@ -258,6 +258,31 @@ void this_counts(int n) noexcept {
   throw ignored1();
 }
 
+void thrower(int n) {
+  throw n;
+}
+
+int directly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'directly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return directly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
functin 'indirectly_recursive' which should not throw exceptions
+
+int recursion_helper(int n) {
+  indirectly_recursive(n);
+}
+
+int indirectly_recursive(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'indirectly_recursive' which should not throw exceptions
+  if (n == 0)
+thrower(n);
+  return recursion_helper(n);
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'main' which should not throw exceptions
   throw 1;


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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2018-10-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware closed this revision.
baloghadamsoftware added a comment.
Herald added a subscriber: donat.nagy.

Closed by commits in the previous comments, just URLs misspelled.


https://reviews.llvm.org/D32906



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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2018-10-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D32906#1257140, @NoQ wrote:

> Also i'll have a look at whether the checker is in a good shape to be enabled 
> by default. I suspect that mismatched iterators might be very safe to enable. 
> With all these solver and rearrangement issues, if they only cause false 
> negatives, it's not blocking enabling the checker by default. The same 
> applies to the debate around `find`.


Unfortunately, we are at the beginning of a long road. I will post several new 
patches that we already test internally. However the only checker with 
acceptable false-positive rate is the `invalidated-iterator` checker. The 
`mismatched-iterator` still has high false-positive rate for iterator-iterator 
mismatches. For iterator-container mismatches it is acceptable. The 
`iterator-range` checker also has still too many false positives.

> One thing that's most likely necessary to do before enabling the checker by 
> default is to add a bug report visitor, so that it added notes when iterators 
> appear for the first time or change their state. Without such notes it's 
> usually very hard to understand warnings. Especially because we're dropping 
> the path within inlined functions that have no interesting events, but when 
> the iterator originates from or gets updated within such function, this 
> information becomes crucial. The visitor might have to hop from one object to 
> another similarly to `trackNullOrUndefValue()` (i.e., by adding more 
> instances of itself that track objects that are being copied or moved into 
> the object of interest at the program point that is currently being visited).

Good idea, I will try to create such a visitor. However the next step should be 
replacing the unaccepted part 9 by a function-summary based solution in a 
separate checker (std-c++-library-functions).


https://reviews.llvm.org/D32906



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


[clang-tools-extra] r344445 - [clang-tidy] Fix for typos in the tests for `bugprone-exception-escape`

2018-10-13 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Sat Oct 13 04:17:59 2018
New Revision: 35

URL: http://llvm.org/viewvc/llvm-project?rev=35&view=rev
Log:
[clang-tidy] Fix for typos in the tests for `bugprone-exception-escape`


Modified:
clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp?rev=35&r1=34&r2=35&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-exception-escape.cpp Sat 
Oct 13 04:17:59 2018
@@ -263,21 +263,21 @@ void thrower(int n) {
 }
 
 int directly_recursive(int n) noexcept {
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'directly_recursive' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'directly_recursive' which should not throw exceptions
   if (n == 0)
 thrower(n);
   return directly_recursive(n);
 }
 
 int indirectly_recursive(int n) noexcept;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
functin 'indirectly_recursive' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'indirectly_recursive' which should not throw exceptions
 
 int recursion_helper(int n) {
   indirectly_recursive(n);
 }
 
 int indirectly_recursive(int n) noexcept {
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
funcion 'indirectly_recursive' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'indirectly_recursive' which should not throw exceptions
   if (n == 0)
 thrower(n);
   return recursion_helper(n);


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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length

2018-10-13 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a subscriber: klimek.
Charusso added a comment.

In https://reviews.llvm.org/D45050#1264435, @JonasToth wrote:

> Unfortunatly this check does not compile on some ARM platforms. It seems that 
> a matcher exceeds the recursion limit in template instantations.
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/4405/steps/build%20stage%201/logs/stdio


Well, I can do nothing, but ask for @klimek's help.

Manuel, could you review this error please?


https://reviews.llvm.org/D45050



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


[PATCH] D53244: [Coverage] Fix PR39258: support coverage regions that start deeper than they end

2018-10-13 Thread Orivej Desh via Phabricator via cfe-commits
orivej created this revision.
orivej added reviewers: bogner, rsmith, vsk, aaron.ballman.
Herald added a subscriber: cfe-commits.

popRegions used to assume that the start location of a region can't be nested 
deeper than the end location, which is not always true.


Repository:
  rC Clang

https://reviews.llvm.org/D53244

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/macros.c


Index: test/CoverageMapping/macros.c
===
--- test/CoverageMapping/macros.c
+++ test/CoverageMapping/macros.c
@@ -4,6 +4,7 @@
 #define MACRO_2 bar()
 #define MACRO_1 return; MACRO_2
 #define MACRO_3 MACRO_2
+#define GOTO goto
 
 void bar() {}
 
@@ -56,6 +57,15 @@
 // CHECK-NEXT: Expansion,File 1, 6:17 -> 6:24 = #1
 // CHECK-NEXT: File 2, 4:17 -> 4:22 = #1
 
+// CHECK-NEXT: func6
+void func6(unsigned count) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> 
[[@LINE+4]]:2 = #0
+begin:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> 
[[@LINE+3]]:2 = #1
+if (count--) // CHECK-NEXT: File 0, [[@LINE]]:9 -> 
[[@LINE]]:16 = #1
+GOTO begin;  // CHECK-NEXT: File 0, [[@LINE]]:9 -> 
[[@LINE]]:19 = #2
+}
+// CHECK-NEXT: Expansion,File 0, 64:9 -> 64:13 = #2
+// CHECK-NEXT: File 1, 7:14 -> 7:18 = #2
+
 int main(int argc, const char *argv[]) {
   func();
   func2();
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -552,6 +552,15 @@
 completeDeferred(Count, DeferredEndLoc);
   }
 
+  size_t locactionDepth(SourceLocation Loc) {
+size_t Depth = 0;
+while (Loc.isValid()) {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  Depth++;
+}
+return Depth;
+  }
+
   /// Pop regions from the stack into the function's list of regions.
   ///
   /// Adds all regions from \c ParentIndex to the top of the stack to the
@@ -566,19 +575,35 @@
 SourceLocation EndLoc = Region.hasEndLoc()
 ? Region.getEndLoc()
 : RegionStack[ParentIndex].getEndLoc();
+bool UnnestEnd = locactionDepth(EndLoc) > locactionDepth(StartLoc);
 while (!SM.isWrittenInSameFile(StartLoc, EndLoc)) {
-  // The region ends in a nested file or macro expansion. Create a
-  // separate region for each expansion.
-  SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
-  assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
-
-  if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
-SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
-
-  EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
-  if (EndLoc.isInvalid())
-llvm::report_fatal_error("File exit not handled before 
popRegions");
+  if (UnnestEnd) {
+// The region ends in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
+assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
+
+if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
+  SourceRegions.emplace_back(Region.getCounter(), NestedLoc, 
EndLoc);
+
+EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
+if (EndLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before 
popRegions");
+  } else {
+// The region begins in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getEndOfFileOrMacro(StartLoc);
+assert(SM.isWrittenInSameFile(StartLoc, NestedLoc));
+
+if (!isRegionAlreadyAdded(StartLoc, NestedLoc))
+  SourceRegions.emplace_back(Region.getCounter(), StartLoc, 
NestedLoc);
+
+StartLoc = getIncludeOrExpansionLoc(StartLoc);
+if (StartLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before 
popRegions");
+  }
 }
+Region.setStartLoc(StartLoc);
 Region.setEndLoc(EndLoc);
 
 MostRecentLocation = EndLoc;


Index: test/CoverageMapping/macros.c
===
--- test/CoverageMapping/macros.c
+++ test/CoverageMapping/macros.c
@@ -4,6 +4,7 @@
 #define MACRO_2 bar()
 #define MACRO_1 return; MACRO_2
 #define MACRO_3 MACRO_2
+#define GOTO goto
 
 void bar() {}
 
@@ -56,6 +57,15 @@
 // CHECK-NEXT: Expansion,File 1, 6:17 -> 6:24 = #1
 // CHECK-NEXT: File 2, 4:17 -> 4:22 = #1
 
+// CHECK-NEXT: func6
+void func6(unsigned count) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+4]]:2 = #0
+begin:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #1
+if (count--) // CHECK-NEXT: File 0, [[@LINE]]

[PATCH] D53244: [Coverage] Fix PR39258: support coverage regions that start deeper than they end

2018-10-13 Thread Orivej Desh via Phabricator via cfe-commits
orivej updated this revision to Diff 169562.
orivej added a comment.

This looks better to me. (There is no difference in check-clang test results.)


Repository:
  rC Clang

https://reviews.llvm.org/D53244

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/macros.c

Index: test/CoverageMapping/macros.c
===
--- test/CoverageMapping/macros.c
+++ test/CoverageMapping/macros.c
@@ -4,6 +4,7 @@
 #define MACRO_2 bar()
 #define MACRO_1 return; MACRO_2
 #define MACRO_3 MACRO_2
+#define GOTO goto
 
 void bar() {}
 
@@ -56,6 +57,15 @@
 // CHECK-NEXT: Expansion,File 1, 6:17 -> 6:24 = #1
 // CHECK-NEXT: File 2, 4:17 -> 4:22 = #1
 
+// CHECK-NEXT: func6
+void func6(unsigned count) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+4]]:2 = #0
+begin:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #1
+if (count--) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:16 = #1
+GOTO begin;  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:19 = #2
+}
+// CHECK-NEXT: Expansion,File 0, 64:9 -> 64:13 = #2
+// CHECK-NEXT: File 1, 7:14 -> 7:18 = #2
+
 int main(int argc, const char *argv[]) {
   func();
   func2();
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -552,6 +552,15 @@
 completeDeferred(Count, DeferredEndLoc);
   }
 
+  size_t locactionDepth(SourceLocation Loc) {
+size_t Depth = 0;
+while (Loc.isValid()) {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  Depth++;
+}
+return Depth;
+  }
+
   /// Pop regions from the stack into the function's list of regions.
   ///
   /// Adds all regions from \c ParentIndex to the top of the stack to the
@@ -566,19 +575,41 @@
 SourceLocation EndLoc = Region.hasEndLoc()
 ? Region.getEndLoc()
 : RegionStack[ParentIndex].getEndLoc();
+size_t StartDepth = locactionDepth(StartLoc);
+size_t EndDepth = locactionDepth(EndLoc);
 while (!SM.isWrittenInSameFile(StartLoc, EndLoc)) {
-  // The region ends in a nested file or macro expansion. Create a
-  // separate region for each expansion.
-  SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
-  assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
-
-  if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
-SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
-
-  EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
-  if (EndLoc.isInvalid())
-llvm::report_fatal_error("File exit not handled before popRegions");
+  bool UnnestStart = StartDepth >= EndDepth;
+  bool UnnestEnd = EndDepth >= StartDepth;
+  if (UnnestEnd) {
+// The region ends in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
+assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
+
+if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
+  SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
+
+EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
+if (EndLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before popRegions");
+EndDepth--;
+  }
+  if (UnnestStart) {
+// The region begins in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getEndOfFileOrMacro(StartLoc);
+assert(SM.isWrittenInSameFile(StartLoc, NestedLoc));
+
+if (!isRegionAlreadyAdded(StartLoc, NestedLoc))
+  SourceRegions.emplace_back(Region.getCounter(), StartLoc, NestedLoc);
+
+StartLoc = getIncludeOrExpansionLoc(StartLoc);
+if (StartLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before popRegions");
+StartDepth--;
+  }
 }
+Region.setStartLoc(StartLoc);
 Region.setEndLoc(EndLoc);
 
 MostRecentLocation = EndLoc;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51868: [libcxx] Build and test fixes for Windows

2018-10-13 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added inline comments.



Comment at: CMakeLists.txt:550
+endif()
 add_compile_flags_if_supported(
+-Wextra -W -Wwrite-strings

EricWF wrote:
> Couldn't we keep the "-Wall" here? And just add something else that adds 
> "/W4"?
> 
> Also, we don't yet support building with MSVC's frontend. Only clang-cl. Does 
> clang-cl not like this existing code?
The `-Wall` flag gets converted to `-Weverything` by Clang-CL; I don’t think we 
should keep it (it causes thousands of warnings per header).

`/W4` is the equivalent flag on Windows.



Comment at: include/filesystem:1396
 
-  _LIBCPP_FUNC_VIS
   void __create_what(int __num_paths);

EricWF wrote:
> hamzasood wrote:
> > compnerd wrote:
> > > This possibly changes the meaning on other targets.  What was the error 
> > > that this triggered?
> > I've re-uploaded the patch with full context to make this clearer.
> > 
> > That's a member function on an exported type, which I don't think should 
> > have any visibility attributes. The specific issue in this case is that 
> > both the class type and the member function are marked as dllimport, which 
> > causes a compilation error.
> Perhaps part of the problem here is that filesystem builds to a static 
> library, not a shared one.
> 
> None the less, this macro is important once we move the definitions from 
> libc++fs.a to libc++.so.
I don’t think member functions are meant to have function visibility, and I 
wasn’t able to find any other such cases in libc++. That’ll always be a hard 
error on Windows because a dllimport class can’t have dllimport member 
functions.



Comment at: test/support/test_macros.h:147
-#  elif defined(_WIN32)
-#if defined(_MSC_VER) && !defined(__MINGW32__)
-#  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library

EricWF wrote:
> hamzasood wrote:
> > hamzasood wrote:
> > > STL_MSFT wrote:
> > > > compnerd wrote:
> > > > > I think that the condition here is inverted, and should be enabled 
> > > > > for MinGW32.
> > > > What error prompted this? It hasn't caused problems when running 
> > > > libc++'s tests against MSVC's STL (with both C1XX and Clang).
> > > The comment above this says that it's copied from `__config`, but they 
> > > must've gone out of sync at some point because `__config` doesn't have 
> > > that extra section that I deleted.
> > > 
> > > This causes lots of errors when testing libc++. E.g. libc++ isn't 
> > > declaring `std::timespec` on Windows because `_LIBCPP_HAS_C11_FEATURES` 
> > > isn't defined, but the tests think that it's available so they try to use 
> > > it (which causes compilation failures in lots of tests).
> > > 
> > > The better solution here might be to update `__config` to match this, but 
> > > I'm not familiar with some of those platforms so this seemed like the 
> > > safest approach for now.
> > This is a workaround for a libc++ issue rather than an MSVC one. See the 
> > response to @compnerd for the full details.
> 
> What tests are failing?
Any test that requires `TEST_HAS_C11_FEATURES` or `TEST_HAS_TIMESPEC_GET`. 
Those test macros aren’t in sync with the corresponding `__config` ones.



Comment at: utils/libcxx/test/config.py:518
 self.cxx.compile_flags += ['-DNOMINMAX']
+# Disable auto-linking; the library is linked manually when
+# configuring the linker flags.

EricWF wrote:
> I think the correct fix here is to disabling linking libc++ when auto linking 
> is enabled by the headers. Because we want to test that the auto link pragmas 
> work.
In that case, it might be worth adding separate auto-linking tests that 
specifically use Clang-CL. Making it work here would involve defining `_DLL` 
for dynamic builds, but I’m not sure if that would interfere with the CRT.


https://reviews.llvm.org/D51868



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 169567.
xbolva00 added a comment.

- New diagnostic group


https://reviews.llvm.org/D52835

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c

Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4.2949673E+9}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -105,6 +105,19 @@
Context.getTargetInfo());
 }
 
+// FIXME: Force the precision of the source value down so we don't print
+// digits which are usually useless (we don't really care here if we
+// truncate a digit by accident in edge cases).  Ideally, APFloat::toString
+// would automatically print the shortest representation, but it's a bit
+// tricky to implement.
+static void PrettyPrintFloat(const llvm::APFloat &floatValue,
+ const llvm::fltSemantics &floatSem,
+ SmallVectorImpl &prettyFloatValue) {
+  unsigned precision = llvm::APFloat::semanticsPrecision(floatSem);
+  precision = llvm::divideCeil(precision * 59, 196);
+  floatValue.toString(prettyFloatValue, precision);
+}
+
 /// Checks that a call expression's argument count is the desired number.
 /// This is useful when doing custom type-checking.  Returns true on error.
 static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount) {
@@ -10414,15 +10427,8 @@
 DiagID = diag::warn_impcast_float_to_integer;
   }
 
-  // FIXME: Force the precision of the source value down so we don't print
-  // digits which are usually useless (we don't really care here if we
-  // truncate a digit by accident in edge cases).  Ideally, APFloat::toString
-  // would automatically print the shortest representation, but it's a bit
-  // tricky to implement.
   SmallString<16> PrettySourceValue;
-  unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
-  precision = (precision * 59 + 195) / 196;
-  Value.toString(PrettySourceValue, precision);
+  PrettyPrintFloat(Value, Value.getSemantics(), PrettySourceValue);
 
   SmallString<16> PrettyTargetValue;
   if (IsBool)
@@ -10855,6 +10861,32 @@
 return;
   }
 
+  if (Source->isIntegerType() && TargetBT && TargetBT->isFloatingType()) {
+llvm::APSInt IntValue;
+if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+  if (S.SourceMgr.isInSystemMacro(CC))
+return;
+  const llvm::fltSemantics &FloatSemantics =
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0));
+  llvm::APFloat FloatValue(FloatSemantics);
+  if (FloatValue.convertFromAPInt(IntValue, Source->isSignedIntegerType(),
+  llvm::APFloat::rmNearestTiesToEven) !=
+  llvm::APFloat::opOK) {
+SmallString<16> PrettyTargetValue;
+SmallString<16> PrettySourceValue;
+PrettyPrintFloat(FloatValue, FloatSemantics, PrettyTargetValue);
+IntValue.toString(PrettySourceValue);
+
+S.DiagRuntimeBehavior(
+E->getExprLoc(), E,
+S.PDiag(diag::warn_impcast_precision_float_to_integer)
+<< E->getType() << T << PrettySourceValue << PrettyTargetValue
+<< E->getSourceRange() << clang::SourceRange(CC));
+return;
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3223,6 +3223,10 @@
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
+def warn_impcast_precision_float_to_integer : Warning<
+  "implicit conversion from %0 to %1 changes value from %2 to %3">,
+  InGroup;
+
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -51,6 +51,7 @@
 def ConstantConversion :
   DiagGroup<"constant-

[PATCH] D51868: [libcxx] Build and test fixes for Windows

2018-10-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Libc++ fs works on Windows now?


https://reviews.llvm.org/D51868



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


[PATCH] D53244: [Coverage] Fix PR39258: support coverage regions that start deeper than they end

2018-10-13 Thread Orivej Desh via Phabricator via cfe-commits
orivej updated this revision to Diff 169568.
orivej added a comment.

Fix typo


Repository:
  rC Clang

https://reviews.llvm.org/D53244

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/macros.c

Index: test/CoverageMapping/macros.c
===
--- test/CoverageMapping/macros.c
+++ test/CoverageMapping/macros.c
@@ -4,6 +4,7 @@
 #define MACRO_2 bar()
 #define MACRO_1 return; MACRO_2
 #define MACRO_3 MACRO_2
+#define GOTO goto
 
 void bar() {}
 
@@ -56,6 +57,15 @@
 // CHECK-NEXT: Expansion,File 1, 6:17 -> 6:24 = #1
 // CHECK-NEXT: File 2, 4:17 -> 4:22 = #1
 
+// CHECK-NEXT: func6
+void func6(unsigned count) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+4]]:2 = #0
+begin:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #1
+if (count--) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:16 = #1
+GOTO begin;  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:19 = #2
+}
+// CHECK-NEXT: Expansion,File 0, 64:9 -> 64:13 = #2
+// CHECK-NEXT: File 1, 7:14 -> 7:18 = #2
+
 int main(int argc, const char *argv[]) {
   func();
   func2();
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -552,6 +552,15 @@
 completeDeferred(Count, DeferredEndLoc);
   }
 
+  size_t locationDepth(SourceLocation Loc) {
+size_t Depth = 0;
+while (Loc.isValid()) {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  Depth++;
+}
+return Depth;
+  }
+
   /// Pop regions from the stack into the function's list of regions.
   ///
   /// Adds all regions from \c ParentIndex to the top of the stack to the
@@ -566,19 +575,41 @@
 SourceLocation EndLoc = Region.hasEndLoc()
 ? Region.getEndLoc()
 : RegionStack[ParentIndex].getEndLoc();
+size_t StartDepth = locationDepth(StartLoc);
+size_t EndDepth = locationDepth(EndLoc);
 while (!SM.isWrittenInSameFile(StartLoc, EndLoc)) {
-  // The region ends in a nested file or macro expansion. Create a
-  // separate region for each expansion.
-  SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
-  assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
-
-  if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
-SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
-
-  EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
-  if (EndLoc.isInvalid())
-llvm::report_fatal_error("File exit not handled before popRegions");
+  bool UnnestStart = StartDepth >= EndDepth;
+  bool UnnestEnd = EndDepth >= StartDepth;
+  if (UnnestEnd) {
+// The region ends in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);
+assert(SM.isWrittenInSameFile(NestedLoc, EndLoc));
+
+if (!isRegionAlreadyAdded(NestedLoc, EndLoc))
+  SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
+
+EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
+if (EndLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before popRegions");
+EndDepth--;
+  }
+  if (UnnestStart) {
+// The region begins in a nested file or macro expansion. Create a
+// separate region for each expansion.
+SourceLocation NestedLoc = getEndOfFileOrMacro(StartLoc);
+assert(SM.isWrittenInSameFile(StartLoc, NestedLoc));
+
+if (!isRegionAlreadyAdded(StartLoc, NestedLoc))
+  SourceRegions.emplace_back(Region.getCounter(), StartLoc, NestedLoc);
+
+StartLoc = getIncludeOrExpansionLoc(StartLoc);
+if (StartLoc.isInvalid())
+  llvm::report_fatal_error("File exit not handled before popRegions");
+StartDepth--;
+  }
 }
+Region.setStartLoc(StartLoc);
 Region.setEndLoc(EndLoc);
 
 MostRecentLocation = EndLoc;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r344462 - Re-commit r344234 "clang-cl: Add /showFilenames option (PR31957)"

2018-10-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Sat Oct 13 12:13:14 2018
New Revision: 344462

URL: http://llvm.org/viewvc/llvm-project?rev=344462&view=rev
Log:
Re-commit r344234 "clang-cl: Add /showFilenames option (PR31957)"

The test was failing on e.g. PPC which can't target Windows. Fix by
requiring X86 target in the test. Also, make sure the output goes to a
temporary directory, since CWD may not be writable.

Added:
cfe/trunk/test/Driver/cl-showfilenames.c
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Job.h
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=344462&r1=344461&r2=344462&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Oct 13 12:13:14 2018
@@ -158,6 +158,10 @@ def _SLASH_Qvec_ : CLFlag<"Qvec-">,
 def _SLASH_showIncludes : CLFlag<"showIncludes">,
   HelpText<"Print info about included files to stderr">,
   Alias;
+def _SLASH_showFilenames : CLFlag<"showFilenames">,
+  HelpText<"Print the name of each compiled file">;
+def _SLASH_showFilenames_ : CLFlag<"showFilenames-">,
+  HelpText<"Don't print the name of each compiled file (default)">;
 def _SLASH_source_charset : CLCompileJoined<"source-charset:">,
   HelpText<"Source encoding, supports only UTF-8">, Alias;
 def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">,

Modified: cfe/trunk/include/clang/Driver/Job.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=344462&r1=344461&r2=344462&view=diff
==
--- cfe/trunk/include/clang/Driver/Job.h (original)
+++ cfe/trunk/include/clang/Driver/Job.h Sat Oct 13 12:13:14 2018
@@ -56,6 +56,9 @@ class Command {
   /// The list of program arguments which are inputs.
   llvm::opt::ArgStringList InputFilenames;
 
+  /// Whether to print the input filenames when executing.
+  bool PrintInputFilenames = false;
+
   /// Response file name, if this command is set to use one, or nullptr
   /// otherwise
   const char *ResponseFile = nullptr;
@@ -125,6 +128,9 @@ public:
 
   /// Print a command argument, and optionally quote it.
   static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote);
+
+  /// Set whether to print the input filenames when executing.
+  void setPrintInputFilenames(bool P) { PrintInputFilenames = P; }
 };
 
 /// Like Command, but with a fallback which is executed in case

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=344462&r1=344461&r2=344462&view=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Sat Oct 13 12:13:14 2018
@@ -316,6 +316,12 @@ void Command::setEnvironment(llvm::Array
 
 int Command::Execute(ArrayRef> Redirects,
  std::string *ErrMsg, bool *ExecutionFailed) const {
+  if (PrintInputFilenames) {
+for (const char *Arg : InputFilenames)
+  llvm::outs() << llvm::sys::path::filename(Arg) << "\n";
+llvm::outs().flush();
+  }
+
   SmallVector Argv;
 
   Optional> Env;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=344462&r1=344461&r2=344462&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sat Oct 13 12:13:14 2018
@@ -5067,6 +5067,13 @@ void Clang::ConstructJob(Compilation &C,
 C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
   }
 
+  // Make the compile command echo its inputs for /showFilenames.
+  if (Output.getType() == types::TY_Object &&
+  Args.hasFlag(options::OPT__SLASH_showFilenames,
+   options::OPT__SLASH_showFilenames_, false)) {
+C.getJobs().getJobs().back()->setPrintInputFilenames(true);
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_pg))
 if (!shouldUseFramePointer(Args, Triple))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"

Added: cfe/trunk/test/Driver/cl-showfilenames.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-showfilenames.c?rev=344462&view=auto
==
--- cfe/trunk/test/Driver/cl-showfilenames.c (added)
+++ cfe/trunk/test/Driver/cl-showfilenames.c Sat Oct 13 12:13:14 2018
@@ -0,0 +1,23 @@
+// We have to run the compilation step to see the output, so we must be able to
+// target Windows.
+// REQUIRES: x86-registered-target
+
+// RUN

[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once

2018-10-13 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: donat.nagy.

Ping, @NoQ, can you go a little bit more in depth about what you'd prefer to 
see here?


https://reviews.llvm.org/D51531



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


[PATCH] D52031: [analyzer] Small SMT API improvement

2018-10-13 Thread Enrico Steffinlongo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344463: [analyzer] Small SMT API improvement (authored by 
esteffin, committed by ).
Herald added subscribers: cfe-commits, donat.nagy.

Repository:
  rC Clang

https://reviews.llvm.org/D52031

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp


Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -859,7 +859,7 @@
   }
 
   /// Reset the solver and remove all constraints.
-  void reset() const override { Z3_solver_reset(Context.Context, Solver); }
+  void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
   void print(raw_ostream &OS) const override {
 OS << Z3_solver_to_string(Context.Context, Solver);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
@@ -283,7 +283,7 @@
   virtual void pop(unsigned NumStates = 1) = 0;
 
   /// Reset the solver and remove all constraints.
-  virtual void reset() const = 0;
+  virtual void reset() = 0;
 
   virtual void print(raw_ostream &OS) const = 0;
 };


Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -859,7 +859,7 @@
   }
 
   /// Reset the solver and remove all constraints.
-  void reset() const override { Z3_solver_reset(Context.Context, Solver); }
+  void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
   void print(raw_ostream &OS) const override {
 OS << Z3_solver_to_string(Context.Context, Solver);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
@@ -283,7 +283,7 @@
   virtual void pop(unsigned NumStates = 1) = 0;
 
   /// Reset the solver and remove all constraints.
-  virtual void reset() const = 0;
+  virtual void reset() = 0;
 
   virtual void print(raw_ostream &OS) const = 0;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50818: [analyzer] Improved cmake configuration for Z3

2018-10-13 Thread Enrico Steffinlongo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344464: [analyzer] Improved cmake configuration for Z3 
(authored by esteffin, committed by ).
Herald added subscribers: cfe-commits, donat.nagy.

Repository:
  rC Clang

https://reviews.llvm.org/D50818

Files:
  CMakeLists.txt
  cmake/modules/FindZ3.cmake
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -394,22 +394,35 @@
 option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
 option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
 
-option(CLANG_ANALYZER_BUILD_Z3
-  "Build the static analyzer with the Z3 constraint manager." OFF)
+set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
 
-option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+find_package(Z3 4.7.1 EXACT)
 
-if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3))
-  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
+if (CLANG_ANALYZER_Z3_INSTALL_DIR)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "Z3 4.7.1 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR: ${CLANG_ANALYZER_Z3_INSTALL_DIR}.")
+  endif()
 endif()
 
-if(CLANG_ANALYZER_BUILD_Z3)
-  find_package(Z3 4.5)
-  if(Z3_FOUND)
-set(CLANG_ANALYZER_WITH_Z3 1)
-  else()
-message(FATAL_ERROR "Cannot find Z3 header file or shared library")
+set(CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
+
+option(CLANG_ANALYZER_ENABLE_Z3_SOLVER
+  "Enable Support for the Z3 constraint solver in the Clang Static Analyzer."
+  ${CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT}
+)
+
+if (CLANG_ANALYZER_ENABLE_Z3_SOLVER)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "CLANG_ANALYZER_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.")
   endif()
+
+  set(CLANG_ANALYZER_WITH_Z3 1)
+endif()
+
+option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+
+if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_ENABLE_Z3_SOLVER))
+  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
 endif()
 
 if(CLANG_ENABLE_ARCMT)
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -926,7 +926,7 @@
   return llvm::make_unique();
 #else
   llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
-   "with -DCLANG_ANALYZER_BUILD_Z3=ON",
+   "with -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=ON",
false);
   return nullptr;
 #endif
@@ -938,7 +938,7 @@
   return llvm::make_unique(Eng, StMgr.getSValBuilder());
 #else
   llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
-   "with -DCLANG_ANALYZER_BUILD_Z3=ON",
+   "with -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=ON",
false);
   return nullptr;
 #endif
Index: cmake/modules/FindZ3.cmake
===
--- cmake/modules/FindZ3.cmake
+++ cmake/modules/FindZ3.cmake
@@ -1,13 +1,36 @@
+# Looking for Z3 in CLANG_ANALYZER_Z3_INSTALL_DIR
 find_path(Z3_INCLUDE_DIR NAMES z3.h
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}/include
PATH_SUFFIXES libz3 z3
)
 
 find_library(Z3_LIBRARIES NAMES z3 libz3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES lib bin
)
 
-find_program(Z3_EXECUTABLE z3)
+find_program(Z3_EXECUTABLE z3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES bin
+   )
+
+# If Z3 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR look in the default directories
+find_path(Z3_INCLUDE_DIR NAMES z3.h
+   PATH_SUFFIXES libz3 z3
+   )
+
+find_library(Z3_LIBRARIES NAMES z3 libz3
+   PATH_SUFFIXES lib bin
+   )
+
+find_program(Z3_EXECUTABLE z3
+   PATH_SUFFIXES bin
+   )
 
-if(Z3_INCLUDE_DIR AND Z3_EXECUTABLE)
+if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
 execute_process (COMMAND ${Z3_EXECUTABLE} -version
   OUTPUT_VARIABLE libz3_version_str
   ERROR_QUIET
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2018-10-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D52527



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


r344463 - [analyzer] Small SMT API improvement

2018-10-13 Thread Enrico Steffinlongo via cfe-commits
Author: esteffin
Date: Sat Oct 13 12:42:10 2018
New Revision: 344463

URL: http://llvm.org/viewvc/llvm-project?rev=344463&view=rev
Log:
[analyzer] Small SMT API improvement

Summary: Removed const qualifier from reset method of SMTSolver and Z3Solver 
objects.

Reviewers: mikhail.ramalho, george.karpenkov, NoQ, ddcc

Reviewed By: NoQ

Subscribers: xazax.hun, szepet, a.sidorin, Szelethus

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h?rev=344463&r1=344462&r2=344463&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTSolver.h Sat 
Oct 13 12:42:10 2018
@@ -283,7 +283,7 @@ public:
   virtual void pop(unsigned NumStates = 1) = 0;
 
   /// Reset the solver and remove all constraints.
-  virtual void reset() const = 0;
+  virtual void reset() = 0;
 
   virtual void print(raw_ostream &OS) const = 0;
 };

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=344463&r1=344462&r2=344463&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Sat Oct 13 
12:42:10 2018
@@ -859,7 +859,7 @@ public:
   }
 
   /// Reset the solver and remove all constraints.
-  void reset() const override { Z3_solver_reset(Context.Context, Solver); }
+  void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
   void print(raw_ostream &OS) const override {
 OS << Z3_solver_to_string(Context.Context, Solver);


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


r344464 - [analyzer] Improved cmake configuration for Z3

2018-10-13 Thread Enrico Steffinlongo via cfe-commits
Author: esteffin
Date: Sat Oct 13 12:45:48 2018
New Revision: 344464

URL: http://llvm.org/viewvc/llvm-project?rev=344464&view=rev
Log:
[analyzer] Improved cmake configuration for Z3

Summary:
Enhanced support for Z3 in the cmake configuration of clang; now it is possible 
to specify any arbitrary Z3 install prefix (CLANG_ANALYZER_Z3_PREFIX) to cmake 
with lib (or bin) and include folders. Before the patch only in cmake default 
locations
were searched (https://cmake.org/cmake/help/v3.4/command/find_path.html).

Specifying any CLANG_ANALYZER_Z3_PREFIX will force also CLANG_ANALYZER_BUILD_Z3 
to ON.

Removed also Z3 4.5 version requirement since it was not checked, and now Clang 
works with Z3 4.7

Reviewers: NoQ, george.karpenkov, mikhail.ramalho

Reviewed By: george.karpenkov

Subscribers: rnkovacs, NoQ, esteffin, george.karpenkov, delcypher, ddcc, 
mgorny, xazax.hun, szepet, a.sidorin, Szelethus

Tags: #clang

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/FindZ3.cmake
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344464&r1=344463&r2=344464&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Sat Oct 13 12:45:48 2018
@@ -394,22 +394,35 @@ option(CLANG_BUILD_TOOLS
 option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
 option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
 
-option(CLANG_ANALYZER_BUILD_Z3
-  "Build the static analyzer with the Z3 constraint manager." OFF)
+set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 
solver.")
 
-option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+find_package(Z3 4.7.1 EXACT)
 
-if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR 
CLANG_ANALYZER_BUILD_Z3))
-  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")
+if (CLANG_ANALYZER_Z3_INSTALL_DIR)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "Z3 4.7.1 has not been found in 
CLANG_ANALYZER_Z3_INSTALL_DIR: ${CLANG_ANALYZER_Z3_INSTALL_DIR}.")
+  endif()
 endif()
 
-if(CLANG_ANALYZER_BUILD_Z3)
-  find_package(Z3 4.5)
-  if(Z3_FOUND)
-set(CLANG_ANALYZER_WITH_Z3 1)
-  else()
-message(FATAL_ERROR "Cannot find Z3 header file or shared library")
+set(CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
+
+option(CLANG_ANALYZER_ENABLE_Z3_SOLVER
+  "Enable Support for the Z3 constraint solver in the Clang Static Analyzer."
+  ${CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT}
+)
+
+if (CLANG_ANALYZER_ENABLE_Z3_SOLVER)
+  if (NOT Z3_FOUND)
+message(FATAL_ERROR "CLANG_ANALYZER_ENABLE_Z3_SOLVER cannot be enabled 
when Z3 is not available.")
   endif()
+
+  set(CLANG_ANALYZER_WITH_Z3 1)
+endif()
+
+option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+
+if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR 
CLANG_ANALYZER_ENABLE_Z3_SOLVER))
+  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")
 endif()
 
 if(CLANG_ENABLE_ARCMT)

Modified: cfe/trunk/cmake/modules/FindZ3.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/FindZ3.cmake?rev=344464&r1=344463&r2=344464&view=diff
==
--- cfe/trunk/cmake/modules/FindZ3.cmake (original)
+++ cfe/trunk/cmake/modules/FindZ3.cmake Sat Oct 13 12:45:48 2018
@@ -1,13 +1,36 @@
+# Looking for Z3 in CLANG_ANALYZER_Z3_INSTALL_DIR
 find_path(Z3_INCLUDE_DIR NAMES z3.h
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}/include
PATH_SUFFIXES libz3 z3
)
 
 find_library(Z3_LIBRARIES NAMES z3 libz3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES lib bin
)
 
-find_program(Z3_EXECUTABLE z3)
+find_program(Z3_EXECUTABLE z3
+   NO_DEFAULT_PATH
+   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
+   PATH_SUFFIXES bin
+   )
+
+# If Z3 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR look in the 
default directories
+find_path(Z3_INCLUDE_DIR NAMES z3.h
+   PATH_SUFFIXES libz3 z3
+   )
+
+find_library(Z3_LIBRARIES NAMES z3 libz3
+   PATH_SUFFIXES lib bin
+   )
+
+find_program(Z3_EXECUTABLE z3
+   PATH_SUFFIXES bin
+   )
 
-if(Z3_INCLUDE_DIR AND Z3_EXECUTABLE)
+if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
 execute_process (COMMAND ${Z3_EXECUTABLE} -version
   OUTPUT_VARIABLE libz3_version_str
   ERROR_QUIET

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=344464&r1=344463&r2=344464&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3Const

[PATCH] D52920: Introduce code_model macros

2018-10-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

LGTM as well. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D52920



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


[PATCH] D53066: [RFC] [Driver] Use forward slashes in most linker arguments

2018-10-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 169579.
mstorsjo retitled this revision from "[RFC] [MinGW] Print paths with forward 
slashes in commands printed with -v" to "[RFC] [Driver] Use forward slashes in 
most linker arguments".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Tested the earlier discussed solution, and it seems to work fine for my 
particular case with libtool.


https://reviews.llvm.org/D53066

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -378,15 +378,15 @@
 SmallString<128> P(LibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + 
Suffix);
 if (getVFS().exists(P))
-  return P.str();
+  return llvm::sys::path::convert_to_slash(P);
   }
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
   const char *Env = TT.isAndroid() ? "-android" : "";
   SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
-  return Path.str();
+  return llvm::sys::path::convert_to_slash(Path);
 }
 
 const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
@@ -425,7 +425,7 @@
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return D.GetFilePath(Name, *this);
+  return llvm::sys::path::convert_to_slash(D.GetFilePath(Name, *this));
 }
 
 std::string ToolChain::GetProgramPath(const char *Name) const {
@@ -774,12 +774,14 @@
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getLibraryPaths())
-if(LibPath.length() > 0)
-  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if (LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(
+  StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
 
   for (const auto &LibPath : getFilePaths())
-if(LibPath.length() > 0)
-  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if (LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(
+  StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -378,15 +378,15 @@
 SmallString<128> P(LibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
 if (getVFS().exists(P))
-  return P.str();
+  return llvm::sys::path::convert_to_slash(P);
   }
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
   const char *Env = TT.isAndroid() ? "-android" : "";
   SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
-  return Path.str();
+  return llvm::sys::path::convert_to_slash(Path);
 }
 
 const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
@@ -425,7 +425,7 @@
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return D.GetFilePath(Name, *this);
+  return llvm::sys::path::convert_to_slash(D.GetFilePath(Name, *this));
 }
 
 std::string ToolChain::GetProgramPath(const char *Name) const {
@@ -774,12 +774,14 @@
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getLibraryPaths())
-if(LibPath.length() > 0)
-  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if (LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(
+  StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
 
   for (const auto &LibPath : getFilePaths())
-if(LibPath.length() > 0)
-  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if (LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(
+  StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r344468 - Move some helpers from the global namespace into anonymous ones.

2018-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 13 15:18:22 2018
New Revision: 344468

URL: http://llvm.org/viewvc/llvm-project?rev=344468&view=rev
Log:
Move some helpers from the global namespace into anonymous ones.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Sat Oct 13 15:18:22 2018
@@ -72,7 +72,8 @@ public:
 } // namespace
 
 // Returns callbacks that can be used to update the FileIndex with new ASTs.
-std::unique_ptr makeUpdateCallbacks(FileIndex *FIndex) {
+static std::unique_ptr
+makeUpdateCallbacks(FileIndex *FIndex) {
   struct CB : public ParsingCallbacks {
 CB(FileIndex *FIndex) : FIndex(FIndex) {}
 FileIndex *FIndex;


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


r344468 - Move some helpers from the global namespace into anonymous ones.

2018-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 13 15:18:22 2018
New Revision: 344468

URL: http://llvm.org/viewvc/llvm-project?rev=344468&view=rev
Log:
Move some helpers from the global namespace into anonymous ones.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Sat Oct 13 
15:18:22 2018
@@ -196,6 +196,7 @@ bool CallAndMessageChecker::uninitRefOrP
   return false;
 }
 
+namespace {
 class FindUninitializedField {
 public:
   SmallVector FieldChain;
@@ -234,6 +235,7 @@ public:
 return false;
   }
 };
+} // namespace
 
 bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
SVal V,

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Sat Oct 13 
15:18:22 2018
@@ -337,6 +337,7 @@ void ExprInspectionChecker::analyzerDeno
   C.addTransition(C.getState()->set(Sym, E));
 }
 
+namespace {
 class SymbolExpressor
 : public SymExprVisitor> {
   ProgramStateRef State;
@@ -369,6 +370,7 @@ public:
 return None;
   }
 };
+} // namespace
 
 void ExprInspectionChecker::analyzerExpress(const CallExpr *CE,
 CheckerContext &C) const {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sat Oct 13 15:18:22 2018
@@ -98,11 +98,12 @@ STATISTIC(NumMaxBlockCountReachedInInlin
 STATISTIC(NumTimesRetriedWithoutInlining,
 "The # of times we re-evaluated a call without inlining");
 
-
 
//===--===//
 // Internal program state traits.
 
//===--===//
 
+namespace {
+
 // When modeling a C++ constructor, for a variety of reasons we need to track
 // the location of the object for the duration of its ConstructionContext.
 // ObjectsUnderConstruction maps statements within the construction context
@@ -164,6 +165,7 @@ public:
 return Impl < RHS.Impl;
   }
 };
+} // namespace
 
 typedef llvm::ImmutableMap
 ObjectsUnderConstructionMap;


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


r344469 - Try harder to fix test/Driver/cl-showfilenames.c

2018-10-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Sat Oct 13 15:22:03 2018
New Revision: 344469

URL: http://llvm.org/viewvc/llvm-project?rev=344469&view=rev
Log:
Try harder to fix test/Driver/cl-showfilenames.c

Follow-up to r344462.

Modified:
cfe/trunk/test/Driver/cl-showfilenames.c

Modified: cfe/trunk/test/Driver/cl-showfilenames.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-showfilenames.c?rev=344469&r1=344468&r2=344469&view=diff
==
--- cfe/trunk/test/Driver/cl-showfilenames.c (original)
+++ cfe/trunk/test/Driver/cl-showfilenames.c Sat Oct 13 15:22:03 2018
@@ -2,11 +2,11 @@
 // target Windows.
 // REQUIRES: x86-registered-target
 
-// RUN: %clang_cl /c /Fo%T/ /showFilenames -- %s 2>&1 | FileCheck 
-check-prefix=show %s
-// RUN: %clang_cl /c /Fo%T/ /showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | 
FileCheck -check-prefix=multiple %s
+// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames -- %s 2>&1 | 
FileCheck -check-prefix=show %s
+// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames -- %s 
%S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s
 
-// RUN: %clang_cl /c /Fo%T/ -- %s 2>&1 | FileCheck -check-prefix=noshow %s
-// RUN: %clang_cl /c /Fo%T/ /showFilenames /showFilenames- -- %s 2>&1 | 
FileCheck -check-prefix=noshow %s
+// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ -- %s 2>&1 | FileCheck 
-check-prefix=noshow %s
+// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames 
/showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s
 
 
 #pragma message "Hello"


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


[PATCH] D53248: [Driver] Support direct split DWARF emission for Fuchsia

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: pcc, jakehehrlich, echristo.
Herald added subscribers: cfe-commits, JDevlieghere, aprantl, mgorny.

This enables the driver support for direct split DWARF emission for
Fuchsia in addition to Linux.


Repository:
  rC Clang

https://reviews.llvm.org/D53248

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -149,3 +149,8 @@
 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -gsplit-dwarf -c %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
+// CHECK-SPLIT-DWARF: "-split-dwarf-file" "fuchsia.dwo"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3047,8 +3047,8 @@
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
+  // FIXME: Currently only works on Linux and Fuchsia.
+  if (T.isOSLinux() || T.isOSFuchsia()) {
 if (!SplitDWARFInlining)
   CmdArgs.push_back("-fno-split-dwarf-inlining");
 
@@ -3814,7 +3814,8 @@
 
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
-  bool SplitDWARF = SplitDWARFArg && RawTriple.isOSLinux() &&
+  bool SplitDWARF = SplitDWARFArg &&
+(RawTriple.isOSLinux() || RawTriple.isOSFuchsia()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   const char *SplitDWARFOut;
@@ -5752,8 +5753,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  const llvm::Triple &T = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux()) {
+  (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
 CmdArgs.push_back(SplitDebugName(Args, Input));
   }
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -133,6 +133,7 @@
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
+  llvm-dwp
   llvm-lib
   llvm-nm
   llvm-objcopy


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -149,3 +149,8 @@
 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -gsplit-dwarf -c %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
+// CHECK-SPLIT-DWARF: "-split-dwarf-file" "fuchsia.dwo"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3047,8 +3047,8 @@
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
+  // FIXME: Currently only works on Linux and Fuchsia.
+  if (T.isOSLinux() || T.isOSFuchsia()) {
 if (!SplitDWARFInlining)
   CmdArgs.push_back("-fno-split-dwarf-inlining");
 
@@ -3814,7 +3814,8 @@
 
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
-  bool SplitDWARF = SplitDWARFArg && RawTriple.isOSLinux() &&
+  bool SplitDWARF = SplitDWARFArg &&
+(RawTriple.isOSLinux() || RawTriple.isOSFuchsia()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   const char *SplitDWARFOut;
@@ -5752,8 +5753,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  const llvm::Triple &T = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux()) {
+  (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
 CmdArgs.push_back(SplitDebugName(Args, Input));
   }
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -133,6 +133,7 @@
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
+  llvm-dwp
   llvm-lib
   llvm-nm
   llvm-objcopy
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.

[PATCH] D53248: [Driver] Support direct split DWARF emission for Fuchsia

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I'm fine moving the test to `test/Driver/split-debug.c` if you prefer to have 
all target tests in a single file.


Repository:
  rC Clang

https://reviews.llvm.org/D53248



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


[PATCH] D53231: [Sema] Fix PR38987: keep end location of a direct initializer list

2018-10-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for looking into this! Do you know why the InitializationKind doesn't 
contain the right brace locations in this scenario? Should it?


Repository:
  rC Clang

https://reviews.llvm.org/D53231



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


[PATCH] D53248: [Driver] Support direct split DWARF emission for Fuchsia

2018-10-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

I'm ok with the "here are a bunch of fuchsia tests" file :)

-eric


Repository:
  rC Clang

https://reviews.llvm.org/D53248



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


[PATCH] D53249: Force Hexagon to use default (hexagon-link) linker

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: sidneym, rsmith.
Herald added a subscriber: cfe-commits.

Hexagon relies on hexagon-link so invoke Clang to -fuse-ld=ld to
always use the default linker, otherwise tests break when the Clang
default linker is set to anything other than default.


Repository:
  rC Clang

https://reviews.llvm.org/D53249

Files:
  clang/test/Driver/hexagon-toolchain-elf.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -877,7 +877,7 @@
 // Check that we do not pass --hash-style=gnu or --hash-style=both to
 // hexagon linux linker
 // RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=hexagon-linux-gnu \
+// RUN: --target=hexagon-linux-gnu -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-HEXAGON %s
 // CHECK-HEXAGON: "{{.*}}hexagon-link{{(.exe)?}}"
 // CHECK-HEXAGON-NOT: "--hash-style={{gnu|both}}"
Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -57,63 +57,63 @@
 // -
 // Test -mcpu= -mv
 // -
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv4 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK020 %s
 // CHECK020: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
 // CHECK020: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v4/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv5 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK021 %s
 // CHECK021: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
 // CHECK021: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v5/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv55 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK022 %s
 // CHECK022: "-cc1" {{.*}} "-target-cpu" "hexagonv55"
 // CHECK022: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v55/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv60 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK023 %s
 // CHECK023: "-cc1" {{.*}} "-target-cpu" "hexagonv60"
 // CHECK023: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v60/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv62 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK024 %s
 // CHECK024: "-cc1" {{.*}} "-target-cpu" "hexagonv62"
 // CHECK024: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v62/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv65 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // CHECK025: "-cc1" {{.*}} "-target-cpu" "hexagonv65"
 // CHECK025: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -O3 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK026 %s
 // CHECK026-NOT: "-ffp-contract=fast"
 // CHECK026: hexagon-link
 
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -O3 -ffp-contract=off \
 // RUN:   %s 2>&1 \
@@ -128,7 +128,7 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // Defaults for C
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=ld \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv60 \
 // RUN:   %s 2>&1 \
@@ -149,7

[PATCH] D53249: Force Hexagon to use default (hexagon-link) linker

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This was introduced in https://reviews.llvm.org/D53038 which broke all our bots 
that use `CLANG_DEFAULT_LINKER="lld"`. The same solution was applied to other 
targets (e.g. https://reviews.llvm.org/D49899) and while isn't great it should 
at least unbreak vendors that use non-default linkers.


Repository:
  rC Clang

https://reviews.llvm.org/D53249



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


[PATCH] D53250: [ToolChain] Use default linker if the toolchain uses a custom one

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: rsmith, Hahnfeld.
Herald added a subscriber: cfe-commits.

When the toolchain overrides default linker, use it rather than the
default Clang one which is unlikely to be useable for that toolchain
anyway. This avoids the need to explicitly specify -fuse-ld in tests
for all targets that use custom linkers.


Repository:
  rC Clang

https://reviews.llvm.org/D53250

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -424,44 +424,46 @@
   return getTool(AC);
 }
 
-std::string ToolChain::GetFilePath(const char *Name) const {
+std::string ToolChain::GetFilePath(StringRef Name) const {
   return D.GetFilePath(Name, *this);
 }
 
-std::string ToolChain::GetProgramPath(const char *Name) const {
+std::string ToolChain::GetProgramPath(StringRef Name) const {
   return D.GetProgramPath(Name, *this);
 }
 
 std::string ToolChain::GetLinkerPath() const {
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef DefaultLinker = getDefaultLinker();
 
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
 if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;
-  } else if (UseLinker.empty() || UseLinker == "ld") {
+  } else if (UseLinker.empty() || UseLinker == "ld" || DefaultLinker != "ld") {
 // If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-return GetProgramPath(getDefaultLinker());
+// or if the toolchain overrides default linker, then use whatever the
+// default linker is.
+return GetProgramPath(DefaultLinker);
   } else {
 llvm::SmallString<8> LinkerName;
 if (Triple.isOSDarwin())
   LinkerName.append("ld64.");
 else
   LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+std::string LinkerPath(GetProgramPath(LinkerName));
 if (llvm::sys::fs::can_execute(LinkerPath))
   return LinkerPath;
   }
 
   if (A)
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 
-  return GetProgramPath(getDefaultLinker());
+  return GetProgramPath(DefaultLinker);
 }
 
 types::ID ToolChain::LookupTypeForExtension(StringRef Ext) const {
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -286,8 +286,8 @@
 
   // Helper methods
 
-  std::string GetFilePath(const char *Name) const;
-  std::string GetProgramPath(const char *Name) const;
+  std::string GetFilePath(StringRef Name) const;
+  std::string GetProgramPath(StringRef Name) const;
 
   /// Returns the linker path, respecting the -fuse-ld= argument to determine
   /// the linker suffix or name.


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -424,44 +424,46 @@
   return getTool(AC);
 }
 
-std::string ToolChain::GetFilePath(const char *Name) const {
+std::string ToolChain::GetFilePath(StringRef Name) const {
   return D.GetFilePath(Name, *this);
 }
 
-std::string ToolChain::GetProgramPath(const char *Name) const {
+std::string ToolChain::GetProgramPath(StringRef Name) const {
   return D.GetProgramPath(Name, *this);
 }
 
 std::string ToolChain::GetLinkerPath() const {
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef DefaultLinker = getDefaultLinker();
 
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
 if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;
-  } else if (UseLinker.empty() || UseLinker == "ld") {
+  } else if (UseLinker.empty() || UseLinker == "ld" || DefaultLinker != "ld") {
 // If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-return GetProgramPath(getDefaultLinker());
+// or if the toolchain overrides default linker, then use whatever the
+// default linker is.
+return GetProgramPath(DefaultLinker);
   } else {
 llvm::SmallString<8> LinkerName;
 if (Triple.isOSDarwin())
   LinkerName.append("ld64.");
 else
   LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+std::string LinkerPath(GetProgramPath(LinkerNa

[PATCH] D53250: [ToolChain] Use default linker if the toolchain uses a custom one

2018-10-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This should avoid workarounds such as https://reviews.llvm.org/D49899 or 
https://reviews.llvm.org/D53249.


Repository:
  rC Clang

https://reviews.llvm.org/D53250



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