typename std::enable_if< !traits::detail::is_unique_future< typename util::invoke_result<Func, Future>::type >::value >::type invoke_continuation(Func& func, Future && future, Continuation& cont) { typedef std::is_void< typename util::invoke_result<Func, Future>::type > is_void; hpx::util::annotate_function annotate(func); invoke_continuation(func, std::forward<Future>(future), cont, is_void()); }
bool SCSM::DetectOne(const bowIndex &bow, const string &logo_path, const string &pic_name) { // 读入图像 IplImage *src_img = cvLoadImage(logo_path.c_str(), 1); Mat mimg = imread(logo_path); if (mimg.empty()) { return false; } img = mimg; // 获取目标位置 annotate(); objrectangle.x = topleft.x; objrectangle.y = topleft.y; objrectangle.width = bottomright.x - topleft.x; objrectangle.height = bottomright.y - topleft.y; fixedCenter.x = objrectangle.width/2; fixedCenter.y = objrectangle.height/2; // fixedCenter.x = QuantizeLocation(objrectangle.width/2, objrectangle.width); // 量化坐标 // fixedCenter.y = QuantizeLocation(objrectangle.height/2, objrectangle.height); // 量化坐标 // 创建子图像 if (objrectangle.width==0) { objrectangle.x = 0; objrectangle.y = 0; objrectangle.width = src_img->width; objrectangle.height = src_img->height; retrievaltotal = true; } cvSetImageROI(src_img, objrectangle); IplImage *pSubImage = cvCreateImage(cvSize(objrectangle.width, objrectangle.height), src_img->depth, src_img->nChannels); cvCopy(src_img, pSubImage, NULL); cvResetImageROI(src_img); // 提取子图像bow特征 Mat sub_img(pSubImage, 0); logoInfor logoFeat; logoFeat.baseinfor.filepath = logo_path; bool ret1 = bow.getBowFeat(sub_img, pic_name, logoFeat); // 建立多角度尺度位置信息 bool ret2 = BuildSRLocation(logoFeat); // 利用bow进行投票,simlistVP为最后相似度由高到底将数据库图片排序 bool ret3 = SearchDataset(bow); // 在数据库图片中画出方框 bool ret4 = DrawRectangle(); retrievaltotal = false; cvReleaseImage(&pSubImage); cvReleaseImage(&src_img); return true; }
void gen8_vec4_generator::generate_code(exec_list *instructions, struct annotation_info *annotation) { if (unlikely(debug_flag)) { if (shader_prog) { fprintf(stderr, "Native code for %s vertex shader %d:\n", shader_prog->Label ? shader_prog->Label : "unnamed", shader_prog->Name); } else { fprintf(stderr, "Native code for vertex program %d:\n", prog->Id); } } cfg_t *cfg = NULL; if (unlikely(debug_flag)) cfg = new(mem_ctx) cfg_t(instructions); foreach_list(node, instructions) { vec4_instruction *ir = (vec4_instruction *) node; struct brw_reg src[3], dst; if (unlikely(debug_flag)) annotate(brw, annotation, cfg, ir, next_inst_offset); for (unsigned int i = 0; i < 3; i++) { src[i] = ir->get_src(prog_data, i); } dst = ir->get_dst(); default_state.conditional_mod = ir->conditional_mod; default_state.predicate = ir->predicate; default_state.predicate_inverse = ir->predicate_inverse; default_state.saturate = ir->saturate; const unsigned pre_emit_nr_inst = nr_inst; generate_vec4_instruction(ir, dst, src); if (ir->no_dd_clear || ir->no_dd_check) { assert(nr_inst == pre_emit_nr_inst + 1 || !"no_dd_check or no_dd_clear set for IR emitting more " "than 1 instruction"); gen8_instruction *last = &store[pre_emit_nr_inst]; gen8_set_no_dd_clear(last, ir->no_dd_clear); gen8_set_no_dd_check(last, ir->no_dd_check); } }
void KVServer::handle_lookup(KVRequest* request) { int rc = 0; KeyVal* newKV = NULL; printf("Looking for key %d\n", (int)request->kv.key); fflush(stdout); newKV = (KeyVal*) hash_table_lookup(&db, &request->kv); if (newKV == NULL) { // Send an empty reply printf("\tFailed to find key. Sending empty reply.\n"); fflush(stdout); Value empty; empty.len = 0; rc = sendto(sock, &empty, sizeof(Value), 0, (sockaddr*)&remote_addr, sizeof(remote_addr)); } else { annotate("found", newKV); rc = sendto(sock, &newKV->val, newKV->val.len+sizeof(Value), 0, (sockaddr*)&remote_addr, sizeof(remote_addr)); } if (rc == -1) { fprintf(stderr, "(KeyValueServer) Failed to send lookup reply!\n"); } }
ibbox_t*get_bitmap_bboxes(unsigned char*alpha, int width, int height, int rowsize) { int size = width*height; if(width<=1 || height<=1) return get_bitmap_bboxes_simple(alpha, width, height, rowsize); context_t context; context.alpha = alpha; context.rowsize = rowsize; context.width = width; context.height = height; context.heads = 0; context.count = 1; void**group = annotate(&context); fix_small_boxes(&context); overlap_bboxes(&context); #ifdef MAIN display(&context); #endif ibbox_t*bboxes = 0; head_t*h = context.heads; while(h) { head_t*next = h->next; ibbox_t*bbox = malloc(sizeof(ibbox_t)); memcpy(bbox, &h->bbox, sizeof(ibbox_t)); /* ibbox_t defines the open upper bound */ bbox->xmax++; bbox->ymax++; bbox->next = bboxes; bboxes = bbox; free(h); h = next; } free(context.group); return bboxes; }
// Output TEXT on controlling TTY if we're in annotation mode void tty_full_name(const string& pos) { if (command_tty == 0) return; if (app_data.annotate >= 2) { const string s = "source " + pos; annotate(s.chars()); } else if (app_data.annotate == 1) { _tty_out("\032\032" + pos + "\n"); } else { const string line = source_view->get_line(pos); if (!line.empty()) _tty_out(line + "\n"); } }
void KVServer::handle_insert(KVRequest* request) { KeyVal* newKV = NULL; // If the key is already present, we need to remove it first // (because hash_table doesn't like inserts for existing values) newKV = (KeyVal*) hash_table_lookup(&db, &request->kv); if (newKV != NULL) { hash_table_remove(&db, newKV); free(newKV); } // Now copy the request and insert it into our database newKV = KV_clone(&request->kv); uint32_t hash131 = hash_buf(newKV->val.bytes, newKV->val.len); lite_assert(newKV); hash_table_insert(&db, newKV); annotate("insert", newKV); int rc; rc = sendto(sock, &hash131, sizeof(hash131), 0, (sockaddr*)&remote_addr, sizeof(remote_addr)); if (rc == -1) { fprintf(stderr, "(KeyValueServer) Failed to send insert reply!\n"); } }
Error BaseContext::compile(FuncNode* func) { BaseNode* end = func->getEnd(); BaseNode* stop = end->getNext(); _func = func; _stop = stop; _extraBlock = end; ASMJIT_PROPAGATE_ERROR(fetch()); ASMJIT_PROPAGATE_ERROR(removeUnreachableCode()); ASMJIT_PROPAGATE_ERROR(analyze()); if (_compiler->hasLogger()) ASMJIT_PROPAGATE_ERROR(annotate()); ASMJIT_PROPAGATE_ERROR(translate()); // We alter the compiler cursor, because it doesn't make sense to reference // it after compilation - some nodes may disappear and it's forbidden to add // new code after the compilation is done. _compiler->_setCursor(NULL); return kErrorOk; }
#include "lookupeffect.c" #include <stdlib.h> #include "AS3/AS3.h" // Mark the functions declaration with a GCC attribute specifying the // AS3 signature we want it to have in the generated SWC. The functions will // be located in the FlasCCTest.lookupeffect namespace. void initializeScreenDiffuseBuffer_AS3() __attribute__((used, annotate("as3sig:public function initializeScreenDiffuseBuffer_AS3(resX0:int,resY0:int):uint"), annotate("as3package:FlasCCTest.lookupeffect"))); void initializeScreenDiffuseBuffer_AS3() { int* result; //copy the AS3 resolution variables resX0, resY0 (parameters of the swc function initializeScreenDiffuseBuffer_AS3) //to C variables resX, resY in lookupeffect.c AS3_GetScalarFromVar(resX,resX0); AS3_GetScalarFromVar(resY,resY0); //get the pointer of the screen buffer result = initializeScreenDiffuseBuffer(resX,resY); // return the result (using an AS3 return rather than a C/C++ return) AS3_Return(result); } void initializeDiffuseBuffer_AS3() __attribute__((used, annotate("as3sig:public function initializeDiffuseBuffer_AS3(resX1:int,resY1:int):uint"), annotate("as3package:FlasCCTest.lookupeffect"))); void initializeDiffuseBuffer_AS3() {
#include <memory> #include <cstdlib> #include <type_traits> //[[annotate(randomattr)]] namespace Arf __attribute__((annotate("arf"))) { struct __attribute__((annotate("woof"))) Woof { int __attribute__((annotate("howl"))) howlpower; void __attribute__((annotate("bark"))) Bark () { } }; } int main() { }
#include <stdlib.h> #include "AS3/AS3.h" int square1(int a){ return a * a; } // First we mark the function declaration with a GCC attribute specifying the // AS3 signature we want it to have in the generated SWC. The function will // be located in the sample.MurmurHash namespace. void multipleSWC1() __attribute__((used, annotate("as3sig:public function multipleSWC1(keystr:String):uint"), annotate("as3package:sample.MultipleSWC1"))); void multipleSWC1() { // simple return int result = 5; int squared = square1(result); // return the result (using an AS3 return rather than a C/C++ return) AS3_Return(result); }
} } void release() { callOnDestruction = false; } }; template<typename ExitFunction> ScopeExit<ExitFunction> MakeScopeExit(ExitFunction&& func) { return ScopeExit<ExitFunction>(std::move(func)); } class Foo { public: __attribute__((annotate("moz_implicit"))) Foo(std::nullptr_t); Foo(); }; void a1() { Throw(); } int a2() { Throw(); // expected-error {{You must immediately return after calling this function}} return MakeAnInt(); } int a3() { // RAII operations happening after a must-immediately-return are fine. auto atExit = MakeScopeExit([] { DoAnythingElse(); });
/* Print data values for variable varid. * * Recursive to handle possibility of variables with multiple * unlimited dimensions, for which the CDL syntax requires use of "{" * and "}" in data section to disambiguate the size of nested records * in a simple linear list of values. */ static int print_rows( int level, /* 0 at top-level, incremented for each recursive level */ int ncid, /* netcdf id */ int varid, /* variable id */ const ncvar_t *vp, /* variable */ size_t ncols, /* number of values in a row */ int rank, /* number of elements in following 3 arrays */ size_t vdims[], /* variable dimension sizes */ size_t cor[], /* corner coordinates */ size_t edg[], /* edges of hypercube */ void *vals, /* allocated buffer for ncols values in a row */ int marks_pending /* number of pending closing "}" record markers */ ) { int d0 = 0; size_t inc = 1; int i; bool_t mark_record = (level > 0 && is_unlim_dim(ncid, vp->dims[level])); safebuf_t *sb = sbuf_new(); if (rank > 0) d0 = vdims[level]; for(i = level + 1; i < rank; i++) { inc *= vdims[i]; } if(mark_record) { /* the whole point of this recursion is printing these "{}" */ lput("{"); marks_pending++; /* matching "}"s to emit after last "row" */ } if(rank - level > 1) { /* this level is just d0 next levels */ size_t *local_cor = emalloc((rank + 1) * sizeof(size_t)); size_t *local_edg = emalloc((rank + 1) * sizeof(size_t)); for(i = 0; i < rank; i++) { local_cor[i] = cor[i]; local_edg[i] = edg[i]; } local_cor[level] = 0; local_edg[level] = 1; for(i = 0; i < d0 - 1; i++) { print_rows(level + 1, ncid, varid, vp, ncols, rank, vdims, local_cor, local_edg, vals, 0); local_cor[level] += 1; } print_rows(level + 1, ncid, varid, vp, ncols, rank, vdims, local_cor, local_edg, vals, marks_pending); free(local_edg); free(local_cor); } else { /* bottom out of recursion */ char *valp = vals; bool_t lastrow; int j; if(formatting_specs.brief_data_cmnts && rank > 1) { annotate_brief(vp, cor, vdims); } NC_CHECK(nc_get_vara(ncid, varid, cor, edg, (void *)valp)); for(i=0; i < d0 - 1; i++) { print_any_val(sb, vp, (void *)valp); valp += vp->tinfo->size; /* next value according to type */ if (formatting_specs.full_data_cmnts) { printf("%s, ", sb->buf); annotate (vp, cor, i); } else { sbuf_cat(sb, ", "); lput(sbuf_str(sb)); } } print_any_val(sb, vp, (void *)valp); /* determine if this is the last row */ lastrow = true; for(j = 0; j < rank - 1; j++) { if (cor[j] != vdims[j] - 1) { lastrow = false; break; } } if (formatting_specs.full_data_cmnts) { for (j = 0; j < marks_pending; j++) { sbuf_cat(sb, "}"); } printf("%s", sbuf_str(sb)); lastdelim (0, lastrow); annotate (vp, cor, i); } else { for (j = 0; j < marks_pending; j++) { sbuf_cat(sb, "}"); } lput(sbuf_str(sb)); lastdelim2 (0, lastrow); } } sbuf_free(sb); return NC_NOERR; }
#include <stdio.h> #include <unistd.h> #include <string.h> #include <stdarg.h> #include "AS3/AS3.h" // https://www.adobe.com/devnet-docs/flascc/docs/capidocs/as3.html // https://github.com/crossbridge-community/crossbridge/blob/master/samples/06_SWIG/PassingData/PassData.as void as3_init() __attribute__(( used, annotate("as3sig:public function init(inputFormat:String, inputCodec:String, inputSampleRate:int, inputChannels:int, outputFormat:String, outputCodec:String, outputSampleRate:int, outputChannels:int, outputBitRate:int, outputBufferMaxSeconds:int):int"), annotate("as3package:com.marstonstudio.crossusermedia.encoder.flascc") )); void as3_init(const char *i_format_name, const char *i_codec_name, int i_sample_rate, int i_channels, const char *o_format_name, const char *o_codec_name, int o_sample_rate, int o_channels, int o_bit_rate, int o_buffer_max_seconds) { AS3_MallocString(i_format_name, inputFormat); AS3_MallocString(i_codec_name, inputCodec); AS3_GetScalarFromVar(i_sample_rate, inputSampleRate); AS3_GetScalarFromVar(i_channels, inputChannels); AS3_MallocString(o_format_name, outputFormat); AS3_MallocString(o_codec_name, outputCodec); AS3_GetScalarFromVar(o_sample_rate, outputSampleRate); AS3_GetScalarFromVar(o_channels, outputChannels); AS3_GetScalarFromVar(o_bit_rate, outputBitRate); AS3_GetScalarFromVar(o_buffer_max_seconds, outputBufferMaxSeconds); int status = init(i_format_name, i_codec_name, i_sample_rate, i_channels, o_format_name,
#define INIT_PLUGIN_GET(parent, filepath, errorMessage) \ INIT_PLUGIN (parent, filepath); \ KeySet * keySet = ksNew (0, KS_END); \ succeed_if (plugin->kdbGet (plugin, keySet, parentKey) == ELEKTRA_PLUGIN_STATUS_SUCCESS, errorMessage) #define CLOSE_PLUGIN() \ keyDel (parentKey); \ ksDel (keySet); \ PLUGIN_CLOSE () // -- Functions ---------------------------------------------------------------------------------------------------------------------------- static void test_contract (void) #ifdef __llvm__ __attribute__ ((annotate ("oclint:suppress[high ncss method]"))) #endif { printf ("• Retrieve plugin contract\n"); INIT_PLUGIN_GET ("system/elektra/modules/yamlcpp", "", "Could not retrieve plugin contract"); CLOSE_PLUGIN (); } static void test_read (char const * const filepath, KeySet * const expected) #ifdef __llvm__ __attribute__ ((annotate ("oclint:suppress"))) #endif { printf ("• Retrieve data from file “%s”\n", filepath);
); char *optimizedShader; AS3_MallocString(optimizedShader, srcstr); if( !saveFile(dest, optimizedShader) ) abort(); return 0; #endif AS3_GoAsync(); } extern "C" void compileShader() __attribute__((used, annotate("as3sig:public function compileShader(src:String, mode:int, optimize:Boolean, gles:Boolean = false):String"))); extern "C" void compileShader() { // Copy the AS3 string to the C heap (must be free'd later) char *src = NULL; AS3_MallocString(src, src); bool gles = false; AS3_CopyScalarToVar(gles, gles); glslopt_ctx* gContext = glslopt_initialize(gles); int mode; AS3_GetScalarFromVar(mode, mode);
#include <stdlib.h> #include <AS3\AS3.h> #include <AS3\AS3++.h> void _localvar_alloc() __attribute__((used, annotate("as3sig:public function internal_localvar_alloc():int"), annotate("as3package:recastnavigation.internal_api"))); void _localvar_alloc() { AS3_Return(new AS3::local::var()); } void _localvar_set() __attribute__((used, annotate("as3sig:public function internal_localvar_set(var_ptr:int, obj:Object):void"), annotate("as3package:recastnavigation.internal_api"))); void _localvar_set() { AS3::local::var * var; AS3_GetScalarFromVar(var, var_ptr); AS3_GetVarxxFromVar(*var, obj); } void _localvar_get() __attribute__((used, annotate("as3sig:public function internal_localvar_get(var_ptr:int):Object"), annotate("as3package:recastnavigation.internal_api"))); void _localvar_get() { AS3::local::var * var;
// Fetch position from GDB output ANSWER. void PosBuffer::filter (string& answer) { if (answer.length() == 0) return; // Check program state switch (gdb->type()) { case BASH: { if (has_prefix(answer, "Reading ")) started = true; break; } case GDB: { // If GDB prints a "Current function" line, it overrides whatever // came before (e.g. "stopped in"). if (has_prefix(answer, "Current function is ")) already_read= Null; // Check program state if (has_prefix(answer, "Starting program: ")) started = true; if (has_prefix(answer, "The program no longer exists")) terminated = true; if (has_prefix(answer, "Program received signal")) signaled = true; if (has_prefix(answer, "Program terminated with signal")) signaled = terminated = true; if (answer.contains("has changed; re-reading symbols")) recompiled = true; if (has_prefix(answer, "Current language: ")) gdb->program_language(answer); if (has_prefix(answer, "The current source language is ")) gdb->program_language(answer); if (terminated) annotate("exited"); if (signaled) annotate("signalled"); } break; case DBG: { // Check program state if (has_prefix(answer, "Starting program: ")) started = true; } break; case DBX: { if (has_prefix(answer, "Running: ")) started = true; if (answer.contains("has been recompiled")) recompiled = true; if (has_prefix(answer, "signal ")) signaled = true; } break; case MAKE: { if (has_prefix(answer, "Reading makefiles...")) started = true; break; } case PERL: { if (has_prefix(answer, "Loading DB routines from perl5db.pl")) recompiled = true; } break; case XDB: case JDB: case PYDB: break; // Nothing special } // Check for terminated program int i = -1; while ((i = answer.index("rogram", i + 1)) > 0) { int j = i; while (j > 0 && answer[j - 1] != '\n') j--; #if RUNTIME_REGEX static regex rxterminated("([Tt]he )?[Pp]rogram " "(exited|terminated" "|is not being run|no longer exists).*"); #endif if (answer.matches(rxterminated, j)) terminated = true; } if (answer.contains("no active process") || answer.contains("execution completed") || answer.contains("application exited")) terminated = true; // Check for auto command if (app_data.auto_commands) { answer.prepend(auto_cmd_part); auto_cmd_part = ""; string pfx = app_data.auto_command_prefix; if (!auto_cmd_buffer.empty() && !auto_cmd_buffer.contains('\n', -1)) { // Complete pending auto command if (answer.contains('\n')) { auto_cmd_buffer += answer.through('\n'); answer = answer.after('\n'); } else { auto_cmd_buffer += answer; answer = ""; } } int index; while ((index = answer.index(pfx)) >= 0) { string cmd = answer.from(index); if (cmd.contains('\n')) cmd = cmd.through('\n'); answer = answer.before(index) + answer.from(int(index + cmd.length())); cmd = cmd.after(pfx); auto_cmd_buffer += cmd; } if (pfx.contains(answer, 0)) { auto_cmd_part = answer; answer = ""; } } // Fetch and store position info, return remainder switch (already_read) { case PosComplete: if (gdb->type() == GDB) filter_gdb(answer); // Slurp in the source annotation // Nothing more to filter - skip possible line number info filter_line(answer); break; case PosPart: answer.prepend (answer_buffer); answer_buffer = ""; already_read = Null; // FALL THROUGH case Null: { // Now go for the actual position. switch (gdb->type()) { case BASH: filter_bash(answer); break; case DBG: filter_dbg(answer); break; case DBX: filter_dbx(answer); break; case GDB: filter_gdb(answer); break; case JDB: filter_jdb(answer); break; case MAKE: filter_make(answer); break; case PERL: filter_perl(answer); break; case PYDB: filter_pydb(answer); break; case XDB: filter_xdb(answer); break; } filter_line(answer); } break; } }
* This source code is licensed under the BSD style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #include <vector> namespace folly { #define TYPEVAR(Name) \ struct __attribute__((annotate("__infer_type_var"))) Name {}; TYPEVAR(a1); TYPEVAR(a2); TYPEVAR(a3); template <class Delim, class String, class OutputType> void split(const Delim& delimiter, const String& input, std::vector<OutputType>& out, bool ignoreEmpty = false) { out.resize(1); return; } template __attribute__((annotate("__infer_generic_model"))) void split<a1, a2, a3>(const a1& delimiter, const a2& input, std::vector<a3>& out, const bool ignoreEmpty); }
: delimiter(delimiter), quote(quote), removeBlankLines(removeBlankLines), parseTokens(parseTokens) { } CSVParser::~CSVParser() { } /** * @param rows 2-dimensional Array (or Vector) of Strings * @param delimiter * @param quote * @param tempBuffer A reusable buffer to improve performance */ void createCSV() __attribute__((used, annotate("as3sig:public function createCSV(rows:*, delimiter:String = ',', quote:String = '\"', tempBuffer:ByteArray = null):String"), annotate("as3package:weave.flascc"), annotate("as3import:flash.utils.ByteArray"))); void createCSV() { inline_nonreentrant_as3("\ var firstRow:Boolean = true;\ var out:ByteArray = tempBuffer || new ByteArray();\ out.position = 0;\ for each (var row:* in rows)\ {\ if (firstRow)\ firstRow = false;\ else\ out.writeByte(%0);\ var firstItem:Boolean = true;\
void PosBuffer::filter_gdb(string& answer) { // Try to find out current PC even for non-existent source if (check_pc && pc_buffer.empty()) { // `$pc = ADDRESS' #if RUNTIME_REGEX static regex rxpc("\\$pc *= *" RXADDRESS); #endif int pc_index = index(answer, rxpc, "$pc "); if (pc_index >= 0) { int addr_index = answer.index('='); fetch_address(answer, addr_index, pc_buffer); // Strip this line from ANSWER int end_line = answer.index('\n', pc_index); int start_line = pc_index; while (start_line > 0 && answer[start_line - 1] != '\n') start_line--; if (end_line < 0) answer.from(start_line) = ""; else answer.at(start_line, end_line - start_line + 1) = ""; } } if (check_pc && pc_buffer.empty() || check_func && func_buffer.empty()) { // `Breakpoint N, ADDRESS in FUNCTION (ARGS...)' #if RUNTIME_REGEX static regex rxstopped_addr("Breakpoint *[1-9][0-9]*, *" RXADDRESS); #endif int pc_index = index(answer, rxstopped_addr, "Breakpoint"); if (pc_index >= 0) { annotate("stopped"); pc_index = answer.index(','); fetch_address(answer, pc_index, pc_buffer); fetch_in_function(answer, pc_index, func_buffer); } } if (check_pc && pc_buffer.empty() || check_func && func_buffer.empty()) { // `#FRAME ADDRESS in FUNCTION (ARGS...)' #if RUNTIME_REGEX static regex rxframe_addr("#[0-9][0-9]* *" RXADDRESS); #endif int pc_index = index(answer, rxframe_addr, "#"); if (pc_index == 0 || pc_index > 0 && answer[pc_index - 1] == '\n') { pc_index = answer.index(' '); fetch_address(answer, pc_index, pc_buffer); fetch_in_function(answer, pc_index, func_buffer); } } if (check_pc && pc_buffer.empty() || check_func && func_buffer.empty()) { // `No line number available for // address ADDRESS <FUNCTION>' #if RUNTIME_REGEX static regex rxaddr("address *" RXADDRESS); #endif int pc_index = index(answer, rxaddr, "address "); if (pc_index >= 0) { pc_index = answer.index(' '); fetch_address(answer, pc_index, pc_buffer); if (func_buffer.empty()) { string line = answer.from(pc_index); line = line.after('<'); line = line.before('>'); if (!line.empty()) func_buffer = line; } } } if (check_pc && pc_buffer.empty() && !answer.empty()) { // `ADDRESS in FUNCTION' #if RUNTIME_REGEX static regex rxaddress_in(RXADDRESS " in "); #endif int pc_index = -1; if (is_address_start(answer[0]) && answer.contains(rxaddress_in, 0)) { pc_index = 0; } else { #if RUNTIME_REGEX static regex rxnladdress_in("\n" RXADDRESS " in "); #endif pc_index = index(answer, rxnladdress_in, "\n"); } if (pc_index >= 0) { fetch_address(answer, pc_index, pc_buffer); fetch_in_function(answer, pc_index, func_buffer); } } // Try to find out current function name, even for // non-existing addresses if (check_func && func_buffer.empty()) { // `Breakpoint N, FUNCTION (ARGS...)' // This regex used for PYDB as well. #if RUNTIME_REGEX static regex rxstopped_func("Breakpoint *[1-9][0-9]*, *"); #endif int bp_index = index(answer, rxstopped_func, "Breakpoint"); if (bp_index >= 0) fetch_function(answer, bp_index, func_buffer); } if (check_func && func_buffer.empty()) { // `#FRAME FUNCTION' #if RUNTIME_REGEX static regex rxframe_func("#[0-9][0-9]* *[a-zA-Z_].*[(]"); #endif int frame_index = index(answer, rxframe_addr, "#"); if (frame_index == 0 || frame_index > 0 && answer[frame_index - 1] == '\n') { fetch_function(answer, frame_index, func_buffer); } } if (check_func && func_buffer.empty()) { // FUNCTION (ARGS...) at FILE:POS int at_index = answer.index(" at "); if (at_index > 0) { int nl_index = answer.index('\n', at_index - answer.length() - 1) + 1; fetch_function(answer, nl_index, func_buffer); // Try to construct position from `at FILE:POS' (vxworks) string file = answer.after(" at "); file = file.before('\n'); if (file.contains(rxaddress, 0)) { // This is `at ADDRESS' (GDB output) } else if (file.contains(":") && !file.contains(": ")) { pos_buffer = file; already_read = PosComplete; return; } } } // Look for regular source info // (GDB's annotations are prefixed with "^Z^Z") int index1 = answer.index ("\032\032"); if (index1 < 0) { int index_p = answer.index ("\032"); if (index_p >= 0 && index_p == int(answer.length()) - 1) { // Possible begin of position info at end of ANSWER answer_buffer = "\032"; answer = answer.before (index_p); already_read = PosPart; return; } // Handle erroneous `info line' output like // `Line number 10 is out of range for "t1.f".' // At least get the file name. #if RUNTIME_REGEX static regex rxout_of_range( "Line number [0-9]+ is out of range for "); #endif index_p = index(answer, rxout_of_range, "Line number"); if (index_p >= 0) { string file = answer.after('\"', index_p); file = file.before('\"'); pos_buffer = file + ":1"; already_read = PosComplete; return; } // Try to construct position from `Line xxxx of "filename"' (vxworks) // which is the output of an 'info line' command string line = answer.after("Line "); string file = answer.after('\"'); if (!line.empty() && !file.empty()) { line = line.before(" of"); file = file.before('\"') + ":" + line; if (!line.empty() && !file.empty()) { pos_buffer = file; already_read = PosComplete; return; } } // Try FUNCTION (ARGS...) at FILE:POS // here to properly handle up/down commands int at_index = answer.index(" at "); int br_index = answer.index("Break"); if ( (at_index > 0) && (br_index < 0) ) { int nl_index = answer.index('\n', at_index - answer.length() - 1) + 1; fetch_function(answer, nl_index, func_buffer); // Try to construct position from `at FILE:POS' (vxworks) string file = answer.after(" at "); file = file.before('\n'); if (!file.empty()) { pos_buffer = file; already_read = PosComplete; return; } } // Nothing found return; } // ANSWER contains position info int index2 = answer.index ("\n", index1); if (index2 == -1) { // Position info is incomplete answer_buffer = answer.from (index1); answer = answer.before (index1); already_read = PosPart; return; } assert (index1 < index2); // Position info is complete pos_buffer = answer.at(index1 + 2, index2 - (index1 + 2)); if (pos_buffer.contains("source ", 0)) { // This happens with GDB in annotation level 2 pos_buffer = pos_buffer.after("source "); } int last_colon = pos_buffer.index(':', -1); pc_buffer = pos_buffer.after(last_colon); if (!pc_buffer.contains(rxaddress_start, 0)) pc_buffer = "0x" + pc_buffer; pc_buffer = pc_buffer.through(rxaddress); answer.at(index1, index2 - index1 + 1) = ""; if (!pos_buffer.empty()) already_read = PosComplete; }
void set_buttons_from_gdb(Widget buttons, string& text) { bool yn = gdb->ends_with_yn(text); if (yn) { if (!gdb_asks_yn) annotate("query"); gdb_asks_yn = true; } else if (gdb->isReadyWithPrompt()) { if (gdb_asks_yn) annotate("post-query"); gdb_asks_yn = false; unpost_gdb_yn(); } if (yn && !gdb_keyboard_command) { // Fetch previous output lines, in case this is a multi-line message. String s = XmTextGetString(gdb_w); string prompt(s); XtFree(s); // FIXME: Handle JDB char prompt_start = (gdb->type() == XDB ? '>' : '('); int pos = prompt.index(prompt_start, -1); if (pos >= 0) pos = prompt.index('\n', pos) + 1; if (pos == 0) pos = messagePosition; XmTextReplace(gdb_w, pos, XmTextGetLastPosition(gdb_w), XMST("")); promptPosition = pos; prompt = prompt.from(pos); if (text.contains('(')) prompt += text.before('(', -1); // Don't repeat `(y or n)' else prompt += text; post_gdb_yn(prompt); text = ""; return; } if (buttons == 0) return; static bool last_yn = false; if (yn == last_yn) return; last_yn = yn; if (XtIsComposite(buttons)) { set_sensitive(buttons, false); WidgetList children = 0; Cardinal num_children = 0; XtVaGetValues(buttons, XmNchildren, &children, XmNnumChildren, &num_children, XtPointer(0)); int i; for (i = 0; i < int(num_children); i++) XtManageChild(children[i]); for (i = 0; i < int(num_children); i++) { Widget w = children[i]; string name = XtName(w); if (yn == (name == "Yes" || name == "No")) XtManageChild(w); else XtUnmanageChild(w); } set_sensitive(buttons, true); } }
// RUN: %clang_cc1 %s -emit-llvm -o %t1 // RUN: FileCheck --check-prefix=FOO %s < %t1 // RUN: FileCheck --check-prefix=A %s < %t1 // RUN: FileCheck --check-prefix=BAR %s < %t1 // RUN: FileCheck --check-prefix=FOOS %s < %t1 // END. static __attribute((annotate("sfoo_0"))) __attribute((annotate("sfoo_1"))) char sfoo; __attribute((annotate("foo_0"))) __attribute((annotate("foo_1"))) char foo; void __attribute((annotate("ann_a_0"))) __attribute((annotate("ann_a_1"))) __attribute((annotate("ann_a_2"))) __attribute((annotate("ann_a_3"))) a(char *a); void __attribute((annotate("ann_a_0"))) __attribute((annotate("ann_a_1"))) a(char *a) { __attribute__((annotate("bar_0"))) __attribute__((annotate("bar_1"))) static char bar; sfoo = 0; } // FOOS: target triple // FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section "llvm.metadata" // FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section "llvm.metadata" // FOOS-NOT: sfoo_ // FOOS: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* @sfoo{{.*}}i8* @sfoo{{.*}}, section "llvm.metadata" // FOO: target triple // FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section "llvm.metadata" // FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section "llvm.metadata" // FOO-NOT: foo_ // FOO: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* @foo{{.*}}i8* @foo{{.*}}, section "llvm.metadata" // A: target triple // A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata" // A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata"
// RUN: c-index-test -test-load-source all %s | FileCheck %s class Test { public: __attribute__((annotate("spiffy_method"))) void aMethod(); public __attribute__((annotate("works"))): void anotherMethod(); // annotation attribute should be propagated. private __attribute__((annotate("investigations"))): //propagated annotation should have changed from "works" to "investigations" void inlineMethod() {} protected: // attribute propagation should have stopped here void methodWithoutAttribute(); }; // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2] // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8] // CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60] // CHECK-NEXT: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43] // CHECK-NEXT: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43] // CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40] // CHECK-NEXT: CXXMethod=anotherMethod:8:8 Extent=[8:3 - 8:23] // CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40] // CHECK-NEXT: CXXAccessSpecifier=:10:1 (Definition) Extent=[10:1 - 10:53] // CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50] // CHECK-NEXT: CXXMethod=inlineMethod:12:8 (Definition) Extent=[12:3 - 12:25] // CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50] // CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #include <stdio.h> #include <AS3/AS3.h> class SomeClass { public: ~SomeClass() { printf("~SomeClass!\n"); } }; void foo() __attribute__((used, annotate("as3sig:public function as3foo():int"))); void foo() { SomeClass sc; AS3_Return(13); } void bar() __attribute((used, annotate("as3sig:public function as3bar():Array"))); void bar() { SomeClass sc; AS3_ReturnAS3Var(([3,4,5])); } void baz() __attribute((used, annotate("as3sig:public function as3baz():void"))); void baz()
/* * RUN: clang %cflags -emit-llvm -S %s -o %t.ll * RUN: soaap -o %t.soaap.ll %t.ll | FileCheck %s * * CHECK: Running Soaap Pass */ int a() __attribute__((annotate("hello"))) { return 0; } int main(int argc, char** argv) { return a(); }
// RUN: FileCheck --check-prefix=LOCAL %s < %t1 // RUN: FileCheck --check-prefix=UNDEF %s < %t1 // RUN: FileCheck --check-prefix=PARAM %s < %t1 // END. // LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" // LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata" // UNDEF: private unnamed_addr constant [15 x i8] c"undefvar_ann_0\00", section "llvm.metadata" // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" // PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata" int foo(int v __attribute__((annotate("param_ann_2"))) __attribute__((annotate("param_ann_3")))); int foo(int v __attribute__((annotate("param_ann_0"))) __attribute__((annotate("param_ann_1")))) { return v + 1; // PARAM: define {{.*}}@foo // PARAM: [[V:%.*]] = alloca i32 // PARAM: bitcast i32* [[V]] to i8* // PARAM-NEXT: call void @llvm.var.annotation( // PARAM-NEXT: bitcast i32* [[V]] to i8* // PARAM-NEXT: call void @llvm.var.annotation( // PARAM-NEXT: bitcast i32* [[V]] to i8* // PARAM-NEXT: call void @llvm.var.annotation( // PARAM-NEXT: bitcast i32* [[V]] to i8* // PARAM-NEXT: call void @llvm.var.annotation( } void local(void) {
// RUN: %clang_cc1 %s -fsyntax-only -verify void __attribute__((annotate("foo"))) foo(float *a) { __attribute__((annotate("bar"))) int x; __attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}} __attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}} int u = __builtin_annotation(z, (char*) 0); // expected-error {{__builtin_annotation requires a non wide string constant}} int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{__builtin_annotation requires a non wide string constant}} int w = __builtin_annotation(z, "foo"); }
void View_Unlabeled::erase_iterator( Cache::iterator pos ) { annotate(pos, label, Any()); }
/* * Print a number of char variable values as a text string, where the * optional comments for each value identify the variable, and each * dimension index. */ static void pr_tvals( const ncvar_t *vp, /* variable */ size_t len, /* number of values to print */ bool_t lastrow, /* true if this is the last row for this * variable, so terminate with ";" instead * of "," */ const char *vals, /* pointer to block of values */ const size_t *cor /* corner coordinates */ ) { long iel; const char *sp; printf("\""); /* adjust len so trailing nulls don't get printed */ sp = vals + len; while (len != 0 && *--sp == '\0') len--; for (iel = 0; iel < len; iel++) { unsigned char uc; switch (uc = *vals++ & 0377) { case '\b': printf("\\b"); break; case '\f': printf("\\f"); break; case '\n': /* generate linebreaks after new-lines */ printf("\\n\",\n \""); break; case '\r': printf("\\r"); break; case '\t': printf("\\t"); break; case '\v': printf("\\v"); break; case '\\': printf("\\\\"); break; case '\'': printf("\\\'"); break; case '\"': printf("\\\""); break; default: if (isprint(uc)) printf("%c",uc); else printf("\\%.3o",uc); break; } } printf("\""); /* if (fsp && formatting_specs.full_data_cmnts) { */ if (formatting_specs.full_data_cmnts) { lastdelim (0, lastrow); annotate (vp, (size_t *)cor, 0L); } else { lastdelim2 (0, lastrow); } }