[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
loladiro created this revision. LLVM commit https://reviews.llvm.org/D33655 was reverted, because it exposed an assertion failure, in `GenerateVarArgsThunk`. That function attempts to clone a function before clang is entirely done generating the debug info for the current compliation unit. That is not a valid use of the API, because it expects that there are no temporary MD nodes in the nodes that it needs to clone. However, until now, this did not cause any problems (though could have caused assertions in the backend due to mismatched debug info metadata). Attempt to rectify this by finalizing the SP before attempting to clone it. The requisite LLVM API is being introduced in https://reviews.llvm.org/D33704. https://reviews.llvm.org/D33705 Files: lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGVTables.cpp Index: lib/CodeGen/CGVTables.cpp === --- lib/CodeGen/CGVTables.cpp +++ lib/CodeGen/CGVTables.cpp @@ -152,6 +152,12 @@ llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true); llvm::Function *BaseFn = cast(Callee); + // We may not clone a subprogram that contains temporary metadata, so finalize + // it now - we will not be modifying it. + if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) +if (llvm::DISubprogram *SP = BaseFn->getSubprogram()) + DI->finalizeSP(SP); + // Clone to thunk. llvm::ValueToValueMapTy VMap; llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap); Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -308,6 +308,7 @@ ~CGDebugInfo(); void finalize(); + void finalizeSP(llvm::DISubprogram *SP) { DBuilder.finalizeSP(SP); } /// Module debugging: Support for building PCMs. /// @{ Index: lib/CodeGen/CGVTables.cpp === --- lib/CodeGen/CGVTables.cpp +++ lib/CodeGen/CGVTables.cpp @@ -152,6 +152,12 @@ llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true); llvm::Function *BaseFn = cast(Callee); + // We may not clone a subprogram that contains temporary metadata, so finalize + // it now - we will not be modifying it. + if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) +if (llvm::DISubprogram *SP = BaseFn->getSubprogram()) + DI->finalizeSP(SP); + // Clone to thunk. llvm::ValueToValueMapTy VMap; llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap); Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -308,6 +308,7 @@ ~CGDebugInfo(); void finalize(); + void finalizeSP(llvm::DISubprogram *SP) { DBuilder.finalizeSP(SP); } /// Module debugging: Support for building PCMs. /// @{ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24371: Add diagnostics to require_constant_initialization
loladiro added a comment. Sure, I'll commit it. https://reviews.llvm.org/D24371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
loladiro updated this revision to Diff 101092. loladiro added a comment. Finalize all subprograms when we're done emitting them. The one we're interested in is a side effect, but doing this uniformly might be cleaner and help avoid similar errors in the future. https://reviews.llvm.org/D33705 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CodeGenFunction.cpp Index: lib/CodeGen/CodeGenFunction.cpp === --- lib/CodeGen/CodeGenFunction.cpp +++ lib/CodeGen/CodeGenFunction.cpp @@ -348,7 +348,7 @@ // Emit debug descriptor for function end. if (CGDebugInfo *DI = getDebugInfo()) -DI->EmitFunctionEnd(Builder); +DI->EmitFunctionEnd(Builder, CurFn); // Reset the debug location to that of the simple 'return' expression, if any // rather than that of the end of the function's scope '}'. Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -367,7 +367,7 @@ void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType); /// Constructs the debug code for exiting a function. - void EmitFunctionEnd(CGBuilderTy &Builder); + void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn); /// Emit metadata to indicate the beginning of a new lexical block /// and push the block onto the stack. Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3263,7 +3263,7 @@ void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) { assert(CurInlinedAt && "unbalanced inline scope stack"); - EmitFunctionEnd(Builder); + EmitFunctionEnd(Builder, nullptr); setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt()); } @@ -3332,7 +3332,7 @@ LexicalBlockStack.pop_back(); } -void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) { +void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) { assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); unsigned RCount = FnBeginRegionCount.back(); assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch"); @@ -3344,6 +3344,9 @@ LexicalBlockStack.pop_back(); } FnBeginRegionCount.pop_back(); + + if (Fn && Fn->getSubprogram()) +DBuilder.finalizeSubprogram(Fn->getSubprogram()); } llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, Index: lib/CodeGen/CodeGenFunction.cpp === --- lib/CodeGen/CodeGenFunction.cpp +++ lib/CodeGen/CodeGenFunction.cpp @@ -348,7 +348,7 @@ // Emit debug descriptor for function end. if (CGDebugInfo *DI = getDebugInfo()) -DI->EmitFunctionEnd(Builder); +DI->EmitFunctionEnd(Builder, CurFn); // Reset the debug location to that of the simple 'return' expression, if any // rather than that of the end of the function's scope '}'. Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -367,7 +367,7 @@ void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType); /// Constructs the debug code for exiting a function. - void EmitFunctionEnd(CGBuilderTy &Builder); + void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn); /// Emit metadata to indicate the beginning of a new lexical block /// and push the block onto the stack. Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3263,7 +3263,7 @@ void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) { assert(CurInlinedAt && "unbalanced inline scope stack"); - EmitFunctionEnd(Builder); + EmitFunctionEnd(Builder, nullptr); setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt()); } @@ -3332,7 +3332,7 @@ LexicalBlockStack.pop_back(); } -void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) { +void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) { assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); unsigned RCount = FnBeginRegionCount.back(); assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch"); @@ -3344,6 +3344,9 @@ LexicalBlockStack.pop_back(); } FnBeginRegionCount.pop_back(); + + if (Fn && Fn->getSubprogram()) +DBuilder.finalizeSubprogram(Fn->getSubprogram()); } llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
loladiro added a comment. @aprantl @dblaikie See if you like this better. https://reviews.llvm.org/D33705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
loladiro added a comment. There's already such a test case, but the cloning currently doesn't assert properly (but it can generate incorrect code). https://reviews.llvm.org/D33655 fixes that up, so I think the testing is covered once that LLVM commit goes in. I'll hold off a little while to give @aprantl a chance to look at this as well, but I do want to get this in in short order, so I can recommit https://reviews.llvm.org/D33655. https://reviews.llvm.org/D33705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
loladiro added a comment. I don't think that change is entirely necessary. I don't have any strong objections to it, but I also don't see a good reason to require it. In any case, let me get this in to be able to re-land https://reviews.llvm.org/D33655 and we can revisit the more disruptive change later. https://reviews.llvm.org/D33705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D62885: [analyzer] Add werror flag for analyzer warnings
loladiro created this revision. loladiro added a reviewer: NoQ. Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun. Herald added a project: clang. We're using the clang static analyzer together with a number of custom analyses in our CI system to ensure that certain invariants are statiesfied for by the code every commit. Unfortunately, there currently doesn't seem to be a good way to determine whether any analyzer warnings were emitted, other than parsing clang's output (or using scan-build, which then in turn parses clang's output). As a simpler mechanism, simply add a `-analyzer-werror` flag to CC1 that causes the analyzer to emit its warnings as errors instead. I briefly tried to have this be `Werror=analyzer` and make it go through that machinery instead, but that seemed more trouble than it was worth in terms of conflicting with options to the actual build and special cases that would be required to circumvent the analyzers usual attempts to quiet non-analyzer warnings. This is simple and it works well. Repository: rC Clang https://reviews.llvm.org/D62885 Files: include/clang/Driver/CC1Options.td include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/Frontend/CompilerInvocation.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/override-werror.c Index: test/Analysis/override-werror.c === --- test/Analysis/override-werror.c +++ test/Analysis/override-werror.c @@ -1,14 +1,17 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -Werror %s -analyzer-store=region -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -Werror %s -analyzer-store=region -analyzer-werror -verify=werror // This test case illustrates that using '-analyze' overrides the effect of // -Werror. This allows basic warnings not to interfere with producing // analyzer results. -char* f(int *p) { - return p; // expected-warning{{incompatible pointer types}} +char* f(int *p) { + return p; // expected-warning{{incompatible pointer types}} \ + werror-warning{{incompatible pointer types}} } void g(int *p) { - if (!p) *p = 0; // expected-warning{{null}} + if (!p) *p = 0; // expected-warning{{null}} \ + werror-error{{null}} } Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -83,10 +83,11 @@ namespace { class ClangDiagPathDiagConsumer : public PathDiagnosticConsumer { DiagnosticsEngine &Diag; - bool IncludePath; + bool IncludePath, Werror; + public: ClangDiagPathDiagConsumer(DiagnosticsEngine &Diag) -: Diag(Diag), IncludePath(false) {} + : Diag(Diag), IncludePath(false), Werror(false) {} ~ClangDiagPathDiagConsumer() override {} StringRef getName() const override { return "ClangDiags"; } @@ -101,9 +102,13 @@ IncludePath = true; } + void enableWerror() { Werror = true; } + void FlushDiagnosticsImpl(std::vector &Diags, FilesMade *filesMade) override { -unsigned WarnID = Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0"); +unsigned WarnID = +Werror ? Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0") + : Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0"); unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0"); for (std::vector::iterator I = Diags.begin(), @@ -225,6 +230,9 @@ new ClangDiagPathDiagConsumer(PP.getDiagnostics()); PathConsumers.push_back(clangDiags); + if (Opts->AnalyzerWerror) +clangDiags->enableWerror(); + if (Opts->AnalysisDiagOpt == PD_TEXT) { clangDiags->enablePaths(); @@ -255,7 +263,7 @@ #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN) \ case NAME##Model: CreateConstraintMgr = CREATEFN; break; #include "clang/StaticAnalyzer/Core/Analyses.def" -} +}; } void DisplayFunction(const Decl *D, AnalysisMode Mode, @@ -357,9 +365,8 @@ if (VD->getAnyInitializer()) return true; -llvm::Expected CTUDeclOrError = - CTU.getCrossTUDefinition(VD, Opts->CTUDir, Opts->CTUIndexName, - Opts->DisplayCTUProgress); +llvm::Expected CTUDeclOrError = CTU.getCrossTUDefinition( +VD, Opts->CTUDir, Opts->CTUIndexName, Opts->DisplayCTUProgress); if (!CTUDeclOrError) { handleAllErrors(CTUDeclOrError.takeError(), Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -309,6 +309,7 @@ Args.hasArg(OPT_analyzer_viz_egraph_graphviz); Opts.DumpExplodedGraphTo = Args.ge
[PATCH] D62885: [analyzer] Add werror flag for analyzer warnings
loladiro marked an inline comment as done. loladiro added a comment. > So, you'd like to make this a frontend flag in order not to expose it to > "regular" end users? Or was it because, well, every other flag we have is a > frontend flag? Little bit of both? We already need to pass a bunch of `Xanalyzer` and `Xclang` features in order to set things up correctly and it seemed like a more prominent flag would cause more debate and delay in getting this in ;). > For a project whose entire foundation is based on an estimation (I mean to > refer to false positives), I fear that this flag would be impractical for > most users. I certainly wouldn't like to receive an error on a false > positive, but I can see that for your specific use, while on specific > checkers are enabled, this would be fine. But again, do we really do this > flag justice by "simply" making it a frontend flag? Yeah, we're a bit of a special case here in that we consider false positives for our analysis a bug (in the analysis), so Werror makes more sense for us (since the analysis is also in the repo being CI'd). > At the end of the day, the idea sounds great, and I'm not opposed to landing > this before resolve this paradox. Comment at: test/Analysis/override-werror.c:10 + return p; // expected-warning{{incompatible pointer types}} \ + werror-warning{{incompatible pointer types}} } Szelethus wrote: > Why isn't this `werror-error`? Unlike the other error (which is generated by the analyzer), this is a semantic error (i.e. would get emitted even in the absence of the analyzer). The `-analyzer-werror` flag only touches those warnings generated by the analyzer, so this is the desired behavior. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62885/new/ https://reviews.llvm.org/D62885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D66035: [WebAssembly] WIP: Add support for reference types
loladiro updated this revision to Diff 214467. loladiro added a comment. Herald added a project: clang. Herald added a subscriber: cfe-commits. Accidentally only pushed half the changes Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66035/new/ https://reviews.llvm.org/D66035 Files: clang/lib/Basic/Targets/WebAssembly.h lld/wasm/WriterUtils.cpp llvm/include/llvm/BinaryFormat/Wasm.h llvm/include/llvm/BinaryFormat/WasmRelocs.def llvm/include/llvm/CodeGen/TargetLowering.h llvm/include/llvm/CodeGen/ValueTypes.td llvm/include/llvm/MC/MCExpr.h llvm/include/llvm/MC/MCSymbolWasm.h llvm/include/llvm/Object/Wasm.h llvm/include/llvm/Support/MachineValueType.h llvm/lib/BinaryFormat/Wasm.cpp llvm/lib/CodeGen/CodeGenPrepare.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/ValueTypes.cpp llvm/lib/MC/MCExpr.cpp llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Object/WasmObjectFile.cpp llvm/lib/ObjectYAML/WasmYAML.cpp llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp llvm/lib/Target/WebAssembly/WebAssembly.td llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp llvm/tools/yaml2obj/yaml2wasm.cpp llvm/utils/TableGen/CodeGenTarget.cpp Index: llvm/utils/TableGen/CodeGenTarget.cpp === --- llvm/utils/TableGen/CodeGenTarget.cpp +++ llvm/utils/TableGen/CodeGenTarget.cpp @@ -192,6 +192,7 @@ case MVT::iPTRAny: return "MVT::iPTRAny"; case MVT::Untyped: return "MVT::Untyped"; case MVT::exnref: return "MVT::exnref"; + case MVT::anyref: return "MVT::anyref"; default: llvm_unreachable("ILLEGAL VALUE TYPE!"); } } Index: llvm/tools/yaml2obj/yaml2wasm.cpp === --- llvm/tools/yaml2obj/yaml2wasm.cpp +++ llvm/tools/yaml2obj/yaml2wasm.cpp @@ -174,6 +174,7 @@ case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TABLE: encodeULEB128(Info.ElementIndex, SubSection.getStream()); if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 || (Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp === --- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -109,8 +109,8 @@ const TargetOptions &Options, Optional RM, Optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, -TT.isArch64Bit() ? "e-m:e-p:64:64-i64:64-n32:64-S128" - : "e-m:e-p:32:32-i64:64-n32:64-S128", +TT.isArch64Bit() ? "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1" + : "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1", TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT), getEffectiveCodeModel(CM, CodeModel::Large), OL), TLOF(new WebAssemblyTargetObjectFile()) { Index: llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h === --- llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h +++ llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h @@ -47,6 +47,7 @@ bool HasMultivalue = false; bool HasMutableGlobals = false; bool HasTailCall = false; + bool HasReferenceTypes = false; /// String name of used CPU. std::string CPUString; @@ -104,6 +105,7 @@ bool hasMultivalue() const { return HasMultivalue; } bool hasMutableGlobals() const { return HasMutableGlobals; } bool hasTailCall() const { return HasTailCall; } + bool hasReferenceTypes() const { return HasReferenceTypes; } /// Parses features string setting specified subtarget options. Definition of //
[PATCH] D88630: [clang/CMake] Respect LLVM_TOOLS_INSTALL_DIR
loladiro created this revision. loladiro added a reviewer: tstellar. Herald added subscribers: cfe-commits, mgorny. Herald added a project: clang. loladiro requested review of this revision. Otherwise clang installs all of its tools into `bin/` while LLVM installs its tools into (LLVM_TOOLS_INSTALL_DIR). I could swear this used to work (and in fact the julia build system assumes it), but I can't pin down a specific commit that would have broken this, and julia has been relying on pre-compiled binaries for a while now (that don't use this setting), so it may have been broken for quite a while. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D88630 Files: clang/cmake/modules/AddClang.cmake Index: clang/cmake/modules/AddClang.cmake === --- clang/cmake/modules/AddClang.cmake +++ clang/cmake/modules/AddClang.cmake @@ -170,7 +170,7 @@ install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION bin + RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR} COMPONENT ${name}) if(NOT LLVM_ENABLE_IDE) Index: clang/cmake/modules/AddClang.cmake === --- clang/cmake/modules/AddClang.cmake +++ clang/cmake/modules/AddClang.cmake @@ -170,7 +170,7 @@ install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION bin + RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR} COMPONENT ${name}) if(NOT LLVM_ENABLE_IDE) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.
loladiro added a comment. @jrtc27 is correct. This absolutely must not apply to non-integral address spaces. It is not legal for LLVM to introduce additional ptrtoint instructions for non-integral address spaces that were not present in the original input IR. That doesn't change if the spelling of a ptrtoint/inttoptr pair is changed to bitcast. There is a bit of a larger issue here that LLVM IR isn't really rich enough to currently describe what operations are legal for the optimizer to introduce and what aren't. Every frontend/backend that uses them has their own rules that appear obvious for a particular use case, but aren't necessarily general. A similar issue applies to commuting GEPs with addrspacecasts. I'm wondering if we need something like the datalayout but for describing relationships between addrspaces and what things are legal and what are not. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114533/new/ https://reviews.llvm.org/D114533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30589: [ExprInspectionChecker] Improve usability for C
loladiro created this revision. Some of the magic functions take arguments of arbitrary type. However, for semantic correctness, the compiler still requires a declaration of these functions with the correct type. Since C does not have argument-type-overloaded function, this made those functions hard to use in C code. Improve this situation by allowing arbitrary suffixes in the affected magic functions' names, thus allowing the user to create different declarations for different types. https://reviews.llvm.org/D30589 Files: docs/analyzer/DebugChecks.rst lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp test/Analysis/explain-svals.c Index: test/Analysis/explain-svals.c === --- /dev/null +++ test/Analysis/explain-svals.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s + +struct S { + int z; +}; + +void clang_analyzer_explain_int(int); +void clang_analyzer_explain_voidp(void *); +void clang_analyzer_explain_S(struct S); + +int glob; + +void test_1(int param, void *ptr) { + clang_analyzer_explain_voidp(&glob); // expected-warning-re^pointer to global variable 'glob'$ + clang_analyzer_explain_int(param); // expected-warning-re^argument 'param'$ + clang_analyzer_explain_voidp(ptr); // expected-warning-re^argument 'ptr'$ + if (param == 42) +clang_analyzer_explain_int(param); // expected-warning-re^signed 32-bit integer '42'$ +} + +void test_2(struct S s) { + clang_analyzer_explain_S(s); //expected-warning-re^lazily frozen compound value of parameter 's'$ + clang_analyzer_explain_voidp(&s); // expected-warning-re^pointer to parameter 's'$ + clang_analyzer_explain_int(s.z); // expected-warning-re^initial value of field 'z' of parameter 's'$ +} Index: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp === --- lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -72,8 +72,8 @@ &ExprInspectionChecker::analyzerWarnIfReached) .Case("clang_analyzer_warnOnDeadSymbol", &ExprInspectionChecker::analyzerWarnOnDeadSymbol) -.Case("clang_analyzer_explain", &ExprInspectionChecker::analyzerExplain) -.Case("clang_analyzer_dump", &ExprInspectionChecker::analyzerDump) +.StartsWith("clang_analyzer_explain", &ExprInspectionChecker::analyzerExplain) +.StartsWith("clang_analyzer_dump", &ExprInspectionChecker::analyzerDump) .Case("clang_analyzer_getExtent", &ExprInspectionChecker::analyzerGetExtent) .Case("clang_analyzer_printState", &ExprInspectionChecker::analyzerPrintState) Index: docs/analyzer/DebugChecks.rst === --- docs/analyzer/DebugChecks.rst +++ docs/analyzer/DebugChecks.rst @@ -178,15 +178,21 @@ This function explains the value of its argument in a human-readable manner in the warning message. You can make as many overrides of its prototype in the test code as necessary to explain various integral, pointer, - or even record-type values. + or even record-type values. To simplify usage in C code (where overloading + the function declaration is not allowed), you may append an arbitrary suffix + to the function name, without affecting functionality. Example usage:: void clang_analyzer_explain(int); void clang_analyzer_explain(void *); +// Useful in C code +void clang_analyzer_explain_int(int); + void foo(int param, void *ptr) { clang_analyzer_explain(param); // expected-warning{{argument 'param'}} + clang_analyzer_explain_int(param); // expected-warning{{argument 'param'}} if (!ptr) clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}} } Index: test/Analysis/explain-svals.c === --- /dev/null +++ test/Analysis/explain-svals.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s + +struct S { + int z; +}; + +void clang_analyzer_explain_int(int); +void clang_analyzer_explain_voidp(void *); +void clang_analyzer_explain_S(struct S); + +int glob; + +void test_1(int param, void *ptr) { + clang_analyzer_explain_voidp(&glob); // expected-warning-re^pointer to global variable 'glob'$ + clang_analyzer_explain_int(param); // expected-warning-re^argument 'param'$ + clang_analyzer_explain_voidp(ptr); // expected-warning-re^argument 'ptr'$ + if (param == 42) +clang_analyzer_explain_int(param); // expected-warning-re^signed 32-bit integer '42'$ +} + +void test_2(struct S s) { + clang_analyzer_explain_S(s); //expected-warning-re{
[PATCH] D27564: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times
loladiro added a comment. I take it this supersedes https://reviews.llvm.org/D24372? I apologize for not getting around to commiting that yet, but if it does supersede that revision, we should probably keep the tests that we have there. https://reviews.llvm.org/D27564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits