Re: [PATCH] D14014: Checker of proper vfork usage
ygribov added a comment. > What happens when this checker and the security.insecureAPI.vfork are enabled > at the same time? Both checkers will emit warnings independently (which I think is ok). > Did you run this checker on a large body of code? Did it find any issues? Yes, I've ran it on Android 5 and found several violations (function calls, assignments). Frankly I think that most existing uses of vfork do not obey the specification. > What is needed to turn this into a non-alpha checker? I guess that's question for maintainers) We have to consider that vfork is used rarely enough. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:44 @@ +43,3 @@ +// Pattern matches to extract lhs in `lhs = vfork()' statement. +static const VarDecl *GetAssignedVariable(const CallEvent &Call, + CheckerContext &C) { zaks.anna wrote: > This should be added as a utility function. Does this exist elsewhere? Frankly this function only handles two common patterns right now (assignment and initialization). This was enough for all uses of vfork which I've seen but I'm afraid that general case may require much more work. I'll try to find any dups. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:63 @@ +62,3 @@ + return D; + } while (0); + zaks.anna wrote: > Can this be rewritten so that it is more clear why this terminates? > Also, I'd prefer to use "while(true)". Actually this isn't really a loop - it's a common do-while-false idiom which allows to reduce amount of nesting. You can check for similar pattern in ArrayBoundCheckerV2.cpp and also other parts of codebase. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:155 @@ +154,3 @@ +if (!BT) + BT.reset(new BuiltinBug(this, "Dangerous construct in vforked process")); + zaks.anna wrote: > "a vforked process"? Right. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:163 @@ +162,3 @@ +auto Report = llvm::make_unique(*BT, os.str(), N); +C.emitReport(std::move(Report)); + } zaks.anna wrote: > Ideally, we would point out where the vfork has occurred along the path with > a BugReportVisitor. (But it's not a blocker.) Yeah, that would be nice. But vfork code blocks are typically very small (5-10 LOC) so it'll all be clear anyway. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:208 @@ +207,3 @@ + && !isCallWhitelisted(Call.getCalleeIdentifier(), C)) +reportBug("Calling functions (except exec(3) or _exit(2))", C); +} zaks.anna wrote: > We are not listing the full whitelist here. Should we drop the "(except ..)" > from the message? What about except exec*() or _exit() ? Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:226 @@ +225,3 @@ + + reportBug("Assigning variables (except return value of vfork)", C); +} zaks.anna wrote: > "except return value" -> "except the return value"? Or maybe we should drop > the "(except ...)" here as well to make the message shorter. I'd rather keep it. Comment at: test/Analysis/vfork.c:24 @@ +23,3 @@ +// Ensure that writing variables is prohibited. +x = 0; // expected-warning{{}} +break; zaks.anna wrote: > We should check for the exact expected warning in regression tests. Ok. http://reviews.llvm.org/D14014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13673: Add initial support for the MUSL C library.
vkalintiris added a comment. In http://reviews.llvm.org/D13673#271518, @EricWF wrote: > Thanks for the update, I think this should be good to go. I'll give it a > final once over tonight. Ping. http://reviews.llvm.org/D13673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12358: [Analyzer] Widening loops which do not exit
seaneveson updated this revision to Diff 38717. seaneveson added a comment. Updated to latest revision http://reviews.llvm.org/D12358 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/CMakeLists.txt lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/LoopWidening.cpp test/Analysis/analyzer-config.c test/Analysis/analyzer-config.cpp test/Analysis/loop-widening.c Index: test/Analysis/loop-widening.c === --- /dev/null +++ test/Analysis/loop-widening.c @@ -0,0 +1,190 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s + +void clang_analyzer_eval(int); +void clang_analyzer_warnIfReached(); + +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); + +void loop_which_iterates_limit_times_not_widened() { + int i; + int x = 1; + // Check loop isn't widened by checking x isn't invalidated + for (i = 0; i < 1; ++i) {} + clang_analyzer_eval(x == 1); // expected-warning {{TRUE}} + for (i = 0; i < 2; ++i) {} + clang_analyzer_eval(x == 1); // expected-warning {{TRUE}} + for (i = 0; i < 3; ++i) {} + // FIXME loss of precision as a result of evaluating the widened loop body + // *instead* of the last iteration. + clang_analyzer_eval(x == 1); // expected-warning {{UNKNOWN}} +} + +int a_global; + +void loop_evaluated_before_widening() { + int i; + a_global = 1; + for (i = 0; i < 10; ++i) { +if (i == 2) { + // True before widening then unknown after. + clang_analyzer_eval(a_global == 1); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} +} + } + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void warnings_after_loop() { + int i; + for (i = 0; i < 10; ++i) {} + char *m = (char*)malloc(12); +} // expected-warning {{Potential leak of memory pointed to by 'm'}} + +void for_loop_exits() { + int i; + for (i = 0; i < 10; ++i) {} + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void while_loop_exits() { + int i = 0; + while (i < 10) {++i;} + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void do_while_loop_exits() { + int i = 0; + do {++i;} while (i < 10); + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void loop_body_is_widened() { + int i = 0; + while (i < 100) { +if (i > 10) { + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} +++i; + } + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void invariably_infinite_loop() { + int i = 0; + while (1) { ++i; } + clang_analyzer_warnIfReached(); // no-warning +} + +void invariably_infinite_break_loop() { + int i = 0; + while (1) { +++i; +int x = 1; +if (!x) break; + } + clang_analyzer_warnIfReached(); // no-warning +} + +void reachable_break_loop() { + int i = 0; + while (1) { +++i; +if (i == 100) break; + } + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void condition_constrained_true_in_loop() { + int i = 0; + while (i < 50) { +clang_analyzer_eval(i < 50); // expected-warning {{TRUE}} +++i; + } + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void condition_constrained_false_after_loop() { + int i = 0; + while (i < 50) { +++i; + } + clang_analyzer_eval(i >= 50); // expected-warning {{TRUE}} + clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} +} + +void multiple_exit_test() { + int x = 0; + int i = 0; + while (i < 50) { +if (x) { + i = 10; + break; +} +++i; + } + // Reachable by 'normal' exit + if (i == 50) clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} + // Reachable by break point + if (i == 10) clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} + // Not reachable + if (i < 10) clang_analyzer_warnIfReached(); // no-warning + if (i > 10 && i < 50) clang_analyzer_warnIfReached(); // no-warning +} + +void pointer_doesnt_leak_from_loop() { + int *h_ptr = (int *) malloc(sizeof(int)); + for (int i = 0; i < 2; ++i) {} + for (int i = 0; i < 10; ++i) {} // no-warning + free(h_ptr); +} + +int g_global; + +void unknown_after_loop(int s_arg) { + g_global = 0; + s_arg = 1; + int s_local = 2; + int *h_ptr = malloc(sizeof(int)); + + for (int i = 0; i < 10; ++i) {} + + clang_analyzer_eval(g_global); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(s_arg); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(s_local); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(h_ptr == 0); // expected-warning {{UNKNOWN}} + free(h_ptr); +} + +void variable_bound_exiting_loops_widened(int x) { + int i = 0; + int t = 1; + while (i < x) { +
Re: [PATCH] D12358: [Analyzer] Widening loops which do not exit
This revision was automatically updated to reflect the committed changes. Closed by commit rL251621: [Analyzer] Widening loops which do not exit (authored by seaneveson). Changed prior to commit: http://reviews.llvm.org/D12358?vs=38717&id=38718#toc Repository: rL LLVM http://reviews.llvm.org/D12358 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp cfe/trunk/test/Analysis/analyzer-config.c cfe/trunk/test/Analysis/analyzer-config.cpp cfe/trunk/test/Analysis/loop-widening.c Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -262,6 +262,9 @@ /// \sa shouldInlineLambdas Optional InlineLambdas; + /// \sa shouldWidenLoops + Optional WidenLoops; + /// A helper function that retrieves option for a given full-qualified /// checker name. /// Options for checkers can be specified via 'analyzer-config' command-line @@ -526,6 +529,10 @@ /// generated each time a LambdaExpr is visited. bool shouldInlineLambdas(); + /// Returns true if the analysis should try to widen loops. + /// This is controlled by the 'widen-loops' config option. + bool shouldWidenLoops(); + public: AnalyzerOptions() : AnalysisStoreOpt(RegionStoreModel), Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h @@ -0,0 +1,37 @@ +//===--- LoopWidening.h - Instruction class definition --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// This header contains the declarations of functions which are used to widen +/// loops which do not otherwise exit. The widening is done by invalidating +/// anything which might be modified by the body of the loop. +/// +//===--===// + +#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPWIDENING_H +#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPWIDENING_H + +#include "clang/Analysis/CFG.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" + +namespace clang { +namespace ento { + +/// \brief Get the states that result from widening the loop. +/// +/// Widen the loop by invalidating anything that might be modified +/// by the loop body in any iteration. +ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, +const LocationContext *LCtx, +unsigned BlockCount, +const Stmt *LoopStmt); + +} // end namespace ento +} // end namespace clang + +#endif Index: cfe/trunk/test/Analysis/analyzer-config.c === --- cfe/trunk/test/Analysis/analyzer-config.c +++ cfe/trunk/test/Analysis/analyzer-config.c @@ -25,6 +25,7 @@ // CHECK-NEXT: min-cfg-size-treat-functions-as-large = 14 // CHECK-NEXT: mode = deep // CHECK-NEXT: region-store-small-struct-limit = 2 +// CHECK-NEXT: widen-loops = false // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 14 +// CHECK-NEXT: num-entries = 15 Index: cfe/trunk/test/Analysis/loop-widening.c === --- cfe/trunk/test/Analysis/loop-widening.c +++ cfe/trunk/test/Analysis/loop-widening.c @@ -0,0 +1,190 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s + +void clang_analyzer_eval(int); +void clang_analyzer_warnIfReached(); + +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); + +void loop_which_iterates_limit_times_not_widened() { + int i; + int x = 1; + // Check loop isn't widened by checking x isn't invalidated + for (i = 0; i < 1; ++i) {} + clang_analyzer_eval(x == 1); // expected-warning {{TRUE}} + for (i = 0; i < 2; ++i) {} + clang_analyzer_eval(x == 1); // expected-warning {{TRUE}} + for (i = 0; i < 3; ++i) {} + // FIXME loss of precision as a result of evaluating the widened loop body + // *instead* of the last iteration. + clang_analyzer_eval(x == 1); // exp
r251621 - [Analyzer] Widening loops which do not exit
Author: seaneveson Date: Thu Oct 29 05:04:41 2015 New Revision: 251621 URL: http://llvm.org/viewvc/llvm-project?rev=251621&view=rev Log: [Analyzer] Widening loops which do not exit Summary: Dear All, We have been looking at the following problem, where any code after the constant bound loop is not analyzed because of the limit on how many times the same block is visited, as described in bugzillas #7638 and #23438. This problem is of interest to us because we have identified significant bugs that the checkers are not locating. We have been discussing a solution involving ranges as a longer term project, but I would like to propose a patch to improve the current implementation. Example issue: ``` for (int i = 0; i < 1000; ++i) {...something...} int *p = 0; *p = 0xDEADBEEF; ``` The proposal is to go through the first and last iterations of the loop. The patch creates an exploded node for the approximate last iteration of constant bound loops, before the max loop limit / block visit limit is reached. It does this by identifying the variable in the loop condition and finding the value which is “one away” from the loop being false. For example, if the condition is (x < 10), then an exploded node is created where the value of x is 9. Evaluating the loop body with x = 9 will then result in the analysis continuing after the loop, providing x is incremented. The patch passes all the tests, with some modifications to coverage.c, in order to make the ‘function_which_gives_up’ continue to give up, since the changes allowed the analysis to progress past the loop. This patch does introduce possible false positives, as a result of not knowing the state of variables which might be modified in the loop. I believe that, as a user, I would rather have false positives after loops than do no analysis at all. I understand this may not be the common opinion and am interested in hearing your views. There are also issues regarding break statements, which are not considered. A more advanced implementation of this approach might be able to consider other conditions in the loop, which would allow paths leading to breaks to be analyzed. Lastly, I have performed a study on large code bases and I think there is little benefit in having “max-loop” default to 4 with the patch. For variable bound loops this tends to result in duplicated analysis after the loop, and it makes little difference to any constant bound loop which will do more than a few iterations. It might be beneficial to lower the default to 2, especially for the shallow analysis setting. Please let me know your opinions on this approach to processing constant bound loops and the patch itself. Regards, Sean Eveson SN Systems - Sony Computer Entertainment Group Reviewers: jordan_rose, krememek, xazax.hun, zaks.anna, dcoughlin Subscribers: krememek, xazax.hun, cfe-commits Differential Revision: http://reviews.llvm.org/D12358 Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp cfe/trunk/test/Analysis/loop-widening.c Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Analysis/analyzer-config.c cfe/trunk/test/Analysis/analyzer-config.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=251621&r1=251620&r2=251621&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Thu Oct 29 05:04:41 2015 @@ -262,6 +262,9 @@ private: /// \sa shouldInlineLambdas Optional InlineLambdas; + /// \sa shouldWidenLoops + Optional WidenLoops; + /// A helper function that retrieves option for a given full-qualified /// checker name. /// Options for checkers can be specified via 'analyzer-config' command-line @@ -526,6 +529,10 @@ public: /// generated each time a LambdaExpr is visited. bool shouldInlineLambdas(); + /// Returns true if the analysis should try to widen loops. + /// This is controlled by the 'widen-loops' config option. + bool shouldWidenLoops(); + public: AnalyzerOptions() : AnalysisStoreOpt(RegionStoreModel), Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h?rev=251621&view=auto == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h (added) +++ cfe/trunk/include/clan
Re: [PATCH] D14152: Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.
angelgarcia updated this revision to Diff 38727. angelgarcia added a comment. Add tests. http://reviews.llvm.org/D14152 Files: include/clang/ASTMatchers/ASTMatchers.h unittests/ASTMatchers/ASTMatchersTest.cpp Index: unittests/ASTMatchers/ASTMatchersTest.cpp === --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1890,6 +1890,21 @@ EXPECT_TRUE(notMatches("class X { int f(); };", cxxMethodDecl(isPure(; } +TEST(Matcher, MatchesCopyAssignmentOperator) { + EXPECT_TRUE(matches("class X { X &operator=(X); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(const X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(volatile X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(const volatile X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(notMatches("class X { X &operator=(X &&); };", + cxxMethodDecl(isCopyAssignmentOperator(; +} + TEST(Matcher, MatchesConstMethod) { EXPECT_TRUE( matches("struct A { void foo() const; };", cxxMethodDecl(isConst(; @@ -4671,6 +4686,16 @@ decl(has(decl(equalsNode(TypedNode.bind(""))), *Node, Context)) != nullptr; } + bool verify(const BoundNodes &Nodes, ASTContext &Context, const Type *Node) { +// Use the original typed pointer to verify we can pass pointers to subtypes +// to equalsNode. +const T *TypedNode = cast(Node); +const auto *Dec = Nodes.getNodeAs("decl"); +return selectFirst( + "", match(fieldDecl(hasParent(decl(has(fieldDecl( + hasType(type(equalsNode(TypedNode)).bind(""))), + *Dec, Context)) != nullptr; + } }; TEST(IsEqualTo, MatchesNodesByIdentity) { @@ -4680,6 +4705,10 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "void f() { if (true) if(true) {} }", ifStmt().bind(""), new VerifyAncestorHasChildIsEqual())); + EXPECT_TRUE(matchAndVerifyResultTrue( + "class X { class Y {} y; };", + fieldDecl(hasName("y"), hasType(type().bind(""))).bind("decl"), + new VerifyAncestorHasChildIsEqual())); } TEST(MatchFinder, CheckProfiling) { Index: include/clang/ASTMatchers/ASTMatchers.h === --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -3385,6 +3385,23 @@ return Node.isConst(); } +/// \brief Matches if the given method declaration declares a copy assignment +/// operator. +/// +/// Given +/// \code +/// struct A { +/// A &operator=(const A &); +/// A &operator=(A &&); +/// }; +/// \endcode +/// +/// cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not +/// the second one. +AST_MATCHER(CXXMethodDecl, isCopyAssignmentOperator) { + return Node.isCopyAssignmentOperator(); +} + /// \brief Matches if the given method declaration overrides another method. /// /// Given @@ -4307,10 +4324,15 @@ /// \brief Matches if a node equals another node. /// /// \c Stmt has pointer identity in the AST. -/// AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt*, Other, 1) { return &Node == Other; } +/// \brief Matches if a node equals another node. +/// +/// \c Type has pointer identity in the AST. +AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type*, Other, 2) { +return &Node == Other; +} /// @} Index: unittests/ASTMatchers/ASTMatchersTest.cpp === --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1890,6 +1890,21 @@ EXPECT_TRUE(notMatches("class X { int f(); };", cxxMethodDecl(isPure(; } +TEST(Matcher, MatchesCopyAssignmentOperator) { + EXPECT_TRUE(matches("class X { X &operator=(X); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(const X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(volatile X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(matches("class X { X &operator=(const volatile X &); };", + cxxMethodDecl(isCopyAssignmentOperator(; + EXPECT_TRUE(notMatches("class X { X &operator=(X &&); };", + cxxMethodDecl(isCopyAssignmentOperator
Re: [PATCH] D14145: modernize-use-default supports copy constructor and copy-assignment operator.
angelgarcia updated this revision to Diff 38728. angelgarcia added a comment. Put more logic into the matchers. Btw, do you know how can I get the exception specification of a function? http://reviews.llvm.org/D14145 Files: clang-tidy/modernize/UseDefaultCheck.cpp test/clang-tidy/modernize-use-default-copy.cpp test/clang-tidy/modernize-use-default.cpp Index: test/clang-tidy/modernize-use-default.cpp === --- test/clang-tidy/modernize-use-default.cpp +++ test/clang-tidy/modernize-use-default.cpp @@ -1,137 +1,159 @@ // RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -class A { +// Out of line definition. +class OL { public: - A(); - ~A(); + OL(); + ~OL(); }; -A::A() {} +OL::OL() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default] -// CHECK-FIXES: A::A() = default; -A::~A() {} +// CHECK-FIXES: OL::OL() = default; +OL::~OL() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default] -// CHECK-FIXES: A::~A() = default; +// CHECK-FIXES: OL::~OL() = default; // Inline definitions. -class B { +class IL { public: - B() {} + IL() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: B() = default; - ~B() {} + // CHECK-FIXES: IL() = default; + ~IL() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~B() = default; + // CHECK-FIXES: ~IL() = default; }; +// Non-empty body. void f(); - -class C { +class NE { public: - // Non-empty constructor body. - C() { f(); } - // Non-empty destructor body. - ~C() { f(); } + NE() { f(); } + ~NE() { f(); } }; -class D { +// Initializer or arguments. +class IA { public: // Constructor with initializer. - D() : Field(5) {} + IA() : Field(5) {} // Constructor with arguments. - D(int Arg1, int Arg2) {} + IA(int Arg1, int Arg2) {} int Field; }; // Private constructor/destructor. -class E { - E() {} +class Priv { + Priv() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: E() = default; - ~E() {} + // CHECK-FIXES: Priv() = default; + ~Priv() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~E() = default; + // CHECK-FIXES: ~Priv() = default; }; // struct. -struct F { - F() {} +struct ST { + ST() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: F() = default; - ~F() {} + // CHECK-FIXES: ST() = default; + ~ST() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: F() = default; + // CHECK-FIXES: ST() = default; }; // Deleted constructor/destructor. -class G { +class Del { public: - G() = delete; - ~G() = delete; + Del() = delete; + ~Del() = delete; }; // Do not remove other keywords. -class H { +class KW { public: - explicit H() {} + explicit KW() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: explicit H() = default; - virtual ~H() {} + // CHECK-FIXES: explicit KW() = default; + virtual ~KW() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: virtual ~H() = default; + // CHECK-FIXES: virtual ~KW() = default; }; // Nested class. -struct I { - struct II { -II() {} +struct N { + struct NN { +NN() {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' -// CHECK-FIXES: II() = default; -~II() {} +// CHECK-FIXES: NN() = default; +~NN() {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' -// CHECK-FIXES: ~II() = default; +// CHECK-FIXES: ~NN() = default; }; int Int; }; // Class template. template -class J { +class Temp { public: - J() {} + Temp() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: J() = default; - ~J() {} + // CHECK-FIXES: Temp() = default; + ~Temp() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~J() = default; + // CHECK-FIXES: ~Temp() = default; }; // Non user-provided constructor/destructor. -struct K { +struct Imp { int Int; }; void g() { - K *PtrK = new K(); - PtrK->~K(); - delete PtrK; + Imp *PtrImp = new Imp(); + PtrImp->~Imp(); + delete PtrImp; } // Already using default. -struct L { - L() = default; - ~L() = default; -}; -struct M { - M(); - ~M(); +struct IDef { + IDef() = default; + ~IDef() = default; +}; +struct ODef { + ODef(); + ~ODef(); }; -M::M() = default; -M::~M() = default; +ODef::ODef() = default; +ODef::~ODef() = default; // Delegating constructor and overriden destructor. -struct N : H { - N() : H() {} - ~N() override {} +struct DC : KW { + DC() : KW() {} + ~DC() override {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~N(
Re: [PATCH] D14145: modernize-use-default supports copy constructor and copy-assignment operator.
angelgarcia updated this revision to Diff 38730. angelgarcia marked an inline comment as done. angelgarcia added a comment. Remove debugging code. http://reviews.llvm.org/D14145 Files: clang-tidy/modernize/UseDefaultCheck.cpp test/clang-tidy/modernize-use-default-copy.cpp test/clang-tidy/modernize-use-default.cpp Index: test/clang-tidy/modernize-use-default.cpp === --- test/clang-tidy/modernize-use-default.cpp +++ test/clang-tidy/modernize-use-default.cpp @@ -1,137 +1,159 @@ // RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -class A { +// Out of line definition. +class OL { public: - A(); - ~A(); + OL(); + ~OL(); }; -A::A() {} +OL::OL() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default] -// CHECK-FIXES: A::A() = default; -A::~A() {} +// CHECK-FIXES: OL::OL() = default; +OL::~OL() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default] -// CHECK-FIXES: A::~A() = default; +// CHECK-FIXES: OL::~OL() = default; // Inline definitions. -class B { +class IL { public: - B() {} + IL() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: B() = default; - ~B() {} + // CHECK-FIXES: IL() = default; + ~IL() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~B() = default; + // CHECK-FIXES: ~IL() = default; }; +// Non-empty body. void f(); - -class C { +class NE { public: - // Non-empty constructor body. - C() { f(); } - // Non-empty destructor body. - ~C() { f(); } + NE() { f(); } + ~NE() { f(); } }; -class D { +// Initializer or arguments. +class IA { public: // Constructor with initializer. - D() : Field(5) {} + IA() : Field(5) {} // Constructor with arguments. - D(int Arg1, int Arg2) {} + IA(int Arg1, int Arg2) {} int Field; }; // Private constructor/destructor. -class E { - E() {} +class Priv { + Priv() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: E() = default; - ~E() {} + // CHECK-FIXES: Priv() = default; + ~Priv() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~E() = default; + // CHECK-FIXES: ~Priv() = default; }; // struct. -struct F { - F() {} +struct ST { + ST() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: F() = default; - ~F() {} + // CHECK-FIXES: ST() = default; + ~ST() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: F() = default; + // CHECK-FIXES: ST() = default; }; // Deleted constructor/destructor. -class G { +class Del { public: - G() = delete; - ~G() = delete; + Del() = delete; + ~Del() = delete; }; // Do not remove other keywords. -class H { +class KW { public: - explicit H() {} + explicit KW() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: explicit H() = default; - virtual ~H() {} + // CHECK-FIXES: explicit KW() = default; + virtual ~KW() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: virtual ~H() = default; + // CHECK-FIXES: virtual ~KW() = default; }; // Nested class. -struct I { - struct II { -II() {} +struct N { + struct NN { +NN() {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' -// CHECK-FIXES: II() = default; -~II() {} +// CHECK-FIXES: NN() = default; +~NN() {} // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' -// CHECK-FIXES: ~II() = default; +// CHECK-FIXES: ~NN() = default; }; int Int; }; // Class template. template -class J { +class Temp { public: - J() {} + Temp() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: J() = default; - ~J() {} + // CHECK-FIXES: Temp() = default; + ~Temp() {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~J() = default; + // CHECK-FIXES: ~Temp() = default; }; // Non user-provided constructor/destructor. -struct K { +struct Imp { int Int; }; void g() { - K *PtrK = new K(); - PtrK->~K(); - delete PtrK; + Imp *PtrImp = new Imp(); + PtrImp->~Imp(); + delete PtrImp; } // Already using default. -struct L { - L() = default; - ~L() = default; -}; -struct M { - M(); - ~M(); +struct IDef { + IDef() = default; + ~IDef() = default; +}; +struct ODef { + ODef(); + ~ODef(); }; -M::M() = default; -M::~M() = default; +ODef::ODef() = default; +ODef::~ODef() = default; // Delegating constructor and overriden destructor. -struct N : H { - N() : H() {} - ~N() override {} +struct DC : KW { + DC() : KW() {} + ~DC() override {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ~N() override = default; + // CHECK-FIXES:
[PATCH] D14176: Only copy small types in modernize-loop-convert.
angelgarcia created this revision. angelgarcia added a reviewer: klimek. angelgarcia added subscribers: cfe-commits, alexfh. If the size of the type is above a certain bound, we'll take a const reference. This bound can be set as an option. For now, the default value is 16 bytes. http://reviews.llvm.org/D14176 Files: clang-tidy/modernize/LoopConvertCheck.cpp clang-tidy/modernize/LoopConvertCheck.h clang-tidy/modernize/ModernizeTidyModule.cpp test/clang-tidy/Inputs/modernize-loop-convert/structures.h test/clang-tidy/modernize-loop-convert-basic.cpp Index: test/clang-tidy/modernize-loop-convert-basic.cpp === --- test/clang-tidy/modernize-loop-convert-basic.cpp +++ test/clang-tidy/modernize-loop-convert-basic.cpp @@ -113,6 +113,14 @@ // CHECK-FIXES: for (const auto & Elem : NonCopy) // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X); + const TriviallyCopyableButBig Big[N]{}; + for (int I = 0; I < N; ++I) { +printf("2 * %d = %d\n", Big[I].X, Big[I].X + Big[I].X); + } + // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead + // CHECK-FIXES: for (const auto & Elem : Big) + // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X); + bool Something = false; for (int I = 0; I < N; ++I) { if (Something) Index: test/clang-tidy/Inputs/modernize-loop-convert/structures.h === --- test/clang-tidy/Inputs/modernize-loop-convert/structures.h +++ test/clang-tidy/Inputs/modernize-loop-convert/structures.h @@ -23,6 +23,11 @@ int X; }; +struct TriviallyCopyableButBig { + int X; + char Array[16]; +}; + struct S { typedef MutableVal *iterator; typedef const MutableVal *const_iterator; Index: clang-tidy/modernize/ModernizeTidyModule.cpp === --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -47,6 +47,10 @@ ClangTidyOptions getModuleOptions() override { ClangTidyOptions Options; auto &Opts = Options.CheckOptions; +// For types whose size in bytes is above this threshold, we prefer taking a +// const-reference than making a copy. +Opts["modernize-loop-convert.MaxCopySize"] = "16"; + Opts["modernize-loop-convert.MinConfidence"] = "reasonable"; Opts["modernize-loop-convert.NamingStyle"] = "CamelCase"; Opts["modernize-pass-by-value.IncludeStyle"] = "llvm";// Also: "google". Index: clang-tidy/modernize/LoopConvertCheck.h === --- clang-tidy/modernize/LoopConvertCheck.h +++ clang-tidy/modernize/LoopConvertCheck.h @@ -66,6 +66,7 @@ const ForStmt *Loop, LoopFixerKind FixerKind); std::unique_ptr TUInfo; + const unsigned long long MaxCopySize; const Confidence::Level MinConfidence; const VariableNamer::NamingStyle NamingStyle; }; Index: clang-tidy/modernize/LoopConvertCheck.cpp === --- clang-tidy/modernize/LoopConvertCheck.cpp +++ clang-tidy/modernize/LoopConvertCheck.cpp @@ -230,18 +230,18 @@ // FIXME: Also, a record doesn't necessarily need begin() and end(). Free // functions called begin() and end() taking the container as an argument // are also allowed. - TypeMatcher RecordWithBeginEnd = qualType( - anyOf(qualType(isConstQualified(), - hasDeclaration(cxxRecordDecl( - hasMethod(cxxMethodDecl(hasName("begin"), isConst())), - hasMethod(cxxMethodDecl(hasName("end"), - isConst() // hasDeclaration - ),// qualType -qualType(unless(isConstQualified()), - hasDeclaration( - cxxRecordDecl(hasMethod(hasName("begin")), + TypeMatcher RecordWithBeginEnd = qualType(anyOf( + qualType(isConstQualified(), + hasDeclaration(cxxRecordDecl( + hasMethod(cxxMethodDecl(hasName("begin"), isConst())), + hasMethod(cxxMethodDecl(hasName("end"), + isConst() // hasDeclaration + ),// qualType + qualType( + unless(isConstQualified()), + hasDeclaration(cxxRecordDecl(hasMethod(hasName("begin")), hasMethod(hasName("end") // qualType -)); + )); StatementMatcher SizeCallMatcher = cxxMemberCallExpr( argumentCountIs(0), @@ -409,6 +409,7 @@ LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo), + MaxCopySize(std::stoull(Options.get("MaxC
Re: [PATCH] D14014: Checker of proper vfork usage
ygribov updated this revision to Diff 38740. ygribov added a comment. Updated after Anna's review. http://reviews.llvm.org/D14014 Files: lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/VforkChecker.cpp test/Analysis/Inputs/system-header-simulator.h test/Analysis/vfork.c Index: test/Analysis/vfork.c === --- /dev/null +++ test/Analysis/vfork.c @@ -0,0 +1,114 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.unix.Vfork -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.unix.Vfork -verify -x c++ %s + +#include "Inputs/system-header-simulator.h" + +void foo(); + +// Ensure that child process is properly checked. +int f1(int x) { + pid_t pid = vfork(); + if (pid != 0) +return 0; + + switch (x) { + case 0: +// Ensure that modifying pid is ok. +pid = 1; // no-warning +// Ensure that calling whitelisted routines is ok. +execl("", "", 0); // no-warning +_exit(1); // no-warning +break; + case 1: +// Ensure that writing variables is prohibited. +x = 0; // expected-warning{{Assigning variables (except return value of vfork) is prohibited after a successful vfork}} +break; + case 2: +// Ensure that calling functions is prohibited. +foo(); // expected-warning{{Calling functions (except exec*() or _exit()) is prohibited after a successful vfork}} +break; + default: +// Ensure that returning from function is prohibited. +return 0; + } + + while(1); +} // expected-warning{{Returning from a function is prohibited after a successful vfork}} + +// Same as previous but without explicit pid variable. +int f2(int x) { + pid_t pid = vfork(); + + switch (x) { + case 0: +// Ensure that writing pid is ok. +pid = 1; // no-warning +// Ensure that calling whitelisted routines is ok. +execl("", "", 0); // no-warning +_exit(1); // no-warning +break; + case 1: +// Ensure that writing variables is prohibited. +x = 0; // expected-warning{{Assigning variables (except return value of vfork) is prohibited after a successful vfork}} +break; + case 2: +// Ensure that calling functions is prohibited. +foo(); // expected-warning{{Calling functions (except exec*() or _exit()) is prohibited after a successful vfork}} +break; + default: +// Ensure that returning from function is prohibited. +return 0; + } + + while(1); +} // expected-warning{{Returning from a function is prohibited after a successful vfork}} + +// Ensure that parent process isn't restricted. +int f3(int x) { + if (vfork() == 0) +_exit(1); + x = 0; // no-warning + foo(); // no-warning + return 0; +} // no-warning + +// Unbound pids are special so test them separately. +void f4(int x) { + switch (x) { + case 0: +vfork(); +x = 0; // expected-warning{{Assigning variables (except return value of vfork) is prohibited after a successful vfork}} +break; + + case 1: +{ + char args[2]; + switch (vfork()) { + case 0: +args[0] = 0; // expected-warning{{Assigning variables (except return value of vfork) is prohibited after a successful vfork}} +exit(1); + } + break; +} + + case 2: +{ + pid_t pid; + if ((pid = vfork()) == 0) +while(1); // no-warning + break; +} + } + while(1); +} //no-warning + + +void f5() { + // See "libxtables: move some code to avoid cautions in vfork man page" + // (http://lists.netfilter.org/pipermail/netfilter-buglog/2014-October/003280.html). + if (vfork() == 0) { +execl("prog", "arg1", 0); // no-warning +exit(1); // expected-warning{{Calling functions (except exec*() or _exit()) is prohibited after a successful vfork}} + } +} + Index: test/Analysis/Inputs/system-header-simulator.h === --- test/Analysis/Inputs/system-header-simulator.h +++ test/Analysis/Inputs/system-header-simulator.h @@ -86,3 +86,13 @@ char * p; } SomeStruct; void fakeSystemHeaderCall(SomeStruct *); + +typedef int pid_t; +pid_t fork(void); +pid_t vfork(void); +int execl(const char *path, const char *arg, ...); + +void exit(int status) __attribute__ ((__noreturn__)); +void _exit(int status) __attribute__ ((__noreturn__)); +void _Exit(int status) __attribute__ ((__noreturn__)); + Index: lib/StaticAnalyzer/Checkers/VforkChecker.cpp === --- /dev/null +++ lib/StaticAnalyzer/Checkers/VforkChecker.cpp @@ -0,0 +1,239 @@ +//===- VforkChecker.cpp Vfork usage checks --*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +
Re: [PATCH] D14014: Checker of proper vfork usage
ygribov marked 15 inline comments as done. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:45 @@ +44,3 @@ + CheckerContext &C) { + const Expr *CE = Call.getOriginExpr(); + It seems that other checkers do more or less the same throw-away predicates (e.g. see isAssignmentOp in DereferenceChecker.cpp). Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:164 @@ +163,3 @@ +// TODO: mark vfork call in BugReportVisitor +C.emitReport(std::move(Report)); + } I've added a TODO. http://reviews.llvm.org/D14014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251633 - [mips] Add support for the new mips-mti-linux toolchain.
Author: vkalintiris Date: Thu Oct 29 10:33:53 2015 New Revision: 251633 URL: http://llvm.org/viewvc/llvm-project?rev=251633&view=rev Log: [mips] Add support for the new mips-mti-linux toolchain. The original commit in r249137 added the mips-mti-linux toolchain. However, the newly added tests of that commit failed in few buildbots. This commit re-applies the original changes but XFAILs the test file which caused the buildbot failures. This will allow us to examine what's going wrong without having to commit/revert large changes. Added: cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mips-r2-hard-musl/lib/linux/libclang_rt.builtins-mips.a cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mips-r2-hard-musl/lib/linux/libclang_rt.builtins-mips.so cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mipsel-r2-hard-musl/lib/linux/libclang_rt.builtins-mipsel.a cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mipsel-r2-hard-musl/lib/linux/libclang_rt.builtins-mipsel.so cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crt1.o cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crti.o cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crtn.o cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crt1.o cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crti.o cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crtn.o cfe/trunk/test/Driver/mips-mti-linux.c Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/lib/Driver/ToolChains.h cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Driver/Tools.h Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=251633&r1=251632&r2=251633&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct 29 10:33:53 2015 @@ -2153,6 +2153,11 @@ void Driver::generatePrefixedToolNames( // FIXME: Needs a better variable than DefaultTargetTriple Names.emplace_back(DefaultTargetTriple + "-" + Tool); Names.emplace_back(Tool); + + // Allow the discovery of tools prefixed with LLVM's default target triple. + std::string LLVMDefaultTargetTriple = llvm::sys::getDefaultTargetTriple(); + if (LLVMDefaultTargetTriple != DefaultTargetTriple) +Names.emplace_back(LLVMDefaultTargetTriple + "-" + Tool); } static bool ScanDirForExecutable(SmallString<128> &Dir, @@ -2248,6 +2253,9 @@ const ToolChain &Driver::getToolChain(co case llvm::Triple::Linux: if (Target.getArch() == llvm::Triple::hexagon) TC = new toolchains::HexagonToolChain(*this, Target, Args); + else if ((Target.getVendor() == llvm::Triple::MipsTechnologies) && + !Target.hasEnvironment()) +TC = new toolchains::MipsLLVMToolChain(*this, Target, Args); else TC = new toolchains::Linux(*this, Target, Args); break; Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=251633&r1=251632&r2=251633&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Oct 29 10:33:53 2015 @@ -333,7 +333,6 @@ Tool *ToolChain::SelectTool(const JobAct std::string ToolChain::GetFilePath(const char *Name) const { return D.GetFilePath(Name, *this); - } std::string ToolChain::GetProgramPath(const char *Name) const { Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251633&r1=251632&r2=251633&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct 29 10:33:53 2015 @@ -1294,8 +1294,9 @@ bool Generic_GCC::GCCInstallationDetecto "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; - static const char *const MIPSTriples[] = { - "mips-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu"}; + static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", +"mips-mti-linux-gnu", +"mips-img-linux-gnu"}; static const char *const MIPSELLibDirs[] = {"/lib"}; static const char *const MIPSELTriples[] = { "mipsel-linux-gnu", "mipsel-linux-android", "mips-img-linux-gnu"}; @@ -1686,6 +1687,32 @@ static bool findMIPSMultilibs(const Driv }); } + // Check for Musl toolchain multilibs + MultilibSet MuslMip
Re: [PATCH] D13388: Add support for querying the visibility of a cursor
michaelwu added a comment. Review ping? http://reviews.llvm.org/D13388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14179: Remove some legacy mingw-w64 gcc struct info
martell created this revision. martell added a reviewer: rnk. martell added a subscriber: cfe-commits. GCC versions starting at 4.8+ conform to standard Windows 64-bit ABI. Not quite sure if we should keep this to support mingw-w64 and gcc 4.6 Thoughts ? Also it seems to fix: https://llvm.org/bugs/show_bug.cgi?id=24408&list_id=75541 Thanks to awson for the tip http://reviews.llvm.org/D14179 Files: lib/CodeGen/TargetInfo.cpp Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -,10 +,6 @@ if (RT->getDecl()->hasFlexibleArrayMember()) return getNaturalAlignIndirect(Ty, /*ByVal=*/false); -// FIXME: mingw-w64-gcc emits 128-bit struct as i128 -if (Width == 128 && IsMingw64) - return ABIArgInfo::getDirect( - llvm::IntegerType::get(getVMContext(), Width)); } // vectorcall adds the concept of a homogenous vector aggregate, similar to Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -,10 +,6 @@ if (RT->getDecl()->hasFlexibleArrayMember()) return getNaturalAlignIndirect(Ty, /*ByVal=*/false); -// FIXME: mingw-w64-gcc emits 128-bit struct as i128 -if (Width == 128 && IsMingw64) - return ABIArgInfo::getDirect( - llvm::IntegerType::get(getVMContext(), Width)); } // vectorcall adds the concept of a homogenous vector aggregate, similar to ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Buildbot e-mail notification has been changed
On 28 October 2015 at 16:33, Galina Kistanova via llvm-commits wrote: > E-mail notification has been changed in the buildmaster. Now it should not > count interrupted builds to figure out if notification should be send. Thanks Galina, that'll reduce the noise considerably! cheers, --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target
martell created this revision. martell added a reviewer: rnk. martell added subscribers: cfe-commits, yaron.keren, compnerd. As of commit b8a164 mingw-w64 support clang with -fms-extensions. We can built the mingw-w64 crt with clang now also. As we are dropping support for mingw.org I think switching to this would be a good move rather then using the gcc hacks we currently comply to http://sourceforge.net/p/mingw-w64/mingw-w64/ci/b8a16418409d88215cce97727a42cc25eb011f3e/ http://reviews.llvm.org/D14180 Files: lib/Driver/Tools.cpp Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4654,7 +4654,7 @@ // -fms-extensions=0 is default. if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions, - IsWindowsMSVC)) + IsWindowsMSVC || IsWindowsGNU)) CmdArgs.push_back("-fms-extensions"); // -fno-use-line-directives is default. Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4654,7 +4654,7 @@ // -fms-extensions=0 is default. if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions, - IsWindowsMSVC)) + IsWindowsMSVC || IsWindowsGNU)) CmdArgs.push_back("-fms-extensions"); // -fno-use-line-directives is default. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251638 - Add a link to the DXR project
Author: ehsan Date: Thu Oct 29 12:20:17 2015 New Revision: 251638 URL: http://llvm.org/viewvc/llvm-project?rev=251638&view=rev Log: Add a link to the DXR project DXR is a project developed at Mozilla that implements a code indexing and browsing utility on top of libclang that has features such as call graph querying. Modified: cfe/trunk/www/related.html Modified: cfe/trunk/www/related.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/related.html?rev=251638&r1=251637&r2=251638&view=diff == --- cfe/trunk/www/related.html (original) +++ cfe/trunk/www/related.html Thu Oct 29 12:20:17 2015 @@ -82,6 +82,17 @@ + DXR + + + Site: +https://github.com/mozilla/dxr#dxr";>https://github.com/mozilla/dxr + + +DXR is a code search and navigation tool aimed at making sense of large projects like Firefox. It supports full-text and regex searches as well as structural queries like "Find all the callers of this function." + + + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251639 - add support of the latest Ubuntu (Xenial Xerus)
Author: sylvestre Date: Thu Oct 29 12:27:55 2015 New Revision: 251639 URL: http://llvm.org/viewvc/llvm-project?rev=251639&view=rev Log: add support of the latest Ubuntu (Xenial Xerus) Modified: cfe/trunk/lib/Driver/ToolChains.cpp Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251639&r1=251638&r2=251639&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct 29 12:27:55 2015 @@ -3253,6 +3253,7 @@ enum Distro { UbuntuUtopic, UbuntuVivid, UbuntuWily, + UbuntuXenial, UnknownDistro }; @@ -3267,7 +3268,7 @@ static bool IsDebian(enum Distro Distro) } static bool IsUbuntu(enum Distro Distro) { - return Distro >= UbuntuHardy && Distro <= UbuntuWily; + return Distro >= UbuntuHardy && Distro <= UbuntuXenial; } static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) { @@ -3297,6 +3298,7 @@ static Distro DetectDistro(const Driver .Case("utopic", UbuntuUtopic) .Case("vivid", UbuntuVivid) .Case("wily", UbuntuWily) + .Case("xenial", UbuntuXenial) .Default(UnknownDistro); return Version; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info
awson added a subscriber: awson. awson added a comment. Btw, It is a terrible bug. It is hard to imagine how much C++ code it renders broken on 64-bit mingw-w64 clang. For example, any of hashtable-using code doesn't work etc etc. http://reviews.llvm.org/D14179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251643 - clang-format: [JS] Add goog.setTestOnly to the list of stuff that
Author: djasper Date: Thu Oct 29 14:05:20 2015 New Revision: 251643 URL: http://llvm.org/viewvc/llvm-project?rev=251643&view=rev Log: clang-format: [JS] Add goog.setTestOnly to the list of stuff that is import-statement-like and shouldn't be wrapped. Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251643&r1=251642&r2=251643&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Oct 29 14:05:20 2015 @@ -727,7 +727,7 @@ public: while (CurrentToken) { if (CurrentToken->is(tok::kw_virtual)) KeywordVirtualFound = true; - if (IsImportStatement(*CurrentToken)) + if (isImportStatement(*CurrentToken)) ImportStatement = true; if (!consumeToken()) return LT_Invalid; @@ -748,14 +748,15 @@ public: } private: - bool IsImportStatement(const FormatToken &Tok) { + bool isImportStatement(const FormatToken &Tok) { // FIXME: Closure-library specific stuff should not be hard-coded but be // configurable. return Style.Language == FormatStyle::LK_JavaScript && Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) && Tok.Next->Next && (Tok.Next->Next->TokenText == "module" || + Tok.Next->Next->TokenText == "provide" || Tok.Next->Next->TokenText == "require" || - Tok.Next->Next->TokenText == "provide") && + Tok.Next->Next->TokenText == "setTestOnly") && Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren); } Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=251643&r1=251642&r2=251643&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Oct 29 14:05:20 2015 @@ -252,6 +252,8 @@ TEST_F(FormatTestJS, GoogModules) { getGoogleJSStyleWithColumns(40)); verifyFormat("var long = goog.require('this.is.really.absurdly.long');", getGoogleJSStyleWithColumns(40)); + verifyFormat("goog.setTestOnly('this.is.really.absurdly.long');", + getGoogleJSStyleWithColumns(40)); // These should be wrapped normally. verifyFormat( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info
rnk added a comment. Rafael, we don't support pre GCC 4.7 mingw right? They switched to thiscall on 32bit, right? I think we can take a break for x64. http://reviews.llvm.org/D14179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13610: [CodeGen] Fix CodeGenModule::CreateGlobalInitOrDestructFunction
echristo accepted this revision. echristo added a comment. This revision is now accepted and ready to land. LGTM. Thanks! -eric http://reviews.llvm.org/D13610 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251650 - Suppress uninteresting output from crash-recovery-modules.m
Author: nico Date: Thu Oct 29 15:43:31 2015 New Revision: 251650 URL: http://llvm.org/viewvc/llvm-project?rev=251650&view=rev Log: Suppress uninteresting output from crash-recovery-modules.m No behavior change, but it makes this test a bit easier to debug when it fails. Modified: cfe/trunk/test/Index/crash-recovery-modules.m Modified: cfe/trunk/test/Index/crash-recovery-modules.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/crash-recovery-modules.m?rev=251650&r1=251649&r2=251650&view=diff == --- cfe/trunk/test/Index/crash-recovery-modules.m (original) +++ cfe/trunk/test/Index/crash-recovery-modules.m Thu Oct 29 15:43:31 2015 @@ -2,13 +2,13 @@ // RUN: rm -rf %t // Parse the file, such that building the module will cause Clang to crash. -// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s 2> %t.err +// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s > /dev/null 2> %t.err // RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s // CHECK-CRASH: crash-recovery-modules.m:16:9:{16:2-16:14}: fatal error: could not build module 'Crash' // Parse the file again, without crashing, to make sure that // subsequent parses do the right thing. -// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s +// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s > /dev/null // REQUIRES: crash-recovery // REQUIRES: shell @@ -26,10 +26,10 @@ void test() { // RUN: rm -rf %t // Check that libclang crash-recovery works; both with a module building crash... -// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH -DLIBCLANG_CRASH %s 2> %t.err +// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH -DLIBCLANG_CRASH %s > /dev/null 2> %t.err // RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s // ...and with module building successful. -// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DLIBCLANG_CRASH %s 2> %t.err +// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DLIBCLANG_CRASH %s > /dev/null 2> %t.err // RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s // CHECK-LIBCLANG-CRASH: libclang: crash detected during parsing // CHECK-LIBCLANG-CRASH: Unable to load translation unit! ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12793: Three new overflow builtins with generic argument types
rjmccall added a comment. Sorry for the delay. Committed with a few minor tweaks in r251650. http://reviews.llvm.org/D12793 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251651 - Add support for __builtin_{add,sub,mul}_overflow.
Author: rjmccall Date: Thu Oct 29 15:48:01 2015 New Revision: 251651 URL: http://llvm.org/viewvc/llvm-project?rev=251651&view=rev Log: Add support for __builtin_{add,sub,mul}_overflow. Patch by David Grayson! Added: cfe/trunk/test/Sema/builtins-overflow.c Modified: cfe/trunk/docs/LanguageExtensions.rst cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-overflow.c Modified: cfe/trunk/docs/LanguageExtensions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=251651&r1=251650&r2=251651&view=diff == --- cfe/trunk/docs/LanguageExtensions.rst (original) +++ cfe/trunk/docs/LanguageExtensions.rst Thu Oct 29 15:48:01 2015 @@ -1679,17 +1679,20 @@ an example of their usage: errorcode_t security_critical_application(...) { unsigned x, y, result; ... -if (__builtin_umul_overflow(x, y, &result)) +if (__builtin_mul_overflow(x, y, &result)) return kErrorCodeHackers; ... use_multiply(result); ... } -A complete enumeration of the builtins are: +Clang provides the following checked arithmetic builtins: .. code-block:: c + bool __builtin_add_overflow (type1 x, type2 y, type3 *sum); + bool __builtin_sub_overflow (type1 x, type2 y, type3 *diff); + bool __builtin_mul_overflow (type1 x, type2 y, type3 *prod); bool __builtin_uadd_overflow (unsigned x, unsigned y, unsigned *sum); bool __builtin_uaddl_overflow (unsigned long x, unsigned long y, unsigned long *sum); bool __builtin_uaddll_overflow(unsigned long long x, unsigned long long y, unsigned long long *sum); @@ -1709,6 +1712,21 @@ A complete enumeration of the builtins a bool __builtin_smull_overflow (long x, long y, long *prod); bool __builtin_smulll_overflow(long long x, long long y, long long *prod); +Each builtin performs the specified mathematical operation on the +first two arguments and stores the result in the third argument. If +possible, the result will be equal to mathematically-correct result +and the builtin will return 0. Otherwise, the builtin will return +1 and the result will be equal to the unique value that is equivalent +to the mathematically-correct result modulo two raised to the *k* +power, where *k* is the number of bits in the result type. The +behavior of these builtins is well-defined for all argument values. + +The first three builtins work generically for operands of any integer type, +including boolean types. The operands need not have the same type as each +other, or as the result. The other builtins may implicitly promote or +convert their operands before performing the operation. + +Query for this feature with ``__has_builtin(__builtin_add_overflow)``, etc. .. _langext-__c11_atomic: Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=251651&r1=251650&r2=251651&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Thu Oct 29 15:48:01 2015 @@ -1217,6 +1217,9 @@ BUILTIN(__builtin_subcl, "ULiULiCULiCULi BUILTIN(__builtin_subcll, "ULLiULLiCULLiCULLiCULLi*", "n") // Checked Arithmetic Builtins for Security. +BUILTIN(__builtin_add_overflow, "v.", "nt") +BUILTIN(__builtin_sub_overflow, "v.", "nt") +BUILTIN(__builtin_mul_overflow, "v.", "nt") BUILTIN(__builtin_uadd_overflow, "bUiCUiCUi*", "n") BUILTIN(__builtin_uaddl_overflow, "bULiCULiCULi*", "n") BUILTIN(__builtin_uaddll_overflow, "bULLiCULLiCULLi*", "n") Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251651&r1=251650&r2=251651&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 29 15:48:01 2015 @@ -6260,6 +6260,12 @@ def warn_atomic_op_has_invalid_memory_or "memory order argument to atomic operation is invalid">, InGroup>; +def err_overflow_builtin_must_be_int : Error< + "operand argument to overflow builtin must be an integer (%0 invalid)">; +def err_overflow_builtin_must_be_ptr_int : Error< + "result argument to overflow builtin must be a pointer " + "to a non-const integer (%0 invalid)">; + def err_atomic_load_store_uses_lib : Error< "atomic %select{load|store}0 requires runtime support that is not " "available for this target">; Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=251651&r1=251650&r2=251651&vie
r251653 - Mark InternalDebugOpt driver options as CoreOptions.
Author: nico Date: Thu Oct 29 15:53:49 2015 New Revision: 251653 URL: http://llvm.org/viewvc/llvm-project?rev=251653&view=rev Log: Mark InternalDebugOpt driver options as CoreOptions. Mostly has the effect of making -ccc-print-phases usable from clang-cl. Modified: cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=251653&r1=251652&r2=251653&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 29 15:53:49 2015 @@ -145,7 +145,7 @@ def ccc_pch_is_pth : Flag<["-"], "ccc-pc HelpText<"Use pretokenized headers for precompiled headers">; class InternalDebugOpt : Group, - Flags<[DriverOption, HelpHidden]>; + Flags<[DriverOption, HelpHidden, CoreOption]>; def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt, HelpText<"Simulate installation in the given directory">; def ccc_print_phases : Flag<["-"], "ccc-print-phases">, InternalDebugOpt, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info
Correct. I we just switched to the 4.7 abi in r197163. Cheers, Rafael On 29 October 2015 at 12:25, Reid Kleckner wrote: > rnk added a comment. > > Rafael, we don't support pre GCC 4.7 mingw right? They switched to thiscall > on 32bit, right? I think we can take a break for x64. > > > http://reviews.llvm.org/D14179 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14188: Format: support inline namespaces
compnerd created this revision. compnerd added a reviewer: djasper. compnerd added a subscriber: cfe-commits. Herald added a subscriber: klimek. Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. http://reviews.llvm.org/D14188 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2192,6 +2192,13 @@ "}// my_namespace\n" "#endif// HEADER_GUARD")); + EXPECT_EQ("namespace A::B {\n" +"class C {};\n" +"}", +format("namespace A::B {\n" + "class C {};\n" + "}")); + FormatStyle Style = getLLVMStyle(); Style.NamespaceIndentation = FormatStyle::NI_All; EXPECT_EQ("namespace out {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1367,7 +1367,8 @@ const FormatToken &InitialToken = *FormatTok; nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->Tok.is(tok::identifier) || + FormatTok->Tok.is(tok::coloncolon)) nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (ShouldBreakBeforeBrace(Style, InitialToken)) Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2192,6 +2192,13 @@ "}// my_namespace\n" "#endif// HEADER_GUARD")); + EXPECT_EQ("namespace A::B {\n" +"class C {};\n" +"}", +format("namespace A::B {\n" + "class C {};\n" + "}")); + FormatStyle Style = getLLVMStyle(); Style.NamespaceIndentation = FormatStyle::NI_All; EXPECT_EQ("namespace out {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1367,7 +1367,8 @@ const FormatToken &InitialToken = *FormatTok; nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->Tok.is(tok::identifier) || + FormatTok->Tok.is(tok::coloncolon)) nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (ShouldBreakBeforeBrace(Style, InitialToken)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14188: Format: support inline namespaces
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Expression can be simplified, otherwise looks good. Comment at: lib/Format/UnwrappedLineParser.cpp:1370 @@ -1369,2 +1369,3 @@ nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->Tok.is(tok::identifier) || + FormatTok->Tok.is(tok::coloncolon)) while (FormatTok->isOneOf(tok::identifier, tok::coloncolon)) nextToken(); http://reviews.llvm.org/D14188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251665 - Revert r249929 ("Split out of ").
Author: rsmith Date: Thu Oct 29 18:32:29 2015 New Revision: 251665 URL: http://llvm.org/viewvc/llvm-project?rev=251665&view=rev Log: Revert r249929 ("Split out of "). This change caused problems when building code like povray that: a) uses 'using namespace std;' b) is built on an environment where the C library provides the "wrong" (non-const-correct) interface for the str* functions c) makes an unqualified call to one of those str* functions A patch is out for review to add a facility to fix this (and to give the correct signatures for these functions whenever possible, even when the C library does not do so). This revert is expected to be temporary. Removed: libcxx/trunk/include/string.h Modified: libcxx/trunk/include/cstring Modified: libcxx/trunk/include/cstring URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=251665&r1=251664&r2=251665&view=diff == --- libcxx/trunk/include/cstring (original) +++ libcxx/trunk/include/cstring Thu Oct 29 18:32:29 2015 @@ -78,42 +78,37 @@ using ::strcmp; using ::strncmp; using ::strcoll; using ::strxfrm; -using ::strcspn; -using ::strspn; -#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS -using ::strtok; -#endif -using ::memset; -using ::strerror; -using ::strlen; -// MSVCRT, GNU libc and its derivates already have the correct prototype in -// if __cplusplus is defined. This macro can be defined by users if -// their C library provides the right signature. -#if defined(__GLIBC__) || defined(_LIBCPP_MSVCRT) || defined(__sun__) || \ -defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) -#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS -#endif +using ::memchr; -#ifdef _LIBCPP_STRING_H_HAS_CONST_OVERLOADS using ::strchr; + +using ::strcspn; + using ::strpbrk; + using ::strrchr; -using ::memchr; + +using ::strspn; + using ::strstr; -#else -inline _LIBCPP_INLINE_VISIBILITY const char* strchr(const char* __s, int __c) {return ::strchr(__s, __c);} + +// MSVCRT, GNU libc and its derivates already have the correct prototype in #ifdef __cplusplus +#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);} -inline _LIBCPP_INLINE_VISIBILITY const char* strpbrk(const char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);} inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);} -inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int __c) {return ::strrchr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);} -inline _LIBCPP_INLINE_VISIBILITY const void* memchr(const void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);} inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);} -inline _LIBCPP_INLINE_VISIBILITY const char* strstr(const char* __s1, const char* __s2) {return ::strstr(__s1, __s2);} inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);} #endif +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS +using ::strtok; +#endif +using ::memset; +using ::strerror; +using ::strlen; + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTRING Removed: libcxx/trunk/include/string.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string.h?rev=251664&view=auto == --- libcxx/trunk/include/string.h (original) +++ libcxx/trunk/include/string.h (removed) @@ -1,63 +0,0 @@ -// -*- C++ -*- -//===--- string.h -===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef _LIBCPP_STRING_H -#define _LIBCPP_STRING_H - -/* -string.h synopsis - -Macros: - -NULL - -Types: - -size_t - -void* memcpy(void* restrict s1, const void* restrict s2, size_t n); -void* memmove(void* s1, const void* s2, size_t n); -char* strcpy (char* restrict s1, const char* restrict s2); -char* strncpy(char* restrict s1, const char* restrict s2, size_t n); -char* strcat (char* restrict s1, const char* restrict s2); -char* strncat(char* restrict s1, const char* restrict s2, size_t n); -int memcmp(const void* s1, const void* s2, size_t n); -int strcmp (const char* s1, const char* s2); -int strncmp(const char* s1, const char* s2, size_t n); -int strcoll(const char* s1, const char* s2); -size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n); -cons
r251666 - Fix the emission of ARC ivar layouts in the non-fragile Mac runtime.
Author: rjmccall Date: Thu Oct 29 18:36:14 2015 New Revision: 251666 URL: http://llvm.org/viewvc/llvm-project?rev=251666&view=rev Log: Fix the emission of ARC ivar layouts in the non-fragile Mac runtime. My previous change in this area accidentally broke the rule when InstanceBegin was not a multiple of the word size. Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp cfe/trunk/test/CodeGenObjC/arc-ivar-layout.m Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=251666&r1=251665&r2=251666&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Oct 29 18:36:14 2015 @@ -2081,7 +2081,7 @@ llvm::Constant *CGObjCCommonMac::BuildGC llvm::SmallVector buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n block variable layout for block: "); builder.dump(buffer); } @@ -4861,6 +4861,9 @@ llvm::Constant *IvarLayoutBuilder::build endOfLastScanInWords = endOfScanInWords; } + if (buffer.empty()) +return llvm::ConstantPointerNull::get(CGM.Int8PtrTy); + // For GC layouts, emit a skip to the end of the allocation so that we // have precise information about the entire thing. This isn't useful // or necessary for the ARC-style layout strings. @@ -4922,9 +4925,9 @@ CGObjCCommonMac::BuildIvarLayout(const O // up. // // ARC layout strings only include the class's ivars. In non-fragile - // runtimes, that means starting at InstanceStart. In fragile runtimes, - // there's no InstanceStart, so it means starting at the end of the - // superclass, rounded up to word alignment. + // runtimes, that means starting at InstanceStart, rounded up to word + // alignment. In fragile runtimes, there's no InstanceStart, so it means + // starting at the end of the superclass, rounded up to word alignment. // // MRC weak layout strings follow the ARC style. CharUnits baseOffset; @@ -4938,10 +4941,12 @@ CGObjCCommonMac::BuildIvarLayout(const O } else if (auto superClass = OI->getSuperClass()) { auto startOffset = CGM.getContext().getASTObjCInterfaceLayout(superClass).getSize(); - baseOffset = startOffset.RoundUpToAlignment(CGM.getPointerAlign()); + baseOffset = startOffset; } else { baseOffset = CharUnits::Zero(); } + +baseOffset = baseOffset.RoundUpToAlignment(CGM.getPointerAlign()); } else { CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); @@ -4965,7 +4970,7 @@ CGObjCCommonMac::BuildIvarLayout(const O llvm::SmallVector buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n%s ivar layout for class '%s': ", ForStrongLayout ? "strong" : "weak", OMD->getClassInterface()->getName().str().c_str()); Modified: cfe/trunk/test/CodeGenObjC/arc-ivar-layout.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-ivar-layout.m?rev=251666&r1=251665&r2=251666&view=diff == --- cfe/trunk/test/CodeGenObjC/arc-ivar-layout.m (original) +++ cfe/trunk/test/CodeGenObjC/arc-ivar-layout.m Thu Oct 29 18:36:14 2015 @@ -1,6 +1,4 @@ -// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -S %s -o %t-64.s -// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s -// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm %s -o %t-64.s | FileCheck -check-prefix CHECK-LP64 %s // rdar://8991729 @interface NSObject { @@ -17,8 +15,7 @@ @implementation AllPointers @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.1: -// CHECK-LP64-NEXT: .asciz "\003" +// CHECK-LP64: strong ivar layout for class 'AllPointers': 0x03, 0x00 @class NSString, NSNumber; @interface A : NSObject { @@ -38,10 +35,12 @@ @implementation A @end +// CHECK-LP64: strong ivar layout for class 'A': 0x02, 0x00 +// CHECK-LP64: weak ivar layout for class 'A': 0x31, 0x00 + @implementation B @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.15: -// CHECK-LP64-NEXT: .asciz "\022" +// CHECK-LP64: strong ivar layout for class 'B': 0x12, 0x00 @interface UnsafePerson { @public @@ -52,8 +51,8 @@ @end @implementation UnsafePerson @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.20: -// CHECK-LP64-NEXT: .asciz "!" + +// CHECK-LP64: strong ivar layout for class 'UnsafePerson': 0x21, 0x00 // rdar://16136439 @interface rdar16136439 @@ -61,5 +60,20 @@ @end @implementation rdar16136439 @end -// CHECK-LP64: L_OBJC_PROP_NAME_ATTR_.29: -// CHECK-LP6
Re: [PATCH] D14152: Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D14152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14176: Only copy small types in modernize-loop-convert.
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D14176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.
rjmccall added a comment. In http://reviews.llvm.org/D12614#274349, @sfantao wrote: > Hi John, > > Thanks for the remark! > > In http://reviews.llvm.org/D12614#272354, @rjmccall wrote: > > > CurFuncDecl is supposed to be the enclosing user function. Things like > > outlined functions should be getting stored in CurCodeDecl; that's how it's > > done for blocks and lambdas. > > > Apologies I was not accurate in my previous post. `CurFuncDecl` is in fact > the declaration of the enclosing user function. What is not defined in some > times undefined is `CurGD` and this is what I was trying to use to get the > right mangled name of the user function, given that it also encodes the > structor type. So my question is: is there a good/safe way to get the mangled > name of the user function given the function declaration? I didn't find any > good way to do that without replicating part of the stuff that happens in the > mangler. You don't actually want the structor type of the parent, because the nested declaration is logically the same declaration across all of them. For example, a lambda used in a constructor is still just a single type; there aren't implicitly 1-3 different types just because there are 1-3 different variant entrypoints for the constructor. The way this generally works is that you just pick a single canonical variant. For example, the Itanium ABI says that you mangle local entities within constructors as if they were defined within the complete-object variant. If you want to add a method to one of the CXXABI objects to pick a canonical GD for a declaration, feel free. http://reviews.llvm.org/D12614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] Reinstate and fix overload sets to be const-correct wherever possible
Hi, The attached patch undoes the revert of r249929, and adds an extension to allow (and ) to work properly even in environments such as iOS where the underlying libc does not provide C++'s const-correct overloads of strchr and friends. This works as follows: * The macro _LIBCPP_PREFERRED_OVERLOAD is, where possible, defined by <__config> to an attribute that provides the following semantics: - A function declaration with the attribute declares a different function from a function declaration without the attribute. - Overload resolution prefers a function with the attribute over a function without. * For each of the functions that has a "broken" signature in C, if we don't believe that the C library provided the C++ signatures, and we have a _LIBCPP_PREFERRED_OVERLOAD, then we add the C++ declarations and mark them as preferred over the C overloads. * The overloads provided in namespace std always exactly match those in ::. This results in the following changes in cases where the underlying libc provides the C signature not the C++ one, compared to the status quo: : char *strchr(const char*, int) // #1 char *strchr(char*, int) // #2 const char *strchr(const char*, int) // #3 We used to provide #1 and #2 in namespace std (in ) and only #1 in global namespace (in ). For a very old clang or non-clang compiler, we now have only #1 in both places (note that #2 is essentially useless). This is unlikely to be a visible change in real code, but it's slightly broken either way and we can't fix it. For newer clang (3.6 onwards?), we now have correct signatures (#2 and #3) in :: and std (depending on header). Taking address of strchr requires ~trunk clang (but it didn't work before either, so this is not really a regression). : wchar_t *wcschr(const wchar_t *, wchar_t) // #1 const wchar_t *wcschr(const wchar_t *, wchar_t) // #2 wchar_t *wcschr(wchar_t *, wchar_t) // #3 We used to provide #1 in global namespace, and #2 and #3 in namespace std. This broke code that uses 'using namespace std;'. For a very old clang or non-clang compiler, we now have #1 in global namespace and namespace std. This fixes the ambiguity errors, but decreases const-correctness in this case. On the whole, this seems like an improvement to me. For newer clang, we now have correct signatures (#2 and #3) in :: and std (depending on header). As above, taking address doesn't work unless you're using very recent Clang (this is not a regression in ::, but is a regression in namespace std). To summarize, we previously had ad-hoc, inconsistent, slightly broken rules for and , and with this patch we fix the overload set to give the exact C++ semantics where possible (for all recent versions of Clang), and otherwise leave the C signatures alone. string-wchar-overload-sets.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249929 - Split out of .
I reverted this change in r251665, and started a new thread for the patch to reinstate this and fix the ambiguity issue. On Wed, Oct 28, 2015 at 11:01 AM, Michael Zolotukhin via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Hi Eric, Richard, > > Any news on this? The test is still broken, should we revert the commit > for now? > > Thanks, > Michael > > On Oct 24, 2015, at 1:18 AM, Eric Fiselier wrote: > > Hi Michael, > > Sorry I'm holding this patch up in review. The fix is quite "novel" and I > want to make sure we get it right. If we can't land it over the weekend > I'll ask Richard to revert while we work on it. > > /Eric > On Oct 23, 2015 10:13 PM, "Michael Zolotukhin via cfe-commits" < > cfe-commits@lists.llvm.org> wrote: > > Hi Richard, > > Is this patch ready for commit, or were you just checking an idea? Our > bots are still failing to build povray, so we’re really looking forward for > some fix:) > > Thanks, > Michael > > On Oct 15, 2015, at 6:21 PM, Manman Ren via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > > On Oct 15, 2015, at 1:41 PM, Richard Smith wrote: > > On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> >> On Oct 15, 2015, at 11:25 AM, Richard Smith >> wrote: >> >> I assume the code in question has a "using namespace std;"? >> >> Yes >> >> I don't see any way around this other than giving up on trying to fix the >> function signatures here (or maybe adding a Clang feature to let us fix the >> bad signature). >> >> Can you elaborate on how to fix the bad signature by adding a Clang >> feature? I want to see how hard it is before giving up on trying to fix the >> signatures. >> > > I thought about this a bit more, and we already have a feature that can be > used for this. > > Please let me know if the attached patch resolves the issue for you. This > should also fix the wrong overload sets for these functions being provided > by on Darwin. > > > This works on my testing case. Thanks!! > > Manman > > > > Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD > that can be applied to a function to (a) mark it as a separate overload > from any other function with the same signature without the overload, and > (b) instruct the compiler that it's preferred over another function with > the same signature without the attribute. This allows us to replace the > libc function > > char *strchr(const char *, int); > > with the C++ overload set: > > const char *strchr(const char *, int); > char *strchr(char *, int); > > It only works with Clang, though; for other compilers, we leave the C > library's signature alone (as we used to before my patches landed). > > Thanks, >> Manman >> >> >> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" < >> cfe-commits@lists.llvm.org> wrote: >> >>> Hi Richard, >>> >>> This is causing a failure when building povray on iOS. >>> >>> Compilation error: >>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20: >>> error: call to 'strrchr' is ambiguous >>> const char *p=strrchr(name, '.’); >>> >>> iOS.sdk/usr/include/string.h:87:7: note: candidate function >>> char*strrchr(const char *, int); >>> ^ >>> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46: >>> note: candidate function >>> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, >>> int __c) {return ::strrchr(__s, __c);} >>> >>> It is a little strange to have "char*strrchr(const char *, int);” in >>> iOS. But it is already in our SDK. >>> >>> Do you have any suggestion on how to fix this? >>> >>> Thanks, >>> Manman >>> >>> > On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> > >>> > Author: rsmith >>> > Date: Fri Oct 9 20:25:31 2015 >>> > New Revision: 249929 >>> > >>> > URL: http://llvm.org/viewvc/llvm-project?rev=249929&view=rev >>> > Log: >>> > Split out of . >>> > >>> > Also fix the overload set for the five functions whose signatures >>> change in the >>> > case where we can fix it. This is already covered by existing tests >>> for the >>> > affected systems. >>> > >>> > Added: >>> >libcxx/trunk/include/string.h >>> > - copied, changed from r249736, libcxx/trunk/include/cstring >>> > Modified: >>> >libcxx/trunk/include/cstring >>> > >>> > Modified: libcxx/trunk/include/cstring >>> > URL: >>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff >>> > >>> == >>> > --- libcxx/trunk/include/cstring (original) >>> > +++ libcxx/trunk/include/cstring Fri Oct 9 20:25:31 2015 >>> > @@ -78,37 +78,42 @@ using ::strcmp; >>> > using ::strncmp; >>> > using ::strcoll; >>> > using ::strxfrm; >>> > +using ::strcspn; >>> > +using ::strspn; >>> >
[PATCH] D14191: Make ArgumentAdjuster aware of the current file being processed.
alexfh created this revision. alexfh added a reviewer: klimek. alexfh added a subscriber: cfe-commits. Herald added a subscriber: klimek. This is needed to handle per-project configurations when adding extra arguments in clang-tidy for example. http://reviews.llvm.org/D14191 Files: include/clang/Tooling/ArgumentsAdjusters.h lib/Tooling/ArgumentsAdjusters.cpp lib/Tooling/CommonOptionsParser.cpp lib/Tooling/Tooling.cpp unittests/Tooling/ToolingTest.cpp Index: unittests/Tooling/ToolingTest.cpp === --- unittests/Tooling/ToolingTest.cpp +++ unittests/Tooling/ToolingTest.cpp @@ -288,7 +288,7 @@ bool Found = false; bool Ran = false; ArgumentsAdjuster CheckSyntaxOnlyAdjuster = - [&Found, &Ran](const CommandLineArguments &Args) { + [&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) { Ran = true; if (std::find(Args.begin(), Args.end(), "-fsyntax-only") != Args.end()) Found = true; Index: lib/Tooling/Tooling.cpp === --- lib/Tooling/Tooling.cpp +++ lib/Tooling/Tooling.cpp @@ -409,7 +409,7 @@ std::vector CommandLine = CompileCommand.CommandLine; if (ArgsAdjuster) -CommandLine = ArgsAdjuster(CommandLine); +CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename); assert(!CommandLine.empty()); CommandLine[0] = MainExecutable; // FIXME: We need a callback mechanism for the tool writer to output a Index: lib/Tooling/CommonOptionsParser.cpp === --- lib/Tooling/CommonOptionsParser.cpp +++ lib/Tooling/CommonOptionsParser.cpp @@ -86,7 +86,7 @@ adjustCommands(std::vector Commands) const { for (CompileCommand &Command : Commands) for (const auto &Adjuster : Adjusters) -Command.CommandLine = Adjuster(Command.CommandLine); +Command.CommandLine = Adjuster(Command.CommandLine, Command.Filename); return Commands; } }; Index: lib/Tooling/ArgumentsAdjusters.cpp === --- lib/Tooling/ArgumentsAdjusters.cpp +++ lib/Tooling/ArgumentsAdjusters.cpp @@ -13,15 +13,13 @@ //===--===// #include "clang/Tooling/ArgumentsAdjusters.h" -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/StringRef.h" namespace clang { namespace tooling { /// Add -fsyntax-only option to the commnand line arguments. ArgumentsAdjuster getClangSyntaxOnlyAdjuster() { - return [](const CommandLineArguments &Args) { + return [](const CommandLineArguments &Args, StringRef /*unused*/) { CommandLineArguments AdjustedArgs; for (size_t i = 0, e = Args.size(); i != e; ++i) { StringRef Arg = Args[i]; @@ -36,7 +34,7 @@ } ArgumentsAdjuster getClangStripOutputAdjuster() { - return [](const CommandLineArguments &Args) { + return [](const CommandLineArguments &Args, StringRef /*unused*/) { CommandLineArguments AdjustedArgs; for (size_t i = 0, e = Args.size(); i < e; ++i) { StringRef Arg = Args[i]; @@ -55,7 +53,7 @@ ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra, ArgumentInsertPosition Pos) { - return [Extra, Pos](const CommandLineArguments &Args) { + return [Extra, Pos](const CommandLineArguments &Args, StringRef /*unused*/) { CommandLineArguments Return(Args); CommandLineArguments::iterator I; @@ -78,8 +76,8 @@ ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First, ArgumentsAdjuster Second) { - return [First, Second](const CommandLineArguments &Args) { -return Second(First(Args)); + return [First, Second](const CommandLineArguments &Args, StringRef File) { +return Second(First(Args, File), File); }; } Index: include/clang/Tooling/ArgumentsAdjusters.h === --- include/clang/Tooling/ArgumentsAdjusters.h +++ include/clang/Tooling/ArgumentsAdjusters.h @@ -17,6 +17,8 @@ #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/StringRef.h" #include #include #include @@ -31,8 +33,8 @@ /// /// Command line argument adjuster is responsible for command line arguments /// modification before the arguments are used to run a frontend action. -typedef std::function -ArgumentsAdjuster; +typedef std::function ArgumentsAdjuster; /// \brief Gets an argument adjuster that converts input command line arguments /// to the "syntax check only" variant. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251677 - Initialize @catch variables correctly in fragile-runtime ARC.
Author: rjmccall Date: Thu Oct 29 19:56:02 2015 New Revision: 251677 URL: http://llvm.org/viewvc/llvm-project?rev=251677&view=rev Log: Initialize @catch variables correctly in fragile-runtime ARC. Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp cfe/trunk/lib/CodeGen/CGObjCRuntime.h cfe/trunk/test/CodeGenObjC/fragile-arc.m Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=251677&r1=251676&r2=251677&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Oct 29 19:56:02 2015 @@ -4135,7 +4135,7 @@ void CGObjCMac::EmitTryOrSynchronizedStm assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?"); // These types work out because ConvertType(id) == i8*. - CGF.Builder.CreateStore(Caught, CGF.GetAddrOfLocalVar(CatchParam)); + EmitInitOfCatchParam(CGF, Caught, CatchParam); } CGF.EmitStmt(CatchStmt->getCatchBody()); @@ -4182,7 +4182,7 @@ void CGObjCMac::EmitTryOrSynchronizedStm llvm::Value *Tmp = CGF.Builder.CreateBitCast(Caught, CGF.ConvertType(CatchParam->getType())); - CGF.Builder.CreateStore(Tmp, CGF.GetAddrOfLocalVar(CatchParam)); + EmitInitOfCatchParam(CGF, Tmp, CatchParam); CGF.EmitStmt(CatchStmt->getCatchBody()); Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=251677&r1=251676&r2=251677&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Thu Oct 29 19:56:02 2015 @@ -256,24 +256,7 @@ void CGObjCRuntime::EmitTryCatchStmt(Cod llvm::Value *CastExn = CGF.Builder.CreateBitCast(Exn, CatchType); CGF.EmitAutoVarDecl(*CatchParam); - - Address CatchParamAddr = CGF.GetAddrOfLocalVar(CatchParam); - - switch (CatchParam->getType().getQualifiers().getObjCLifetime()) { - case Qualifiers::OCL_Strong: -CastExn = CGF.EmitARCRetainNonBlock(CastExn); -// fallthrough - - case Qualifiers::OCL_None: - case Qualifiers::OCL_ExplicitNone: - case Qualifiers::OCL_Autoreleasing: -CGF.Builder.CreateStore(CastExn, CatchParamAddr); -break; - - case Qualifiers::OCL_Weak: -CGF.EmitARCInitWeak(CatchParamAddr, CastExn); -break; - } + EmitInitOfCatchParam(CGF, CastExn, CatchParam); } CGF.ObjCEHValueStack.push_back(Exn); @@ -297,6 +280,30 @@ void CGObjCRuntime::EmitTryCatchStmt(Cod CGF.EmitBlock(Cont.getBlock()); } +void CGObjCRuntime::EmitInitOfCatchParam(CodeGenFunction &CGF, + llvm::Value *exn, + const VarDecl *paramDecl) { + + Address paramAddr = CGF.GetAddrOfLocalVar(paramDecl); + + switch (paramDecl->getType().getQualifiers().getObjCLifetime()) { + case Qualifiers::OCL_Strong: +exn = CGF.EmitARCRetainNonBlock(exn); +// fallthrough + + case Qualifiers::OCL_None: + case Qualifiers::OCL_ExplicitNone: + case Qualifiers::OCL_Autoreleasing: +CGF.Builder.CreateStore(exn, paramAddr); +return; + + case Qualifiers::OCL_Weak: +CGF.EmitARCInitWeak(paramAddr, exn); +return; + } + llvm_unreachable("invalid ownership qualifier"); +} + namespace { struct CallSyncExit final : EHScopeStack::Cleanup { llvm::Value *SyncExitFn; Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=251677&r1=251676&r2=251677&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original) +++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Thu Oct 29 19:56:02 2015 @@ -100,6 +100,10 @@ protected: llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *exceptionRethrowFn); + + void EmitInitOfCatchParam(CodeGenFunction &CGF, llvm::Value *exn, +const VarDecl *paramDecl); + /// Emits an \@synchronize() statement, using the \p syncEnterFn and /// \p syncExitFn arguments as the functions called to lock and unlock /// the object. This function can be called by subclasses that use Modified: cfe/trunk/test/CodeGenObjC/fragile-arc.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/fragile-arc.m?rev=251677&r1=251676&r2=251677&view=diff == --- cfe/trunk/test/CodeGenObjC/fragile-arc.m (original) +++ cfe/trunk/test/CodeGenObjC/fragile-arc.m Thu Oct 29 19:56:02
[PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.
alexfh created this revision. alexfh added a reviewer: klimek. alexfh added a subscriber: cfe-commits. This patch depends on http://reviews.llvm.org/D14191 http://reviews.llvm.org/D14192 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidyOptions.cpp clang-tidy/ClangTidyOptions.h modularize/Modularize.cpp test/clang-tidy/custom-diagnostics.cpp Index: test/clang-tidy/custom-diagnostics.cpp === --- /dev/null +++ test/clang-tidy/custom-diagnostics.cpp @@ -0,0 +1,10 @@ +// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow' %s -- | count 0 +// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow' \ +// RUN: -config='{ExtraArgs: ["-Wshadow"]}' %s -- \ +// RUN: | FileCheck -implicit-check-not='{{warning:|error:}}' %s + +void f() { + int a; + { int a; } + // CHECK: :[[@LINE-1]]:9: warning: declaration shadows a local variable [clang-diagnostic-shadow] +} Index: modularize/Modularize.cpp === --- modularize/Modularize.cpp +++ modularize/Modularize.cpp @@ -356,7 +356,8 @@ // if no other "-x" option is present. static ArgumentsAdjuster getModularizeArgumentsAdjuster(DependencyMap &Dependencies) { - return [&Dependencies](const CommandLineArguments &Args) { + return [&Dependencies](const CommandLineArguments &Args, + StringRef /*unused*/) { std::string InputFile = findInputFile(Args); DependentsVector &FileDependents = Dependencies[InputFile]; CommandLineArguments NewArgs(Args); Index: clang-tidy/ClangTidyOptions.h === --- clang-tidy/ClangTidyOptions.h +++ clang-tidy/ClangTidyOptions.h @@ -83,6 +83,14 @@ /// \brief Key-value mapping used to store check-specific options. OptionMap CheckOptions; + + typedef std::vector ArgList; + + /// \brief Add extra compilation arguments to the end of the list. + llvm::Optional ExtraArgs; + + /// \brief Add extra compilation arguments to the start of the list. + llvm::Optional ExtraArgsBefore; }; /// \brief Abstract interface for retrieving various ClangTidy options. Index: clang-tidy/ClangTidyOptions.cpp === --- clang-tidy/ClangTidyOptions.cpp +++ clang-tidy/ClangTidyOptions.cpp @@ -27,6 +27,7 @@ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter) LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange) LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair) +LLVM_YAML_IS_SEQUENCE_VECTOR(std::string) namespace llvm { namespace yaml { @@ -88,6 +89,8 @@ IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors); IO.mapOptional("User", Options.User); IO.mapOptional("CheckOptions", NOpts->Options); +IO.mapOptional("ExtraArgs", Options.ExtraArgs); +IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore); } }; @@ -129,6 +132,10 @@ Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors; if (Other.User) Result.User = Other.User; + if (Other.ExtraArgs) +Result.ExtraArgs = Other.ExtraArgs; + if (Other.ExtraArgsBefore) +Result.ExtraArgsBefore = Other.ExtraArgsBefore; for (const auto &KeyValue : Other.CheckOptions) Result.CheckOptions[KeyValue.first] = KeyValue.second; Index: clang-tidy/ClangTidy.cpp === --- clang-tidy/ClangTidy.cpp +++ clang-tidy/ClangTidy.cpp @@ -42,6 +42,9 @@ #include #include + +#include "llvm/ADT/StringExtras.h" + using namespace clang::ast_matchers; using namespace clang::driver; using namespace clang::tooling; @@ -376,6 +379,20 @@ std::vector *Errors, ProfileData *Profile) { ClangTool Tool(Compilations, InputFiles); clang::tidy::ClangTidyContext Context(std::move(OptionsProvider)); + ArgumentsAdjuster PerFileExtraArgumentsInserter = [&Context]( + const CommandLineArguments &Args, StringRef Filename) { +Context.setCurrentFile(Filename); +const ClangTidyOptions &Opts = Context.getOptions(); +CommandLineArguments AdjustedArgs; +if (Opts.ExtraArgsBefore) + AdjustedArgs = *Opts.ExtraArgsBefore; +AdjustedArgs.insert(AdjustedArgs.begin(), Args.begin(), Args.end()); +if (Opts.ExtraArgs) + AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(), + Opts.ExtraArgs->end()); +return AdjustedArgs; + }; + Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter); if (Profile) Context.setCheckProfileData(Profile); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14146: Introduction of -miamcu option
aturetsk created this revision. aturetsk added a reviewer: rsmith. aturetsk added subscribers: cfe-commits, mkuper, DavidKreitzer, anadolskiy, zansari. Add initial support of -miamcu option which triggers MCU ABI. http://reviews.llvm.org/D14146 Files: include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/iamcu-abi.c Index: test/Driver/iamcu-abi.c === --- /dev/null +++ test/Driver/iamcu-abi.c @@ -0,0 +1,5 @@ +// RUN: %clang -target i386-unknown-linux -m32 -miamcu %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck %s + +// CHECK: "-mfloat-abi" "soft" +// CHECK: "-mstack-alignment=4" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1907,6 +1907,16 @@ << A->getOption().getName() << Value; } } + + // If -miamcu is set then set flags to support MCU ABI. + if (Args.getLastArg(options::OPT_miamcu)) { +if (getToolChain().getArch() != llvm::Triple::x86) + getToolChain().getDriver().Diag(diag::err_drv_unsupported_opt) + << "-miamcu"; +CmdArgs.push_back("-mfloat-abi"); +CmdArgs.push_back("soft"); +CmdArgs.push_back("-mstack-alignment=4"); + } } void Clang::AddHexagonTargetArgs(const ArgList &Args, Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1223,6 +1223,8 @@ def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, CoreOption]>; def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, CoreOption]>; def mabi_EQ : Joined<["-"], "mabi=">, Group; +def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, CoreOption]>, + HelpText<"Use Intel MCU ABI.">; def malign_functions_EQ : Joined<["-"], "malign-functions=">, Group; def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group; def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group; Index: test/Driver/iamcu-abi.c === --- /dev/null +++ test/Driver/iamcu-abi.c @@ -0,0 +1,5 @@ +// RUN: %clang -target i386-unknown-linux -m32 -miamcu %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck %s + +// CHECK: "-mfloat-abi" "soft" +// CHECK: "-mstack-alignment=4" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1907,6 +1907,16 @@ << A->getOption().getName() << Value; } } + + // If -miamcu is set then set flags to support MCU ABI. + if (Args.getLastArg(options::OPT_miamcu)) { +if (getToolChain().getArch() != llvm::Triple::x86) + getToolChain().getDriver().Diag(diag::err_drv_unsupported_opt) + << "-miamcu"; +CmdArgs.push_back("-mfloat-abi"); +CmdArgs.push_back("soft"); +CmdArgs.push_back("-mstack-alignment=4"); + } } void Clang::AddHexagonTargetArgs(const ArgList &Args, Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1223,6 +1223,8 @@ def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, CoreOption]>; def mx32 : Flag<["-"], "mx32">, Group, Flags<[DriverOption, CoreOption]>; def mabi_EQ : Joined<["-"], "mabi=">, Group; +def miamcu : Flag<["-"], "miamcu">, Group, Flags<[DriverOption, CoreOption]>, + HelpText<"Use Intel MCU ABI.">; def malign_functions_EQ : Joined<["-"], "malign-functions=">, Group; def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group; def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [PATCH] D13673: Add initial support for the MUSL C library.
s/__NetBSD_\)/__NetBSD__\)/ From: Vasileios Kalintiris [vasileios.kalinti...@imgtec.com] Sent: Thursday, October 29, 2015 2:50 AM To: vasileios.kalinti...@imgtec.com; mclow.li...@gmail.com; Roelofs, Jonathan; e...@efcs.ca Cc: j...@chromium.org; tbergham...@google.com; danalb...@google.com; srhi...@google.com; cfe-commits@lists.llvm.org Subject: Re: [PATCH] D13673: Add initial support for the MUSL C library. vkalintiris added a comment. In http://reviews.llvm.org/D13673#271518, @EricWF wrote: > Thanks for the update, I think this should be good to go. I'll give it a > final once over tonight. Ping. http://reviews.llvm.org/D13673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14170: Fix false positive warning about memory leak for QApplication::postEvent
Dushistov created this revision. Dushistov added reviewers: Ayal, zaks.anna, dcoughlin, xazax.hun. Dushistov added a subscriber: cfe-commits. Recent version of clang (3.7) start complain about such code: void send(QObject *obj) { QKeyEvent *event = new QKeyEvent(QEvent::KeyRelease, Qt::Key_Tab, Qt::NoModifier); qApp->postEvent(obj, event); } warning: Potential leak of memory pointed to by 'event' This is false positive, because of according to Qt documentation Qt take care about memory allocated for QEvent: http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent Because of Qt popular enought I suggest to handle postEvent case in MallocChecker http://reviews.llvm.org/D14170 Files: lib/StaticAnalyzer/Checkers/MallocChecker.cpp Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2511,6 +2511,10 @@ return true; } + if (FName.endswith("postEvent") || FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") { +return true; + } + // Handle cases where we know a buffer's /address/ can escape. // Note that the above checks handle some special cases where we know that // even though the address escapes, it's still our responsibility to free the Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2511,6 +2511,10 @@ return true; } + if (FName.endswith("postEvent") || FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") { +return true; + } + // Handle cases where we know a buffer's /address/ can escape. // Note that the above checks handle some special cases where we know that // even though the address escapes, it's still our responsibility to free the ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target
compnerd requested changes to this revision. compnerd added a reviewer: compnerd. compnerd added a comment. This revision now requires changes to proceed. Please add a unit test for this. http://reviews.llvm.org/D14180 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251690 - Format: support inline namespaces
Author: compnerd Date: Fri Oct 30 00:07:56 2015 New Revision: 251690 URL: http://llvm.org/viewvc/llvm-project?rev=251690&view=rev Log: Format: support inline namespaces Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=251690&r1=251689&r2=251690&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Oct 30 00:07:56 2015 @@ -1367,7 +1367,7 @@ void UnwrappedLineParser::parseNamespace const FormatToken &InitialToken = *FormatTok; nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->isOneOf(tok::identifier, tok::coloncolon)) nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (ShouldBreakBeforeBrace(Style, InitialToken)) Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251690&r1=251689&r2=251690&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 30 00:07:56 2015 @@ -2192,6 +2192,13 @@ TEST_F(FormatTest, FormatsNamespaces) { "}// my_namespace\n" "#endif// HEADER_GUARD")); + EXPECT_EQ("namespace A::B {\n" +"class C {};\n" +"}", +format("namespace A::B {\n" + "class C {};\n" + "}")); + FormatStyle Style = getLLVMStyle(); Style.NamespaceIndentation = FormatStyle::NI_All; EXPECT_EQ("namespace out {\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13643: [Sema] Warn on ternary comparison
mgrabovsky added a comment. Any other remarks? http://reviews.llvm.org/D13643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits