Re: [PATCH] D13289: [libc++] Provide additional templates for valarray transcendentals that satisfy the standard synopsis
petpav01 added a comment. It would be probably better if the patch changed the original templates to take only `__val_expr` as there is now no need for them to match valarray too. This should be a simple change but requires additional tests so I will wait for initial feedback that this approach is preferred. http://reviews.llvm.org/D13289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13217: [ARM] The Driver does not set the +strict-align flag when targeting armv6m + netbsd
rengolin added inline comments. Comment at: lib/Basic/Targets.cpp:4456 @@ -4455,3 +4455,1 @@ -if (ArchVersion < 6 || - (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M)) labrinea wrote: > rengolin wrote: > > Why is this not necessary any more? > The logic is still necessary for the back-end to emit aligned loads and > stores, but it should be moved to the Driver, where +strict-align is set for > all arch+OS combinations as shown below. Oh, so this ended up as a work-around for the correct change that you just did, below? http://reviews.llvm.org/D13217 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11700: Added remove taint support to ProgramState.
franchiotta added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:444-448 @@ +443,7 @@ + + SymbolRef + getSymbolFromStmt(const Stmt *S, const LocationContext *LCtx) const; + + const MemRegion* + getRegionFromStmt(const Stmt *S, const LocationContext *LCtx) const; + krememek wrote: > krememek wrote: > > Can we add documentation comments for these? Seems like generally useful > > utility methods. We could also probably just make these public. > Actually, I'm wondering if we really need to add these at all. They are just > one liners that easily could be written where they are used. Right. Removing these methods, and adding the one-liners directly where they are used. Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:653-654 @@ -654,3 +652,4 @@ + *LCtx) const { if (const Expr *E = dyn_cast_or_null(S)) S = E->IgnoreParens(); krememek wrote: > Is this even needed? I think Environment::getSVal() already handles > parenthesis and other ignored expressions. This looks like dead code. > > This can probably just be an inline method in ProgramState.h, that just > forwards to getSVal(S, LCtx).getAsSymbol(). > > Alternatively, if this is only called once, we don't need to add a method at > all, since it is just a one liner. Yes, you are right. It is not needed since it is handle by ignoreTransparentExprs method in Environment module. I will not add this method at all. Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:660-663 @@ +659,6 @@ + +const MemRegion* ProgramState::getRegionFromStmt(const Stmt *S, const LocationContext + *LCtx) const { + return getSVal(S, LCtx).getAsRegion(); +} + krememek wrote: > This is just a one-liner. Do we really need this method at all? It is only > called once. We don't. I will add the one-liner directly where it is used. Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:672-676 @@ -660,7 +671,7 @@ - const MemRegion *R = getSVal(S, LCtx).getAsRegion(); + const MemRegion *R = getRegionFromStmt(S, LCtx); addTaint(R, Kind); // Cannot add taint, so just return the state. return this; } krememek wrote: > This looks fishy. 'addTaint' returns a new state, but then the return value > is ignored, and 'this' is returned. Yes, it does.. I will return at the time the last addTaint is invoked. Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:704-708 @@ +703,7 @@ + + const MemRegion *R = getRegionFromStmt(S, LCtx); + removeTaint(R, Kind); + + // Cannot remove taint, so just return the state. + return this; +} krememek wrote: > This looks fishy. 'removeTaint' returns a new state, but then the return > value is ignored. 'ProgramState' values are immutable, so this method > appears to do nothing. Yes, you are right. I will return at the time the last addTaint is invoked. http://reviews.llvm.org/D11700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r249235 - Replace double negation of !FileID.isInvalid() with FileID.isValid().
Author: yrnkrn Date: Sat Oct 3 05:46:20 2015 New Revision: 249235 URL: http://llvm.org/viewvc/llvm-project?rev=249235=rev Log: Replace double negation of !FileID.isInvalid() with FileID.isValid(). +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. Modified: cfe/trunk/include/clang/Basic/SourceLocation.h cfe/trunk/lib/ARCMigrate/ObjCMT.cpp cfe/trunk/lib/Basic/SourceManager.cpp cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp cfe/trunk/lib/Edit/EditedSource.cpp cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp cfe/trunk/lib/Frontend/TextDiagnostic.cpp cfe/trunk/lib/Index/CommentToXML.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PreprocessingRecord.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/lib/Sema/SemaObjCProperty.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=249235=249234=249235=diff == --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Sat Oct 3 05:46:20 2015 @@ -43,6 +43,7 @@ class FileID { public: FileID() : ID(0) {} + bool isValid() const { return ID != 0; } bool isInvalid() const { return ID == 0; } bool operator==(const FileID ) const { return ID == RHS.ID; } Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=249235=249234=249235=diff == --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original) +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Sat Oct 3 05:46:20 2015 @@ -1805,7 +1805,7 @@ private: FileID FID; unsigned Offset; std::tie(FID, Offset) = SourceMgr.getDecomposedLoc(Loc); - assert(!FID.isInvalid()); + assert(FID.isValid()); SmallString<200> Path = StringRef(SourceMgr.getFileEntryForID(FID)->getName()); llvm::sys::fs::make_absolute(Path); @@ -1862,8 +1862,8 @@ void ObjCMigrateASTConsumer::HandleTrans for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end(); D != DEnd; ++D) { FileID FID = PP.getSourceManager().getFileID((*D)->getLocation()); - if (!FID.isInvalid()) -if (!FileId.isInvalid() && FileId != FID) { + if (FID.isValid()) +if (FileId.isValid() && FileId != FID) { if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) AnnotateImplicitBridging(Ctx); } Modified: cfe/trunk/lib/Basic/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=249235=249234=249235=diff == --- cfe/trunk/lib/Basic/SourceManager.cpp (original) +++ cfe/trunk/lib/Basic/SourceManager.cpp Sat Oct 3 05:46:20 2015 @@ -1408,7 +1408,7 @@ unsigned SourceManager::getPresumedLineN /// considered to be from a system header. SrcMgr::CharacteristicKind SourceManager::getFileCharacteristic(SourceLocation Loc) const { - assert(!Loc.isInvalid() && "Can't get file characteristic of invalid loc!"); + assert(Loc.isValid() && "Can't get file characteristic of invalid loc!"); std::pairLocInfo = getDecomposedExpansionLoc(Loc); bool Invalid = false; const SLocEntry = getSLocEntry(LocInfo.first, ); @@ -1613,7 +1613,7 @@ FileID SourceManager::translateFile(cons // location in the main file. Optional SourceFileUID; Optional SourceFileName; - if (!MainFileID.isInvalid()) { + if (MainFileID.isValid()) { bool Invalid = false; const SLocEntry = getSLocEntry(MainFileID, ); if (Invalid) @@ -1786,7 +1786,7 @@ SourceLocation SourceManager::translateL /// 110 -> SourceLocation() void SourceManager::computeMacroArgsCache(MacroArgsMap *, FileID FID) const { - assert(!FID.isInvalid()); + assert(FID.isValid()); assert(!CachePtr); CachePtr = new MacroArgsMap(); Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=249235=249234=249235=diff == --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original) +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Sat Oct 3 05:46:20 2015 @@ -244,7 +244,7 @@ public: assert(Region.hasEndLoc() && "incomplete region"); SourceLocation LocStart = Region.getStartLoc(); -
[clang-tools-extra] r249235 - Replace double negation of !FileID.isInvalid() with FileID.isValid().
Author: yrnkrn Date: Sat Oct 3 05:46:20 2015 New Revision: 249235 URL: http://llvm.org/viewvc/llvm-project?rev=249235=rev Log: Replace double negation of !FileID.isInvalid() with FileID.isValid(). +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=249235=249234=249235=diff == --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (original) +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Sat Oct 3 05:46:20 2015 @@ -118,7 +118,7 @@ getRewrittenData(const std::vectorbegin(), Buffer->end()); Modified: clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp?rev=249235=249234=249235=diff == --- clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp (original) +++ clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp Sat Oct 3 05:46:20 2015 @@ -354,7 +354,7 @@ bool IncludeDirectives::hasInclude(const Replacement IncludeDirectives::addAngledInclude(const clang::FileEntry *File, llvm::StringRef Include) { FileID FID = Sources.translateFile(File); - assert(!FID.isInvalid() && "Invalid file entry given!"); + assert(FID.isValid() && "Invalid file entry given!"); if (hasInclude(File, Include)) return Replacement(); Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp?rev=249235=249234=249235=diff == --- clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp (original) +++ clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp Sat Oct 3 05:46:20 2015 @@ -578,7 +578,7 @@ bool ForLoopIndexUseVisitor::TraverseMem Context->getLangOpts()); // If something complicated is happening (i.e. the next token isn't an // arrow), give up on making this work. -if (!ArrowLoc.isInvalid()) { +if (ArrowLoc.isValid()) { Usages.push_back(Usage(ResultExpr, /*IsArrow=*/true, SourceRange(Base->getExprLoc(), ArrowLoc))); return true; Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=249235=249234=249235=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Sat Oct 3 05:46:20 2015 @@ -559,7 +559,7 @@ bool ForLoopIndexUseVisitor::TraverseMem Context->getLangOpts()); // If something complicated is happening (i.e. the next token isn't an // arrow), give up on making this work. -if (!ArrowLoc.isInvalid()) { +if (ArrowLoc.isValid()) { addUsage(Usage(ResultExpr, Usage::UK_MemberThroughArrow, SourceRange(Base->getExprLoc(), ArrowLoc))); return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.
EricWF created this revision. EricWF added reviewers: rsmith, majnemer. EricWF added subscribers: cfe-commits, mclow.lists. Currently when a function annotated with __attribute__((nonnull)) is called in an unevaluated context with a null argument a -Wnonnull warning is emitted. This warning seems like a false positive unless the call expression is potentially evaluated. Disclaimer: I have no idea what I'm doing. http://reviews.llvm.org/D13408 Files: lib/Sema/SemaChecking.cpp test/Sema/non-null-warning.c Index: test/Sema/non-null-warning.c === --- test/Sema/non-null-warning.c +++ test/Sema/non-null-warning.c @@ -39,4 +39,5 @@ int main () { foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}} + (void)sizeof(foo(0)); // expect no warning when in an unevaluated context. } Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1348,7 +1348,8 @@ } if (FDecl || Proto) { -CheckNonNullArguments(*this, FDecl, Proto, Args, Loc); +if (!isUnevaluatedContext()) + CheckNonNullArguments(*this, FDecl, Proto, Args, Loc); // Type safety checking. if (FDecl) { Index: test/Sema/non-null-warning.c === --- test/Sema/non-null-warning.c +++ test/Sema/non-null-warning.c @@ -39,4 +39,5 @@ int main () { foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}} + (void)sizeof(foo(0)); // expect no warning when in an unevaluated context. } Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1348,7 +1348,8 @@ } if (FDecl || Proto) { -CheckNonNullArguments(*this, FDecl, Proto, Args, Loc); +if (!isUnevaluatedContext()) + CheckNonNullArguments(*this, FDecl, Proto, Args, Loc); // Type safety checking. if (FDecl) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11700: Added remove taint support to ProgramState.
franchiotta updated the summary for this revision. franchiotta updated this revision to Diff 36431. franchiotta added a comment. Some changes made based on the received suggestions. http://reviews.llvm.org/D11700 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Core/ProgramState.cpp Index: lib/StaticAnalyzer/Core/ProgramState.cpp === --- lib/StaticAnalyzer/Core/ProgramState.cpp +++ lib/StaticAnalyzer/Core/ProgramState.cpp @@ -648,32 +648,24 @@ return true; } -ProgramStateRef ProgramState::addTaint(const Stmt *S, - const LocationContext *LCtx, - TaintTagType Kind) const { - if (const Expr *E = dyn_cast_or_null(S)) -S = E->IgnoreParens(); - +ProgramStateRef ProgramState::addTaint(const Stmt *S, const LocationContext + *LCtx, TaintTagType Kind) const { SymbolRef Sym = getSVal(S, LCtx).getAsSymbol(); if (Sym) return addTaint(Sym, Kind); const MemRegion *R = getSVal(S, LCtx).getAsRegion(); - addTaint(R, Kind); - - // Cannot add taint, so just return the state. - return this; + return addTaint(R, Kind); } ProgramStateRef ProgramState::addTaint(const MemRegion *R, - TaintTagType Kind) const { + TaintTagType Kind) const { if (const SymbolicRegion *SR = dyn_cast_or_null(R)) return addTaint(SR->getSymbol(), Kind); return this; } -ProgramStateRef ProgramState::addTaint(SymbolRef Sym, - TaintTagType Kind) const { +ProgramStateRef ProgramState::addTaint(SymbolRef Sym, TaintTagType Kind) const { // If this is a symbol cast, remove the cast before adding the taint. Taint // is cast agnostic. while (const SymbolCast *SC = dyn_cast(Sym)) @@ -684,6 +676,35 @@ return NewState; } +ProgramStateRef ProgramState::removeTaint(const Stmt *S, const LocationContext + *LCtx, TaintTagType Kind) const { + SymbolRef Sym = getSVal(S, LCtx).getAsSymbol(); + if (Sym) +return removeTaint(Sym, Kind); + + const MemRegion *R = getSVal(S, LCtx).getAsRegion(); + return removeTaint(R, Kind); +} + +ProgramStateRef ProgramState::removeTaint(const MemRegion *R, + TaintTagType Kind) const { + if (const SymbolicRegion *SR = dyn_cast_or_null(R)) +return removeTaint(SR->getSymbol(), Kind); + return this; +} + +ProgramStateRef ProgramState::removeTaint(SymbolRef Sym, + TaintTagType Kind) const { + // If this is a symbol cast, remove the cast before removing the taint. Taint + // is cast agnostic. + while (const SymbolCast *SC = dyn_cast(Sym)) +Sym = SC->getOperand(); + + ProgramStateRef NewState = remove(Sym); + assert(NewState); + return NewState; +} + bool ProgramState::isTainted(const Stmt *S, const LocationContext *LCtx, TaintTagType Kind) const { if (const Expr *E = dyn_cast_or_null(S)) Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -341,15 +341,27 @@ /// Create a new state in which the statement is marked as tainted. ProgramStateRef addTaint(const Stmt *S, const LocationContext *LCtx, - TaintTagType Kind = TaintTagGeneric) const; + TaintTagType Kind = TaintTagGeneric) const; /// Create a new state in which the symbol is marked as tainted. ProgramStateRef addTaint(SymbolRef S, - TaintTagType Kind = TaintTagGeneric) const; + TaintTagType Kind = TaintTagGeneric) const; /// Create a new state in which the region symbol is marked as tainted. ProgramStateRef addTaint(const MemRegion *R, - TaintTagType Kind = TaintTagGeneric) const; + TaintTagType Kind = TaintTagGeneric) const; + + /// Create a new state in which the statement is marked as non-tainted. + ProgramStateRef removeTaint(const Stmt *S, const LocationContext *LCtx, + TaintTagType Kind = TaintTagGeneric) const; + + /// Create a new state in which the symbol is marked as non-tainted. + ProgramStateRef removeTaint(SymbolRef S, + TaintTagType Kind = TaintTagGeneric) const; + + /// Create a new state in which the region symbol is marked as non-tainted. + ProgramStateRef removeTaint(const MemRegion *R, + TaintTagType Kind = TaintTagGeneric) const; /// Check if the statement is tainted in the current
Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.
flx updated this revision to Diff 36433. flx added a comment. Updated patch to new cxx* matcher variants. http://reviews.llvm.org/D12839 Files: clang-tidy/misc/MoveConstructorInitCheck.cpp clang-tidy/misc/MoveConstructorInitCheck.h clang-tidy/modernize/PassByValueCheck.cpp clang-tidy/modernize/ReplaceAutoPtrCheck.cpp clang-tidy/utils/CMakeLists.txt clang-tidy/utils/IncludeSorter.cpp clang-tidy/utils/IncludeSorter.h clang-tidy/utils/Matchers.h clang-tidy/utils/TypeTraits.cpp clang-tidy/utils/TypeTraits.h docs/clang-tidy/checks/misc-move-constructor-init.rst test/clang-tidy/misc-move-constructor-init.cpp Index: test/clang-tidy/misc-move-constructor-init.cpp === --- test/clang-tidy/misc-move-constructor-init.cpp +++ test/clang-tidy/misc-move-constructor-init.cpp @@ -1,78 +1,145 @@ -// RUN: %python %S/check_clang_tidy.py %s misc-move-constructor-init %t - -template struct remove_reference {typedef T type;}; -template struct remove_reference{typedef T type;}; -template struct remove_reference {typedef T type;}; - -template -typename remove_reference::type&& move(T&& arg) { - return static_cast::type&&>(arg); -} - -struct C { - C() = default; - C(const C&) = default; -}; - -struct B { - B() {} - B(const B&) {} - B(B &&) {} -}; - -struct D : B { - D() : B() {} - D(const D ) : B(RHS) {} - // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init] - // CHECK-MESSAGES: 19:3: note: copy constructor being called - // CHECK-MESSAGES: 20:3: note: candidate move constructor here - D(D &) : B(RHS) {} -}; - -struct E : B { - E() : B() {} - E(const E ) : B(RHS) {} - E(E &) : B(move(RHS)) {} // ok -}; - -struct F { - C M; - - F(F &&) : M(C()) {} // ok -}; - -struct G { - G() = default; - G(const G&) = default; - G(G&&) = delete; -}; - -struct H : G { - H() = default; - H(const H&) = default; - H(H &) : G(RHS) {} // ok -}; - -struct I { - I(const I &) = default; // suppresses move constructor creation -}; - -struct J : I { - J(J &) : I(RHS) {} // ok -}; - -struct K {}; // Has implicit copy and move constructors, is trivially copyable -struct L : K { - L(L &) : K(RHS) {} // ok -}; - -struct M { - B Mem; - // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init] - M(M &) : Mem(RHS.Mem) {} -}; - -struct N { - B Mem; - N(N &) : Mem(move(RHS.Mem)) {} -}; +// RUN: %python %S/check_clang_tidy.py %s misc-move-constructor-init %t -- -std=c++11 -isystem %S/Inputs/Headers + +#include + +// CHECK-FIXES: #include + +template struct remove_reference {typedef T type;}; +template struct remove_reference {typedef T type;}; +template struct remove_reference {typedef T type;}; + +template +typename remove_reference::type&& move(T&& arg) { + return static_cast::type&&>(arg); +} + +struct C { + C() = default; + C(const C&) = default; +}; + +struct B { + B() {} + B(const B&) {} + B(B &&) {} +}; + +struct D : B { + D() : B() {} + D(const D ) : B(RHS) {} + // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init] + // CHECK-MESSAGES: 23:3: note: copy constructor being called + // CHECK-MESSAGES: 24:3: note: candidate move constructor here + D(D &) : B(RHS) {} +}; + +struct E : B { + E() : B() {} + E(const E ) : B(RHS) {} + E(E &) : B(move(RHS)) {} // ok +}; + +struct F { + C M; + + F(F &&) : M(C()) {} // ok +}; + +struct G { + G() = default; + G(const G&) = default; + G(G&&) = delete; +}; + +struct H : G { + H() = default; + H(const H&) = default; + H(H &) : G(RHS) {} // ok +}; + +struct I { + I(const I &) = default; // suppresses move constructor creation +}; + +struct J : I { + J(J &) : I(RHS) {} // ok +}; + +struct K {}; // Has implicit copy and move constructors, is trivially copyable +struct L : K { + L(L &) : K(RHS) {} // ok +}; + +struct M { + B Mem; + // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init] + M(M &) : Mem(RHS.Mem) {} +}; + +struct N { + B Mem; + N(N &) : Mem(move(RHS.Mem)) {} +}; + +struct Movable { + Movable(Movable &&) = default; + Movable(const Movable &) = default; + Movable =(const Movable &) = default; + ~Movable() {} +}; + +struct TriviallyCopyable { + TriviallyCopyable() = default; + TriviallyCopyable(TriviallyCopyable &&) = default; + TriviallyCopyable(const TriviallyCopyable &) = default; +}; + +struct Positive { + Positive(Movable M) : M_(M) {} + // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to avoid copy [misc-move-constructor-init] + // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {} + Movable M_; +}; + +struct
Re: [PATCH] D10407: Diagnose const atomics and allow more qualified arguments in __atomic builtins.
EricWF abandoned this revision. EricWF added a comment. Abandoning. I bit off more that I could chew. I committed the part @rsmith approved separably as r249252. http://reviews.llvm.org/D10407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249226 - [libcxx] Use newest supported language dialect when running the test suite.
Hello Eric, it looks like this patch broke the lab.llvm.org buildbots (darwin+cmake): http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/7544/consoleFull#2729576478254eaf0-7326-4999-85b0-388101f2d404 could you please investigate and/or revert the change? thanks, Adrian > On Oct 2, 2015, at 7:32 PM, Eric Fiselier via cfe-commits >wrote: > > Author: ericwf > Date: Fri Oct 2 21:32:23 2015 > New Revision: 249226 > > URL: http://llvm.org/viewvc/llvm-project?rev=249226=rev > Log: > [libcxx] Use newest supported language dialect when running the test suite. > > Summary: > Currently the test suite defaults to C++11 mode if no standard version is > supplied to LIT using `--param=std=c++XX`. This patch changes that behavior > so that the newest possible dialect is selected instead. > > I have already patched the C++11 bot to explicitly specify > `--param=std=c++11`. I'm just putting this up for review to see if anybody > objects to this idea. > > Reviewers: mclow.lists, jroelofs, danalbert > > Subscribers: cfe-commits > > Differential Revision: http://reviews.llvm.org/D13331 > > Modified: >libcxx/trunk/test/libcxx/test/config.py > > Modified: libcxx/trunk/test/libcxx/test/config.py > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=249226=249225=249226=diff > == > --- libcxx/trunk/test/libcxx/test/config.py (original) > +++ libcxx/trunk/test/libcxx/test/config.py Fri Oct 2 21:32:23 2015 > @@ -344,7 +344,20 @@ class Configuration(object): > # Try and get the std version from the command line. Fall back to > # default given in lit.site.cfg is not present. If default is not > # present then force c++11. > -std = self.get_lit_conf('std', 'c++11') > +std = self.get_lit_conf('std') > +if not std: > +# Choose the newest possible language dialect if none is given. > +possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03'] > +for s in possible_stds: > +if self.cxx.hasCompileFlag('-std=%s' % s): > +std = s > +self.lit_config.note( > +'inferred language dialect as: %s' % std) > +break > +if not std: > +self.lit_config.fatal( > +'Failed to infer a supported language dialect from one > of %r' > +% possible_stds) > self.cxx.compile_flags += ['-std={0}'.format(std)] > self.config.available_features.add(std) > # Configure include paths > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13420: Fix deduction of __atomic_load's parameter types.
EricWF created this revision. EricWF added reviewers: majnemer, rsmith. EricWF added a subscriber: cfe-commits. __atomic_load's allows it's first argument to be a pointer to a const type. However the second argument is an output parameter and must be a pointer to non-const. This patch fixes the signature of __atomic_load generated by clang so that it respects the above requirements. http://reviews.llvm.org/D13420 Files: lib/Sema/SemaChecking.cpp test/Sema/atomic-ops.c Index: test/Sema/atomic-ops.c === --- test/Sema/atomic-ops.c +++ test/Sema/atomic-ops.c @@ -118,7 +118,10 @@ __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}} (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}} __atomic_load(s1, s2, memory_order_acquire); - (void)__atomic_load(I, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}} + __atomic_load(CI, I, memory_order_relaxed); + __atomic_load(I, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}} + __atomic_load(CI, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}} + __c11_atomic_store(i, 1, memory_order_seq_cst); __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}} (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1513,6 +1513,8 @@ // C__c11_atomic_load(A *, int) Load, // void __atomic_load(A *, CP, int) +LoadCopy, +// void __atomic_store(A *, CP, int) Copy, // C__c11_atomic_add(A *, M, int) Arithmetic, @@ -1525,8 +1527,8 @@ // bool __atomic_compare_exchange(A *, C *, CP, bool, int, int) GNUCmpXchg } Form = Init; - const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 4, 5, 6 }; - const unsigned NumVals[] = { 1, 0, 1, 1, 1, 2, 2, 3 }; + const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 }; + const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 }; // where: // C is an appropriate type, // A is volatile _Atomic(C) for __c11 builtins and is C for GNU builtins, @@ -1556,8 +1558,11 @@ Form = Load; break; - case AtomicExpr::AO__c11_atomic_store: case AtomicExpr::AO__atomic_load: +Form = LoadCopy; +break; + + case AtomicExpr::AO__c11_atomic_store: case AtomicExpr::AO__atomic_store: case AtomicExpr::AO__atomic_store_n: Form = Copy; @@ -1644,7 +1649,7 @@ return ExprError(); } ValType = AtomTy->getAs()->getValueType(); - } else if (Form != Load && Op != AtomicExpr::AO__atomic_load) { + } else if (Form != Load && Form != LoadCopy) { if (ValType.isConstQualified()) { Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_pointer) << Ptr->getType() << Ptr->getSourceRange(); @@ -1705,10 +1710,11 @@ // atomic_fetch_or takes a pointer to a volatile 'A'. We shouldn't let the // volatile-ness of the pointee-type inject itself into the result or the - // other operands. + // other operands. Similarly atomic_load can take a pointer to a const 'A'. ValType.removeLocalVolatile(); + ValType.removeLocalConst(); QualType ResultType = ValType; - if (Form == Copy || Form == GNUXchg || Form == Init) + if (Form == Copy || Form == LoadCopy || Form == GNUXchg || Form == Init) ResultType = Context.VoidTy; else if (Form == C11CmpXchg || Form == GNUCmpXchg) ResultType = Context.BoolTy; @@ -1719,10 +1725,6 @@ if (!IsC11 && !IsN) ByValType = Ptr->getType(); - // FIXME: __atomic_load allows the first argument to be a a pointer to const - // but not the second argument. We need to manually remove possible const - // qualifiers. - // The first argument --- the pointer --- has a fixed type; we // deduce the types of the rest of the arguments accordingly. Walk // the remaining arguments, converting them to the deduced value type. @@ -1780,6 +1782,7 @@ case Load: SubExprs.push_back(TheCall->getArg(1)); // Order break; + case LoadCopy: case Copy: case Arithmetic: case Xchg: Index: test/Sema/atomic-ops.c === --- test/Sema/atomic-ops.c +++ test/Sema/atomic-ops.c @@ -118,7 +118,10 @@ __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}} (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}} __atomic_load(s1, s2, memory_order_acquire); - (void)__atomic_load(I, CI, memory_order_relaxed); //
[PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility
loladiro created this revision. loladiro added reviewers: aaron.ballman, rsmith, rnk. loladiro added a subscriber: cfe-commits. loladiro set the repository for this revision to rL LLVM. When we were looking at a template instantiation, that itself was a template instantiation (say a templated member of a templated class), we weren't looking back far enough along the chain of instantiations to find a VisibilityAttr (which we don't copy when instantiating templates). This patch attempts to address that as well as adding a few test cases for these situations. Repository: rL LLVM http://reviews.llvm.org/D13419 Files: lib/AST/Decl.cpp lib/AST/DeclCXX.cpp test/CodeGenCXX/visibility.cpp Index: test/CodeGenCXX/visibility.cpp === --- test/CodeGenCXX/visibility.cpp +++ test/CodeGenCXX/visibility.cpp @@ -1314,3 +1314,57 @@ // CHECK-LABEL: define void @_ZN6test693foo1fEv // CHECK-HIDDEN-LABEL: define hidden void @_ZN6test693foo1fEv } + +namespace test70 { + template < typename T > class foo { + public: + T x; + template < typename S > + HIDDEN S AddS(S); + template < typename S > class HIDDEN barS { +public: + static S AddS2(foo x, S); + }; + template < typename S > class HIDDEN barZ { + public: +template < typename Z > + static S AddSZ(foo x, S, Z); + }; + }; + + // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4AddSIxEET_S3_ + // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4AddSIxEET_S3_ + template < typename T > + template < typename S > + HIDDEN S foo::AddS(S y) { + return ((S) x) + y; + } + + // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4barSIxE5AddS2ES1_x + // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4barSIxE5AddS2ES1_x + template < typename T > + template < typename S > + HIDDEN S foo::barS::AddS2(foo x, S y) { + return ((S) x.x) + y; + } + + // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4barZIxE5AddSZIcEExS1_xT_ + // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4barZIxE5AddSZIcEExS1_xT_ + template < typename T > + template < typename S > + template < typename Z > + HIDDEN S foo::barZ::AddSZ(foo x, S y, Z z) { + return ((S) x.x) + y + ((S) z); + } + + extern template struct foo; + template struct foo; + + void f() { + auto var = foo{5}; + auto bar = var.AddS((long long)3); + auto bar2 = decltype(var)::barS::AddS2(var,3); + auto bar3 = decltype(var)::barZ::AddSZ(var,3,(char)0); + } +} + Index: lib/AST/DeclCXX.cpp === --- lib/AST/DeclCXX.cpp +++ lib/AST/DeclCXX.cpp @@ -1261,20 +1261,22 @@ if (auto *TD = dyn_cast(this)) { auto From = TD->getInstantiatedFrom(); if (auto *CTD = From.dyn_cast()) { - while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) { + auto *NewCTD = CTD; + do { +CTD = NewCTD; if (NewCTD->isMemberSpecialization()) break; -CTD = NewCTD; - } + } while ((NewCTD = CTD->getInstantiatedFromMemberTemplate())); return CTD->getTemplatedDecl()->getDefinition(); } if (auto *CTPSD = From.dyn_cast()) { - while (auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) { + auto *NewCTPSD = CTPSD; + do { +CTPSD = NewCTPSD; if (NewCTPSD->isMemberSpecialization()) break; -CTPSD = NewCTPSD; - } + } while ((NewCTPSD = CTPSD->getInstantiatedFromMember())); return CTPSD->getDefinition(); } } Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -1049,7 +1049,9 @@ // If this is a member class of a specialization of a class template // and the corresponding decl has explicit visibility, use that. if (const CXXRecordDecl *RD = dyn_cast(ND)) { -CXXRecordDecl *InstantiatedFrom = RD->getInstantiatedFromMemberClass(); +const CXXRecordDecl *InstantiatedFrom = RD->getTemplateInstantiationPattern(); +if (!InstantiatedFrom) + InstantiatedFrom = RD->getInstantiatedFromMemberClass(); if (InstantiatedFrom) return getVisibilityOf(InstantiatedFrom, kind); } @@ -1084,16 +1086,11 @@ } // Also handle function template specializations. if (const FunctionDecl *fn = dyn_cast(ND)) { -// If the function is a specialization of a template with an -// explicit visibility attribute, use that. -if (FunctionTemplateSpecializationInfo *templateInfo - = fn->getTemplateSpecializationInfo()) - return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(), - kind); - -// If the function is a member of a specialization of a class template +// If the function is a member of a specialization of a some template // and the
r249252 - Diagnose const atomics in __atomic builtins.
Author: ericwf Date: Sat Oct 3 19:11:02 2015 New Revision: 249252 URL: http://llvm.org/viewvc/llvm-project?rev=249252=rev Log: Diagnose const atomics in __atomic builtins. Diagnose when a pointer to const T is used as the first argument in at atomic builtin unless that builtin is a load operation. This is already checked for C11 atomics builtins but not for __atomic ones. This patch was given the LGTM by rsmith when it was part of a larger review. (See http://reviews.llvm.org/D10407) Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/Sema/atomic-ops.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=249252=249251=249252=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Oct 3 19:11:02 2015 @@ -6202,6 +6202,9 @@ def err_atomic_op_needs_atomic : Error< def err_atomic_op_needs_non_const_atomic : Error< "address argument to atomic operation must be a pointer to non-const _Atomic " "type (%0 invalid)">; +def err_atomic_op_needs_non_const_pointer : Error< + "address argument to atomic operation must be a pointer to non-const " + "type (%0 invalid)">; def err_atomic_op_needs_trivial_copy : Error< "address argument to atomic operation must be a pointer to a " "trivially-copyable type (%0 invalid)">; Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=249252=249251=249252=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Oct 3 19:11:02 2015 @@ -1644,6 +1644,12 @@ ExprResult Sema::SemaAtomicOpsOverloaded return ExprError(); } ValType = AtomTy->getAs()->getValueType(); + } else if (Form != Load && Op != AtomicExpr::AO__atomic_load) { +if (ValType.isConstQualified()) { + Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_pointer) +<< Ptr->getType() << Ptr->getSourceRange(); + return ExprError(); +} } // For an arithmetic operation, the implied arithmetic must be well-formed. @@ -1681,9 +1687,6 @@ ExprResult Sema::SemaAtomicOpsOverloaded return ExprError(); } - // FIXME: For any builtin other than a load, the ValType must not be - // const-qualified. - switch (ValType.getObjCLifetime()) { case Qualifiers::OCL_None: case Qualifiers::OCL_ExplicitNone: @@ -1716,6 +1719,10 @@ ExprResult Sema::SemaAtomicOpsOverloaded if (!IsC11 && !IsN) ByValType = Ptr->getType(); + // FIXME: __atomic_load allows the first argument to be a a pointer to const + // but not the second argument. We need to manually remove possible const + // qualifiers. + // The first argument --- the pointer --- has a fixed type; we // deduce the types of the rest of the arguments accordingly. Walk // the remaining arguments, converting them to the deduced value type. Modified: cfe/trunk/test/Sema/atomic-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=249252=249251=249252=diff == --- cfe/trunk/test/Sema/atomic-ops.c (original) +++ cfe/trunk/test/Sema/atomic-ops.c Sat Oct 3 19:11:02 2015 @@ -85,41 +85,54 @@ _Static_assert(__atomic_always_lock_free _Static_assert(!__atomic_always_lock_free(8, ), ""); _Static_assert(__atomic_always_lock_free(8, ), ""); -void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d, - int *I, int **P, float *D, struct S *s1, struct S *s2) { +void f(_Atomic(int) *i, const _Atomic(int) *ci, + _Atomic(int*) *p, _Atomic(float) *d, + int *I, const int *CI, + int **P, float *D, struct S *s1, struct S *s2) { __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}} + __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} + __c11_atomic_load(0); // expected-error {{too few arguments to function}} __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}} __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}} __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}} + __c11_atomic_store(i, 0, memory_order_relaxed); + __c11_atomic_store(ci, 0, memory_order_relaxed); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}} __c11_atomic_load(i, memory_order_seq_cst);
r249259 - SourceRanges are small and trivially copyable, don't them by reference.
Author: ctopper Date: Sat Oct 3 23:53:55 2015 New Revision: 249259 URL: http://llvm.org/viewvc/llvm-project?rev=249259=rev Log: SourceRanges are small and trivially copyable, don't them by reference. Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h cfe/trunk/include/clang/Basic/Diagnostic.h cfe/trunk/include/clang/Basic/PartialDiagnostic.h cfe/trunk/include/clang/Basic/SourceLocation.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/lib/Format/WhitespaceManager.cpp cfe/trunk/lib/Format/WhitespaceManager.h cfe/trunk/lib/Lex/PPExpressions.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h?rev=249259=249258=249259=diff == --- cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h (original) +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h Sat Oct 3 23:53:55 2015 @@ -104,11 +104,11 @@ public: /// \brief About to call the constructor for a matcher. enum ConstructMatcherEnum { ConstructMatcher }; Context(ConstructMatcherEnum, Diagnostics *Error, StringRef MatcherName, -const SourceRange ); +SourceRange MatcherRange); /// \brief About to recurse into parsing one argument for a matcher. enum MatcherArgEnum { MatcherArg }; Context(MatcherArgEnum, Diagnostics *Error, StringRef MatcherName, -const SourceRange , unsigned ArgNumber); +SourceRange MatcherRange, unsigned ArgNumber); ~Context(); private: @@ -137,7 +137,7 @@ public: /// All the context information will be kept on the error message. /// \return a helper class to allow the caller to pass the arguments for the /// error message, using the << operator. - ArgStream addError(const SourceRange , ErrorType Error); + ArgStream addError(SourceRange Range, ErrorType Error); /// \brief Information stored for one frame of the context. struct ContextFrame { Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=249259=249258=249259=diff == --- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original) +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Sat Oct 3 23:53:55 2015 @@ -81,7 +81,7 @@ public: /// matcher if an error occurred. In that case, \c Error will contain a /// description of the error. virtual VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, - const SourceRange , + SourceRange NameRange, StringRef BindID, ArrayRef Args, Diagnostics *Error) = 0; @@ -129,7 +129,7 @@ public: lookupMatcherCtor(StringRef MatcherName) override; VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, - const SourceRange , + SourceRange NameRange, StringRef BindID, ArrayRef Args, Diagnostics *Error) override; Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h?rev=249259=249258=249259=diff == --- cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h (original) +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h Sat Oct 3 23:53:55 2015 @@ -106,7 +106,7 @@ public: ///
[clang-tools-extra] r249258 - SourceRanges are small and trivially copyable, don't them by reference. NFC
Author: ctopper Date: Sat Oct 3 23:53:37 2015 New Revision: 249258 URL: http://llvm.org/viewvc/llvm-project?rev=249258=rev Log: SourceRanges are small and trivially copyable, don't them by reference. NFC Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp?rev=249258=249257=249258=diff == --- clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp (original) +++ clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp Sat Oct 3 23:53:37 2015 @@ -811,7 +811,7 @@ void LoopFixer::doConversion(ASTContext AliasVarIsRef = AliasVar->getType()->isReferenceType(); // We keep along the entire DeclStmt to keep the correct range here. -const SourceRange = AliasDecl->getSourceRange(); +SourceRange ReplaceRange = AliasDecl->getSourceRange(); std::string ReplacementText; if (AliasUseRequired) Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp?rev=249258=249257=249258=diff == --- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Sat Oct 3 23:53:37 2015 @@ -243,11 +243,11 @@ std::vector IncludeSorter::Ge std::string CurrentText; std::vector Fixes; for (const auto : Edits) { -const SourceRange = LineEdit.second.first; // If the current edit is on the next line after the previous edit, add it // to the current block edit. if (LineEdit.first == CurrentEndLine + 1 && CurrentRange.getBegin() != CurrentRange.getEnd()) { + SourceRange EditRange = LineEdit.second.first; if (EditRange.getBegin() != EditRange.getEnd()) { ++CurrentEndLine; CurrentRange.setEnd(EditRange.getEnd()); @@ -260,7 +260,7 @@ std::vector IncludeSorter::Ge } CurrentEndLine = LineEdit.first; - CurrentRange = EditRange; + CurrentRange = LineEdit.second.first; CurrentText = LineEdit.second.second; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249226 - [libcxx] Use newest supported language dialect when running the test suite.
Hi Adrian, So the goal of this patch was to increase the coverage of the test suite by default. Previously we used C++11 as the default but this meant that new C++14 and C++1z tests were never run. The failures you are seeing are all C++14 tests. We should work on actually fixing the failing tests. Reverting the commit will only hide these test failures again. All of the errors seem to be caused by latent problems in how libc++ links to libc++abi. on Apple platforms. libc++ always uses the system provided libc++abi even when it should use a newer version. I *think* I know how to fix these issues but I would appreciate an Apple expert to look at the fixes. Would you be able to help? /Eric ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11908: Clang support for -fthinlto.
tejohnson updated this revision to Diff 36453. tejohnson added a comment. - Rename code gen option to EmitFunctionSummary as per review for http://reviews.llvm.org/D13107. - Clang format the latest changes. Let me know if it looks good now. http://reviews.llvm.org/D11908 Files: include/clang/Driver/Driver.h include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Driver.cpp lib/Driver/SanitizerArgs.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/Driver/clang_f_opts.c test/Driver/lto.c test/Driver/thinlto.c test/Misc/thinlto.c Index: test/Misc/thinlto.c === --- /dev/null +++ test/Misc/thinlto.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s +// CHECK: %t +// RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s +// +// CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc + +// RUN: %clang -ccc-print-phases %s -flto=thin 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s +// +// CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}thinlto.c", c +// CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output +// CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc +// CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image + +// -flto=thin should cause link using gold plugin with thinlto option, +// also confirm that it takes precedence over earlier -fno-lto and -flto=full. +// RUN: %clang -### %s -flto=full -fno-lto -flto=thin 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s +// +// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so" +// CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto" + +// Check that subsequent -flto=full takes precedence +// RUN: %clang -### %s -flto=thin -flto=full 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s +// +// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so" +// CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto" + +// Check that subsequent -fno-lto takes precedence +// RUN: %clang -### %s -flto=thin -fno-lto 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s +// +// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so" +// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto" Index: test/Driver/lto.c === --- test/Driver/lto.c +++ test/Driver/lto.c @@ -1,25 +1,51 @@ // -flto causes a switch to llvm-bc object files. -// RUN: %clang -ccc-print-phases -c %s -flto 2> %t.log -// RUN: grep '2: compiler, {1}, ir' %t.log -// RUN: grep '3: backend, {2}, lto-bc' %t.log +// RUN: %clang -ccc-print-phases -c %s -flto 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILE-ACTIONS < %t %s +// +// CHECK-COMPILE-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILE-ACTIONS: 3: backend, {2}, lto-bc -// RUN: %clang -ccc-print-phases %s -flto 2> %t.log -// RUN: grep '0: input, ".*lto.c", c' %t.log -// RUN: grep '1: preprocessor, {0}, cpp-output' %t.log -// RUN: grep '2: compiler, {1}, ir' %t.log -// RUN: grep '3: backend, {2}, lto-bc' %t.log -// RUN: grep '4: linker, {3}, image' %t.log +// RUN: %clang -ccc-print-phases %s -flto 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-ACTIONS < %t %s +// +// CHECK-COMPILELINK-ACTIONS: 0: input, "{{.*}}lto.c", c +// CHECK-COMPILELINK-ACTIONS: 1: preprocessor, {0}, cpp-output +// CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir +// CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc +// CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image // llvm-bc and llvm-ll outputs need to match regular suffixes // (unfortunately). -// RUN: %clang %s -flto -save-temps -### 2> %t.log -// RUN: grep '"-o" ".*lto\.i" "-x" "c" ".*lto\.c"' %t.log -// RUN: grep '"-o" ".*lto\.bc" .*".*lto\.i"' %t.log -// RUN: grep '"-o" ".*lto\.o" .*".*lto\.bc"' %t.log -// RUN: grep '".*a\.\(out\|exe\)" .*".*lto\.o"' %t.log +// RUN: %clang %s -flto -save-temps -### 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s +// +// CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.i" "-x" "c" "{{.*}}lto.c" +// CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.bc" {{.*}}"{{.*}}lto.i" +// CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.o" {{.*}}"{{.*}}lto.bc" +// CHECK-COMPILELINK-SUFFIXES: "{{.*}}a.{{(out|exe)}}" {{.*}}"{{.*}}lto.o" -// RUN: %clang %s -flto -S -### 2> %t.log -// RUN: grep '"-o" ".*lto\.s" "-x" "c" ".*lto\.c"' %t.log +// RUN: %clang %s -flto -S -### 2> %t +// RUN: FileCheck -check-prefix=CHECK-COMPILE-SUFFIXES < %t %s +// +// CHECK-COMPILE-SUFFIXES: "-o" "{{.*}}lto.s" "-x" "c" "{{.*}}lto.c" // RUN: not %clang %s -emit-llvm 2>&1 | FileCheck --check-prefix=LLVM-LINK %s // LLVM-LINK: -emit-llvm cannot be used when linking + +// -flto should cause link using gold plugin +// RUN: %clang -### %s -flto 2> %t +// RUN:
r249260 - Pass SourceRange by value in a test I missed in r249259.
Author: ctopper Date: Sun Oct 4 00:09:13 2015 New Revision: 249260 URL: http://llvm.org/viewvc/llvm-project?rev=249260=rev Log: Pass SourceRange by value in a test I missed in r249259. Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=249260=249259=249260=diff == --- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original) +++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Sun Oct 4 00:09:13 2015 @@ -50,7 +50,7 @@ public: } VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, -const SourceRange , +SourceRange NameRange, StringRef BindID, ArrayRef Args, Diagnostics *Error) override { @@ -102,7 +102,7 @@ TEST(ParserTest, ParseString) { EXPECT_EQ("1:1: Error parsing string token: <\"Baz>", Sema.Errors[2]); } -bool matchesRange(const SourceRange , unsigned StartLine, +bool matchesRange(SourceRange Range, unsigned StartLine, unsigned EndLine, unsigned StartColumn, unsigned EndColumn) { EXPECT_EQ(StartLine, Range.Start.Line); EXPECT_EQ(EndLine, Range.End.Line); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r249232 - fix previous commit
Author: compnerd Date: Sat Oct 3 02:15:28 2015 New Revision: 249232 URL: http://llvm.org/viewvc/llvm-project?rev=249232=rev Log: fix previous commit Forgot to add the '='. In cl mode, --target must have an '='. Modified: cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=249232=249231=249232=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Sat Oct 3 02:15:28 2015 @@ -95,20 +95,20 @@ // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s // Oi_: -fno-builtin -// RUN: %clang_cl /Os --target i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s -// RUN: %clang_cl /Os --target x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s +// RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s +// RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s // Os-NOT: -mdisable-fp-elim // Os: -momit-leaf-frame-pointer // Os: -Os -// RUN: %clang_cl /Ot --target i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s -// RUN: %clang_cl /Ot --target x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s +// RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s +// RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s // Ot-NOT: -mdisable-fp-elim // Ot: -momit-leaf-frame-pointer // Ot: -O2 -// RUN: %clang_cl /Ox --target i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s -// RUN: %clang_cl /Ox --target x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s +// RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s +// RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s // Ox-NOT: -mdisable-fp-elim // Ox: -momit-leaf-frame-pointer // Ox: -O2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits