[PATCH] D35108: Fix crash parsing invalid code
ogoffart created this revision. The code in the test caused a crash with this backtrace: RecordLayoutBuilder.cpp:2934: const clang::ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const clang::RecordDecl *) const: Assertion `!D->isInvalidDecl() && "Cannot get layout of invalid decl!"' failed. [...] #7 0x7f63963d845a __assert_fail_base (/usr/lib/libc.so.6+0x2c45a) #8 0x7f63963d84d2 (/usr/lib/libc.so.6+0x2c4d2) #9 0x7f63937a0631 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const /home/olivier/prog/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2935:3 #10 0x7f63937a1ad5 getFieldOffset(clang::ASTContext const&, clang::FieldDecl const*) /home/olivier/prog/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:3057:37 #11 0x7f6391869f14 clang::Sema::RefersToMemberWithReducedAlignment(clang::Expr*, llvm::function_ref) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaChecking.cpp:12139:23 #12 0x7f639186a2f8 clang::Sema::CheckAddressOfPackedMember(clang::Expr*) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaChecking.cpp:12190:1 #13 0x7f6391a7a81c clang::Sema::CheckAddressOfOperand(clang::ActionResult&, clang::SourceLocation) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaExpr.cpp:1:10 #14 0x7f6391a7f5d2 clang::Sema::CreateBuiltinUnaryOp(clang::SourceLocation, clang::UnaryOperatorKind, clang::Expr*) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaExpr.cpp:11932:18 Fixing by bailing out for invalid classes. https://reviews.llvm.org/D35108 Files: lib/Sema/SemaChecking.cpp test/Sema/address-packed.c Index: test/Sema/address-packed.c === --- test/Sema/address-packed.c +++ test/Sema/address-packed.c @@ -329,3 +329,14 @@ uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + + +void *g14(struct Invalid0 *ivl) +{ +return &(ivl->x); +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -12101,7 +12101,7 @@ ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); // We do not care about non-data members. -if (!FD || FD->isInvalidDecl()) +if (!FD || FD->isInvalidDecl() || RD->isInvalidDecl()) return; AnyIsPacked = Index: test/Sema/address-packed.c === --- test/Sema/address-packed.c +++ test/Sema/address-packed.c @@ -329,3 +329,14 @@ uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + + +void *g14(struct Invalid0 *ivl) +{ +return &(ivl->x); +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -12101,7 +12101,7 @@ ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); // We do not care about non-data members. -if (!FD || FD->isInvalidDecl()) +if (!FD || FD->isInvalidDecl() || RD->isInvalidDecl()) return; AnyIsPacked = ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35108: Fix crash parsing invalid code
rogfer01 added a comment. Hi @ogoffart thanks for fixing this. I suggest some minor change for the check, other than that this looks good to me. Comment at: lib/Sema/SemaChecking.cpp:12099 BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); Can you make the check for `RD->isInvalidDecl()` here instead? ``` if (RD->isInvalidDecl()) return; ``` https://reviews.llvm.org/D35108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
baloghadamsoftware created this revision. Since the range-based constraint manager (default) is weak in handling comparisons where symbols are on both sides it is wise to rearrange them to have symbols only on the left side. Thus e.g. `A + n >= B + m` becomes `A - B >= m - n` which enables the constraint manager to store a range `m - n .. MAX_VALUE` for the symbolic expression `A - B`. This can be used later to check whether e.g. `A + k == B + l` can be true, which is also rearranged to `A - B == l - k` so the constraint manager can check whether `l - k` is in the range (thus greater than or equal to `m - m`). https://reviews.llvm.org/D35109 Files: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/std-c-library-functions.c test/Analysis/svalbuilder-rearrange-comparisons.c Index: test/Analysis/svalbuilder-rearrange-comparisons.c === --- /dev/null +++ test/Analysis/svalbuilder-rearrange-comparisons.c @@ -0,0 +1,156 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s + +void clang_analyzer_dump(int x); +void clang_analyzer_printState(); + +int f(); + +void compare_different_symbol() { + int x = f(), y = f(); + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 0}} +} + +void compare_different_symbol_plus_left_int() { + int x = f()+1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_minus_left_int() { + int x = f()-1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_different_symbol_plus_right_int() { + int x = f(), y = f()+2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 2}} +} + +void compare_different_symbol_minus_right_int() { + int x = f(), y = f()-2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 2}} +} + +void compare_different_symbol_plus_left_plus_right_int() { + int x = f()+2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_plus_left_minus_right_int() { + int x = f()+2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 3}} +} + +void compare_different_symbol_minus_left_plus_right_int() { + int x = f()-2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 3}} +} + +void compare_different_symbol_minus_left_minus_right_int() { + int x = f()-2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_same_symbol() { + int x = f(), y = x; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{1 S32b}} +} + +void compare_same_symbol_plus_left_int() { + int x = f(), y = x; + ++x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_minus_left_int() { + int x = f(), y = x; + --x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_plus_right_int() { + int x = f(), y = x+1; + clang_analyzer_dump(x); // expected-warning{{conj
[PATCH] D31326: Add option to export fixes to run-clang-tidy.py
mfherbst updated this revision to Diff 105592. mfherbst added a comment. Herald added a subscriber: JDevlieghere. - Adapted patch to changes suggested by alexfh - Added comment why setting MainSourceFile to an empty string if fixes are exported https://reviews.llvm.org/D31326 Files: run-clang-tidy.py Index: run-clang-tidy.py === --- run-clang-tidy.py +++ run-clang-tidy.py @@ -35,6 +35,7 @@ """ import argparse +import glob import json import multiprocessing import os @@ -45,6 +46,7 @@ import sys import tempfile import threading +import yaml def find_compilation_database(path): @@ -87,14 +89,36 @@ return start +def merge_replacement_files(tmpdir, fixfile): + """Merge all replacement files in a directory into a single fixfile""" + # MainSourceFile: The key is required by the definition inside + # include/clang/Tooling/ReplacementsYaml.h, but the value + # is actually never usid inside clang-apply-replacements, + # so we set it to '' here. + merged={ 'MainSourceFile': '', 'Replacements': [] } + + for replacefile in glob.iglob(tmpdir + '/*.yaml'): +with open(replacefile, 'r') as f: + content = yaml.safe_load(f) + if not content: +continue # Skip empty files + +try: + merged['Replacements'].extend(content['Replacements']) +except KeyError: + pass # Ignore files with missing keys + + if merged['Replacements']: +with open(fixfile,'w') as out: + yaml.safe_dump(merged, out) + def apply_fixes(args, tmpdir): - """Calls clang-apply-fixes on a given directory. Deletes the dir when done.""" + """Calls clang-apply-fixes on a given directory.""" invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') invocation.append(tmpdir) subprocess.call(invocation) - shutil.rmtree(tmpdir) def run_tidy(args, tmpdir, build_path, queue): @@ -129,6 +153,9 @@ 'headers to output diagnostics from. Diagnostics from ' 'the main file of each translation unit are always ' 'displayed.') + parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes', + help='Create a yaml file to store suggested fixes in, ' + 'which can be applied with clang-apply-replacements') parser.add_argument('-j', type=int, default=0, help='number of tidy instances to be run in parallel.') parser.add_argument('files', nargs='*', default=['.*'], @@ -178,7 +205,7 @@ max_task = multiprocessing.cpu_count() tmpdir = None - if args.fix: + if args.fix or args.export_fixes: tmpdir = tempfile.mkdtemp() # Build up a big regexy filter from all command line arguments. @@ -205,13 +232,20 @@ # This is a sad hack. Unfortunately subprocess goes # bonkers with ctrl-c and we start forking merrily. print '\nCtrl-C detected, goodbye.' -if args.fix: +if tmpdir: shutil.rmtree(tmpdir) os.kill(0, 9) + if args.export_fixes: +print 'Writing fixes to ' + args.export_fixes +merge_replacement_files(tmpdir, args.export_fixes) + if args.fix: print 'Applying fixes ...' apply_fixes(args, tmpdir) + if tmpdir: +shutil.rmtree(tmpdir) + if __name__ == '__main__': main() Index: run-clang-tidy.py === --- run-clang-tidy.py +++ run-clang-tidy.py @@ -35,6 +35,7 @@ """ import argparse +import glob import json import multiprocessing import os @@ -45,6 +46,7 @@ import sys import tempfile import threading +import yaml def find_compilation_database(path): @@ -87,14 +89,36 @@ return start +def merge_replacement_files(tmpdir, fixfile): + """Merge all replacement files in a directory into a single fixfile""" + # MainSourceFile: The key is required by the definition inside + # include/clang/Tooling/ReplacementsYaml.h, but the value + # is actually never usid inside clang-apply-replacements, + # so we set it to '' here. + merged={ 'MainSourceFile': '', 'Replacements': [] } + + for replacefile in glob.iglob(tmpdir + '/*.yaml'): +with open(replacefile, 'r') as f: + content = yaml.safe_load(f) + if not content: +continue # Skip empty files + +try: + merged['Replacements'].extend(content['Replacements']) +except KeyError: + pass # Ignore files with missing keys + + if merged['Replacements']: +with open(fixfile,'w') as out: + yaml.safe_dump(merged, out) + def apply_fixes(args, tmpdir): - """Calls clang-apply-fixes on a given directory. Deletes the dir when done.""" + """Calls clang-apply-fixes on a given directory.""" invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') invocation.append(tmpdir) subprocess.call(invocation) - shutil.rmtree(tmpdir) def run_tidy
[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference
baloghadamsoftware created this revision. If range `[m .. n]` is stored for symbolic expression `A - B`, then we can deduce the range for `B - A` which is [-n .. -m]. This is only true for signed types, unless the range is `[0 .. 0]`. https://reviews.llvm.org/D35110 Files: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/std-c-library-functions.c test/Analysis/svalbuilder-rearrange-comparisons.c Index: test/Analysis/svalbuilder-rearrange-comparisons.c === --- /dev/null +++ test/Analysis/svalbuilder-rearrange-comparisons.c @@ -0,0 +1,156 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s + +void clang_analyzer_dump(int x); +void clang_analyzer_printState(); + +int f(); + +void compare_different_symbol() { + int x = f(), y = f(); + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 0}} +} + +void compare_different_symbol_plus_left_int() { + int x = f()+1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_minus_left_int() { + int x = f()-1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_different_symbol_plus_right_int() { + int x = f(), y = f()+2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 2}} +} + +void compare_different_symbol_minus_right_int() { + int x = f(), y = f()-2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 2}} +} + +void compare_different_symbol_plus_left_plus_right_int() { + int x = f()+2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_plus_left_minus_right_int() { + int x = f()+2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 3}} +} + +void compare_different_symbol_minus_left_plus_right_int() { + int x = f()-2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 3}} +} + +void compare_different_symbol_minus_left_minus_right_int() { + int x = f()-2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_same_symbol() { + int x = f(), y = x; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{1 S32b}} +} + +void compare_same_symbol_plus_left_int() { + int x = f(), y = x; + ++x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_minus_left_int() { + int x = f(), y = x; + --x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_plus_right_int() { + int x = f(), y = x+1; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_minus_right_int() { + int x = f(), y = x-1; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(x == y);
[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference
baloghadamsoftware updated this revision to Diff 105593. baloghadamsoftware added a comment. Wrong patch files was uploaded first. https://reviews.llvm.org/D35110 Files: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp test/Analysis/ptr-arith.c Index: test/Analysis/ptr-arith.c === --- test/Analysis/ptr-arith.c +++ test/Analysis/ptr-arith.c @@ -272,42 +272,23 @@ void zero_implies_reversed_equal(int *lhs, int *rhs) { clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{UNKNOWN}} if ((rhs - lhs) == 0) { -#ifdef ANALYZER_CM_Z3 clang_analyzer_eval(rhs != lhs); // expected-warning{{FALSE}} clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}} -#else -clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}} -clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} -#endif return; } clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{FALSE}} -#ifdef ANALYZER_CM_Z3 clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}} clang_analyzer_eval(rhs != lhs); // expected-warning{{TRUE}} -#else - clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} - clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}} -#endif } void canonical_equal(int *lhs, int *rhs) { clang_analyzer_eval(lhs == rhs); // expected-warning{{UNKNOWN}} if (lhs == rhs) { -#ifdef ANALYZER_CM_Z3 clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}} -#else -clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} -#endif return; } clang_analyzer_eval(lhs == rhs); // expected-warning{{FALSE}} - -#ifdef ANALYZER_CM_Z3 clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}} -#else - clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} -#endif } void compare_element_region_and_base(int *p) { Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp === --- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -256,6 +256,29 @@ return newRanges; } + // Turn all [A, B] ranges to [-B, -A]. Turn minimal signed value to maximal + // signed value and vice versa. + RangeSet Negate(BasicValueFactory &BV, Factory &F) const { +PrimRangeSet newRanges = F.getEmptySet(); + +for (iterator i = begin(), e = end(); i != e; ++i) { + const llvm::APSInt &from = i->From(), &to = i->To(); + const llvm::APSInt &newFrom = (to.isMinSignedValue() ? + BV.getMaxValue(to) : + (to.isMaxSignedValue() ? + BV.getMinValue(to) : + BV.getValue(- to))); + const llvm::APSInt &newTo = (from.isMinSignedValue() ? + BV.getMaxValue(from) : + (from.isMaxSignedValue() ? +BV.getMinValue(from) : +BV.getValue(- from))); + newRanges = F.add(newRanges, Range(newFrom, newTo)); +} + +return newRanges; + } + void print(raw_ostream &os) const { bool isFirst = true; os << "{ "; @@ -465,11 +488,36 @@ if (ConstraintRangeTy::data_type *V = State->get(Sym)) return *V; - // Lazily generate a new RangeSet representing all possible values for the - // given symbol type. + // If Sym is a difference of symbols A - B, then maybe we have range set + // stored for B - A. BasicValueFactory &BV = getBasicVals(); QualType T = Sym->getType(); + if (const SymSymExpr *SSE = dyn_cast(Sym)) { +if (SSE->getOpcode() == BO_Sub) { + SymbolManager &SymMgr = State->getSymbolManager(); + // If the type of A - B is the same as the type of A, then use the type of + // B as the type of B - A. Otherwise keep the type of A - B. + SymbolRef negSym = SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, + SSE->getLHS(), + (T == SSE->getLHS()->getType()) ? + SSE->getRHS()->getType() : T); + if (ConstraintRangeTy::data_type *negV = + State->get(negSym)) { +// Do not negate an unsigned range set, unless it is [0, 0]. +if((negV->getConcreteValue() && +(*negV->getConcreteValue() == 0)) || + SSE->getLHS()->getType()->isSignedIntegerOrEnumerationType() || + SSE->getLHS()->getType()->isPointerType()) { + return negV->Negate(BV, F); +} + } +} + } + + // Lazily generate a new RangeSet representing all possible values for the + // given symbol type. + RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T)); // Special case: references are known to be non-zero. ___
[PATCH] D31326: Add option to export fixes to run-clang-tidy.py
mfherbst added inline comments. Comment at: run-clang-tidy.py:105 + elif merged['MainSourceFile'] != content['MainSourceFile']: +# The values given for MainSourceFile are inconsistent. +# Just empty MainSourceFile blank: alexfh wrote: > This is going to be the case for each non-trivial invocation of this script. > Do we need to keep `MainSourceFile` at all? Good point. As it turns out clang-apply-replacement never uses the value afaik. The field needs to be around, however, since the definition of the replacements ``yaml`` format ( see ``clang/include/clang/Tooling/ReplacementsYaml.h``) makes it mandatory. https://reviews.llvm.org/D31326 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32642: [Analyzer] Iterator Checker - Part 2: Increment, decrement operators and ahead-of-begin checks
baloghadamsoftware updated this revision to Diff 105594. baloghadamsoftware added a comment. Simplified for enhanced SValBuilder and ConstraintManager. https://reviews.llvm.org/D32642 Files: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp test/Analysis/Inputs/system-header-simulator-cxx.h test/Analysis/diagnostics/explicit-suppression.cpp test/Analysis/iterator-range.cpp Index: test/Analysis/iterator-range.cpp === --- test/Analysis/iterator-range.cpp +++ test/Analysis/iterator-range.cpp @@ -13,7 +13,110 @@ } } +void simple_good_end_negated(const std::vector &v) { + auto i = v.end(); + if (!(i == v.end())) { +clang_analyzer_warnIfReached(); +*i; // no-warning + } +} + void simple_bad_end(const std::vector &v) { auto i = v.end(); *i; // expected-warning{{Iterator accessed outside of its range}} } + +void simple_good_begin(const std::vector &v) { + auto i = v.begin(); + if (i != v.begin()) { +clang_analyzer_warnIfReached(); +*--i; // no-warning + } +} + +void simple_good_begin_negated(const std::vector &v) { + auto i = v.begin(); + if (!(i == v.begin())) { +clang_analyzer_warnIfReached(); +*--i; // no-warning + } +} + +void simple_bad_begin(const std::vector &v) { + auto i = v.begin(); + *--i; // expected-warning{{Iterator accessed outside of its range}} +} + +void copy(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + *i2; // expected-warning{{Iterator accessed outside of its range}} +} + +void decrease(const std::vector &v) { + auto i = v.end(); + --i; + *i; // no-warning +} + +void copy_and_decrease1(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + --i1; + *i1; // no-warning +} + +void copy_and_decrease2(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + --i1; + *i2; // expected-warning{{Iterator accessed outside of its range}} +} + +void copy_and_increase1(const std::vector &v) { + auto i1 = v.begin(); + auto i2 = i1; + ++i1; + if (i1 == v.end()) +*i2; // no-warning +} + +void copy_and_increase2(const std::vector &v) { + auto i1 = v.begin(); + auto i2 = i1; + ++i1; + if (i2 == v.end()) +*i2; // expected-warning{{Iterator accessed outside of its range}} +} + +void copy_and_increase3(const std::vector &v) { + auto i1 = v.begin(); + auto i2 = i1; + ++i1; + if (v.end() == i2) +*i2; // expected-warning{{Iterator accessed outside of its range}} +} + +void tricky(std::vector &V, int e) { + const auto first = V.begin(); + const auto comp1 = (first != V.end()), comp2 = (first == V.end()); + if (comp1) +*first; +} + +void loop(std::vector &V, int e) { + auto start = V.begin(); + while (true) { +auto item = std::find(start, V.end(), e); +if (item == V.end()) + break; +*item; // no-warning +start = ++item; // no-warning + } +} + +void bad_move(std::list &L1, std::list &L2) { + auto i0 = --L2.cend(); + L1 = std::move(L2); + *++i0; // expected-warning{{Iterator accessed outside of its range}} +} Index: test/Analysis/diagnostics/explicit-suppression.cpp === --- test/Analysis/diagnostics/explicit-suppression.cpp +++ test/Analysis/diagnostics/explicit-suppression.cpp @@ -19,6 +19,6 @@ void testCopyNull(C *I, C *E) { std::copy(I, E, (C *)0); #ifndef SUPPRESSED - // expected-warning@../Inputs/system-header-simulator-cxx.h:490 {{Called C++ object pointer is null}} + // expected-warning@../Inputs/system-header-simulator-cxx.h:514 {{Called C++ object pointer is null}} #endif } Index: test/Analysis/Inputs/system-header-simulator-cxx.h === --- test/Analysis/Inputs/system-header-simulator-cxx.h +++ test/Analysis/Inputs/system-header-simulator-cxx.h @@ -252,6 +252,12 @@ return size_t(_finish - _start); } +void clear(); + +void push_back(const T &value); +void push_back(T &&value); +void pop_back(); + T &operator[](size_t n) { return _start[n]; } @@ -295,6 +301,8 @@ list& operator=(list &&other); list& operator=(std::initializer_list ilist); +void clear(); + iterator begin() { return iterator(_start); } const_iterator begin() const { return const_iterator(_start); } const_iterator cbegin() const { return const_iterator(_start); } @@ -330,6 +338,16 @@ return size_t(_finish - _start); } +void clear(); + +void push_back(const T &value); +void push_back(T &&value); +void pop_back(); + +void push_front(const T &value); +void push_front(T &&value); +void pop_front(); + T &operator[](size_t n) { return _start[n]; } @@ -369,6 +387,12 @@ forward_list(forward_list &&other); ~forward_list(); +void clear(); + +void push_front(const T &value); +void push_front(T &&value); +void pop_front(); + i
[PATCH] D33719: Add _Float16 as a C/C++ source language type
SjoerdMeijer added a comment. Thanks Richard. I've opened an cxx abi issue, see comments inline. I will start working now on the doc update, and will do that in a companion change. Cheers. Comment at: lib/AST/ItaniumMangle.cpp:2457-2460 + case BuiltinType::Float16: case BuiltinType::Half: Out << "Dh"; break; rsmith wrote: > Distinct types should have distinct manglings. Please open an issue at > https://github.com/itanium-cxx-abi/cxx-abi/ to discuss how to mangle these > cases. I've opened issue: https://github.com/itanium-cxx-abi/cxx-abi/issues/21 https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk
mteodor added a comment. In https://reviews.llvm.org/D12407#314671, @klimek wrote: > I think we'll want somebody to find out whether there are simpler ways to > implement this. **Format on save** was implemented by https://reviews.llvm.org/D29221. What's the new functionality in the **reformat** implementation? Always trigger a (re)format even if there are no changes? Probably not a good idea. https://reviews.llvm.org/D12407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35041: [analyzer] Fix modeling of bool based types
alexshap updated this revision to Diff 105597. Repository: rL LLVM https://reviews.llvm.org/D35041 Files: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/enum.cpp Index: test/Analysis/enum.cpp === --- test/Analysis/enum.cpp +++ test/Analysis/enum.cpp @@ -37,3 +37,33 @@ } return true; } + +bool testNoCrashOnSwitchEnumBoolConstant() { + EnumBool E = EnumBool::F; + switch (E) { +case EnumBool::F: + return false; + } + return true; +} + +typedef __INTPTR_TYPE__ intptr_t; +bool testNoCrashOnSwitchEnumBoolConstantCastedFromNullptr() { + EnumBool E = static_cast((intptr_t)nullptr); + switch (E) { + case EnumBool::F: +return false; + } + return true; +} + +bool testNoCrashOnSwitchEnumBoolConstantCastedFromPtr() { + int X; + intptr_t P = (intptr_t)&X; + EnumBool E = static_cast(P); + switch (E) { + case EnumBool::F: +return false; + } + return true; +} Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp === --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -71,18 +71,15 @@ } SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val, QualType castTy) { - bool isLocType = Loc::isLocType(castTy); - if (val.getAs()) return val; if (Optional LI = val.getAs()) { if (isLocType) return LI->getLoc(); - // FIXME: Correctly support promotions/truncations. -unsigned castSize = Context.getTypeSize(castTy); +unsigned castSize = Context.getIntWidth(castTy); if (castSize == LI->getNumBits()) return val; return makeLocAsInteger(LI->getLoc(), castSize); @@ -173,7 +170,7 @@ } if (castTy->isIntegralOrEnumerationType()) { -unsigned BitWidth = Context.getTypeSize(castTy); +unsigned BitWidth = Context.getIntWidth(castTy); if (!val.getAs()) return makeLocAsInteger(val, BitWidth); Index: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -124,7 +124,7 @@ /// Returns the type of the APSInt used to store values of the given QualType. APSIntType getAPSIntType(QualType T) const { assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T)); -return APSIntType(Ctx.getTypeSize(T), +return APSIntType(Ctx.getIntWidth(T), !T->isSignedIntegerOrEnumerationType()); } Index: test/Analysis/enum.cpp === --- test/Analysis/enum.cpp +++ test/Analysis/enum.cpp @@ -37,3 +37,33 @@ } return true; } + +bool testNoCrashOnSwitchEnumBoolConstant() { + EnumBool E = EnumBool::F; + switch (E) { +case EnumBool::F: + return false; + } + return true; +} + +typedef __INTPTR_TYPE__ intptr_t; +bool testNoCrashOnSwitchEnumBoolConstantCastedFromNullptr() { + EnumBool E = static_cast((intptr_t)nullptr); + switch (E) { + case EnumBool::F: +return false; + } + return true; +} + +bool testNoCrashOnSwitchEnumBoolConstantCastedFromPtr() { + int X; + intptr_t P = (intptr_t)&X; + EnumBool E = static_cast(P); + switch (E) { + case EnumBool::F: +return false; + } + return true; +} Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp === --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -71,18 +71,15 @@ } SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val, QualType castTy) { - bool isLocType = Loc::isLocType(castTy); - if (val.getAs()) return val; if (Optional LI = val.getAs()) { if (isLocType) return LI->getLoc(); - // FIXME: Correctly support promotions/truncations. -unsigned castSize = Context.getTypeSize(castTy); +unsigned castSize = Context.getIntWidth(castTy); if (castSize == LI->getNumBits()) return val; return makeLocAsInteger(LI->getLoc(), castSize); @@ -173,7 +170,7 @@ } if (castTy->isIntegralOrEnumerationType()) { -unsigned BitWidth = Context.getTypeSize(castTy); +unsigned BitWidth = Context.getIntWidth(castTy); if (!val.getAs()) return makeLocAsInteger(val, BitWidth); Index: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -124,7 +124,7 @@ /// Returns the type of the APSInt used to store values of the given QualType. APSIntType getAPSIntType(QualType T)
[PATCH] D33537: [clang-tidy] Exception Escape Checker
baloghadamsoftware added a comment. In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote: > The check in https://reviews.llvm.org/D3 is using a CFG, not just > checking direct throws. I tested the latest revision (the fronted patch already included) on my test file. Disregarding of the not so important parameters (`EnabledFunctions` and `IgnoredExceptions`) I do not get warnings for any indirect throws (`indirect_implicit()` and `indirect_explicit()`). So for me it does not seem to be using the CFG. Furthermore, I do not get warning for `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` should not catch it. The same happens in `throw_catch_rethrow_the_rest()`, where `catch(int &)` should not catch `1.1`, but `catch(...)` should catch and rethrow it. This latter may be a bug. https://reviews.llvm.org/D33537 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34404: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Looks good. Thanks! Repository: rL LLVM https://reviews.llvm.org/D34404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35061: [ObjC] Avoid the -Wunguarded-availability warnings for protocol requirements in protocol/class/category declarations
This revision was automatically updated to reflect the committed changes. arphaman marked an inline comment as done. Closed by commit rL307368: [ObjC] Avoid the -Wunguarded-availability warnings for protocol (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D35061?vs=105442&id=105601#toc Repository: rL LLVM https://reviews.llvm.org/D35061 Files: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaObjC/unguarded-availability.m Index: cfe/trunk/lib/Sema/SemaExpr.cpp === --- cfe/trunk/lib/Sema/SemaExpr.cpp +++ cfe/trunk/lib/Sema/SemaExpr.cpp @@ -128,7 +128,8 @@ static void DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, - bool ObjCPropertyAccess) { + bool ObjCPropertyAccess, + bool AvoidPartialAvailabilityChecks = false) { std::string Message; AvailabilityResult Result; const NamedDecl* OffendingDecl; @@ -138,6 +139,8 @@ return; if (Result == AR_NotYetIntroduced) { +if (AvoidPartialAvailabilityChecks) + return; if (S.getCurFunctionOrMethodDecl()) { S.getEnclosingFunction()->HasPotentialAvailabilityViolations = true; return; @@ -275,7 +278,8 @@ /// bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, - bool ObjCPropertyAccess) { + bool ObjCPropertyAccess, + bool AvoidPartialAvailabilityChecks) { if (getLangOpts().CPlusPlus && isa(D)) { // If there were any diagnostics suppressed by template argument deduction, // emit them now. @@ -360,7 +364,8 @@ } DiagnoseAvailabilityOfDecl(*this, D, Loc, UnknownObjCClass, - ObjCPropertyAccess); + ObjCPropertyAccess, + AvoidPartialAvailabilityChecks); DiagnoseUnusedOfDecl(*this, D, Loc); Index: cfe/trunk/lib/Sema/SemaDeclObjC.cpp === --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp @@ -458,7 +458,10 @@ // Diagnose availability in the context of the ObjC container. Sema::ContextRAII SavedContext(TheSema, CD); for (unsigned i = 0; i < NumProtoRefs; ++i) { -(void)TheSema.DiagnoseUseOfDecl(ProtoRefs[i], ProtoLocs[i]); +(void)TheSema.DiagnoseUseOfDecl(ProtoRefs[i], ProtoLocs[i], +/*UnknownObjCClass=*/nullptr, +/*ObjCPropertyAccess=*/false, +/*AvoidPartialAvailabilityChecks=*/true); } } Index: cfe/trunk/include/clang/Sema/Sema.h === --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -3900,8 +3900,9 @@ bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid); bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, - const ObjCInterfaceDecl *UnknownObjCClass=nullptr, - bool ObjCPropertyAccess=false); + const ObjCInterfaceDecl *UnknownObjCClass = nullptr, + bool ObjCPropertyAccess = false, + bool AvoidPartialAvailabilityChecks = false); void NoteDeletedFunction(FunctionDecl *FD); void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD); std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); Index: cfe/trunk/test/SemaObjC/unguarded-availability.m === --- cfe/trunk/test/SemaObjC/unguarded-availability.m +++ cfe/trunk/test/SemaObjC/unguarded-availability.m @@ -263,3 +263,27 @@ new_int x; // expected-warning{{'new_int' is partial}} }; } + +// rdar://33156429: +// Avoid the warning on protocol requirements. + +AVAILABLE_10_12 +@protocol NewProtocol // expected-note {{'NewProtocol' has been explicitly marked partial here}} +@end + +@protocol ProtocolWithNewProtocolRequirement // expected-note {{annotate 'ProtocolWithNewProtocolRequirement' with an availability attribute to silence}} + +@property(copy) id prop; // expected-warning {{'NewProtocol' is partial: introduced in macOS 10.12}} + +@end + +@interface BaseClass +@end + +@interface ClassWithNewProtocolRequirement : BaseClass + +@end + +@interface BaseClass (CategoryWithNewProtocolRequirement) + +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307368 - [ObjC] Avoid the -Wunguarded-availability warnings for protocol
Author: arphaman Date: Fri Jul 7 02:15:29 2017 New Revision: 307368 URL: http://llvm.org/viewvc/llvm-project?rev=307368&view=rev Log: [ObjC] Avoid the -Wunguarded-availability warnings for protocol requirements in protocol/class/category declarations The unguarded availability warnings in the protocol requirements of a protocol /class/category declaration can be avoided. This matches the behaviour of Swift's diagnostics. The warnings for deprecated/unavailable protocols are preserved. rdar://33156429 Differential Revision: https://reviews.llvm.org/D35061 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaObjC/unguarded-availability.m Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=307368&r1=307367&r2=307368&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Fri Jul 7 02:15:29 2017 @@ -3900,8 +3900,9 @@ public: bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid); bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, - const ObjCInterfaceDecl *UnknownObjCClass=nullptr, - bool ObjCPropertyAccess=false); + const ObjCInterfaceDecl *UnknownObjCClass = nullptr, + bool ObjCPropertyAccess = false, + bool AvoidPartialAvailabilityChecks = false); void NoteDeletedFunction(FunctionDecl *FD); void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD); std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307368&r1=307367&r2=307368&view=diff == --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 7 02:15:29 2017 @@ -458,7 +458,10 @@ static void diagnoseUseOfProtocols(Sema // Diagnose availability in the context of the ObjC container. Sema::ContextRAII SavedContext(TheSema, CD); for (unsigned i = 0; i < NumProtoRefs; ++i) { -(void)TheSema.DiagnoseUseOfDecl(ProtoRefs[i], ProtoLocs[i]); +(void)TheSema.DiagnoseUseOfDecl(ProtoRefs[i], ProtoLocs[i], +/*UnknownObjCClass=*/nullptr, +/*ObjCPropertyAccess=*/false, +/*AvoidPartialAvailabilityChecks=*/true); } } Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=307368&r1=307367&r2=307368&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 7 02:15:29 2017 @@ -128,7 +128,8 @@ Sema::ShouldDiagnoseAvailabilityOfDecl(c static void DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, - bool ObjCPropertyAccess) { + bool ObjCPropertyAccess, + bool AvoidPartialAvailabilityChecks = false) { std::string Message; AvailabilityResult Result; const NamedDecl* OffendingDecl; @@ -138,6 +139,8 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name return; if (Result == AR_NotYetIntroduced) { +if (AvoidPartialAvailabilityChecks) + return; if (S.getCurFunctionOrMethodDecl()) { S.getEnclosingFunction()->HasPotentialAvailabilityViolations = true; return; @@ -275,7 +278,8 @@ void Sema::MaybeSuggestAddingStaticToDec /// bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, - bool ObjCPropertyAccess) { + bool ObjCPropertyAccess, + bool AvoidPartialAvailabilityChecks) { if (getLangOpts().CPlusPlus && isa(D)) { // If there were any diagnostics suppressed by template argument deduction, // emit them now. @@ -360,7 +364,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl * } DiagnoseAvailabilityOfDecl(*this, D, Loc, UnknownObjCClass, - ObjCPropertyAccess); + ObjCPropertyAccess, + AvoidPartialAvailabilityChecks); DiagnoseUnusedOfDecl(*this, D, Loc); Modified: cfe/trunk/test/SemaObjC/unguarded-availability.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability.m?rev=307368&r1=307367&r2=307368&view=diff =
r307371 - Fix crash parsing invalid code
Author: ogoffart Date: Fri Jul 7 02:38:59 2017 New Revision: 307371 URL: http://llvm.org/viewvc/llvm-project?rev=307371&view=rev Log: Fix crash parsing invalid code The code in the test caused a crash with this backtrace: RecordLayoutBuilder.cpp:2934: const clang::ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const clang::RecordDecl *) const: Assertion `!D->isInvalidDecl() && "Cannot get layout of invalid decl!"' failed. [...] #7 0x7f63963d845a __assert_fail_base (/usr/lib/libc.so.6+0x2c45a) #8 0x7f63963d84d2 (/usr/lib/libc.so.6+0x2c4d2) #9 0x7f63937a0631 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const /home/olivier/prog/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2935:3 #10 0x7f63937a1ad5 getFieldOffset(clang::ASTContext const&, clang::FieldDecl const*) /home/olivier/prog/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:3057:37 #11 0x7f6391869f14 clang::Sema::RefersToMemberWithReducedAlignment(clang::Expr*, llvm::function_ref) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaChecking.cpp:12139:23 #12 0x7f639186a2f8 clang::Sema::CheckAddressOfPackedMember(clang::Expr*) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaChecking.cpp:12190:1 #13 0x7f6391a7a81c clang::Sema::CheckAddressOfOperand(clang::ActionResult&, clang::SourceLocation) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaExpr.cpp:1:10 #14 0x7f6391a7f5d2 clang::Sema::CreateBuiltinUnaryOp(clang::SourceLocation, clang::UnaryOperatorKind, clang::Expr*) /home/olivier/prog/llvm/tools/clang/lib/Sema/SemaExpr.cpp:11932:18 Fixing by bailing out for invalid classes. Differential Revision: https://reviews.llvm.org/D35108 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/Sema/address-packed.c Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=307371&r1=307370&r2=307371&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jul 7 02:38:59 2017 @@ -12097,6 +12097,8 @@ void Sema::RefersToMemberWithReducedAlig if (ME->isArrow()) BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); +if (RD->isInvalidDecl()) + return; ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); Modified: cfe/trunk/test/Sema/address-packed.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address-packed.c?rev=307371&r1=307370&r2=307371&view=diff == --- cfe/trunk/test/Sema/address-packed.c (original) +++ cfe/trunk/test/Sema/address-packed.c Fri Jul 7 02:38:59 2017 @@ -329,3 +329,12 @@ void g13(void) { uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + +void *g14(struct Invalid0 *ivl) { + return &(ivl->x); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35108: Fix crash parsing invalid code
This revision was automatically updated to reflect the committed changes. Closed by commit rL307371: Fix crash parsing invalid code (authored by ogoffart). Changed prior to commit: https://reviews.llvm.org/D35108?vs=105590&id=105604#toc Repository: rL LLVM https://reviews.llvm.org/D35108 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/Sema/address-packed.c Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -12097,6 +12097,8 @@ if (ME->isArrow()) BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); +if (RD->isInvalidDecl()) + return; ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); Index: cfe/trunk/test/Sema/address-packed.c === --- cfe/trunk/test/Sema/address-packed.c +++ cfe/trunk/test/Sema/address-packed.c @@ -329,3 +329,12 @@ uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + +void *g14(struct Invalid0 *ivl) { + return &(ivl->x); +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -12097,6 +12097,8 @@ if (ME->isArrow()) BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); +if (RD->isInvalidDecl()) + return; ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); Index: cfe/trunk/test/Sema/address-packed.c === --- cfe/trunk/test/Sema/address-packed.c +++ cfe/trunk/test/Sema/address-packed.c @@ -329,3 +329,12 @@ uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + +void *g14(struct Invalid0 *ivl) { + return &(ivl->x); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
NoQ added a comment. Thanks, this looks great! Because integer promotion rules are tricky, could we, for now, avoid dealing with the situation when left-hand side and right-hand side and the result (all three) are not all of the same type? Or maybe we'd like to support substraction of unsigned values into a signed value of the same size, but still avoid the rest of the cases. Because it'd take an overwhelming amount of testing to ensure that we get all the promotion cases correctly. Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:583 +newRhs = BasicVals.evalAPSInt(BO_Add, *lInt, *rInt); +reverse = (lop == BO_Add); + } else { I'm afraid we may step into `BO_Mul` here, or something like that. Could you add a check somewhere that all the operations involved are either `BO_Add` or `BO_Sub`? https://reviews.llvm.org/D35109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35078: [clang-tidy] Fix modernize-use-override incorrect replacement
This revision was automatically updated to reflect the committed changes. Closed by commit rL307379: [clang-tidy] Fix modernize-use-override incorrect replacement (authored by alexfh). Changed prior to commit: https://reviews.llvm.org/D35078?vs=105554&id=105610#toc Repository: rL LLVM https://reviews.llvm.org/D35078 Files: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Index: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp @@ -38,11 +38,16 @@ File.end()); SmallVector Tokens; Token Tok; + int NestedParens = 0; while (!RawLexer.LexFromRawLexer(Tok)) { -if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) +if ((Tok.is(tok::semi) || Tok.is(tok::l_brace)) && NestedParens == 0) break; if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation())) break; +if (Tok.is(tok::l_paren)) + ++NestedParens; +else if (Tok.is(tok::r_paren)) + --NestedParens; if (Tok.is(tok::raw_identifier)) { IdentifierInfo &Info = Result.Context->Idents.get(StringRef( Sources.getCharacterData(Tok.getLocation()), Tok.getLength())); Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp === --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp @@ -12,6 +12,10 @@ struct MUST_USE_RESULT MustUseResultObject {}; +struct IntPair { + int First, Second; +}; + struct Base { virtual ~Base() {} virtual void a(); @@ -41,6 +45,8 @@ virtual void ne() noexcept(false); virtual void t() throw(); + + virtual void il(IntPair); }; struct SimpleCases : public Base { @@ -221,6 +227,14 @@ // CHECK-FIXES: {{^}} void cv2() const volatile override // some comment }; +struct DefaultArguments : public Base { + // Tests for default arguments (with initializer lists). + // Make sure the override fix is placed after the argument list. + void il(IntPair p = {1, (2 + (3))}) {} + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this + // CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {} +}; + struct Macros : public Base { // Tests for 'virtual' and 'override' being defined through macros. Basically // give up for now. Index: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp @@ -38,11 +38,16 @@ File.end()); SmallVector Tokens; Token Tok; + int NestedParens = 0; while (!RawLexer.LexFromRawLexer(Tok)) { -if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) +if ((Tok.is(tok::semi) || Tok.is(tok::l_brace)) && NestedParens == 0) break; if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation())) break; +if (Tok.is(tok::l_paren)) + ++NestedParens; +else if (Tok.is(tok::r_paren)) + --NestedParens; if (Tok.is(tok::raw_identifier)) { IdentifierInfo &Info = Result.Context->Idents.get(StringRef( Sources.getCharacterData(Tok.getLocation()), Tok.getLength())); Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp === --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp @@ -12,6 +12,10 @@ struct MUST_USE_RESULT MustUseResultObject {}; +struct IntPair { + int First, Second; +}; + struct Base { virtual ~Base() {} virtual void a(); @@ -41,6 +45,8 @@ virtual void ne() noexcept(false); virtual void t() throw(); + + virtual void il(IntPair); }; struct SimpleCases : public Base { @@ -221,6 +227,14 @@ // CHECK-FIXES: {{^}} void cv2() const volatile override // some comment }; +struct DefaultArguments : public Base { + // Tests for default arguments (with initializer lists). + // Make sure the override fix is placed after the argument list. + void il(IntPair p = {1, (2 + (3))}) {} + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this + // CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {} +}; + struct Macros : public Base { // Tests for 'virtual' and 'override' being defined through macros. Basically // give up for now. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r307379 - [clang-tidy] Fix modernize-use-override incorrect replacement
Author: alexfh Date: Fri Jul 7 03:15:24 2017 New Revision: 307379 URL: http://llvm.org/viewvc/llvm-project?rev=307379&view=rev Log: [clang-tidy] Fix modernize-use-override incorrect replacement Summary: For the following code: `modernize-use-override` generates a replacement with incorrect location. ``` struct IntPair { int first, second; }; struct A { virtual void il(IntPair); }; struct B : A { void il(IntPair p = {1, (2 + 3)}) {}; // Generated Fixit: void il(IntPair p = override {1, (2 + 3)}) {}; // Should be: void il(IntPair p = {1, (2 + 3)}) override {}; }; ``` This fixes that and adds a unit test. Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Victor Gao! Differential Revision: https://reviews.llvm.org/D35078 Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp?rev=307379&r1=307378&r2=307379&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp Fri Jul 7 03:15:24 2017 @@ -38,11 +38,16 @@ ParseTokens(CharSourceRange Range, const File.end()); SmallVector Tokens; Token Tok; + int NestedParens = 0; while (!RawLexer.LexFromRawLexer(Tok)) { -if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) +if ((Tok.is(tok::semi) || Tok.is(tok::l_brace)) && NestedParens == 0) break; if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation())) break; +if (Tok.is(tok::l_paren)) + ++NestedParens; +else if (Tok.is(tok::r_paren)) + --NestedParens; if (Tok.is(tok::raw_identifier)) { IdentifierInfo &Info = Result.Context->Idents.get(StringRef( Sources.getCharacterData(Tok.getLocation()), Tok.getLength())); Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp?rev=307379&r1=307378&r2=307379&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Fri Jul 7 03:15:24 2017 @@ -12,6 +12,10 @@ struct MUST_USE_RESULT MustUseResultObject {}; +struct IntPair { + int First, Second; +}; + struct Base { virtual ~Base() {} virtual void a(); @@ -41,6 +45,8 @@ struct Base { virtual void ne() noexcept(false); virtual void t() throw(); + + virtual void il(IntPair); }; struct SimpleCases : public Base { @@ -221,6 +227,14 @@ public: // CHECK-FIXES: {{^}} void cv2() const volatile override // some comment }; +struct DefaultArguments : public Base { + // Tests for default arguments (with initializer lists). + // Make sure the override fix is placed after the argument list. + void il(IntPair p = {1, (2 + (3))}) {} + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this + // CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {} +}; + struct Macros : public Base { // Tests for 'virtual' and 'override' being defined through macros. Basically // give up for now. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307384 - [Frontend] Verify that the bitstream is not empty before reading
Author: arphaman Date: Fri Jul 7 03:25:12 2017 New Revision: 307384 URL: http://llvm.org/viewvc/llvm-project?rev=307384&view=rev Log: [Frontend] Verify that the bitstream is not empty before reading the serialised diagnostics Clang should avoid calling report_fatal_error when the file with the serialised diagnostics is empty. This commit changes Clang's serialised diagnostic reader, now it reports an appropriate error instead of crashing. rdar://31939877 Differential Revision: https://reviews.llvm.org/D35069 Added: cfe/trunk/test/Index/Inputs/empty.dia cfe/trunk/test/Index/read-empty-diags.test Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp?rev=307384&r1=307383&r2=307384&view=diff == --- cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp (original) +++ cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp Fri Jul 7 03:25:12 2017 @@ -27,6 +27,9 @@ std::error_code SerializedDiagnosticRead llvm::BitstreamCursor Stream(**Buffer); Optional BlockInfo; + if (Stream.AtEndOfStream()) +return SDError::InvalidSignature; + // Sniff for the signature. if (Stream.Read(8) != 'D' || Stream.Read(8) != 'I' || Added: cfe/trunk/test/Index/Inputs/empty.dia URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/empty.dia?rev=307384&view=auto == (empty) Added: cfe/trunk/test/Index/read-empty-diags.test URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/read-empty-diags.test?rev=307384&view=auto == --- cfe/trunk/test/Index/read-empty-diags.test (added) +++ cfe/trunk/test/Index/read-empty-diags.test Fri Jul 7 03:25:12 2017 @@ -0,0 +1,2 @@ +// RUN: not c-index-test -read-diagnostics %S/Inputs/empty.dia 2>&1 | FileCheck %s +// CHECK: Trouble deserializing file (Invalid File): Invalid diagnostics signature ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35069: [Frontend] Verify that the bitstream is not empty before reading the serialised diagnostics
This revision was automatically updated to reflect the committed changes. Closed by commit rL307384: [Frontend] Verify that the bitstream is not empty before reading (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D35069?vs=105462&id=105612#toc Repository: rL LLVM https://reviews.llvm.org/D35069 Files: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp cfe/trunk/test/Index/Inputs/empty.dia cfe/trunk/test/Index/read-empty-diags.test Index: cfe/trunk/test/Index/read-empty-diags.test === --- cfe/trunk/test/Index/read-empty-diags.test +++ cfe/trunk/test/Index/read-empty-diags.test @@ -0,0 +1,2 @@ +// RUN: not c-index-test -read-diagnostics %S/Inputs/empty.dia 2>&1 | FileCheck %s +// CHECK: Trouble deserializing file (Invalid File): Invalid diagnostics signature Index: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp === --- cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp +++ cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp @@ -27,6 +27,9 @@ llvm::BitstreamCursor Stream(**Buffer); Optional BlockInfo; + if (Stream.AtEndOfStream()) +return SDError::InvalidSignature; + // Sniff for the signature. if (Stream.Read(8) != 'D' || Stream.Read(8) != 'I' || Index: cfe/trunk/test/Index/read-empty-diags.test === --- cfe/trunk/test/Index/read-empty-diags.test +++ cfe/trunk/test/Index/read-empty-diags.test @@ -0,0 +1,2 @@ +// RUN: not c-index-test -read-diagnostics %S/Inputs/empty.dia 2>&1 | FileCheck %s +// CHECK: Trouble deserializing file (Invalid File): Invalid diagnostics signature Index: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp === --- cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp +++ cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp @@ -27,6 +27,9 @@ llvm::BitstreamCursor Stream(**Buffer); Optional BlockInfo; + if (Stream.AtEndOfStream()) +return SDError::InvalidSignature; + // Sniff for the signature. if (Stream.Read(8) != 'D' || Stream.Read(8) != 'I' || ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307386 - [driver][mips] Pass long-calls feature flag to the MIPS backend
Author: atanasyan Date: Fri Jul 7 03:35:33 2017 New Revision: 307386 URL: http://llvm.org/viewvc/llvm-project?rev=307386&view=rev Log: [driver][mips] Pass long-calls feature flag to the MIPS backend Check the `-mlong-calls` command line option and pass the `long-calls` feature flag to the backend. Handling of this feature flag in the backend needs to be implemented by a separate commit. Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/test/Driver/mips-features.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=307386&r1=307385&r2=307386&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Fri Jul 7 03:35:33 2017 @@ -299,6 +299,8 @@ void mips::getMIPSTargetFeatures(const D options::OPT_modd_spreg, "nooddspreg"); AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4, "nomadd4"); + AddTargetFeature(Args, Features, options::OPT_mlong_calls, + options::OPT_mno_long_calls, "long-calls"); } mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) { Modified: cfe/trunk/test/Driver/mips-features.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=307386&r1=307385&r2=307386&view=diff == --- cfe/trunk/test/Driver/mips-features.c (original) +++ cfe/trunk/test/Driver/mips-features.c Fri Jul 7 03:35:33 2017 @@ -247,3 +247,14 @@ // RUN: | FileCheck --check-prefix=CHECK-IMG-SINGLEFLOAT-FPXX %s // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+single-float" // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx" + +// -mlong-call +// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \ +// RUN: | FileCheck --check-prefix=LONG-CALLS-ON %s +// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \ +// RUN: | FileCheck --check-prefix=LONG-CALLS-OFF %s +// RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=LONG-CALLS-DEF %s +// LONG-CALLS-ON: "-target-feature" "+long-calls" +// LONG-CALLS-OFF: "-target-feature" "-long-calls" +// LONG-CALLS-DEF-NOT: "long-calls" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307388 - Recommit [driver][macOS] Pick the system version for the
Author: arphaman Date: Fri Jul 7 03:41:19 2017 New Revision: 307388 URL: http://llvm.org/viewvc/llvm-project?rev=307388&view=rev Log: Recommit [driver][macOS] Pick the system version for the deployment target if the SDK is newer than the system This commit reverts the revert commit r305891. Now the change from r305678 should be correct because `llvm::sys::getProcessTriple` now returns the correct macOS version of the system after the LLVM change r307372. Original commit message: This commit improves the driver by making sure that it picks the system version for the deployment target when the version of the macOS SDK is newer than the system version. rdar://29449467 Differential Revision: https://reviews.llvm.org/D34175 Added: cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=307388&r1=307387&r2=307388&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Jul 7 03:41:19 2017 @@ -1118,6 +1118,27 @@ void DarwinClang::AddLinkRuntimeLibArgs( } } +/// Returns the most appropriate macOS target version for the current process. +/// +/// If the macOS SDK version is the same or earlier than the system version, +/// then the SDK version is returned. Otherwise the system version is returned. +static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) { + unsigned Major, Minor, Micro; + llvm::Triple SystemTriple(llvm::sys::getProcessTriple()); + if (!SystemTriple.isMacOSX()) +return MacOSSDKVersion; + SystemTriple.getMacOSXVersion(Major, Minor, Micro); + VersionTuple SystemVersion(Major, Minor, Micro); + bool HadExtra; + if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro, + HadExtra)) +return MacOSSDKVersion; + VersionTuple SDKVersion(Major, Minor, Micro); + if (SDKVersion > SystemVersion) +return SystemVersion.getAsString(); + return MacOSSDKVersion; +} + void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { const OptTable &Opts = getDriver().getOpts(); @@ -1229,7 +1250,7 @@ void Darwin::AddDeploymentTarget(Derived SDK.startswith("iPhoneSimulator")) iOSTarget = Version; else if (SDK.startswith("MacOSX")) - OSXTarget = Version; + OSXTarget = getSystemOrSDKMacOSVersion(Version); else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator")) WatchOSTarget = Version; Added: cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c?rev=307388&view=auto == --- cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c (added) +++ cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c Fri Jul 7 03:41:19 2017 @@ -0,0 +1,10 @@ +// REQUIRES: system-darwin + +// Ensure that we never pick a version that's based on the SDK that's newer than +// the system version: +// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk +// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk +// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s + +// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35118: [AArch64] Add support for handling the +sve target feature
aemerson created this revision. aemerson added a project: clang. Herald added subscribers: kristof.beyls, tschuett, javed.absar. [AArch64] Add support for handling the +sve target feature. This also adds the appropriate predefine for SVE if enabled. Depends on https://reviews.llvm.org/D35076 Repository: rL LLVM https://reviews.llvm.org/D35118 Files: lib/Basic/Targets.cpp test/Preprocessor/aarch64-target-features.c Index: test/Preprocessor/aarch64-target-features.c === --- test/Preprocessor/aarch64-target-features.c +++ test/Preprocessor/aarch64-target-features.c @@ -37,6 +37,7 @@ // CHECK-NOT: __ARM_PCS_VFP 1 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2 +// CHECK-NOT: __ARM_FEATURE_SVE // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1 @@ -84,6 +85,10 @@ // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s + +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s +// CHECK-SVE: __ARM_FEATURE_SVE 1 + // == Check whether -mtune accepts mixed-case features. // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -6242,8 +6242,8 @@ static const char *const GCCRegNames[]; enum FPUModeEnum { -FPUMode, -NeonMode +NeonMode = (1 << 0), +SveMode = (1 << 1) }; unsigned FPU; @@ -6377,12 +6377,15 @@ Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : "4"); -if (FPU == NeonMode) { +if (FPU & NeonMode) { Builder.defineMacro("__ARM_NEON", "1"); // 64-bit NEON supports half, single and double precision operations. Builder.defineMacro("__ARM_NEON_FP", "0xE"); } +if (FPU & SveMode) + Builder.defineMacro("__ARM_FEATURE_SVE", "1"); + if (CRC) Builder.defineMacro("__ARM_FEATURE_CRC32", "1"); @@ -6418,21 +6421,24 @@ return Feature == "aarch64" || Feature == "arm64" || Feature == "arm" || - (Feature == "neon" && FPU == NeonMode); + (Feature == "neon" && (FPU & NeonMode)) || + (Feature == "sve" && (FPU & SveMode)); } bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override { -FPU = FPUMode; +FPU = 0; CRC = 0; Crypto = 0; Unaligned = 1; HasFullFP16 = 0; ArchKind = llvm::AArch64::ArchKind::AK_ARMV8A; for (const auto &Feature : Features) { if (Feature == "+neon") -FPU = NeonMode; +FPU |= NeonMode; + if (Feature == "+sve") +FPU |= SveMode; if (Feature == "+crc") CRC = 1; if (Feature == "+crypto") Index: test/Preprocessor/aarch64-target-features.c === --- test/Preprocessor/aarch64-target-features.c +++ test/Preprocessor/aarch64-target-features.c @@ -37,6 +37,7 @@ // CHECK-NOT: __ARM_PCS_VFP 1 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2 +// CHECK-NOT: __ARM_FEATURE_SVE // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1 @@ -84,6 +85,10 @@ // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s + +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s +// CHECK-SVE: __ARM_FEATURE_SVE 1 + // == Check whether -mtune accepts mixed-case features. // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -6242,8 +6242,8 @@ static const char *const GCCRegNames[]; enum FPUModeEnum { -FPUMode, -NeonMode +NeonMode = (1 << 0), +SveMode = (1 << 1) }; unsigned FPU; @@ -6377,12 +6377,15 @@ Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
[PATCH] D35118: [AArch64] Add support for handling the +sve target feature
rengolin added a reviewer: t.p.northover. rengolin added a subscriber: t.p.northover. rengolin added inline comments. Comment at: lib/Basic/Targets.cpp:6245 enum FPUModeEnum { -FPUMode, -NeonMode +NeonMode = (1 << 0), +SveMode = (1 << 1) Is there any AArch64 arch without SIMD? Anyway, that seems deliberate, @t.p.northover any idea? Repository: rL LLVM https://reviews.llvm.org/D35118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35118: [AArch64] Add support for handling the +sve target feature
aemerson added inline comments. Comment at: lib/Basic/Targets.cpp:6245 enum FPUModeEnum { -FPUMode, -NeonMode +NeonMode = (1 << 0), +SveMode = (1 << 1) rengolin wrote: > Is there any AArch64 arch without SIMD? > > Anyway, that seems deliberate, @t.p.northover any idea? SIMD support can be disabled with +nosimd. This change doesn't affect how that works. Repository: rL LLVM https://reviews.llvm.org/D35118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
baloghadamsoftware updated this revision to Diff 105628. baloghadamsoftware added a comment. Type check added and restricted to additive operators. https://reviews.llvm.org/D35109 Files: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp test/Analysis/std-c-library-functions.c test/Analysis/svalbuilder-rearrange-comparisons.c Index: test/Analysis/svalbuilder-rearrange-comparisons.c === --- /dev/null +++ test/Analysis/svalbuilder-rearrange-comparisons.c @@ -0,0 +1,156 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s + +void clang_analyzer_dump(int x); +void clang_analyzer_printState(); + +int f(); + +void compare_different_symbol() { + int x = f(), y = f(); + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 0}} +} + +void compare_different_symbol_plus_left_int() { + int x = f()+1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_minus_left_int() { + int x = f()-1, y = f(); + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_different_symbol_plus_right_int() { + int x = f(), y = f()+2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 2}} +} + +void compare_different_symbol_minus_right_int() { + int x = f(), y = f()-2; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 2}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 2}} +} + +void compare_different_symbol_plus_left_plus_right_int() { + int x = f()+2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}} +} + +void compare_different_symbol_plus_left_minus_right_int() { + int x = f()+2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 3}} +} + +void compare_different_symbol_minus_left_plus_right_int() { + int x = f()-2, y = f()+1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 3}} +} + +void compare_different_symbol_minus_left_minus_right_int() { + int x = f()-2, y = f()-1; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}} + clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}} +} + +void compare_same_symbol() { + int x = f(), y = x; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{1 S32b}} +} + +void compare_same_symbol_plus_left_int() { + int x = f(), y = x; + ++x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_minus_left_int() { + int x = f(), y = x; + --x; + clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_plus_right_int() { + int x = f(), y = x+1; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_minus_right_int() { + int x = f(), y = x-1; + clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} + clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} + clang_analyzer_dump(x == y); + // expected-warning@-1{{0 S32b}} +} + +void compare_same_symbol_plus_left_plus_right_i
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
baloghadamsoftware marked an inline comment as done. baloghadamsoftware added inline comments. Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:583 +newRhs = BasicVals.evalAPSInt(BO_Add, *lInt, *rInt); +reverse = (lop == BO_Add); + } else { NoQ wrote: > I'm afraid we may step into `BO_Mul` here, or something like that. Could you > add a check somewhere that all the operations involved are either `BO_Add` or > `BO_Sub`? I can remember adding BinaryOperator::isAdditiveOp() at the very beginning, maybe I accidentally deleted it. https://reviews.llvm.org/D35109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
baloghadamsoftware marked an inline comment as done. baloghadamsoftware added a comment. In https://reviews.llvm.org/D35109#801921, @NoQ wrote: > Because integer promotion rules are tricky, could we, for now, avoid dealing > with the situation when left-hand side and right-hand side and the result > (all three) are not all of the same type? Or maybe we'd like to support > substraction of unsigned values into a signed value of the same size, but > still avoid the rest of the cases. Because it'd take an overwhelming amount > of testing to ensure that we get all the promotion cases correctly. I think the best place to add and test integer promotion rules is the type system. https://reviews.llvm.org/D35109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307394 - clang-format: [JS] do not wrap after "readonly".
Author: mprobst Date: Fri Jul 7 06:17:10 2017 New Revision: 307394 URL: http://llvm.org/viewvc/llvm-project?rev=307394&view=rev Log: clang-format: [JS] do not wrap after "readonly". Summary: Breaks after "readonly" trigger automatic semicolon insertion in field declarations. Reviewers: krasimir, djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D35112 Modified: cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/FormatToken.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=307394&r1=307393&r2=307394&view=diff == --- cfe/trunk/lib/Format/FormatToken.h (original) +++ cfe/trunk/lib/Format/FormatToken.h Fri Jul 7 06:17:10 2017 @@ -641,6 +641,7 @@ struct AdditionalKeywords { kw_is = &IdentTable.get("is"); kw_let = &IdentTable.get("let"); kw_module = &IdentTable.get("module"); +kw_readonly = &IdentTable.get("readonly"); kw_set = &IdentTable.get("set"); kw_type = &IdentTable.get("type"); kw_var = &IdentTable.get("var"); @@ -678,8 +679,8 @@ struct AdditionalKeywords { // already initialized. JsExtraKeywords = std::unordered_set( {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from, - kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_set, - kw_type, kw_var, kw_yield, + kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly, + kw_set, kw_type, kw_var, kw_yield, // Keywords from the Java section. kw_abstract, kw_extends, kw_implements, kw_instanceof, kw_interface}); } @@ -710,6 +711,7 @@ struct AdditionalKeywords { IdentifierInfo *kw_is; IdentifierInfo *kw_let; IdentifierInfo *kw_module; + IdentifierInfo *kw_readonly; IdentifierInfo *kw_set; IdentifierInfo *kw_type; IdentifierInfo *kw_var; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=307394&r1=307393&r2=307394&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jul 7 06:17:10 2017 @@ -2629,11 +2629,12 @@ bool TokenAnnotator::canBreakBefore(cons } else if (Style.Language == FormatStyle::LK_JavaScript) { const FormatToken *NonComment = Right.getPreviousNonComment(); if (NonComment && -NonComment->isOneOf( -tok::kw_return, tok::kw_continue, tok::kw_break, tok::kw_throw, -Keywords.kw_interface, Keywords.kw_type, tok::kw_static, -tok::kw_public, tok::kw_private, tok::kw_protected, -Keywords.kw_abstract, Keywords.kw_get, Keywords.kw_set)) +NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break, +tok::kw_throw, Keywords.kw_interface, +Keywords.kw_type, tok::kw_static, tok::kw_public, +tok::kw_private, tok::kw_protected, +Keywords.kw_readonly, Keywords.kw_abstract, +Keywords.kw_get, Keywords.kw_set)) return false; // Otherwise automatic semicolon insertion would trigger. if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace)) return false; Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=307394&r1=307393&r2=307394&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jul 7 06:17:10 2017 @@ -930,6 +930,14 @@ TEST_F(FormatTestJS, WrapRespectsAutomat " aaa\n" "];", getGoogleJSStyleWithColumns(12)); + verifyFormat("class X {\n" + " readonly ratherLongField =\n" + " 1;\n" + "}", + "class X {\n" + " readonly ratherLongField = 1;\n" + "}", + getGoogleJSStyleWithColumns(20)); } TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31326: Add option to export fixes to run-clang-tidy.py
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. A few more nits. Comment at: run-clang-tidy.py:93 +def merge_replacement_files(tmpdir, fixfile): + """Merge all replacement files in a directory into a single fixfile""" + # MainSourceFile: The key is required by the definition inside I'm not sure "fixfile" is a word. Just "file" maybe? Comment at: run-clang-tidy.py:96 + # include/clang/Tooling/ReplacementsYaml.h, but the value + # is actually never usid inside clang-apply-replacements, + # so we set it to '' here. nit: "usid" Comment at: run-clang-tidy.py:100 + + for replacefile in glob.iglob(tmpdir + '/*.yaml'): +with open(replacefile, 'r') as f: I'd use `os.path.join()` instead of concatenation. Comment at: run-clang-tidy.py:104 + if not content: +continue # Skip empty files + nit: Add a trailing period. Comment at: run-clang-tidy.py:109 +except KeyError: + pass # Ignore files with missing keys + nit: Add a trailing period. https://reviews.llvm.org/D31326 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33842: CodeGen: Fix address space of global variable
yaxunl marked 4 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:1144 + ? CGM.getNSConcreteGlobalBlock() + : CGM.getNullPointer(CGM.VoidPtrPtrTy, + QualType(CGM.getContext().VoidPtrTy))); rjmccall wrote: > yaxunl wrote: > > rjmccall wrote: > > > You used VoidPtrTy above. > > They are different fields with different types. > They're both the isa field of a block object. The difference is just between > allocating the block globally and allocating it on the stack. You are right, actually they should both be VoidPtrPtrTy to match the type of getNSConcreteGlobalBlock() and getNSConcreteStackBlock(). Fixed. Comment at: lib/CodeGen/TargetInfo.h:237 + virtual unsigned getGlobalVarAddressSpace(const VarDecl *D, +CodeGenModule &CGM) const; + rjmccall wrote: > The CGM is conventionally the first argument. done Comment at: lib/CodeGen/TargetInfo.h:262 + unsigned DestAddr, + llvm::Type *DestTy) const; }; rjmccall wrote: > This should probably take the CGM for completeness. done. https://reviews.llvm.org/D33842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33842: CodeGen: Fix address space of global variable
yaxunl updated this revision to Diff 105644. yaxunl marked 3 inline comments as done. yaxunl added a comment. Revised by John's comments. https://reviews.llvm.org/D33842 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/TargetInfo.cpp lib/CodeGen/TargetInfo.h test/CodeGen/address-space.c test/CodeGen/default-address-space.c test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp Index: test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp === --- test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp +++ test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefixes=X86,CHECK %s +// RUN: %clang_cc1 -std=c++11 -triple amdgcn-amd-amdhsa-amdgiz -DNO_TLS -emit-llvm -o - %s | FileCheck -check-prefixes=AMD,CHECK %s namespace std { typedef decltype(sizeof(int)) size_t; @@ -46,62 +47,82 @@ wantslist1(std::initializer_list); ~wantslist1(); }; - -// CHECK: @_ZGR15globalInitList1_ = internal constant [3 x i32] [i32 1, i32 2, i32 3] -// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZGR15globalInitList1_, i32 0, i32 0), i{{32|64}} 3 } +// X86: @_ZGR15globalInitList1_ = internal constant [3 x i32] [i32 1, i32 2, i32 3] +// X86: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZGR15globalInitList1_, i32 0, i32 0), i{{32|64}} 3 } +// AMD: @_ZGR15globalInitList1_ = internal addrspace(1) constant [3 x i32] [i32 1, i32 2, i32 3] +// AMD: @globalInitList1 = addrspace(1) global %{{[^ ]+}} { i32* addrspacecast (i32 addrspace(1)* getelementptr inbounds ([3 x i32], [3 x i32] addrspace(1)* @_ZGR15globalInitList1_, i32 0, i32 0) to i32*), i{{32|64}} 3 } std::initializer_list globalInitList1 = {1, 2, 3}; +#ifndef NO_TLS namespace thread_local_global_array { - // FIXME: We should be able to constant-evaluate this even though the - // initializer is not a constant expression (pointers to thread_local - // objects aren't really a problem). - // - // CHECK: @_ZN25thread_local_global_array1xE = thread_local global - // CHECK: @_ZGRN25thread_local_global_array1xE_ = internal thread_local constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] - std::initializer_list thread_local x = { 1, 2, 3, 4 }; +// FIXME: We should be able to constant-evaluate this even though the +// initializer is not a constant expression (pointers to thread_local +// objects aren't really a problem). +// +// X86: @_ZN25thread_local_global_array1xE = thread_local global +// X86: @_ZGRN25thread_local_global_array1xE_ = internal thread_local constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] +std::initializer_list thread_local x = {1, 2, 3, 4}; } - -// CHECK: @globalInitList2 = global %{{[^ ]+}} zeroinitializer -// CHECK: @_ZGR15globalInitList2_ = internal global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer - -// CHECK: @_ZN15partly_constant1kE = global i32 0, align 4 -// CHECK: @_ZN15partly_constant2ilE = global {{.*}} null, align 8 -// CHECK: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal global {{.*}} zeroinitializer, align 8 -// CHECK: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = internal global [3 x {{.*}}] zeroinitializer, align 8 -// CHECK: @[[PARTLY_CONSTANT_FIRST:_ZGRN15partly_constant2ilE.*]] = internal constant [3 x i32] [i32 1, i32 2, i32 3], align 4 -// CHECK: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = internal global [2 x i32] zeroinitializer, align 4 -// CHECK: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = internal constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4 - -// CHECK: @[[REFTMP1:.*]] = private constant [2 x i32] [i32 42, i32 43], align 4 -// CHECK: @[[REFTMP2:.*]] = private constant [3 x %{{.*}}] [%{{.*}} { i32 1 }, %{{.*}} { i32 2 }, %{{.*}} { i32 3 }], align 4 +#endif + +// X86: @globalInitList2 = global %{{[^ ]+}} zeroinitializer +// X86: @_ZGR15globalInitList2_ = internal global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer +// AMD: @globalInitList2 = addrspace(1) global %{{[^ ]+}} zeroinitializer +// AMD: @_ZGR15globalInitList2_ = internal addrspace(1) global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer + +// X86: @_ZN15partly_constant1kE = global i32 0, align 4 +// X86: @_ZN15partly_constant2ilE = global {{.*}} null, align 8 +// X86: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal global {{.*}} zeroinitializer, align 8 +// X86: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = internal global [3 x {{.*}}] zeroinitializer, align 8 +// X86: @[[PARTLY_CONSTANT_FIRS
[PATCH] D34985: Do not read the file to determine its name.
karies added a comment. In https://reviews.llvm.org/D34985#801498, @bruno wrote: > @v.g.vassilev will this also benefit from `ContentCache::getBuffer` > improvements from https://reviews.llvm.org/D33275? I guess if `getBuffer` > transparently handles pointing to right buffer we won't need this change? This change is for cases where you have no buffer, because the file was never `fopen()`ed, because it's an `ASTReader` `InputFile`. Repository: rL LLVM https://reviews.llvm.org/D34985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33676: Place implictly declared functions at block scope
chill added a comment. Ping. https://reviews.llvm.org/D33676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor
rnk added a comment. I discussed this with @rsmith and we think the correct fix is to update the DefinitionData bits computed when adding special members. I haven't reviewed this patch in detail, but we came to the conclusion that Clang's optimization to avoid implicit special member declarations in most situations makes it impossible to get the correct answer in all situations here. The explicit loop over `RD->ctors()` is a bug in itself, because important ones may not be there. I'm never able to remember the details, but we believe that's the "right" fix. This would change the values reported by some of the older pre-c++11 GCC type traits (the __has_* ones, I think), but modern versions of libstdc++ no longer use them. We're hesitant to accept a workaround in the meantime because it means we'll have to fix the bug again later and create another ABI break with ourselves. However, we shouldn't let the perfect be the enemy of the good. In practice, I suspect we are not very good about maintaining ABI stability in corner cases this deep. Repository: rL LLVM https://reviews.llvm.org/D35056 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307420 - [X86] Replace 'fallthrough' comments with LLVM_FALLTHROUGH.
Author: ctopper Date: Fri Jul 7 11:41:09 2017 New Revision: 307420 URL: http://llvm.org/viewvc/llvm-project?rev=307420&view=rev Log: [X86] Replace 'fallthrough' comments with LLVM_FALLTHROUGH. Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=307420&r1=307419&r2=307420&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Fri Jul 7 11:41:09 2017 @@ -3890,7 +3890,7 @@ void X86TargetInfo::getTargetDefines(con case CK_PentiumMMX: Builder.defineMacro("__pentium_mmx__"); Builder.defineMacro("__tune_pentium_mmx__"); -// Fallthrough +LLVM_FALLTHROUGH; case CK_i586: case CK_Pentium: defineCPUMacros(Builder, "i586"); @@ -3900,15 +3900,15 @@ void X86TargetInfo::getTargetDefines(con case CK_Pentium3M: case CK_PentiumM: Builder.defineMacro("__tune_pentium3__"); -// Fallthrough +LLVM_FALLTHROUGH; case CK_Pentium2: case CK_C3_2: Builder.defineMacro("__tune_pentium2__"); -// Fallthrough +LLVM_FALLTHROUGH; case CK_PentiumPro: Builder.defineMacro("__tune_i686__"); Builder.defineMacro("__tune_pentiumpro__"); -// Fallthrough +LLVM_FALLTHROUGH; case CK_i686: Builder.defineMacro("__i686"); Builder.defineMacro("__i686__"); @@ -3964,7 +3964,7 @@ void X86TargetInfo::getTargetDefines(con case CK_K6_2: Builder.defineMacro("__k6_2__"); Builder.defineMacro("__tune_k6_2__"); -// Fallthrough +LLVM_FALLTHROUGH; case CK_K6_3: if (CPU != CK_K6_2) { // In case of fallthrough // FIXME: GCC may be enabling these in cases where some other k6 @@ -3973,7 +3973,7 @@ void X86TargetInfo::getTargetDefines(con Builder.defineMacro("__k6_3__"); Builder.defineMacro("__tune_k6_3__"); } -// Fallthrough +LLVM_FALLTHROUGH; case CK_K6: defineCPUMacros(Builder, "k6"); break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307434 - [modules ts] Basic for module linkage.
Author: rsmith Date: Fri Jul 7 13:04:28 2017 New Revision: 307434 URL: http://llvm.org/viewvc/llvm-project?rev=307434&view=rev Log: [modules ts] Basic for module linkage. In addition to the formal linkage rules, the Modules TS includes cases where internal-linkage symbols within a module interface unit can be referenced from outside the module via exported inline functions / templates. We give such declarations "module-internal linkage", which is formally internal linkage, but results in an externally-visible symbol. Modified: cfe/trunk/include/clang/Basic/Linkage.h cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/lib/Index/IndexSymbol.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp Modified: cfe/trunk/include/clang/Basic/Linkage.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Linkage.h?rev=307434&r1=307433&r2=307434&view=diff == --- cfe/trunk/include/clang/Basic/Linkage.h (original) +++ cfe/trunk/include/clang/Basic/Linkage.h Fri Jul 7 13:04:28 2017 @@ -45,6 +45,17 @@ enum Linkage : unsigned char { /// translation units because of types defined in a inline function. VisibleNoLinkage, + /// \brief Internal linkage according to the Modules TS, but can be referred + /// to from other translation units indirectly through inline functions and + /// templates in the module interface. + ModuleInternalLinkage, + + /// \brief Module linkage, which indicates that the entity can be referred + /// to from other translation units within the same module, and indirectly + /// from arbitrary other translation units through inline functions and + /// templates in the module interface. + ModuleLinkage, + /// \brief External linkage, which indicates that the entity can /// be referred to from other translation units. ExternalLinkage @@ -74,15 +85,20 @@ inline bool isDiscardableGVALinkage(GVAL } inline bool isExternallyVisible(Linkage L) { - return L == ExternalLinkage || L == VisibleNoLinkage; + return L >= VisibleNoLinkage; } inline Linkage getFormalLinkage(Linkage L) { - if (L == UniqueExternalLinkage) + switch (L) { + case UniqueExternalLinkage: return ExternalLinkage; - if (L == VisibleNoLinkage) + case VisibleNoLinkage: return NoLinkage; - return L; + case ModuleInternalLinkage: +return InternalLinkage; + default: +return L; + } } inline bool isExternalFormalLinkage(Linkage L) { Modified: cfe/trunk/lib/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=307434&r1=307433&r2=307434&view=diff == --- cfe/trunk/lib/AST/Decl.cpp (original) +++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 7 13:04:28 2017 @@ -573,6 +573,44 @@ static bool isSingleLineLanguageLinkage( return false; } +static bool isExportedFromModuleIntefaceUnit(const NamedDecl *D) { + switch (D->getModuleOwnershipKind()) { + case Decl::ModuleOwnershipKind::Unowned: + case Decl::ModuleOwnershipKind::ModulePrivate: +return false; + case Decl::ModuleOwnershipKind::Visible: + case Decl::ModuleOwnershipKind::VisibleWhenImported: +if (auto *M = D->getOwningModule()) + return M->Kind == Module::ModuleInterfaceUnit; + } + llvm_unreachable("unexpected module ownership kind"); +} + +static LinkageInfo getInternalLinkageFor(const NamedDecl *D) { + // Internal linkage declarations within a module interface unit are modeled + // as "module-internal linkage", which means that they have internal linkage + // formally but can be indirectly accessed from outside the module via inline + // functions and templates defined within the module. + if (auto *M = D->getOwningModule()) +if (M->Kind == Module::ModuleInterfaceUnit) + return LinkageInfo(ModuleInternalLinkage, DefaultVisibility, false); + + return LinkageInfo::internal(); +} + +static LinkageInfo getExternalLinkageFor(const NamedDecl *D) { + // C++ Modules TS [basic.link]/6.8: + // - A name declared at namespace scope that does not have internal linkage + // by the previous rules and that is introduced by a non-exported + // declaration has module linkage. + if (auto *M = D->getOwningModule()) +if (M->Kind == Module::ModuleInterfaceUnit) + if (!isExportedFromModuleIntefaceUnit(D)) +return LinkageInfo(ModuleLinkage, DefaultVisibility, false); + + return LinkageInfo::external(); +} + static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVComputationKind computation) { assert(D->getDeclContext()->getRedeclContext()->isFileContext() &
Re: r307434 - [modules ts] Basic for module linkage.
On 7 July 2017 at 13:04, Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rsmith > Date: Fri Jul 7 13:04:28 2017 > New Revision: 307434 > > URL: http://llvm.org/viewvc/llvm-project?rev=307434&view=rev > Log: > [modules ts] Basic for module linkage. > Sorry, that should say "Basic *support* for module linkage." > In addition to the formal linkage rules, the Modules TS includes cases > where > internal-linkage symbols within a module interface unit can be referenced > from > outside the module via exported inline functions / templates. We give such > declarations "module-internal linkage", which is formally internal > linkage, but > results in an externally-visible symbol. > > Modified: > cfe/trunk/include/clang/Basic/Linkage.h > cfe/trunk/lib/AST/Decl.cpp > cfe/trunk/lib/CodeGen/CodeGenModule.cpp > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > cfe/trunk/lib/Index/IndexSymbol.cpp > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp > > Modified: cfe/trunk/include/clang/Basic/Linkage.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Basic/Linkage.h?rev=307434&r1=307433&r2=307434&view=diff > > == > --- cfe/trunk/include/clang/Basic/Linkage.h (original) > +++ cfe/trunk/include/clang/Basic/Linkage.h Fri Jul 7 13:04:28 2017 > @@ -45,6 +45,17 @@ enum Linkage : unsigned char { >/// translation units because of types defined in a inline function. >VisibleNoLinkage, > > + /// \brief Internal linkage according to the Modules TS, but can be > referred > + /// to from other translation units indirectly through inline functions > and > + /// templates in the module interface. > + ModuleInternalLinkage, > + > + /// \brief Module linkage, which indicates that the entity can be > referred > + /// to from other translation units within the same module, and > indirectly > + /// from arbitrary other translation units through inline functions and > + /// templates in the module interface. > + ModuleLinkage, > + >/// \brief External linkage, which indicates that the entity can >/// be referred to from other translation units. >ExternalLinkage > @@ -74,15 +85,20 @@ inline bool isDiscardableGVALinkage(GVAL > } > > inline bool isExternallyVisible(Linkage L) { > - return L == ExternalLinkage || L == VisibleNoLinkage; > + return L >= VisibleNoLinkage; > } > > inline Linkage getFormalLinkage(Linkage L) { > - if (L == UniqueExternalLinkage) > + switch (L) { > + case UniqueExternalLinkage: > return ExternalLinkage; > - if (L == VisibleNoLinkage) > + case VisibleNoLinkage: > return NoLinkage; > - return L; > + case ModuleInternalLinkage: > +return InternalLinkage; > + default: > +return L; > + } > } > > inline bool isExternalFormalLinkage(Linkage L) { > > Modified: cfe/trunk/lib/AST/Decl.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > Decl.cpp?rev=307434&r1=307433&r2=307434&view=diff > > == > --- cfe/trunk/lib/AST/Decl.cpp (original) > +++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 7 13:04:28 2017 > @@ -573,6 +573,44 @@ static bool isSingleLineLanguageLinkage( >return false; > } > > +static bool isExportedFromModuleIntefaceUnit(const NamedDecl *D) { > + switch (D->getModuleOwnershipKind()) { > + case Decl::ModuleOwnershipKind::Unowned: > + case Decl::ModuleOwnershipKind::ModulePrivate: > +return false; > + case Decl::ModuleOwnershipKind::Visible: > + case Decl::ModuleOwnershipKind::VisibleWhenImported: > +if (auto *M = D->getOwningModule()) > + return M->Kind == Module::ModuleInterfaceUnit; > + } > + llvm_unreachable("unexpected module ownership kind"); > +} > + > +static LinkageInfo getInternalLinkageFor(const NamedDecl *D) { > + // Internal linkage declarations within a module interface unit are > modeled > + // as "module-internal linkage", which means that they have internal > linkage > + // formally but can be indirectly accessed from outside the module via > inline > + // functions and templates defined within the module. > + if (auto *M = D->getOwningModule()) > +if (M->Kind == Module::ModuleInterfaceUnit) > + return LinkageInfo(ModuleInternalLinkage, DefaultVisibility, > false); > + > + return LinkageInfo::internal(); > +} > + > +static LinkageInfo getExternalLinkageFor(const NamedDecl *D) { > + // C++ Modules TS [basic.link]/6.8: > + // - A name declared at namespace scope that does not have internal > linkage > + // by the previous rules and that is introduced by a non-exported > + // declaration has module linkage. > + if (auto *M = D->getOwningModule()) > +if (M->Kind ==
r307438 - Enable the new PM + SamlePGO + ThinLTO testing.
Author: dehao Date: Fri Jul 7 13:53:17 2017 New Revision: 307438 URL: http://llvm.org/viewvc/llvm-project?rev=307438&view=rev Log: Enable the new PM + SamlePGO + ThinLTO testing. Summary: This patch should be enabled after https://reviews.llvm.org/D34895 Reviewers: chandlerc, tejohnson, davidxl Reviewed By: tejohnson Subscribers: sanjoy, mehdi_amini, inglorion, eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D34896 Modified: cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c Modified: cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c?rev=307438&r1=307437&r2=307438&view=diff == --- cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c (original) +++ cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c Fri Jul 7 13:53:17 2017 @@ -1,9 +1,7 @@ // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO // RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO -// FIXME: Run the following command once LTOPreLinkDefaultPipeline is -//customized. -// %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO +// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO // Checks if hot call is inlined by normal compile, but not inlined by // thinlto compile. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307444 - Add testcase for r305850.
Author: lhames Date: Fri Jul 7 14:51:11 2017 New Revision: 307444 URL: http://llvm.org/viewvc/llvm-project?rev=307444&view=rev Log: Add testcase for r305850. Accidentally left this out of the original commit. Added: cfe/trunk/test/Import/import-overrides/ cfe/trunk/test/Import/import-overrides/Inputs/ cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp cfe/trunk/test/Import/import-overrides/test.cpp Added: cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp?rev=307444&view=auto == --- cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp (added) +++ cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp Fri Jul 7 14:51:11 2017 @@ -0,0 +1,9 @@ +class Base { +public: + virtual void foo() {} +}; + +class Derived : public Base { +public: + void foo() override {} +}; Added: cfe/trunk/test/Import/import-overrides/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/test.cpp?rev=307444&view=auto == --- cfe/trunk/test/Import/import-overrides/test.cpp (added) +++ cfe/trunk/test/Import/import-overrides/test.cpp Fri Jul 7 14:51:11 2017 @@ -0,0 +1,7 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s + +// CHECK: Overrides:{{.*}}Base::foo + +void foo() { + Derived d; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307445 - Add sample PGO integration test to cover profile annotation and inlining.
Author: dehao Date: Fri Jul 7 15:01:47 2017 New Revision: 307445 URL: http://llvm.org/viewvc/llvm-project?rev=307445&view=rev Log: Add sample PGO integration test to cover profile annotation and inlining. Summary: The patch makes the integration test cover major sample PGO components. Reviewers: davidxl Reviewed By: davidxl Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D34725 Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof cfe/trunk/test/CodeGen/pgo-sample.c Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof?rev=307445&r1=307444&r2=307445&view=diff == --- cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof (original) +++ cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof Fri Jul 7 15:01:47 2017 @@ -1,2 +1,7 @@ -bar:100:100 - 1: 2000 +bar:1000:1000 + 1: 1000 + 2: 0 +foo:1000:1000 + 1:bar:1000 + 1: 1000 + 2: 1000 Modified: cfe/trunk/test/CodeGen/pgo-sample.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=307445&r1=307444&r2=307445&view=diff == --- cfe/trunk/test/CodeGen/pgo-sample.c (original) +++ cfe/trunk/test/CodeGen/pgo-sample.c Fri Jul 7 15:01:47 2017 @@ -1,6 +1,34 @@ // Test if PGO sample use passes are invoked. // -// Ensure Pass PGOInstrumentationGenPass is invoked. -// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -// CHECK: Remove unused exception handling info -// CHECK: Sample profile pass +// Ensure Pass SampleProfileLoader is invoked. +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=STRUCTURE +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -o - 2>&1 | FileCheck %s +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -fexperimental-new-pass-manager -o - 2>&1 | FileCheck %s +// STRUCTURE: Remove unused exception handling info +// STRUCTURE: Sample profile pass + +void baz(); + +// CHECK-LABEL: @callee( +void callee(int t) { + for (int i = 0; i < t; i++) +baz(); +} + +// CHECK-LABEL: @bar( +// cold call to callee should not be inlined. +// CHECK: call void @callee +void bar(int x) { + if (x < 100) +callee(x); +} + +// CHECK-LABEL: @foo( +// bar should be early-inlined because it is hot inline instance in profile. +// callee should be inlined because it is hot callsite in the inline instance +// of foo:bar. +// CHECK-NOT: call void @callee +// CHECK-NOT: call void @bar +void foo(int x) { + bar(x); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307446 - [MS] Don't statically initialize dllimport member function pointers
Author: rnk Date: Fri Jul 7 15:04:29 2017 New Revision: 307446 URL: http://llvm.org/viewvc/llvm-project?rev=307446&view=rev Log: [MS] Don't statically initialize dllimport member function pointers Summary: r306137 made dllimport pointers to member functions non-constant. This is correct because a load must be executed to resolve any dllimported data. However, r306137 did not account for the use of dllimport member function pointers used as template arguments. This change re-lands r306137 with a template instantiation fix. This fixes PR33570. Reviewers: rnk, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34714 Added: cfe/trunk/test/SemaCXX/dllimport-memptr.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=307446&r1=307445&r2=307446&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 7 15:04:29 2017 @@ -1665,6 +1665,19 @@ static bool CheckLValueConstantExpressio return true; } +/// Member pointers are constant expressions unless they point to a +/// non-virtual dllimport member function. +static bool CheckMemberPointerConstantExpression(EvalInfo &Info, + SourceLocation Loc, + QualType Type, + const APValue &Value) { + const ValueDecl *Member = Value.getMemberPointerDecl(); + const auto *FD = dyn_cast_or_null(Member); + if (!FD) +return true; + return FD->isVirtual() || !FD->hasAttr(); +} + /// Check that this core constant expression is of literal type, and if not, /// produce an appropriate diagnostic. static bool CheckLiteralType(EvalInfo &Info, const Expr *E, @@ -1757,6 +1770,9 @@ static bool CheckConstantExpression(Eval return CheckLValueConstantExpression(Info, DiagLoc, Type, LVal); } + if (Value.isMemberPointer()) +return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value); + // Everything else is fine. return true; } Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=307446&r1=307445&r2=307446&view=diff == --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jul 7 15:04:29 2017 @@ -5319,10 +5319,16 @@ enum NullPointerValueKind { /// value of the appropriate type. static NullPointerValueKind isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, - QualType ParamType, Expr *Arg) { + QualType ParamType, Expr *Arg, + Decl *Entity = nullptr) { if (Arg->isValueDependent() || Arg->isTypeDependent()) return NPV_NotNullPointer; + // dllimport'd entities aren't constant but are available inside of template + // arguments. + if (Entity && Entity->hasAttr()) +return NPV_NotNullPointer; + if (!S.isCompleteType(Arg->getExprLoc(), ParamType)) llvm_unreachable( "Incomplete parameter type in isNullPointerValueTemplateArgument!"); @@ -5566,14 +5572,8 @@ CheckTemplateArgumentAddressOfObjectOrFu // If our parameter has pointer type, check for a null template value. if (ParamType->isPointerType() || ParamType->isNullPtrType()) { -NullPointerValueKind NPV; -// dllimport'd entities aren't constant but are available inside of template -// arguments. -if (Entity && Entity->hasAttr()) - NPV = NPV_NotNullPointer; -else - NPV = isNullPointerValueTemplateArgument(S, Param, ParamType, ArgIn); -switch (NPV) { +switch (isNullPointerValueTemplateArgument(S, Param, ParamType, ArgIn, + Entity)) { case NPV_NullPointer: S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); Converted = TemplateArgument(S.Context.getCanonicalType(ParamType), @@ -5765,39 +5765,8 @@ static bool CheckTemplateArgumentPointer TemplateArgument &Converted) { bool Invalid = false; - // Check for a null pointer value. Expr *Arg = ResultArg; - switch (isNullPointerValueTemplateArgument(S, Param, ParamType, Arg)) { - case NPV_Error: -return true; - case NPV_NullPointer: -S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); -Converted = TemplateArgument(S.Context.getCanonicalType(ParamType), - /*isNullPtr*/true); -return false; - case NPV_NotNullPointer: -break; - } - bool ObjCLifetimeConversion; - if (S.IsQualificatio
r307449 - Revert r307445 as it breaks on certain platforms.
Author: dehao Date: Fri Jul 7 15:40:37 2017 New Revision: 307449 URL: http://llvm.org/viewvc/llvm-project?rev=307449&view=rev Log: Revert r307445 as it breaks on certain platforms. Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof cfe/trunk/test/CodeGen/pgo-sample.c Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof?rev=307449&r1=307448&r2=307449&view=diff == --- cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof (original) +++ cfe/trunk/test/CodeGen/Inputs/pgo-sample.prof Fri Jul 7 15:40:37 2017 @@ -1,7 +1,2 @@ -bar:1000:1000 - 1: 1000 - 2: 0 -foo:1000:1000 - 1:bar:1000 - 1: 1000 - 2: 1000 +bar:100:100 + 1: 2000 Modified: cfe/trunk/test/CodeGen/pgo-sample.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=307449&r1=307448&r2=307449&view=diff == --- cfe/trunk/test/CodeGen/pgo-sample.c (original) +++ cfe/trunk/test/CodeGen/pgo-sample.c Fri Jul 7 15:40:37 2017 @@ -1,34 +1,6 @@ // Test if PGO sample use passes are invoked. // -// Ensure Pass SampleProfileLoader is invoked. -// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=STRUCTURE -// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -o - 2>&1 | FileCheck %s -// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -fexperimental-new-pass-manager -o - 2>&1 | FileCheck %s -// STRUCTURE: Remove unused exception handling info -// STRUCTURE: Sample profile pass - -void baz(); - -// CHECK-LABEL: @callee( -void callee(int t) { - for (int i = 0; i < t; i++) -baz(); -} - -// CHECK-LABEL: @bar( -// cold call to callee should not be inlined. -// CHECK: call void @callee -void bar(int x) { - if (x < 100) -callee(x); -} - -// CHECK-LABEL: @foo( -// bar should be early-inlined because it is hot inline instance in profile. -// callee should be inlined because it is hot callsite in the inline instance -// of foo:bar. -// CHECK-NOT: call void @callee -// CHECK-NOT: call void @bar -void foo(int x) { - bar(x); -} +// Ensure Pass PGOInstrumentationGenPass is invoked. +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s +// CHECK: Remove unused exception handling info +// CHECK: Sample profile pass ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r307450 - Fix diagnostic in verify test to match new Clang output
Author: ericwf Date: Fri Jul 7 16:02:30 2017 New Revision: 307450 URL: http://llvm.org/viewvc/llvm-project?rev=307450&view=rev Log: Fix diagnostic in verify test to match new Clang output Modified: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp Modified: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp?rev=307450&r1=307449&r2=307450&view=diff == --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp (original) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp Fri Jul 7 16:02:30 2017 @@ -30,5 +30,5 @@ typedef volatile std::packaged_task{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task')}} -// expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} +// expected-note-re@future:* 1 {{candidate template ignored: {{(disabled by 'enable_if')|(requirement '.*' was not satisfied) } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM buildmaster will be updated and restarted tonight
Hello everyone, LLVM buildmaster will be updated and restarted after 7 PM Pacific time today. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307455 - Fix warnings introduced by r307434.
Author: rsmith Date: Fri Jul 7 17:37:59 2017 New Revision: 307455 URL: http://llvm.org/viewvc/llvm-project?rev=307455&view=rev Log: Fix warnings introduced by r307434. Modified: cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=307455&r1=307454&r2=307455&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jul 7 17:37:59 2017 @@ -7086,8 +7086,10 @@ CXLinkageKind clang_getCursorLinkage(CXC switch (ND->getLinkageInternal()) { case NoLinkage: case VisibleNoLinkage: return CXLinkage_NoLinkage; + case ModuleInternalLinkage: case InternalLinkage: return CXLinkage_Internal; case UniqueExternalLinkage: return CXLinkage_UniqueExternal; + case ModuleLinkage: case ExternalLinkage: return CXLinkage_External; }; Modified: cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp?rev=307455&r1=307454&r2=307455&view=diff == --- cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp (original) +++ cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp Fri Jul 7 17:37:59 2017 @@ -423,11 +423,13 @@ bool CXIndexDataConsumer::isFunctionLoca if (const NamedDecl *ND = dyn_cast(D)) { switch (ND->getFormalLinkage()) { case NoLinkage: -case VisibleNoLinkage: case InternalLinkage: return true; +case VisibleNoLinkage: +case ModuleInternalLinkage: case UniqueExternalLinkage: llvm_unreachable("Not a sema linkage"); +case ModuleLinkage: case ExternalLinkage: return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307456 - [X86] Move AVX512VPOPCNTDQ in __builtin_cpu_support's enum to match trunk gcc.
Author: ctopper Date: Fri Jul 7 17:47:44 2017 New Revision: 307456 URL: http://llvm.org/viewvc/llvm-project?rev=307456&view=rev Log: [X86] Move AVX512VPOPCNTDQ in __builtin_cpu_support's enum to match trunk gcc. There are two other features before it that we don't currently support in the the frontend or backend so I left placeholders to keep the encoding correct. I think the compiler-rt implementation of this feature is even further out of date. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=307456&r1=307455&r2=307456&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 7 17:47:44 2017 @@ -7335,6 +7335,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx AVX512PF, AVX512VBMI, AVX512IFMA, + AVX5124VNNIW, // TODO implement this fully + AVX5124FMAPS, // TODO implement this fully AVX512VPOPCNTDQ, MAX }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307458 - [ODRHash] Support FriendDecl
Author: rtrieu Date: Fri Jul 7 19:04:42 2017 New Revision: 307458 URL: http://llvm.org/viewvc/llvm-project?rev=307458&view=rev Log: [ODRHash] Support FriendDecl Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td cfe/trunk/lib/AST/ODRHash.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/odr_hash.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=307458&r1=307457&r2=307458&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Jul 7 19:04:42 2017 @@ -127,11 +127,11 @@ def err_module_odr_violation_mismatch_de "%select{definition in module '%2'|defined here}1 found " "%select{end of class|public access specifier|private access specifier|" "protected access specifier|static assert|field|method|type alias|typedef|" - "data member}3">; + "data member|friend declaration}3">; def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found " "%select{end of class|public access specifier|private access specifier|" "protected access specifier|static assert|field|method|type alias|typedef|" - "data member}1">; + "data member|friend declaration}1">; def err_module_odr_violation_mismatch_decl_diff : Error< "%q0 has different definitions in different modules; first difference is " @@ -166,6 +166,9 @@ def err_module_odr_violation_mismatch_de "data member %4 with%select{out|}5 an initializer|" "data member %4 with an initializer|" "data member %4 %select{is constexpr|is not constexpr}5|" + "friend %select{class|function}4|" + "friend %4|" + "friend function %4|" "}3">; def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found " @@ -199,18 +202,21 @@ def note_module_odr_violation_mismatch_d "data member %2 with%select{out|}3 an initializer|" "data member %2 with a different initializer|" "data member %2 %select{is constexpr|is not constexpr}3|" + "friend %select{class|function}2|" + "friend %2|" + "friend function %2|" "}1">; def err_module_odr_violation_mismatch_decl_unknown : Error< "%q0 %select{with definition in module '%2'|defined here}1 has different " "definitions in different modules; first difference is this " "%select{static assert|field|method|type alias|typedef|data member|" - "unexpected decl}3">; + "friend declaration|unexpected decl}3">; def note_module_odr_violation_mismatch_decl_unknown : Note< "but in '%0' found " "%select{different static assert|different field|different method|" "different type alias|different typedef|different data member|" - "another unexpected decl}1">; + "different friend declaration|another unexpected decl}1">; def warn_duplicate_module_file_extension : Warning< "duplicate module file extension block name '%0'">, Modified: cfe/trunk/lib/AST/ODRHash.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=307458&r1=307457&r2=307458&view=diff == --- cfe/trunk/lib/AST/ODRHash.cpp (original) +++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jul 7 19:04:42 2017 @@ -228,6 +228,13 @@ public: Hash.AddQualType(T); } + void AddDecl(const Decl *D) { +Hash.AddBoolean(D); +if (D) { + Hash.AddDecl(D); +} + } + void Visit(const Decl *D) { ID.AddInteger(D->getKind()); Inherited::Visit(D); @@ -321,6 +328,16 @@ public: void VisitTypeAliasDecl(const TypeAliasDecl *D) { Inherited::VisitTypeAliasDecl(D); } + + void VisitFriendDecl(const FriendDecl *D) { +TypeSourceInfo *TSI = D->getFriendType(); +Hash.AddBoolean(TSI); +if (TSI) { + AddQualType(TSI->getType()); +} else { + AddDecl(D->getFriendDecl()); +} + } }; // Only allow a small portion of Decl's to be processed. Remove this once @@ -335,6 +352,7 @@ bool ODRHash::isWhitelistedDecl(const De case Decl::AccessSpec: case Decl::CXXMethod: case Decl::Field: +case Decl::Friend: case Decl::StaticAssert: case Decl::TypeAlias: case Decl::Typedef: Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=307458&r1=307457&r2=307458&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jul 7 19:04:42 2017 @@ -9314,6 +9314,7 @@ void ASTReader::diagnoseOdrViolations() TypeAlias, TypeDef, Var, +Friend, Other } FirstDiffType = Other, SecondDiffType = Other; @@ -9347,6 +9348,8 @@ void ASTRe
[libcxx] r307461 - Fix filesystem build on platforms with weird time_t types.
Author: ericwf Date: Fri Jul 7 21:18:41 2017 New Revision: 307461 URL: http://llvm.org/viewvc/llvm-project?rev=307461&view=rev Log: Fix filesystem build on platforms with weird time_t types. 32-bit powerpc provides a 64 bit time_t type and older ppc64 systems provide time_t as a floating point type. This caused problems when building operations.cpp since operations.cpp contained compile time tests for conversions between time_t and filesystem time type. When these tests failed they caused the libc++ build to fail as well. This is unfortunate. This patch moves the tests out of the source file and into the test suite. It also expands the tests to allow testing of the weird time_t configurations on all platforms. Added: libcxx/trunk/src/experimental/filesystem/filesystem_time_helper.h libcxx/trunk/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp libcxx/trunk/utils/libcxx/test/config.py Added: libcxx/trunk/src/experimental/filesystem/filesystem_time_helper.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_time_helper.h?rev=307461&view=auto == --- libcxx/trunk/src/experimental/filesystem/filesystem_time_helper.h (added) +++ libcxx/trunk/src/experimental/filesystem/filesystem_time_helper.h Fri Jul 7 21:18:41 2017 @@ -0,0 +1,173 @@ +//===--=== +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--=== + +#ifndef FILESYSTEM_TIME_HELPER_H +#define FILESYSTEM_TIME_HELPER_H + +#include "experimental/__config" +#include "chrono" +#include "cstdlib" +#include "climits" + +#include +#include +#if !defined(UTIME_OMIT) +#include // for ::utimes as used in __last_write_time +#endif + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM + +namespace time_detail { namespace { + +using namespace chrono; + +template ::value> +struct fs_time_util_base { + static constexpr auto max_seconds = + duration_cast(FileTimeT::duration::max()).count(); + + static constexpr auto max_nsec = + duration_cast(FileTimeT::duration::max() - + seconds(max_seconds)) + .count(); + + static constexpr auto min_seconds = + duration_cast(FileTimeT::duration::min()).count(); + + static constexpr auto min_nsec_timespec = + duration_cast( + (FileTimeT::duration::min() - seconds(min_seconds)) + seconds(1)) + .count(); + + // Static assert that these values properly round trip. + static_assert((seconds(min_seconds) + + duration_cast(nanoseconds(min_nsec_timespec))) - +duration_cast(seconds(1)) == +FileTimeT::duration::min(), +""); +}; + +template +struct fs_time_util_base { + static const long long max_seconds; + static const long long max_nsec; + static const long long min_seconds; + static const long long min_nsec_timespec; +}; + +template +const long long fs_time_util_base::max_seconds = +duration_cast(FileTimeT::duration::max()).count(); + +template +const long long fs_time_util_base::max_nsec = +duration_cast(FileTimeT::duration::max() - + seconds(max_seconds)) +.count(); + +template +const long long fs_time_util_base::min_seconds = +duration_cast(FileTimeT::duration::min()).count(); + +template +const long long fs_time_util_base::min_nsec_timespec = +duration_cast((FileTimeT::duration::min() - +seconds(min_seconds)) + + seconds(1)) +.count(); + +template +struct fs_time_util : fs_time_util_base { + using Base = fs_time_util_base; + using Base::max_nsec; + using Base::max_seconds; + using Base::min_nsec_timespec; + using Base::min_seconds; + +public: + template + static bool checked_set(CType* out, ChronoType time) { +using Lim = numeric_limits; +if (time > Lim::max() || time < Lim::min()) + return false; +*out = static_cast(time); +return true; + } + + static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) { +if (tm.tv_sec >= 0) { + return (tm.tv_sec < max_seconds) || + (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec); +} else if (tm.tv_sec == (min_seconds - 1)) { + return tm.tv_nsec >= min_nsec_timespec; +} else { + return (tm.tv_sec >= min_seconds); +} + } + + static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) { +auto secs = duration_cast(tm.time_since_epoch()); +auto nsecs = duration_cast(tm.time_since_epoch() - secs);