[PATCH] D54379: Add Hurd toolchain support to Clang
kristina added a comment. I'll re-review when I'm up, from a quick glance it looks much better but I'll have to patch it over my fork and try out a few things (Mostly x86_64 Linux and Darwin test suites). I think the test is lacking a bit, there's a lot of stuff that isn't covered, and there's a lack of negative tests (ie. when invalid input is supplied and matches the triple suffix). Feel free to run tests though, may find something before me, I'm a bit too tired to reconfigure my buildbot to do what I want right now, so I'll leave it until when I'm up. So yeah I may be being a bit nitpicky but I think tests could cover a little bit more. It would also be great to get at least one other Clang reviewer to sign off on this. I can sign off on this myself once I test it, but I feel like getting another set of eyes would be good. But yeah if this is all good and someone else can also skim through this and sign off on it, I can commit the stack when I'm up and when I've done some stuff. If you can, try to build/test with a recent Clang as that usually brings out some benign warnings one may miss if using an older SDK. But very good job in general, this seems a lot better and streamlined than the previous revision. So that said to other Clang reviewers: Gentle ping, would really love a second set of eyes though, though it can wait until Monday at worst since I'd imagine a lot of people are off right now. Thank you. Repository: rC Clang https://reviews.llvm.org/D54379 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r347152 - cmake: z3: Remove EXACT from 4.7.1 after being compatible with 4.8.1
Author: jankratochvil Date: Sun Nov 18 01:36:36 2018 New Revision: 347152 URL: http://llvm.org/viewvc/llvm-project?rev=347152&view=rev Log: cmake: z3: Remove EXACT from 4.7.1 after being compatible with 4.8.1 After check-in of D54391 a comment there by @mikhail.ramalho says: Since we're supporting version 4.8.1 now, the cmake file should be changed to "minimum" instead of "exact". Differential Revision: https://reviews.llvm.org/D54535 Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=347152&r1=347151&r2=347152&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Sun Nov 18 01:36:36 2018 @@ -410,7 +410,7 @@ option(CLANG_ENABLE_STATIC_ANALYZER "Bui set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.") -find_package(Z3 4.7.1 EXACT) +find_package(Z3 4.7.1) if (CLANG_ANALYZER_Z3_INSTALL_DIR) if (NOT Z3_FOUND) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54535: cmake: z3: Remove EXACT from 4.7.1 after being compatible with 4.8.1
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rC347152: cmake: z3: Remove EXACT from 4.7.1 after being compatible with 4.8.1 (authored by jankratochvil, committed by ). Repository: rC Clang https://reviews.llvm.org/D54535 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -410,7 +410,7 @@ set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.") -find_package(Z3 4.7.1 EXACT) +find_package(Z3 4.7.1) if (CLANG_ANALYZER_Z3_INSTALL_DIR) if (NOT Z3_FOUND) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -410,7 +410,7 @@ set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.") -find_package(Z3 4.7.1 EXACT) +find_package(Z3 4.7.1) if (CLANG_ANALYZER_Z3_INSTALL_DIR) if (NOT Z3_FOUND) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p
void added a comment. Ping? I really don't want this review to go on forever. Repository: rC Clang https://reviews.llvm.org/D54355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p
void updated this revision to Diff 174529. void added a comment. Don't re-wrap a ConstExpr. Repository: rC Clang https://reviews.llvm.org/D54355 Files: include/clang/AST/Expr.h lib/AST/ASTImporter.cpp lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaType.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/builtin-functions.cpp test/Sema/builtins.c test/SemaCXX/compound-literal.cpp Index: test/SemaCXX/compound-literal.cpp === --- test/SemaCXX/compound-literal.cpp +++ test/SemaCXX/compound-literal.cpp @@ -36,8 +36,8 @@ POD p = (POD){1, 2}; // CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'brace_initializers::POD' - // CHECK: ConstantExpr {{.*}} 'brace_initializers::POD' - // CHECK-NEXT: CompoundLiteralExpr {{.*}} 'brace_initializers::POD' + // CHECK: CompoundLiteralExpr {{.*}} 'brace_initializers::POD' + // CHECK-NEXT: ConstantExpr {{.*}} 'brace_initializers::POD' // CHECK-NEXT: InitListExpr {{.*}} 'brace_initializers::POD' // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -122,6 +122,14 @@ __builtin_constant_p(1, 2); // expected-error {{too many arguments}} } +// __builtin_constant_p cannot resolve non-constants as a file scoped array. +int expr; +char y[__builtin_constant_p(expr) ? -1 : 1]; // no warning, the builtin is false. + +// no warning, the builtin is false. +struct foo { int a; }; +struct foo x = (struct foo) { __builtin_constant_p(42) ? 37 : 927 }; + const int test17_n = 0; const char test17_c[] = {1, 2, 3, 0}; const char test17_d[] = {1, 2, 3, 4}; Index: test/Analysis/builtin-functions.cpp === --- test/Analysis/builtin-functions.cpp +++ test/Analysis/builtin-functions.cpp @@ -70,14 +70,14 @@ const int j = 2; constexpr int k = 3; clang_analyzer_eval(__builtin_constant_p(42) == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(j) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(k) == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(j + 42) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(k + 42) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(" ") == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(k - 3) == 0); // expected-warning {{FALSE}} clang_analyzer_eval(__builtin_constant_p(k - 3) == 1); // expected-warning {{TRUE}} } Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1283,9 +1283,6 @@ break; case Expr::ConstantExprClass: - // Handled due to it being a wrapper class. - break; - case Stmt::ExprWithCleanupsClass: // Handled due to fully linearised CFG. break; Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2233,10 +2233,6 @@ T = Context.getConstantArrayType(T, ConstVal, ASM, Quals); } - if (ArraySize && !CurContext->isFunctionOrMethod()) -// A file-scoped array must have a constant array size. -ArraySize = new (Context) ConstantExpr(ArraySize); - // OpenCL v1.2 s6.9.d: variable length arrays are not supported. if (getLangOpts().OpenCL && T->isVariableArrayType()) { Diag(Loc, diag::err_opencl_vla); Index: lib/Sema/SemaTemplateDeduction.cpp === --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -178,6 +178,8 @@ while (true) { if (ImplicitCastExpr *IC = dyn_cast(E)) E = IC->getSubExpr(); +else if (ConstantExpr *CE = dyn_cast(E)) + E = CE->getSubExpr(); else if (SubstNonTypeTemplateParmExpr *Subst = dyn_cast(E)) E = Subst->getReplacement(); @@ -5225,6 +5227,8 @@ while (true) { if (co
[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once
This revision was automatically updated to reflect the committed changes. Closed by commit rC347153: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once (authored by Szelethus, committed by ). Changed prior to commit: https://reviews.llvm.org/D51531?vs=163542&id=174530#toc Repository: rC Clang https://reviews.llvm.org/D51531 Files: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp test/Analysis/cxx-uninitialized-object-ptr-ref.cpp Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp === --- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp +++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp @@ -865,3 +865,44 @@ ReferenceTest4::RecordType c, d{37, 38}; ReferenceTest4(d, c); } + +//===--===// +// Tests for objects containing multiple references to the same object. +//===--===// + +struct IntMultipleReferenceToSameObjectTest { + int *iptr; // expected-note{{uninitialized pointee 'this->iptr'}} + int &iref; // no-note, pointee of this->iref was already reported + + int dontGetFilteredByNonPedanticMode = 0; + + IntMultipleReferenceToSameObjectTest(int *i) : iptr(i), iref(*i) {} // expected-warning{{1 uninitialized field}} +}; + +void fIntMultipleReferenceToSameObjectTest() { + int a; + IntMultipleReferenceToSameObjectTest Test(&a); +} + +struct IntReferenceWrapper1 { + int &a; // expected-note{{uninitialized pointee 'this->a'}} + + int dontGetFilteredByNonPedanticMode = 0; + + IntReferenceWrapper1(int &a) : a(a) {} // expected-warning{{1 uninitialized field}} +}; + +struct IntReferenceWrapper2 { + int &a; // no-note, pointee of this->a was already reported + + int dontGetFilteredByNonPedanticMode = 0; + + IntReferenceWrapper2(int &a) : a(a) {} // no-warning +}; + +void fMultipleObjectsReferencingTheSameObjectTest() { + int a; + + IntReferenceWrapper1 T1(a); + IntReferenceWrapper2 T2(a); +} Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp @@ -153,7 +153,7 @@ if (V.isUndef()) { return addFieldToUninits( -LocalChain.add(LocField(FR, /*IsDereferenced*/ false))); +LocalChain.add(LocField(FR, /*IsDereferenced*/ false)), FR); } if (!Opts.CheckPointeeInitialization) { @@ -170,7 +170,7 @@ } if (DerefInfo->IsCyclic) -return addFieldToUninits(LocalChain.add(CyclicLocField(FR))); +return addFieldToUninits(LocalChain.add(CyclicLocField(FR)), FR); const TypedValueRegion *R = DerefInfo->R; const bool NeedsCastBack = DerefInfo->NeedsCastBack; @@ -187,8 +187,9 @@ if (PointeeT->isUnionType()) { if (isUnionUninit(R)) { if (NeedsCastBack) -return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT))); - return addFieldToUninits(LocalChain.add(LocField(FR))); +return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT)), + R); + return addFieldToUninits(LocalChain.add(LocField(FR)), R); } else { IsAnyFieldInitialized = true; return false; @@ -208,8 +209,8 @@ if (isPrimitiveUninit(PointeeV)) { if (NeedsCastBack) - return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT))); -return addFieldToUninits(LocalChain.add(LocField(FR))); + return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT)), R); +return addFieldToUninits(LocalChain.add(LocField(FR)), R); } IsAnyFieldInitialized = true; Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp @@ -28,18 +28,25 @@ using namespace clang; using namespace clang::ento; +/// We'll mark fields (and pointee of fields) that are confirmed to be +/// uninitialized as already analyzed. +REGISTER_SET_WITH_PROGRAMSTATE(AnalyzedRegions, const MemRegion *) + namespace { -class UninitializedObjectChecker : public Checker { +class UninitializedObjectChecker +: public Checker { std::unique_ptr BT_uninitField; public: // The fields of this struct will be initialized when registering the checker. UninitObjCheckerOptions Opts; UninitializedObjectChecker() : BT_uninitField(new BuiltinBug(this, "Uninitialized fiel
r347153 - [analyzer][UninitializedObjectChecker] Uninit regions are only reported once
Author: szelethus Date: Sun Nov 18 03:34:10 2018 New Revision: 347153 URL: http://llvm.org/viewvc/llvm-project?rev=347153&view=rev Log: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once Especially with pointees, a lot of meaningless reports came from uninitialized regions that were already reported. This is fixed by storing all reported fields to the GDM. Differential Revision: https://reviews.llvm.org/D51531 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=347153&r1=347152&r2=347153&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Sun Nov 18 03:34:10 2018 @@ -215,7 +215,11 @@ public: const TypedValueRegion *const R, const UninitObjCheckerOptions &Opts); - const UninitFieldMap &getUninitFields() { return UninitFields; } + /// Returns with the modified state and a map of (uninitialized region, + /// note message) pairs. + std::pair getResults() { +return {State, UninitFields}; + } /// Returns whether the analyzed region contains at least one initialized /// field. Note that this includes subfields as well, not just direct ones, @@ -296,14 +300,16 @@ private: // TODO: Add a support for nonloc::LocAsInteger. /// Processes LocalChain and attempts to insert it into UninitFields. Returns - /// true on success. + /// true on success. Also adds the head of the list and \p PointeeR (if + /// supplied) to the GDM as already analyzed objects. /// /// Since this class analyzes regions with recursion, we'll only store /// references to temporary FieldNode objects created on the stack. This means /// that after analyzing a leaf of the directed tree described above, the /// elements LocalChain references will be destructed, so we can't store it /// directly. - bool addFieldToUninits(FieldChainInfo LocalChain); + bool addFieldToUninits(FieldChainInfo LocalChain, + const MemRegion *PointeeR = nullptr); }; /// Returns true if T is a primitive type. An object of a primitive type only Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp?rev=347153&r1=347152&r2=347153&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp Sun Nov 18 03:34:10 2018 @@ -28,9 +28,14 @@ using namespace clang; using namespace clang::ento; +/// We'll mark fields (and pointee of fields) that are confirmed to be +/// uninitialized as already analyzed. +REGISTER_SET_WITH_PROGRAMSTATE(AnalyzedRegions, const MemRegion *) + namespace { -class UninitializedObjectChecker : public Checker { +class UninitializedObjectChecker +: public Checker { std::unique_ptr BT_uninitField; public: @@ -39,7 +44,9 @@ public: UninitializedObjectChecker() : BT_uninitField(new BuiltinBug(this, "Uninitialized fields")) {} + void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const; + void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const; }; /// A basic field type, that is not a pointer or a reference, it's dynamic and @@ -140,14 +147,20 @@ void UninitializedObjectChecker::checkEn FindUninitializedFields F(Context.getState(), R, Opts); - const UninitFieldMap &UninitFields = F.getUninitFields(); + std::pair UninitInfo = + F.getResults(); - if (UninitFields.empty()) + ProgramStateRef UpdatedState = UninitInfo.first; + const UninitFieldMap &UninitFields = UninitInfo.second; + + if (UninitFields.empty()) { +Context.addTransition(UpdatedState); return; + } // There are uninitialized fields in the record. - ExplodedNode *Node = Context.generateNonFatalErrorNode(Context.getState()); + ExplodedNode *Node = Context.generateNonFatalErrorNode(UpdatedState); if (!Node) return; @@ -188,6 +201,15 @@ void UninitializedObjectChecker::checkEn Context.emitReport(std::move(Report)); } +void Uninitiali
[PATCH] D53069: [analyzer][www] Update avaible_checks.html
Szelethus abandoned this revision. Szelethus added a comment. Herald added subscribers: gamesh411, baloghadamsoftware. In https://reviews.llvm.org/D53069#1274554, @george.karpenkov wrote: > If we want to be serious about this page, it really has to be auto-generated > (like clang-tidy one), but I understand that this is a larger undertaking. Since sphinx is on the way, hopefully, let's just look for a long term solution. https://reviews.llvm.org/D53069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library
mgorny updated this revision to Diff 174534. mgorny edited the summary of this revision. mgorny added a comment. Updated for check order change in master. https://reviews.llvm.org/D54641 Files: cmake/config-ix.cmake Index: cmake/config-ix.cmake === --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -121,10 +121,12 @@ # Look for terminfo library, used in unittests that depend on LLVMSupport. if(LLVM_ENABLE_TERMINFO) - foreach(library tinfo terminfo curses ncurses ncursesw) + foreach(library terminfo tinfo curses ncurses ncursesw) +string(TOUPPER ${library} library_suffix) check_library_exists( - ${library} setupterm "" COMPILER_RT_HAS_TERMINFO) -if(COMPILER_RT_HAS_TERMINFO) + ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix}) +if(COMPILER_RT_HAS_TERMINFO_${library_suffix}) + set(COMPILER_RT_HAS_TERMINFO TRUE) set(COMPILER_RT_TERMINFO_LIB "${library}") break() endif() Index: cmake/config-ix.cmake === --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -121,10 +121,12 @@ # Look for terminfo library, used in unittests that depend on LLVMSupport. if(LLVM_ENABLE_TERMINFO) - foreach(library tinfo terminfo curses ncurses ncursesw) + foreach(library terminfo tinfo curses ncurses ncursesw) +string(TOUPPER ${library} library_suffix) check_library_exists( - ${library} setupterm "" COMPILER_RT_HAS_TERMINFO) -if(COMPILER_RT_HAS_TERMINFO) + ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix}) +if(COMPILER_RT_HAS_TERMINFO_${library_suffix}) + set(COMPILER_RT_HAS_TERMINFO TRUE) set(COMPILER_RT_TERMINFO_LIB "${library}") break() endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54397: [analyzer][NFC] Move CheckerOptInfo to CheckerRegistry.cpp, and make it local
This revision was automatically updated to reflect the committed changes. Closed by commit rL347157: [analyzer][NFC] Move CheckerOptInfo to CheckerRegistry.cpp, and make it local (authored by Szelethus, committed by ). Herald added subscribers: llvm-commits, gamesh411, baloghadamsoftware. Changed prior to commit: https://reviews.llvm.org/D54397?vs=173568&id=174535#toc Repository: rL LLVM https://reviews.llvm.org/D54397 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Index: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp === --- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -17,7 +17,6 @@ #include "clang/StaticAnalyzer/Checkers/ClangCheckers.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" -#include "clang/StaticAnalyzer/Core/CheckerOptInfo.h" #include "clang/StaticAnalyzer/Core/CheckerRegistry.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/ADT/SmallVector.h" @@ -102,44 +101,23 @@ << pluginAPIVersion; } -static SmallVector -getCheckerOptList(const AnalyzerOptions &opts) { - SmallVector checkerOpts; - for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { -const std::pair &opt = opts.CheckersControlList[i]; -checkerOpts.push_back(CheckerOptInfo(opt.first, opt.second)); - } - return checkerOpts; -} - std::unique_ptr ento::createCheckerManager( ASTContext &context, AnalyzerOptions &opts, ArrayRef plugins, ArrayRef> checkerRegistrationFns, DiagnosticsEngine &diags) { auto checkerMgr = llvm::make_unique(context, opts); - SmallVector checkerOpts = getCheckerOptList(opts); - ClangCheckerRegistry allCheckers(plugins, &diags); for (const auto &Fn : checkerRegistrationFns) Fn(allCheckers); - allCheckers.initializeManager(*checkerMgr, checkerOpts); + allCheckers.initializeManager(*checkerMgr, opts, diags); allCheckers.validateCheckerOptions(opts, diags); checkerMgr->finishedCheckerRegistration(); - for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) { -if (checkerOpts[i].isUnclaimed()) { - diags.Report(diag::err_unknown_analyzer_checker) - << checkerOpts[i].getName(); - diags.Report(diag::note_suggest_disabling_all_checkers); -} - - } - return checkerMgr; } @@ -155,8 +133,7 @@ const AnalyzerOptions &opts) { out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n"; - SmallVector checkerOpts = getCheckerOptList(opts); - ClangCheckerRegistry(plugins).printList(out, checkerOpts); + ClangCheckerRegistry(plugins).printList(out, opts); } void ento::printAnalyzerConfigList(raw_ostream &out) { Index: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp @@ -12,7 +12,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" -#include "clang/StaticAnalyzer/Core/CheckerOptInfo.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetVector.h" @@ -30,6 +29,41 @@ using CheckerInfoSet = llvm::SetVector; +namespace { +/// Represents a request to include or exclude a checker or package from a +/// specific analysis run. +/// +/// \sa CheckerRegistry::initializeManager +class CheckerOptInfo { + StringRef Name; + bool Enable; + bool Claimed; + +public: + CheckerOptInfo(StringRef name, bool enable) +: Name(name), Enable(enable), Claimed(false) { } + + StringRef getName() const { return Name; } + bool isEnabled() const { return Enable; } + bool isDisabled() const { return !isEnabled(); } + + bool isClaimed() const { return Claimed; } + bool isUnclaimed() const { return !isClaimed(); } + void claim() { Claimed = true; } +}; + +} // end of anonymous namespace + +static SmallVector +getCheckerOptList(const AnalyzerOptions &opts) { + SmallVector checkerOpts; + for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { +const std::pair &opt = opts.CheckersControlList[i]; +checkerOpts.push_back(CheckerOptInfo(opt.first, opt.second)); + } + return checkerOpts; +} + static bool checkerNameLT(const CheckerRegistry::CheckerInfo &a, const CheckerRegistry::CheckerInfo &b) { return a.FullName < b.FullName; @@ -52,6 +86,7 @@ return false; } +/// Collects the checkers for the supplied \p opt opt
r347157 - [analyzer][NFC] Move CheckerOptInfo to CheckerRegistry.cpp, and make it local
Author: szelethus Date: Sun Nov 18 04:47:03 2018 New Revision: 347157 URL: http://llvm.org/viewvc/llvm-project?rev=347157&view=rev Log: [analyzer][NFC] Move CheckerOptInfo to CheckerRegistry.cpp, and make it local CheckerOptInfo feels very much out of place in CheckerRegistration.cpp, so I moved it to CheckerRegistry.h. Differential Revision: https://reviews.llvm.org/D54397 Removed: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Removed: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h?rev=347156&view=auto == --- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h (removed) @@ -1,44 +0,0 @@ -//===--- CheckerOptInfo.h - Specifies which checkers to use -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef LLVM_CLANG_STATICANALYZER_CORE_CHECKEROPTINFO_H -#define LLVM_CLANG_STATICANALYZER_CORE_CHECKEROPTINFO_H - -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/StringRef.h" - -namespace clang { -namespace ento { - -/// Represents a request to include or exclude a checker or package from a -/// specific analysis run. -/// -/// \sa CheckerRegistry::initializeManager -class CheckerOptInfo { - StringRef Name; - bool Enable; - bool Claimed; - -public: - CheckerOptInfo(StringRef name, bool enable) -: Name(name), Enable(enable), Claimed(false) { } - - StringRef getName() const { return Name; } - bool isEnabled() const { return Enable; } - bool isDisabled() const { return !isEnabled(); } - - bool isClaimed() const { return Claimed; } - bool isUnclaimed() const { return !isClaimed(); } - void claim() { Claimed = true; } -}; - -} // end namespace ento -} // end namespace clang - -#endif Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h?rev=347157&r1=347156&r2=347157&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h Sun Nov 18 04:47:03 2018 @@ -73,8 +73,6 @@ class DiagnosticsEngine; namespace ento { -class CheckerOptInfo; - /// Manages a set of available checkers for running a static analysis. /// The checkers are organized into packages by full name, where including /// a package will recursively include all subpackages and checkers within it. @@ -123,8 +121,8 @@ public: /// all checkers specified by the given CheckerOptInfo list. The order of this /// list is significant; later options can be used to reverse earlier ones. /// This can be used to exclude certain checkers in an included package. - void initializeManager(CheckerManager &mgr, - SmallVectorImpl &opts) const; + void initializeManager(CheckerManager &mgr, const AnalyzerOptions &Opts, + DiagnosticsEngine &diags) const; /// Check if every option corresponds to a specific checker or package. void validateCheckerOptions(const AnalyzerOptions &opts, @@ -133,8 +131,7 @@ public: /// Prints the name and description of all checkers in this registry. /// This output is not intended to be machine-parseable. void printHelp(raw_ostream &out, size_t maxNameChars = 30) const; - void printList(raw_ostream &out, - SmallVectorImpl &opts) const; + void printList(raw_ostream &out, const AnalyzerOptions &opts) const; private: mutable CheckerInfoList Checkers; Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=347157&r1=347156&r2=347157&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Sun Nov 18 04:47:03 2018 @@ -12,7 +12,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" -#include "clang/StaticAnalyzer/Core/CheckerOptInfo.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetVector.h" @@ -30,6 +29,41
[PATCH] D54379: Add Hurd toolchain support to Clang
sthibaul updated this revision to Diff 174536. sthibaul added a comment. I have added a few checks (the ld.so dynamic linker specification, the ../lib32 paths, and /usr/lib/i386-gnu) About negative tests, what kind of invalid input are you thinking about? Repository: rC Clang https://reviews.llvm.org/D54379 Files: lib/Basic/Targets.cpp lib/Basic/Targets/OSTargets.h lib/Driver/CMakeLists.txt lib/Driver/Driver.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Hurd.cpp lib/Driver/ToolChains/Hurd.h lib/Frontend/InitHeaderSearch.cpp test/Driver/Inputs/basic_hurd_tree/include/.keep test/Driver/Inputs/basic_hurd_tree/lib/i386-gnu/.keep test/Driver/Inputs/basic_hurd_tree/lib32/.keep test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/.keep test/Driver/Inputs/basic_hurd_tree/usr/lib/i386-gnu/.keep test/Driver/Inputs/basic_hurd_tree/usr/lib32/.keep test/Driver/hurd.c Index: test/Driver/hurd.c === --- test/Driver/hurd.c +++ test/Driver/hurd.c @@ -0,0 +1,20 @@ +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=i386-pc-gnu \ +// RUN: --sysroot=%S/Inputs/basic_hurd_tree \ +// RUN: | FileCheck --check-prefix=CHECK %s +// CHECK-NOT: warning: +// CHECK: "{{.*}}clang{{(.exe)?}}" +// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK: "-internal-isystem" "[[SYSROOT]]/usr/local/include" +// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/i386-gnu" +// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/include" +// CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include" +// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK: "-dynamic-linker" "/lib/ld.so" +// CHECK: "crtbegin.o" +// CHECK: "-L[[SYSROOT]]/lib/i386-gnu" +// CHECK: "-L[[SYSROOT]]/lib/../lib32" +// CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu" +// CHECK: "-L[[SYSROOT]]/usr/lib/../lib32" +// CHECK: "-L[[SYSROOT]]/lib" +// CHECK: "-L[[SYSROOT]]/usr/lib" Index: lib/Frontend/InitHeaderSearch.cpp === --- lib/Frontend/InitHeaderSearch.cpp +++ lib/Frontend/InitHeaderSearch.cpp @@ -260,6 +260,7 @@ switch (os) { case llvm::Triple::Linux: + case llvm::Triple::Hurd: case llvm::Triple::Solaris: llvm_unreachable("Include management is handled in the driver."); @@ -412,6 +413,7 @@ switch (os) { case llvm::Triple::Linux: + case llvm::Triple::Hurd: case llvm::Triple::Solaris: llvm_unreachable("Include management is handled in the driver."); break; @@ -460,6 +462,7 @@ break; // Everything else continues to use this routine's logic. case llvm::Triple::Linux: + case llvm::Triple::Hurd: case llvm::Triple::Solaris: return; Index: lib/Driver/ToolChains/Hurd.h === --- lib/Driver/ToolChains/Hurd.h +++ lib/Driver/ToolChains/Hurd.h @@ -0,0 +1,46 @@ +//===--- Hurd.h - Hurd ToolChain Implementations --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H +#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H + +#include "Gnu.h" +#include "clang/Driver/ToolChain.h" + +namespace clang { +namespace driver { +namespace toolchains { + +class LLVM_LIBRARY_VISIBILITY Hurd : public Generic_ELF { +public: + Hurd(const Driver &D, const llvm::Triple &Triple, + const llvm::opt::ArgList &Args); + + bool HasNativeLLVMSupport() const override; + + void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, +llvm::opt::ArgStringList &CC1Args) const override; + + virtual std::string computeSysRoot() const; + + virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const; + + std::vector ExtraOpts; + +protected: + Tool *buildAssembler() const override; + Tool *buildLinker() const override; +}; + +} // end namespace toolchains +} // end namespace driver +} // end namespace clang + +#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Hurd_H Index: lib/Driver/ToolChains/Hurd.cpp === --- lib/Driver/ToolChains/Hurd.cpp +++ lib/Driver/ToolChains/Hurd.cpp @@ -0,0 +1,172 @@ +//===--- Hurd.cpp - Hurd ToolChain Implementations *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "Hurd.h" +#include "CommonArgs.h" +#include "clang/Config/config.h" +#include "clang/Driver/Driver.h"
[PATCH] D54675: [AST] Store the expressions in ParenListExpr in a trailing array
riccibruno created this revision. riccibruno added a reviewer: rjmccall. riccibruno added a project: clang. Herald added a reviewer: shafik. Herald added a subscriber: cfe-commits. Use the newly available space in the bit-fields of `Stmt` and store the expressions in a trailing array. This saves 2 pointer per `ParenListExpr`. Repository: rC Clang https://reviews.llvm.org/D54675 Files: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/ASTImporter.cpp lib/AST/Expr.cpp lib/Sema/SemaCoroutine.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterStmt.cpp Index: lib/Serialization/ASTWriterStmt.cpp === --- lib/Serialization/ASTWriterStmt.cpp +++ lib/Serialization/ASTWriterStmt.cpp @@ -559,11 +559,11 @@ void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) { VisitExpr(E); - Record.push_back(E->NumExprs); - for (unsigned i=0; i != E->NumExprs; ++i) -Record.AddStmt(E->Exprs[i]); - Record.AddSourceLocation(E->LParenLoc); - Record.AddSourceLocation(E->RParenLoc); + Record.push_back(E->getNumExprs()); + for (auto *SubStmt : E->exprs()) +Record.AddStmt(SubStmt); + Record.AddSourceLocation(E->getLParenLoc()); + Record.AddSourceLocation(E->getRParenLoc()); Code = serialization::EXPR_PAREN_LIST; } Index: lib/Serialization/ASTReaderStmt.cpp === --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -643,10 +643,9 @@ void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { VisitExpr(E); unsigned NumExprs = Record.readInt(); - E->Exprs = new (Record.getContext()) Stmt*[NumExprs]; - for (unsigned i = 0; i != NumExprs; ++i) -E->Exprs[i] = Record.readSubStmt(); - E->NumExprs = NumExprs; + assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!"); + for (unsigned I = 0; I != NumExprs; ++I) +E->getTrailingObjects()[I] = Record.readSubStmt(); E->LParenLoc = ReadSourceLocation(); E->RParenLoc = ReadSourceLocation(); } @@ -2452,7 +2451,9 @@ break; case EXPR_PAREN_LIST: - S = new (Context) ParenListExpr(Empty); + S = ParenListExpr::CreateEmpty( + Context, + /* NumExprs=*/Record[ASTStmtReader::NumExprFields + 0]); break; case EXPR_UNARY_OPERATOR: Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -6410,8 +6410,7 @@ ExprResult Sema::ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val) { - Expr *expr = new (Context) ParenListExpr(Context, L, Val, R); - return expr; + return ParenListExpr::Create(Context, L, Val, R); } /// Emit a specialized diagnostic when one expression is a null pointer Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -3731,8 +3731,7 @@ ArrayRef Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc) { - Expr *List = new (Context) ParenListExpr(Context, LParenLoc, - Args, RParenLoc); + Expr *List = ParenListExpr::Create(Context, LParenLoc, Args, RParenLoc); return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy, DS, IdLoc, List, EllipsisLoc); } Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -565,8 +565,8 @@ // Create an initialization sequence for the promise type using the // constructor arguments, wrapped in a parenthesized list expression. - Expr *PLE = new (Context) ParenListExpr(Context, FD->getLocation(), - CtorArgExprs, FD->getLocation()); + Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(), +CtorArgExprs, FD->getLocation()); InitializedEntity Entity = InitializedEntity::InitializeVariable(VD); InitializationKind Kind = InitializationKind::CreateForInit( VD->getLocation(), /*DirectInit=*/true, PLE); Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -4008,27 +4008,48 @@ return getBase()->getEndLoc(); } -ParenListExpr::ParenListExpr(const ASTContext& C, SourceLocation lparenloc, - ArrayRef exprs, - SourceLocation rparenloc) - : Expr(ParenListExprClass, QualType(), VK_RValue, OK_Ordinary, - false, false, false, false), -NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(r
[PATCH] D54676: [AST] Pack CallExpr
riccibruno created this revision. riccibruno added a reviewer: rjmccall. riccibruno added a project: clang. Herald added a subscriber: cfe-commits. Use the newly available space in the bit-fields of `Stmt` to store some data from `CallExpr`. This saves 8 bytes per `CallExpr`. This is a straightforward patch, except that it limits the maximum number of arguments to `2^14 - 1`. The maximum number of arguments to a function call is already limited to 16 bits because of `FunctionTypeBitfields::NumParams`, which used to be 15 bits until a few month ago. This also do not leave any space for additional bits, but after looking at the history of `CallExpr` it seems that people are not adding data here very frequently. It would be possible to reuse some bits of the `SubExprs` pointer, but ideally this pointer would be removed by storing the arguments in a trailing array. Alternatively it would be possible to store the number of arguments in a trailing object when it is too large. Repository: rC Clang https://reviews.llvm.org/D54676 Files: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/Expr.cpp Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -1225,23 +1225,26 @@ ExprValueKind VK, SourceLocation rparenloc) : Expr(SC, t, VK, OK_Ordinary, fn->isTypeDependent(), fn->isValueDependent(), fn->isInstantiationDependent(), - fn->containsUnexpandedParameterPack()), - NumArgs(args.size()) { + fn->containsUnexpandedParameterPack()) { + unsigned NumArgs = args.size(); + CallExprBits.NumArgs = NumArgs; + assert((getNumArgs() == NumArgs) && "NumArgs overflow!"); unsigned NumPreArgs = preargs.size(); - SubExprs = new (C) Stmt *[args.size()+PREARGS_START+NumPreArgs]; + CallExprBits.NumPreArgs = NumPreArgs; + + SubExprs = new (C) Stmt *[NumArgs+PREARGS_START+NumPreArgs]; SubExprs[FN] = fn; for (unsigned i = 0; i != NumPreArgs; ++i) { updateDependenciesFromArg(preargs[i]); SubExprs[i+PREARGS_START] = preargs[i]; } - for (unsigned i = 0; i != args.size(); ++i) { + for (unsigned i = 0; i != NumArgs; ++i) { updateDependenciesFromArg(args[i]); SubExprs[i+PREARGS_START+NumPreArgs] = args[i]; } - CallExprBits.NumPreArgs = NumPreArgs; - RParenLoc = rparenloc; + setRParenLoc(rparenloc); } CallExpr::CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, @@ -1259,7 +1262,8 @@ CallExpr::CallExpr(const ASTContext &C, StmtClass SC, unsigned NumPreArgs, EmptyShell Empty) - : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) { + : Expr(SC, Empty), SubExprs(nullptr) { + CallExprBits.NumArgs = 0; // FIXME: Why do we allocate this? SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs](); CallExprBits.NumPreArgs = NumPreArgs; @@ -1317,7 +1321,7 @@ // If shrinking # arguments, just delete the extras and forgot them. if (NumArgs < getNumArgs()) { -this->NumArgs = NumArgs; +CallExprBits.NumArgs = NumArgs; return; } @@ -1334,7 +1338,7 @@ if (SubExprs) C.Deallocate(SubExprs); SubExprs = NewSubExprs; - this->NumArgs = NumArgs; + CallExprBits.NumArgs = NumArgs; } /// getBuiltinCallee - If this is a call to a builtin, return the builtin ID. If Index: include/clang/AST/Stmt.h === --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -422,6 +422,9 @@ unsigned : NumExprBits; unsigned NumPreArgs : 1; +unsigned NumArgs : 14; + +SourceLocation RParenLoc; }; class MemberExprBitfields { Index: include/clang/AST/Expr.h === --- include/clang/AST/Expr.h +++ include/clang/AST/Expr.h @@ -2405,8 +2405,6 @@ class CallExpr : public Expr { enum { FN=0, PREARGS_START=1 }; Stmt **SubExprs; - unsigned NumArgs; - SourceLocation RParenLoc; void updateDependenciesFromArg(Expr *Arg); @@ -2458,8 +2456,7 @@ } /// getNumArgs - Return the number of actual arguments to this call. - /// - unsigned getNumArgs() const { return NumArgs; } + unsigned getNumArgs() const { return CallExprBits.NumArgs; } /// Retrieve the call arguments. Expr **getArgs() { @@ -2472,17 +2469,17 @@ /// getArg - Return the specified argument. Expr *getArg(unsigned Arg) { -assert(Arg < NumArgs && "Arg access out of range!"); +assert(Arg < getNumArgs() && "Arg access out of range!"); return cast_or_null(SubExprs[Arg + getNumPreArgs() + PREARGS_START]); } const Expr *getArg(unsigned Arg) const { -assert(Arg < NumArgs && "Arg access out of range!"); +assert(Arg < getNumArgs() && "Arg access out of range!"); return cast_or_null(SubExprs[Arg + getNumPreArgs() + PREARGS_START]); } /// setArg - Set the specified argument. void setArg(unsigned Arg, Expr *ArgExpr) { -assert(Arg < NumAr
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
aaron.ballman added a comment. It looks like you removed a considerable amount of testing coverage; why? Comment at: lib/Sema/SemaChecking.cpp:10920-10921 +if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) { + if (S.SourceMgr.isInSystemMacro(CC)) +return; + const llvm::fltSemantics &FloatSemantics = aaron.ballman wrote: > It seems wrong to early return here -- that means none of the later checks > are run on system macros, but we've also not diagnosed anything as being > wrong with the user's code yet. This changes the behavior of your patch -- I think it made sense to not trigger this diagnostic in a system macro. I was suggesting that you replace the early return with braces and flip the logic around so that you only do the diagnostic work if you're not in a system macro. https://reviews.llvm.org/D52835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends
hfinkel added a comment. In https://reviews.llvm.org/D53157#1302159, @cameron.mcinally wrote: > In https://reviews.llvm.org/D53157#1301992, @hfinkel wrote: > > > > Just because FENV_ACCESS can be toggled on that granularity doesn't mean > > > we have to represent it that way. We've previously agreed (I think) that > > > if FENV_ACCESS is enabled anywhere in a function we will want to use the > > > constrained intrinsics for all FP operations in the function, not just > > > the ones in the scope where it was specified. > > > > Yes, this is also my understanding. We can't soundly mix the two in the > > same function because we can't prevent the code motion within the function. > > > Ugh, I don't know. The C Standard's language is so vague. To be clear, I mean here that *we* can't mix the two soundly in the same function (where we generate some operations using the constrained instrinsics and some not) because of constraints imposed by our design. The standard may indeed allow for more precision. We'll need to be conservatively correct. > > > In https://reviews.llvm.org/D53157#1301994, @hfinkel wrote: > >> The rounding mode does need to be reset to its default setting when passing >> from FENV_ACCESS "on" to FENV_ACCESS "off", but that seems to be the user's >> responsibility. Are you saying that the implementation should reset it on >> that transition? > > > Yes, that's how I was interpreting the Standard (today). The implementation > should reset the control modes. The verbiage is murky at best though. I'll also point out that whether or not we insert a rounding-mode reset when the pragma changes state is orthogonal to whether we stop emitting constrained intrinsics at that point. > We touched on this in https://reviews.llvm.org/D43142 and I do realize that > my opinion has flip-flopped since then. I previously believed that reseting > the control modes was up to the user, but now I'm not so sure. I suppose that > either way, as long as a fesetround(default_mode_constant) is seen with a > FENV_ACCESS=OFF, we could use that as a barrier to prevent the problematic > code motion. > > Thinking aloud, maybe we should be working on redefining FENV_ACCESS in the C > Standard? It's pretty clear that this section could use some work. > > All that said, my understanding of $7.6.1 in the Standard is cloudy at best. > If I'm the only one that feels this way, I'll drop my objections... I don't read the standard that way, but the standard could certainly be more clear. https://reviews.llvm.org/D53157 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54404: Exclude matchers which can have multiple results
steveire added inline comments. Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:624 + "hasAnyDeclaration", + "hasAnyName", + "hasAnyParameter", sbenza wrote: > I'm not sure what goes in this list. > `hasAnyName` is here but not `hasName`. > What is ambiguous about `hasAnyName`? I have a follow-up which adds output showing that `hasName` can be used. See http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/_X9mnw If there was an entry there for `hasAnyName`, what would go in it? Repository: rC Clang https://reviews.llvm.org/D54404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r347163 - Add the abseil-duration-factory-scale check.
Author: aaronballman Date: Sun Nov 18 08:41:06 2018 New Revision: 347163 URL: http://llvm.org/viewvc/llvm-project?rev=347163&view=rev Log: Add the abseil-duration-factory-scale check. This check removes unneeded scaling of arguments when calling Abseil Time factory functions. Patch by Hyrum Wright. Added: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-duration-factory-scale.rst clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp?rev=347163&r1=347162&r2=347163&view=diff == --- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp Sun Nov 18 08:41:06 2018 @@ -12,6 +12,7 @@ #include "../ClangTidyModuleRegistry.h" #include "DurationDivisionCheck.h" #include "DurationFactoryFloatCheck.h" +#include "DurationFactoryScaleCheck.h" #include "FasterStrsplitDelimiterCheck.h" #include "NoInternalDependenciesCheck.h" #include "NoNamespaceCheck.h" @@ -30,6 +31,8 @@ public: "abseil-duration-division"); CheckFactories.registerCheck( "abseil-duration-factory-float"); +CheckFactories.registerCheck( +"abseil-duration-factory-scale"); CheckFactories.registerCheck( "abseil-faster-strsplit-delimiter"); CheckFactories.registerCheck( Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt?rev=347163&r1=347162&r2=347163&view=diff == --- clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt Sun Nov 18 08:41:06 2018 @@ -4,6 +4,7 @@ add_clang_library(clangTidyAbseilModule AbseilTidyModule.cpp DurationDivisionCheck.cpp DurationFactoryFloatCheck.cpp + DurationFactoryScaleCheck.cpp FasterStrsplitDelimiterCheck.cpp NoInternalDependenciesCheck.cpp NoNamespaceCheck.cpp Added: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp?rev=347163&view=auto == --- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp Sun Nov 18 08:41:06 2018 @@ -0,0 +1,269 @@ +//===--- DurationFactoryScaleCheck.cpp - clang-tidy ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "DurationFactoryScaleCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Tooling/FixIt.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace abseil { + +namespace { + +// Potential scales of our inputs. +enum class DurationScale { + Hours, + Minutes, + Seconds, + Milliseconds, + Microseconds, + Nanoseconds, +}; + +} // namespace + +// Given the name of a duration factory function, return the appropriate +// `DurationScale` for that factory. If no factory can be found for +// `FactoryName`, return `None`. +static llvm::Optional +getScaleForFactory(llvm::StringRef FactoryName) { + static const std::unordered_map ScaleMap( + {{"Nanoseconds", DurationScale::Nanoseconds}, + {"Microseconds", DurationScale::Microseconds}, + {"Milliseconds", DurationScale::Milliseconds}, + {"Seconds", DurationScale::Seconds}, + {"Minutes", DurationScale::Minutes}, + {"Hours", DurationScale::Hours}}); + + auto ScaleIter = ScaleMap.find(FactoryName); + if (ScaleIter == ScaleMap.end()) +return llvm::None; + + return ScaleIter->second; +} + +// Given either an integer or float literal, return its value. +// One and only one of `IntLit` and `FloatLit` should be provided. +static double GetValue(const IntegerLiteral *IntLit, + const FloatingLiteral *FloatLit) { + if (IntLit) +return IntLit
[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check
aaron.ballman closed this revision. aaron.ballman added a comment. I've commit in r347163. Thank you for the patch! https://reviews.llvm.org/D54246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
xbolva00 added a comment. I removed _Float16 related tests since some bots may fall with it, i dont know much about this custom type. Anyway, It is fine on linux x86 64. I will restore them. System macro - I will fix it. https://reviews.llvm.org/D52835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54404: Exclude matchers which can have multiple results
aaron.ballman added inline comments. Comment at: lib/ASTMatchers/Dynamic/Registry.cpp:624 + "hasAnyDeclaration", + "hasAnyName", + "hasAnyParameter", steveire wrote: > sbenza wrote: > > I'm not sure what goes in this list. > > `hasAnyName` is here but not `hasName`. > > What is ambiguous about `hasAnyName`? > I have a follow-up which adds output showing that `hasName` can be used. See > > http://ec2-52-14-16-249.us-east-2.compute.amazonaws.com:10240/z/_X9mnw > > If there was an entry there for `hasAnyName`, what would go in it? > If there was an entry there for hasAnyName, what would go in it? Presumably the same as `hasName()`, though for the purposes of that list, I could see why it would be a bit odd to list it. It almost feels like this isn't about ambiguity of the matchers (at least, not always) so much as it is about sensibility within a "the following are related matchers" list due to there being many different ways for matchers to relate. For instance, a related matcher could be `functionDecl(hasAnyParameter(anything()))`, but you might not want to list that because it's an open-ended problem to generate all such cases and it has very limited value to list them. Is that a better way for me to think about this? Repository: rC Clang https://reviews.llvm.org/D54404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r347178 - Replace the UTF-8 characters in the error message.
Author: brad Date: Sun Nov 18 14:30:58 2018 New Revision: 347178 URL: http://llvm.org/viewvc/llvm-project?rev=347178&view=rev Log: Replace the UTF-8 characters in the error message. Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/test/Driver/mips-abicalls-error.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=347178&r1=347177&r2=347178&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Sun Nov 18 14:30:58 2018 @@ -357,7 +357,7 @@ def warn_drv_unsupported_pic_with_mabica "%select{implicit usage of|}1 -mabicalls and the N64 ABI">, InGroup; def err_drv_unsupported_noabicalls_pic : Error< - "position-independent code requires â-mabicallsâ">; + "position-independent code requires '-mabicalls'">; def err_drv_unsupported_indirect_jump_opt : Error< "'-mindirect-jump=%0' is unsupported with the '%1' architecture">; def err_drv_unknown_indirect_jump_opt : Error< Modified: cfe/trunk/test/Driver/mips-abicalls-error.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abicalls-error.c?rev=347178&r1=347177&r2=347178&view=diff == --- cfe/trunk/test/Driver/mips-abicalls-error.c (original) +++ cfe/trunk/test/Driver/mips-abicalls-error.c Sun Nov 18 14:30:58 2018 @@ -1,2 +1,2 @@ // RUN: not %clang -c -target mips64-linux-gnu -fPIC -mno-abicalls %s 2>&1 | FileCheck %s -// CHECK: error: position-independent code requires â-mabicallsâ +// CHECK: error: position-independent code requires '-mabicalls' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished
a_sidorin updated this revision to Diff 174545. a_sidorin added a comment. Hi @davide and @shafik, Could you please check the updated version of the patch? Repository: rC Clang https://reviews.llvm.org/D44100 Files: lib/AST/ASTImporter.cpp unittests/AST/ASTImporterTest.cpp Index: unittests/AST/ASTImporterTest.cpp === --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -1457,7 +1457,7 @@ } TEST_P(ASTImporterTestBase, - DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) { + CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) { Decl *From, *To; std::tie(From, To) = getImportedDecl( // The original recursive algorithm of ASTImporter first imports 'c' then @@ -3767,5 +3767,16 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportVariables, DefaultTestValuesForRunOptions, ); +TEST_P(ImportDecl, ImportFieldOrder) { + MatchVerifier Verifier; + testImport("struct declToImport {" + " int b = a + 2;" + " int a = 5;" + "};", + Lang_CXX11, "", Lang_CXX11, Verifier, + recordDecl(hasFieldOrder({"b", "a"}))); +} + + } // end namespace ast_matchers } // end namespace clang Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -1658,15 +1658,63 @@ auto ToDCOrErr = Importer.ImportContext(FromDC); return ToDCOrErr.takeError(); } - llvm::SmallVector ImportedDecls; + + const auto *FromRD = dyn_cast(FromDC); for (auto *From : FromDC->decls()) { ExpectedDecl ImportedOrErr = import(From); -if (!ImportedOrErr) +if (!ImportedOrErr) { + // For RecordDecls, failed import of a field will break the layout of the + // structure. Handle it as an error. + if (FromRD) +return ImportedOrErr.takeError(); // Ignore the error, continue with next Decl. // FIXME: Handle this case somehow better. - consumeError(ImportedOrErr.takeError()); + else +consumeError(ImportedOrErr.takeError()); +} } + // Reorder declarations in RecordDecls because they may have another + // order. Keeping field order is vitable because it determines structure + // layout. + // FIXME: This is an ugly fix. Unfortunately, I cannot come with better + // solution for this issue. We cannot defer expression import here because + // type import can depend on them. + if (!FromRD) +return Error::success(); + + + // NOTE: Here and below, we cannot call field_begin() method and its callers + // on ToRD if it has an external storage. Calling field_begin() will + // automatically load all the fields by calling + // LoadFieldsFromExternalStorage(). + auto ImportedDC = import(cast(FromDC)); + assert(ImportedDC); + auto *ToRD = cast(*ImportedDC); + for (auto *D : FromRD->decls()) { +if (isa(D) || isa(D)) { + Decl *ToD = Importer.GetAlreadyImportedOrNull(D); + assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD)); + ToRD->removeDecl(ToD); +} + } + + if (!ToRD->hasExternalLexicalStorage()) +assert(ToRD->field_empty()); + + for (auto *D : FromRD->decls()) { +if (isa(D) || isa(D)) { + Decl *ToD = Importer.GetAlreadyImportedOrNull(D); + assert(ToD); + assert(ToRD == ToD->getDeclContext()); + assert(ToRD == ToD->getLexicalDeclContext()); + if (!ToRD->hasExternalLexicalStorage()) +assert(!ToRD->containsDecl(ToD)); + + ToRD->addDeclInternal(ToD); +} + } + return Error::success(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54675: [AST] Store the expressions in ParenListExpr in a trailing array
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM. Repository: rC Clang https://reviews.llvm.org/D54675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r347179 - [PowerPC] Set the default PLT mode on OpenBSD/powerpc to Secure PLT.
Author: brad Date: Sun Nov 18 16:21:06 2018 New Revision: 347179 URL: http://llvm.org/viewvc/llvm-project?rev=347179&view=rev Log: [PowerPC] Set the default PLT mode on OpenBSD/powerpc to Secure PLT. OpenBSD/powerpc only supports Secure PLT. Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h cfe/trunk/test/Driver/openbsd.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=347179&r1=347178&r2=347179&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Sun Nov 18 16:21:06 2018 @@ -107,15 +107,19 @@ void ppc::getPPCTargetFeatures(const Dri if (FloatABI == ppc::FloatABI::Soft) Features.push_back("-hard-float"); - ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args); + ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Triple, Args); if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt) Features.push_back("+secure-plt"); } -ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList &Args) { +ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args) { if (Args.getLastArg(options::OPT_msecure_plt)) return ppc::ReadGOTPtrMode::SecurePlt; - return ppc::ReadGOTPtrMode::Bss; + if (Triple.isOSOpenBSD()) +return ppc::ReadGOTPtrMode::SecurePlt; + else +return ppc::ReadGOTPtrMode::Bss; } ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) { Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h?rev=347179&r1=347178&r2=347179&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h Sun Nov 18 16:21:06 2018 @@ -38,7 +38,7 @@ FloatABI getPPCFloatABI(const Driver &D, std::string getPPCTargetCPU(const llvm::opt::ArgList &Args); const char *getPPCAsmModeForCPU(StringRef Name); -ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, +ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, Modified: cfe/trunk/test/Driver/openbsd.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=347179&r1=347178&r2=347179&view=diff == --- cfe/trunk/test/Driver/openbsd.c (original) +++ cfe/trunk/test/Driver/openbsd.c Sun Nov 18 16:21:06 2018 @@ -112,3 +112,8 @@ // RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s // CHECK-ARM-FLOAT-ABI-NOT: "-target-feature" "+soft-float" // CHECK-ARM-FLOAT-ABI: "-target-feature" "+soft-float-abi" + +// Check PowerPC for Secure PLT +// RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-POWERPC-SECUREPLT %s +// CHECK-POWERPC-SECUREPLT: "-target-feature" "+secure-plt" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished
davide added a comment. Alexsei, I'm afraid I'm not qualified to review this patch. I would really recommend you to find somebody who's familiar with clang to review it, as it already seems to have broken lldb in the past. Repository: rC Clang https://reviews.llvm.org/D44100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54355: Use is.constant intrinsic for __builtin_constant_p
void updated this revision to Diff 174551. void added a comment. No function pointers Repository: rC Clang https://reviews.llvm.org/D54355 Files: include/clang/AST/Expr.h lib/AST/ASTImporter.cpp lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaType.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/builtin-functions.cpp test/Sema/builtins.c test/SemaCXX/compound-literal.cpp Index: test/SemaCXX/compound-literal.cpp === --- test/SemaCXX/compound-literal.cpp +++ test/SemaCXX/compound-literal.cpp @@ -36,8 +36,8 @@ POD p = (POD){1, 2}; // CHECK-NOT: CXXBindTemporaryExpr {{.*}} 'brace_initializers::POD' - // CHECK: ConstantExpr {{.*}} 'brace_initializers::POD' - // CHECK-NEXT: CompoundLiteralExpr {{.*}} 'brace_initializers::POD' + // CHECK: CompoundLiteralExpr {{.*}} 'brace_initializers::POD' + // CHECK-NEXT: ConstantExpr {{.*}} 'brace_initializers::POD' // CHECK-NEXT: InitListExpr {{.*}} 'brace_initializers::POD' // CHECK-NEXT: IntegerLiteral {{.*}} 1{{$}} // CHECK-NEXT: IntegerLiteral {{.*}} 2{{$}} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -122,6 +122,14 @@ __builtin_constant_p(1, 2); // expected-error {{too many arguments}} } +// __builtin_constant_p cannot resolve non-constants as a file scoped array. +int expr; +char y[__builtin_constant_p(expr) ? -1 : 1]; // no warning, the builtin is false. + +// no warning, the builtin is false. +struct foo { int a; }; +struct foo x = (struct foo) { __builtin_constant_p(42) ? 37 : 927 }; + const int test17_n = 0; const char test17_c[] = {1, 2, 3, 0}; const char test17_d[] = {1, 2, 3, 4}; Index: test/Analysis/builtin-functions.cpp === --- test/Analysis/builtin-functions.cpp +++ test/Analysis/builtin-functions.cpp @@ -70,14 +70,14 @@ const int j = 2; constexpr int k = 3; clang_analyzer_eval(__builtin_constant_p(42) == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(i) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(j) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(k) == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(i + 42) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(j + 42) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(k + 42) == 1); // expected-warning {{TRUE}} clang_analyzer_eval(__builtin_constant_p(" ") == 1); // expected-warning {{TRUE}} - clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{TRUE}} + clang_analyzer_eval(__builtin_constant_p(test_constant_p) == 0); // expected-warning {{UNKNOWN}} clang_analyzer_eval(__builtin_constant_p(k - 3) == 0); // expected-warning {{FALSE}} clang_analyzer_eval(__builtin_constant_p(k - 3) == 1); // expected-warning {{TRUE}} } Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1283,9 +1283,6 @@ break; case Expr::ConstantExprClass: - // Handled due to it being a wrapper class. - break; - case Stmt::ExprWithCleanupsClass: // Handled due to fully linearised CFG. break; Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2233,10 +2233,6 @@ T = Context.getConstantArrayType(T, ConstVal, ASM, Quals); } - if (ArraySize && !CurContext->isFunctionOrMethod()) -// A file-scoped array must have a constant array size. -ArraySize = new (Context) ConstantExpr(ArraySize); - // OpenCL v1.2 s6.9.d: variable length arrays are not supported. if (getLangOpts().OpenCL && T->isVariableArrayType()) { Diag(Loc, diag::err_opencl_vla); Index: lib/Sema/SemaTemplateDeduction.cpp === --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -178,6 +178,8 @@ while (true) { if (ImplicitCastExpr *IC = dyn_cast(E)) E = IC->getSubExpr(); +else if (ConstantExpr *CE = dyn_cast(E)) + E = CE->getSubExpr(); else if (SubstNonTypeTemplateParmExpr *Subst = dyn_cast(E)) E = Subst->getReplacement(); @@ -5225,6 +5227,8 @@ while (true) { if (const Im
[PATCH] D54681: [Driver] Avoid including -lm on the link line with -nostdlib++
phosek created this revision. Herald added a subscriber: cfe-commits. Drivers include -lm because standard C++ libraries such as libc++ and libstdc++ depend on libmath and when statically linking C++ library, this dependency is needed. However, when -nostdlib++ is used, there's no reason to include -lm anymore. Repository: rC Clang https://reviews.llvm.org/D54681 Files: clang/lib/Driver/ToolChains/DragonFly.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Hexagon.cpp clang/lib/Driver/ToolChains/Minix.cpp clang/lib/Driver/ToolChains/NaCl.cpp clang/lib/Driver/ToolChains/NetBSD.cpp clang/lib/Driver/ToolChains/OpenBSD.cpp clang/lib/Driver/ToolChains/PS4CPU.cpp clang/test/Driver/nostdlibxx.cpp Index: clang/test/Driver/nostdlibxx.cpp === --- clang/test/Driver/nostdlibxx.cpp +++ clang/test/Driver/nostdlibxx.cpp @@ -1,8 +1,7 @@ // RUN: %clangxx -target i686-pc-linux-gnu -### -nostdlib++ %s 2> %t // RUN: FileCheck < %t %s -// We should still have -lm and the C standard libraries, but not -lstdc++. +// We should still have C standard libraries, but not -lstdc++. // CHECK-NOT: -lstdc++ // CHECK-NOT: -lc++ -// CHECK: -lm Index: clang/lib/Driver/ToolChains/PS4CPU.cpp === --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -235,9 +235,8 @@ // For PS4, we always want to pass libm, libstdc++ and libkernel // libraries for both C and C++ compilations. CmdArgs.push_back("-lkernel"); -if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) -ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (ToolChain.ShouldLinkCXXStdlib(Args)) { + ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); if (Args.hasArg(options::OPT_pg)) CmdArgs.push_back("-lm_p"); else Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -100,7 +100,6 @@ const char *LinkingOutput) const { const toolchains::OpenBSD &ToolChain = static_cast(getToolChain()); - const Driver &D = getToolChain().getDriver(); ArgStringList CmdArgs; // Silence warning for "clang -g foo.o -o foo" @@ -180,9 +179,8 @@ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { -if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) -ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (ToolChain.ShouldLinkCXXStdlib(Args)) { + ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); if (Args.hasArg(options::OPT_pg)) CmdArgs.push_back("-lm_p"); else Index: clang/lib/Driver/ToolChains/NetBSD.cpp === --- clang/lib/Driver/ToolChains/NetBSD.cpp +++ clang/lib/Driver/ToolChains/NetBSD.cpp @@ -283,9 +283,8 @@ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { addOpenMPRuntime(CmdArgs, getToolChain(), Args); -if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) -ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (ToolChain.ShouldLinkCXXStdlib(Args)) { + ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); CmdArgs.push_back("-lm"); } if (NeedsSanitizerDeps) Index: clang/lib/Driver/ToolChains/NaCl.cpp === --- clang/lib/Driver/ToolChains/NaCl.cpp +++ clang/lib/Driver/ToolChains/NaCl.cpp @@ -131,17 +131,14 @@ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); - if (D.CCCIsCXX() && - !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { -if (ToolChain.ShouldLinkCXXStdlib(Args)) { - bool OnlyLibstdcxxStatic = - Args.hasArg(options::OPT_static_libstdcxx) && !IsStatic; - if (OnlyLibstdcxxStatic) -CmdArgs.push_back("-Bstatic"); - ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); - if (OnlyLibstdcxxStatic) -CmdArgs.push_back("-Bdynamic"); -} + if (ToolChain.ShouldLinkCXXStdlib(Args)) { +bool OnlyLibstdcxxStatic = +Args.hasArg(options::OPT_static_libstdcxx) && !IsStatic; +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); +ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); CmdArgs.push_back("-lm"); } Index: clang/lib/Driver/ToolChains/Minix.cpp === --- clang/lib/Driver/ToolChains/Minix.cpp +++ clang/lib/Driver/ToolChains/Minix.cpp @@ -45,7 +45,6 @@ const InputInfoList &Inputs,
[PATCH] D53231: [Sema] Fix PR38987: keep end location of a direct initializer list
vsk accepted this revision. vsk added a comment. This revision is now accepted and ready to land. The history seems complicated. I think it'd be really useful to sort out why getParenOrBraceRange() couldn't give the right result, but I'd be happy to see this land first to address the crash. Repository: rC Clang https://reviews.llvm.org/D53231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53244: [Coverage] Fix PR39258: support coverage regions that start deeper than they end
vsk added a comment. Friendly ping -- @orivej were you still looking for more feedback? If not, do you still need someone to land this patch on your behalf? Repository: rC Clang https://reviews.llvm.org/D53244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished
a_sidorin added a comment. Hi Davide, I don't mean only review. As I guess, you guys have MacOS machines so you can check if the problem is still present in the updated version. There is no need to remind me about the problem with LLDB since I tried to resolve it. Repository: rC Clang https://reviews.llvm.org/D44100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54676: [AST] Pack CallExpr
rjmccall added a comment. I don't think we should be reducing the number of call arguments we can support, sorry, even if 16K is a fairly absurd number that would probably trip stack overflow protections if you actually executed it. Let's try to keep it at least 64K-ish. Repository: rC Clang https://reviews.llvm.org/D54676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits