blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
1ba61cb52b4bbd5c2eeb157c2afb410f1b00b569
e48b2ede55e28c6142d6452d8fbe68686134b141
/src/AudioConfigIIRFilterBank_F32.cpp
2342ec6676a5b33b460aa5269030c1d0c8d36e6b
[ "MIT" ]
permissive
kxm-creare/Tympan_Library
b33c0f53c6cf105f1a3bac1d41dbee24ee680a29
4fc9206b5040cf934d2cdbdc37dc5872814546f2
refs/heads/master
2021-06-29T16:10:46.589723
2021-06-11T17:50:52
2021-06-11T17:50:52
130,901,324
0
0
MIT
2021-06-11T17:56:19
2018-04-24T19:02:44
HTML
UTF-8
C++
false
false
15,622
cpp
/* * iir_filterbank.cpp * * Created: Chip Audette, Creare LLC, May 2020 * Primarly built upon CHAPRO "Generic Hearing Aid" from * Boys Town National Research Hospital (BTNRH): https://github.com/BTNRH/chapro * * License: MIT License. Use at your own risk. * */ #include "AudioConfigIIRFilterBank_F32.h" #include "utility/BTNRH_iir_filterbank.h" #ifndef fmove #define fmove(x,y,n) memmove(x,y,(n)*sizeof(float)) #endif #ifndef fcopy #define fcopy(x,y,n) memcpy(x,y,(n)*sizeof(float)) #endif #ifndef fzero #define fzero(x,n) memset(x,0,(n)*sizeof(float)) #endif /* iir_filterbank_basic : design a bank of IIR filters with a smooth transition between each b = Output: filter "b" coefficients. float[N_CHAN][N_IIR+1] a = Output: filter "a" coefficients. float[N_CHAN][N_IIR+1] cv = Input: cross-over frequencies (Hz) between filters. float[N_CHAN-1] nc = Input: number of channels (number of filters) n_iir = Input: order of each IIR filter (1 <= N <= 8) sr = Input: Sample rate (Hz) */ int AudioConfigIIRFilterBank_F32::iir_filterbank_basic(float *b, float *a, float *cf, const int nc, const int n_iir, const float sr) { //Serial.print("AudioConfigIIRFilterBank: iir_filterbank: nw_orig = "); Serial.print(nw_orig); //Serial.print(", nw = "); Serial.println(nw); if (n_iir < 1) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank: *** ERROR *** filter order must be at least 1."); return -1; } if (n_iir > 8) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank: *** ERROR *** filter order must be <= 8."); return -1; } //allocate some memory float *z = (float *) calloc(nc*(n_iir*2), sizeof(float)); //z is complex, so needs to be twice as long float *p = (float *) calloc(nc*(n_iir*2), sizeof(float)); //p is complex, so needs to be twice as long float *g = (float *) calloc(nc, sizeof(float)); //design filterbank, zeros and poles and gains //Serial.println("cha_iirfb_design: calling iirfb_zp...");delay(500); int nz = n_iir; //the CHA code from BTNRH uses this notation iirfb_zp(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] cf, //pointer to cutoff frequencies, float[7] sr, //sample rate (Hz) nc, //number of channels (8) nz); //filter order. (4) //change representation from pole-zero to transfer function zp2ba_fb(z,p,nz,nc,b,a); //apply the gain to the b coefficients for (int Ichan = 0; Ichan < nc; Ichan++) { for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { b[Ichan*(nz+1)+Icoeff] *= g[Ichan]; } } return 0; } /* iir_filterbank : design a bank of IIR filters with a smooth transition between each. Also, it computes the best delay for each filter to time-align the inpulse responses. Also, it computes the best gain per band to equlibrate their responses, depsite overlaping coverage. Arguments: b = Output: filter "b" coefficients. float[N_CHAN][N_IIR+1] a = Output: filter "a" coefficients. float[N_CHAN][N_IIR+1] d = Output: filter delay (samples) to align impulse respsones. int[N_CHAN] cv = Input: cross-over frequencies (Hz) between filters. float[N_CHAN-1] nc = Input: number of channels (number of filters) n_iir = Input: order of each IIR filter (1 <= N <= 8) sr = Input: Sample rate (Hz) td = Input: max time delay (mseconds) allowed for aligning the impulse response of the filters */ int AudioConfigIIRFilterBank_F32::iir_filterbank(float *b, float *a, int *d, float *cf, const int nc, const int n_iir, const float sr, const float td) { if (n_iir < 1) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank: *** ERROR *** filter order must be at least 1."); return -1; } if (n_iir > 8) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank: *** ERROR *** filter order must be <= 8."); return -1; } //allocate some memory float *z = (float *) calloc(nc*n_iir*2,sizeof(float)); //z is complex, so needs to be twice as long float *p = (float *) calloc(nc*n_iir*2,sizeof(float)); //p i scomplex, so needs to be twice as long float *g = (float *) calloc(nc, sizeof(float)); // gain is real if (g==NULL) { Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: *** ERROR *** could not allocate memory."); } //Serial.print("AudioConfigIIRFilterBank_F32: iir_filterbank: allocated memory...FreeRAM(B) = "); //Serial.println(FreeRam()); //design filterbank, zeros and poles and gains int nz = n_iir; //the CHA code from BTNRH uses this notation iirfb_zp(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] cf, //pointer to cutoff frequencies, float[7] sr, //sample rate (Hz) nc, //number of channels (8) nz); //filter order. (4) #if 0 //plot zeros and poles and gains Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: orig zero-pole"); for (int Iband=0; Iband < nc; Iband++) { Serial.print(" : Band "); Serial.print(Iband); Serial.print(", Gain = "); Serial.println(g[Iband],8); Serial.print(" : Z: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(z[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); Serial.print(" : P: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(p[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); } #endif //adjust filter to time-align the peaks of the fiter response align_peak_fb(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] d, //delay for each filter (samples). pointer to array int[8] td, //max time delay (msec?) for the filters? sr, //sample rate (Hz) nc, //number of channels nz); //filter order (4) int ret_val = 0; if (0) { //adjust gain of each filter (for flat response even during crossover?) //WARNING: This operation takes a lot of RAM. If ret_val is -1, it failed. ret_val = adjust_gain_fb(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] d, //delay for each filter (samples). pointer to array int[8] cf, //pointer to cutoff frequencies, float[7] sr, //sample rate (Hz) nc, //number of channels (8) nz); //filter order (4) if (ret_val < 0) { Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: *** ERROR *** failed (in adjust_gain_fb."); } } #if 0 //plot zeros and poles and gains Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: prior to b-a conversion"); for (int Iband=0; Iband < nc; Iband++) { Serial.print(" : Band "); Serial.print(Iband); Serial.print(", Gain = "); Serial.println(g[Iband],8); Serial.print(" : Z: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(z[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); Serial.print(" : P: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(p[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); } #endif //change representation from pole-zero to transfer function zp2ba_fb(z,p,nz,nc,b,a); //print the coeff for debugging //Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: "); //for (int Ichan = 0; Ichan < nc; Ichan++) { // Serial.print("Band "); Serial.print(Ichan);Serial.print(", g = "); Serial.print(g[Ichan],5); Serial.print(", b"); // for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { // Serial.print(", "); // Serial.print(b[Ichan*(nz+1)+Icoeff],5); // } // Serial.println(); //} //apply the gain to the b coefficients for (int Ichan = 0; Ichan < nc; Ichan++) { for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { //if ((Ichan == 0) || (Ichan == nc-1)) { //really? only do it for the first and last? WEA 6/8/2020 b[Ichan*(nz+1)+Icoeff] *= g[Ichan]; //} } } //Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: post g*b: "); //for (int Ichan = 0; Ichan < nc; Ichan++) { // Serial.print("Band "); Serial.print(Ichan);Serial.print(", b"); // for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { // Serial.print(", "); // Serial.print(b[Ichan*(nz+1)+Icoeff],5); // } // Serial.println(); //} //release the allocated memory free(g); free(p); free(z); return ret_val; } // Compute the filter coefficients as second-order-sections /* What size is the SOS array? * Each SOS is a biquad specified by 6 values (the three 'b' followed by the three 'a') * For each filter, there are N_IIR/2 biquads. So, for N=6, there are 3 biquads. * So, sos is [nchannels][nbiquads][6] => [nc][ceil(n_iir/2)][6] */ int AudioConfigIIRFilterBank_F32::iir_filterbank_sos(float *sos, int *d, float *cf, const int nc, const int n_iir, const float sr, const float td) { if (n_iir < 1) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank_sos: *** ERROR *** filter order must be at least 1."); return -1; } if (n_iir > 8) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank_sos: *** ERROR *** filter order must be <= 8."); return -1; } if ( (n_iir % 2) != 0 ) { Serial.println("AudioConfigIIRFilterBank: iir_filterbank_sos: *** ERROR *** filter order must be even to make SOS!"); return -1; } //allocate some memory float *z = (float *) calloc(nc*n_iir*2,sizeof(float)); //z is complex, so needs to be twice as long float *p = (float *) calloc(nc*n_iir*2,sizeof(float)); //p i scomplex, so needs to be twice as long float *g = (float *) calloc(nc, sizeof(float)); // gain is real if (g==NULL) { Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank_sos: *** ERROR *** could not allocate memory."); } //Serial.print("AudioConfigIIRFilterBank_F32: iir_filterbank: allocated memory...FreeRAM(B) = "); //Serial.println(FreeRam()); //design filterbank, zeros and poles and gains Serial.println("AudioConfigIIRFilterBank_F32::iir_filterbank_sos: calling iirfb_zp()"); int nz = n_iir; //the CHA code from BTNRH uses this notation iirfb_zp(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] cf, //pointer to cutoff frequencies, float[7] sr, //sample rate (Hz) nc, //number of channels (8) nz); //filter order. (4) #if 0 //plot zeros and poles and gains Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank_sos: orig zero-pole"); for (int Iband=0; Iband < nc; Iband++) { Serial.print(" : Band "); Serial.print(Iband); Serial.print(", Gain = "); Serial.println(g[Iband],8); Serial.print(" : Z: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(z[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); Serial.print(" : P: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(p[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); } #endif //adjust filter to time-align the peaks of the fiter response Serial.println("AudioConfigIIRFilterBank_F32::iir_filterbank_sos: calling align_peak_fb()"); align_peak_fb(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] d, //delay for each filter (samples). pointer to array int[8] td, //max time delay (msec?) for the filters? sr, //sample rate (Hz) nc, //number of channels nz); //filter order (4) int ret_val = 0; if (0) { //adjust gain of each filter (for flat response even during crossover?) //WARNING: This operation takes a lot of RAM. If ret_val is -1, it failed. ret_val = adjust_gain_fb(z, //filter zeros. pointer to array float[64] p, //filter poles. pointer to array float[64] g, //gain for each filter. pointer to array float[8] d, //delay for each filter (samples). pointer to array int[8] cf, //pointer to cutoff frequencies, float[7] sr, //sample rate (Hz) nc, //number of channels (8) nz); //filter order (4) if (ret_val < 0) { Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank_sos: *** ERROR *** failed (in adjust_gain_fb."); } } #if 0 //plot zeros and poles and gains Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank_sos: prior to b-a conversion"); for (int Iband=0; Iband < nc; Iband++) { Serial.print(" : Band "); Serial.print(Iband); Serial.print(", Gain = "); Serial.println(g[Iband],8); Serial.print(" : Z: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(z[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); Serial.print(" : P: ");for (int i=0; i < 2*n_iir; i++) { Serial.print(p[(Iband*2*n_iir)+i],4); Serial.print(", ");}; Serial.println(); } #endif //convert to second order sections Serial.println("AudioConfigIIRFilterBank_F32::iir_filterbank_sos: converting to second order sections"); float bk[3], ak[3]; //each biquad is 3 b coefficients and 3 a coefficients int out_ind ; int n_biquad = nz / 2; int n_coeff_per_biquad = 6; float *zk, *pk; for (int k=0; k < nc; k++) { //loop over filter bands for (int Ibiquad = 0; Ibiquad < n_biquad; Ibiquad++) { //convert zero-pole to transfer function zk = z + (((k * n_biquad + Ibiquad)*2) * 2); //two zeros per biquad (that's the first *2). Each zero is a complex number (that's the second *2) pk = p + (((k * n_biquad + Ibiquad)*2) * 2); //two poles per biquad (that's the first *2). Each pole is a complex number (that's the second *2) int nz_foo = 2; //each biquad is 2nd order zp2ba(zk,pk,nz_foo,bk,ak); //I think that this is in Tympan_Library\src\utility\BTNRH_iir_design.h //apply gain to first coefficients only if (Ibiquad==0) { bk[0] *= g[k]; bk[1] *= g[k]; bk[2] *= g[k]; } //accumulate in sos structure out_ind = (k*n_biquad+Ibiquad)*n_coeff_per_biquad; sos[out_ind+0] = bk[0]; sos[out_ind+1] = bk[1]; sos[out_ind+2] = bk[2]; sos[out_ind+3] = ak[0]; sos[out_ind+4] = ak[1]; sos[out_ind+5] = ak[2]; } } //print the SOS coeff for debugging #if 0 Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank_sos: sos sections"); for (int Iband=0; Iband < nc; Iband++) { Serial.print(" : Band "); Serial.print(Iband); Serial.println(); for (int Ibiquad=0; Ibiquad < n_biquad; Ibiquad++) { out_ind = (Iband*n_biquad+Ibiquad)*n_coeff_per_biquad; //Serial.print(" : sos "); Serial.print(Ibiquad); Serial.print(": "); Serial.print(" "); for (int i=0; i < n_coeff_per_biquad; i++) { Serial.print(sos[out_ind+i],7); Serial.print(", ");}; Serial.println(); } } #endif //apply the gain to the b coefficients //for (int Ichan = 0; Ichan < nc; Ichan++) { // for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { // //if ((Ichan == 0) || (Ichan == nc-1)) { //really? only do it for the first and last? WEA 6/8/2020 // b[Ichan*(nz+1)+Icoeff] *= g[Ichan]; // //} // } //} //Serial.println("AudioConfigIIRFilterBank_F32: iir_filterbank: post g*b: "); //for (int Ichan = 0; Ichan < nc; Ichan++) { // Serial.print("Band "); Serial.print(Ichan);Serial.print(", b"); // for (int Icoeff = 0; Icoeff < n_iir+1; Icoeff++) { // Serial.print(", "); // Serial.print(b[Ichan*(nz+1)+Icoeff],5); // } // Serial.println(); //} //release the allocated memory Serial.println("AudioConfigIIRFilterBank_F32::iir_filterbank_sos: calling freeing memory"); free(g); free(p); free(z); return ret_val; }
[ "chipaudette@yahoo.com" ]
chipaudette@yahoo.com
62d7de7d49db1a0340215a88df46e43eb0eeccd4
65dbef8d4b81ce04ac3a8c9e3a3da91a07313688
/C・C++/独習C++新版/ch03/check_4.cpp
6a6d4f7ab6b8b1fd38343e93ec425bd46cd4eff6
[]
no_license
iinuma0710/programming_study
2c0b9526327cdb98b4c3da7e5cb19125db5f1299
e1eefb062487f32c982c1fed4b4c3739b90fbb37
refs/heads/main
2023-04-18T23:03:49.819678
2021-04-03T03:02:40
2021-04-03T03:02:40
311,096,491
0
0
null
null
null
null
UTF-8
C++
false
false
207
cpp
#include <iostream> class A { int private_val = 77; friend void show(const A& a); }; void show(const A& a) { std::cout << a.private_val << std::endl; } int main() { A aa; show(aa); }
[ "iinuma0710@gmail.com" ]
iinuma0710@gmail.com
975fe2f9bf6b60ea0810bf8f35e8153176d0527c
304dcc859ff1bad63ae881a096e687f7dc3de04b
/Test_PC_Poker/UPGCommon/src/Community/BlackBuddyAddDlg.cpp
54a509bebc15978cea22ef39debc01063746a7ff
[]
no_license
idh37/testrepo
03e416b115563cf62a4436f7a278eda2cd05d115
b07cdd22bd42356522a599963f031a6294e14065
refs/heads/master
2020-07-11T00:57:34.526556
2019-09-10T07:22:35
2019-09-10T07:22:35
204,413,346
0
0
null
null
null
null
UHC
C++
false
false
6,329
cpp
#include "stdafx.h" #include "BlackBuddyAddDlg.h" #include "BlackBuddyAddDlgID.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CBlackBuddyAddDlg::CBlackBuddyAddDlg(CWnd* pParent/* = NULL*/) : LSY::CLSYLibDialogBase(pParent), m_pWndBack(NULL), m_pTxtResult(NULL), m_pEditBlackBuddyIDorNickName(NULL), m_pBtnAddBlackBuddy(NULL), m_pBtnCancelBlackBuddy(NULL), m_pBtnClose(NULL), m_pBtnOK(NULL), m_pBtnCancel(NULL) { } BEGIN_MESSAGE_MAP(CBlackBuddyAddDlg, LSY::CLSYLibDialogBase) END_MESSAGE_MAP() INT_PTR CBlackBuddyAddDlg::DoModal(BLACKBUDDYADDDLGTYPE nType, std::string strMessage, CWnd *pParent) { m_pParentWnd = pParent; m_nStartType = nType; m_nCurType = nType; m_strMessage = strMessage; return CLSYLibDialogBase::DoModal(GetObjectMan(), ID_BLACKLISTADD); } bool CBlackBuddyAddDlg::OnCreatedProject(void) { LSY::CObjectProject *pProject = m_pObjectMan->GetProjectFromID(m_nID); m_pWndBack = (LSY::CWindows *)pProject->GetMainObject(); m_pTxtResult = (LSY::CText *)GetObject(ID_BLACKLISTADD_TXT_USERLIST_ADD); m_pTxtResult->SetText(m_strMessage); m_pEditBlackBuddyIDorNickName = (LSY::CEdit *)GetObject(ID_BLACKLISTADD_EDIT_BLACKLIST_NICKNAME); m_pEditBlackBuddyIDorNickName->SetText(""); m_pBtnAddBlackBuddy = (LSY::CButton *)GetObject(ID_BLACKLISTADD_BTN_ADD_BLACKLIST); m_pBtnAddBlackBuddy->AddHandler(LSY::EM_O_MOUSELCLICK, LSY::Fnt(this, &CBlackBuddyAddDlg::OnClickButton)); m_pBtnCancelBlackBuddy = (LSY::CButton *)GetObject(ID_BLACKLISTADD_BTN_CANCEL_BLACKLIST); m_pBtnCancelBlackBuddy->AddHandler(LSY::EM_O_MOUSELCLICK, LSY::Fnt(this, &CBlackBuddyAddDlg::OnClickButton)); m_pBtnOK = (LSY::CButton *)GetObject(ID_BLACKLISTADD_BTN_OK); m_pBtnOK->AddHandler(LSY::EM_O_MOUSELCLICK, LSY::Fnt(this, &CBlackBuddyAddDlg::OnClickButton)); m_pBtnCancel = (LSY::CButton *)GetObject(ID_BLACKLISTADD_BTN_CANCEL); m_pBtnCancel->AddHandler(LSY::EM_O_MOUSELCLICK, LSY::Fnt(this, &CBlackBuddyAddDlg::OnClickButton)); m_pBtnClose = (LSY::CButton *)GetObject(ID_BLACKLISTADD_BTN_CLOSE); m_pBtnClose->AddHandler(LSY::EM_O_MOUSELCLICK, LSY::Fnt(this, &CBlackBuddyAddDlg::OnClickButton)); m_pObjectMan->SetFocus(m_pEditBlackBuddyIDorNickName); SetCurType(m_nStartType); return TRUE; } void CBlackBuddyAddDlg::SetCurType(BLACKBUDDYADDDLGTYPE nType) { switch(nType) { case BBADT_EDIT: m_pWndBack->SetIndex(2); m_pTxtResult->SetShow(false); m_pEditBlackBuddyIDorNickName->SetShow(true); m_pBtnAddBlackBuddy->SetShow(true); m_pBtnCancelBlackBuddy->SetShow(true); m_pBtnOK->SetShow(false); m_pBtnCancel->SetShow(false); m_pBtnClose->SetShow(false); break; case BBADT_QUESTION: m_pWndBack->SetIndex(1); m_pTxtResult->SetShow(true); m_pTxtResult->SetText("블랙리스트에 추가 하시겠습니까?"); m_pEditBlackBuddyIDorNickName->SetShow(false); m_pBtnAddBlackBuddy->SetShow(false); m_pBtnCancelBlackBuddy->SetShow(false); m_pBtnOK->SetShow(true); m_pBtnCancel->SetShow(true); m_pBtnClose->SetShow(false); break; case BBADT_MESSAGE: m_pWndBack->SetIndex(1); m_pTxtResult->SetShow(true); m_pEditBlackBuddyIDorNickName->SetShow(false); m_pBtnAddBlackBuddy->SetShow(false); m_pBtnCancelBlackBuddy->SetShow(false); m_pBtnOK->SetShow(false); m_pBtnCancel->SetShow(false); m_pBtnClose->SetShow(true); break; } m_nCurType = nType; } LRESULT CBlackBuddyAddDlg::OnClickButton(LSY::CMessage *pMsg) { LSY::CObjectMessage *msg = (LSY::CObjectMessage *)pMsg; switch(msg->GetObject()->GetID()) { case ID_BLACKLISTADD_BTN_ADD_BLACKLIST: { CString strName = m_pEditBlackBuddyIDorNickName->GetText().c_str(); strName.Trim(); if(strName == "") { m_pTxtResult->SetText("블랙리스트에 추가할 닉네임/아이디를 입력해주세요."); SetCurType(BBADT_MESSAGE); } else if(CCommunityManager::Instance()->IsConnect()) { if(CCommunityManager::Instance()->GetMyID() == strName.GetString() || CCommunityManager::Instance()->GetMyNickName() == strName.GetString()) { m_pTxtResult->SetText("자기 자신을 블랙리스트에 추가할 수 없습니다."); SetCurType(BBADT_MESSAGE); } else { SetCurType(BBADT_QUESTION); } } else { m_pTxtResult->SetText("커뮤니티 서버에 연결되어 있지 않아 블랙리스트에 추가할 수 없습니다."); SetCurType(BBADT_MESSAGE); } } break; case ID_BLACKLISTADD_BTN_CANCEL_BLACKLIST: OnCancel(); break; case ID_BLACKLISTADD_BTN_OK: if(m_nStartType == BBADT_EDIT) { CString strName = m_pEditBlackBuddyIDorNickName->GetText().c_str(); strName.Trim(); list<std::string> listNickName; listNickName.push_back(strName.GetString()); CCommunityManager::Instance()->SendGetUserInfo(CCommunityUserInfo::ECUIT_ADDBLACKLIST, NULL, listNickName, ""); } OnOK(); break; case ID_BLACKLISTADD_BTN_CANCEL: if(m_nStartType == BBADT_EDIT) { SetCurType(BBADT_EDIT); } else { OnCancel(); } break; case ID_BLACKLISTADD_BTN_CLOSE: if(m_nStartType == BBADT_MESSAGE) { OnCancel(); } else { SetCurType(BBADT_EDIT); } break; } return TRUE; } bool CBlackBuddyAddDlg::OnAddGroup(const std::string &strName) { return CCommunityManager::Instance()->SendBuddyGroupAdd(strName); } BOOL CBlackBuddyAddDlg::PreTranslateMessage(MSG* pMsg) { if(m_pObjectMan) { switch(pMsg->message) { case WM_SYSKEYDOWN: switch(pMsg->wParam) { case VK_F4: if((GetKeyState(VK_LMENU) & 0xff00) && (m_nStartType == BBADT_EDIT) && (m_nCurType == BBADT_QUESTION)) { SetCurType(BBADT_EDIT); return TRUE; } break; } break; case WM_KEYDOWN: switch(pMsg->wParam) { case VK_RETURN: switch(m_nCurType) { case BBADT_EDIT: { LSY::CMO_MouseLClick msg(m_pBtnAddBlackBuddy, m_pBtnAddBlackBuddy->GetPos()); OnClickButton(&msg); } return TRUE; case BBADT_QUESTION: { LSY::CMO_MouseLClick msg(m_pBtnOK, m_pBtnOK->GetPos()); OnClickButton(&msg); } return TRUE; } break; case VK_ESCAPE: if((m_nStartType == BBADT_EDIT) && (m_nCurType == BBADT_QUESTION)) { SetCurType(BBADT_EDIT); return TRUE; } break; } break; } } return __super::PreTranslateMessage(pMsg); }
[ "idh37@nm-4ones.com" ]
idh37@nm-4ones.com
ce226b28bc80e700d084e00192f7e18199871d82
83d04e85b76463d6ae12e03db7e998ab89da6a44
/C++/1330.cpp
741447068fbf7172dc13f6f41fa4892d84d8d6eb
[]
no_license
tunde02/Algorithms
d10856b704ba8863db40a686d15d3c1a03639cba
ec81db5de25f9b5732a67c925305b3edfefb7be4
refs/heads/main
2023-08-03T18:59:22.738786
2023-07-29T14:04:14
2023-07-29T14:04:14
207,979,167
0
0
null
null
null
null
UTF-8
C++
false
false
192
cpp
#include <iostream> using namespace std; int a, b; int main() { cin >> a >> b; if(a > b) { cout << ">"; } else if(a == b) { cout << "=="; } else { cout << "<"; } return 0; }
[ "snskrktja@naver.com" ]
snskrktja@naver.com
cb341429c1b042dfcb7aa1f3d3b98bec237bcc39
181a888d842f9aafcbb618960f2ffe568ec9fc9c
/Navigator.cpp
7a5a2611da9a0a3712ca5aca80a4ba9ad589fb4b
[]
no_license
katiecai/BruinNav
4b4e0009470e1e69bcb9fb4143d5e76f758e619b
5918e142939e61eaacb2286e0a2a239a54fc327d
refs/heads/master
2020-12-02T19:32:50.227674
2017-07-05T20:21:20
2017-07-05T20:21:20
96,357,998
0
0
null
null
null
null
UTF-8
C++
false
false
10,051
cpp
//#include "provided.h" #include "MyMap.h" #include "support.h" #include <string> #include <vector> #include <queue> #include <iostream> using namespace std; struct Node { Node(const GeoCoord cur, const GeoCoord dest, Node* p, double distance) : m_cur(cur.latitudeText, cur.longitudeText) { h = distanceEarthMiles(cur, dest); g = distance; f = g + h; parent = p; //if queue is empty, pass in nullptr if (parent == nullptr) path.push_back(cur); else { path = parent->path; path.push_back(cur); } } Node() { } GeoCoord m_cur; double f; double g; double h; Node* parent; Node& operator=(const Node& rhs); vector<GeoCoord> path; }; Node& Node::operator=(const Node& rhs) { if (this != &rhs) { m_cur = rhs.m_cur; f = rhs.f; g = rhs.g; h = rhs.h; path = rhs.path; parent = rhs.parent; } return *this; } bool operator==(const Node& lhs, const Node& rhs) { if (lhs.f == rhs.f) return true; return false; } bool operator<(const Node& lhs, const Node& rhs) { if (lhs.f > rhs.f) return true; return false; } bool operator>(const Node& lhs, const Node& rhs) { if (lhs.f < rhs.f) return true; return false; } class NavigatorImpl { public: NavigatorImpl(); ~NavigatorImpl(); bool loadMapData(string mapFile); NavResult navigate(string start, string end, vector<NavSegment>& directions) const; string getDirection(double angle) const; string getTurnDirection(double angle) const; private: MapLoader ml; AttractionMapper am; SegmentMapper sm; }; NavigatorImpl::NavigatorImpl() { } NavigatorImpl::~NavigatorImpl() { } string NavigatorImpl::getDirection(double angle) const { if (angle >= 0 && angle <= 22.5) return "east"; else if (angle > 22.5 && angle <= 67.5) return "northeast"; else if (angle > 67.5 && angle <= 112.5) return "north"; else if (angle > 112.5 && angle <= 157.5) return "northwest"; else if (angle > 157.5 && angle <= 202.5) return "west"; else if (angle > 202.5 && angle <= 247.5) return "southwest"; else if (angle > 247.5 && angle <= 292.5) return "south"; else if (angle > 292.5 && angle <= 337.5) return "southeast"; return "east"; } string NavigatorImpl::getTurnDirection(double angle) const { if (angle < 180) return "left"; else return "right"; } bool NavigatorImpl::loadMapData(string mapFile) { MapLoader ml; if (ml.load(mapFile)) { am.init(ml); sm.init(ml); return true; } return false;// This compiles, but may not be correct } NavResult NavigatorImpl::navigate(string start, string end, vector<NavSegment> &directions) const { //A* MyMap<GeoCoord, Node> closed; priority_queue<Node> open; GeoCoord begin; GeoCoord dest; if (!am.getGeoCoord(start, begin)) return NAV_BAD_SOURCE; if (!am.getGeoCoord(end, dest)) return NAV_BAD_DESTINATION; //push starting coord onto open and closed lists Node first(begin, dest, nullptr, 0); open.push(first); closed.associate(first.m_cur, first); if (first.m_cur == dest) return NAV_SUCCESS; while (!open.empty()) { Node current = open.top(); open.pop(); //found a path of geocoords -> create vector of streetsegments -> create vector of navsegments if (current.m_cur == dest) { closed.associate(current.m_cur, current); cerr << closed.find(dest)->path.size() << endl; vector<GeoCoord> gcPath = closed.find(dest)->path; vector<StreetSegment> correctStreetSegs; // for (int i = 0; i < gcPath.size(); i++) { // cerr << gcPath[i].latitudeText << ", " << gcPath[i].longitudeText << endl; // } for (int j = 0; j < gcPath.size()-1; j++) { vector<StreetSegment> streetSegs = sm.getSegments(closed.find(dest)->path.at(j)); for (int k = 0; k < streetSegs.size(); k++) { //if the start and end geocoords of the street segment are equal to two consecutive geocoords in the path //we found the correct street segment if ((streetSegs[k].segment.start == gcPath[j+1] && streetSegs[k].segment.end == gcPath[j]) || (streetSegs[k].segment.start == gcPath[j] && streetSegs[k].segment.end == gcPath[j+1])) { cerr << "lol"; StreetSegment temp; temp.segment.start = gcPath[j]; temp.segment.end = gcPath[j+1]; temp.streetName = streetSegs[k].streetName; correctStreetSegs.push_back(temp); break; } //loop through attractions to see if the start/end attractions are in the middle of a street for (int l = 0; l < streetSegs[k].attractions.size(); l++) { if ((gcPath[j] == streetSegs[k].attractions[l].geocoordinates && gcPath[j+1] == streetSegs[k].segment.end) || (gcPath[j] == streetSegs[k].attractions[l].geocoordinates && gcPath[j+1] == streetSegs[k].segment.start) || (gcPath[j+1] == streetSegs[k].attractions[l].geocoordinates && gcPath[j] == streetSegs[k].segment.end) || (gcPath[j+1] == streetSegs[k].attractions[l].geocoordinates && gcPath[j] == streetSegs[k].segment.start)) { cerr << "lol"; StreetSegment temp; temp.segment.start = gcPath[j]; temp.segment.end = gcPath[j+1]; temp.streetName = streetSegs[k].streetName; correctStreetSegs.push_back(temp); break; } } } } //push first direction onto vector //if (correctStreetSegs.size() > 0) { string firstDirection = getDirection(angleOfLine(correctStreetSegs[0].segment)); directions.push_back(NavSegment(firstDirection, correctStreetSegs[0].streetName, distanceEarthMiles(correctStreetSegs[0].segment.start, correctStreetSegs[0].segment.end), correctStreetSegs[0].segment)); //} //loop thru rest of street segments for (int l = 1; l < correctStreetSegs.size(); l++) { string dir = getDirection(angleOfLine(correctStreetSegs[l].segment)); double dist = distanceEarthMiles(correctStreetSegs[l].segment.start, correctStreetSegs[l].segment.end); if (correctStreetSegs[l].streetName == correctStreetSegs[l-1].streetName) directions.push_back(NavSegment(dir, correctStreetSegs[l].streetName, dist, correctStreetSegs[l].segment)); else { directions.push_back(NavSegment(getTurnDirection(angleBetween2Lines(correctStreetSegs[l-1].segment, correctStreetSegs[l].segment)), correctStreetSegs[l].streetName)); directions.push_back(NavSegment(dir, correctStreetSegs[l].streetName, dist, correctStreetSegs[l].segment)); } } for (int x = 0; x < directions.size(); x++) { cerr << directions[x].m_streetName << endl; cerr << directions[x].m_direction << endl; cerr << directions[x].m_distance << endl; } // cerr << "success" << endl; return NAV_SUCCESS; } vector<StreetSegment> streets = sm.getSegments(current.m_cur); for (int i = 0; i < streets.size(); i++) { GeoCoord gc; GeoCoord gc2; bool isThereGc2 = false; if (streets[i].segment.end == current.m_cur) gc = streets[i].segment.start; else if (streets[i].segment.start == current.m_cur) gc = streets[i].segment.end; else { gc = streets[i].segment.start; gc2 = streets[i].segment.end; isThereGc2 = true; } //check attractions in case attraction destination is in the middle of the street vector<Attraction> a = streets[i].attractions; for (int j = 0; j < a.size(); j++) { if (a[j].geocoordinates == dest) gc = a[j].geocoordinates; } Node neighbor(gc, dest, &current, current.g + distanceEarthMiles(gc, current.m_cur)); if (closed.find(neighbor.m_cur) == nullptr || (closed.find(neighbor.m_cur) != nullptr && neighbor.f < closed.find(neighbor.m_cur)->f)) open.push(neighbor); if (isThereGc2) open.push(Node(gc2, dest, &current, current.g + distanceEarthMiles(gc2, current.m_cur))); closed.associate(current.m_cur, current); } } return NAV_NO_ROUTE; } //******************** Navigator functions ************************************ // These functions simply delegate to NavigatorImpl's functions. // You probably don't want to change any of this code. Navigator::Navigator() { m_impl = new NavigatorImpl; } Navigator::~Navigator() { delete m_impl; } bool Navigator::loadMapData(string mapFile) { return m_impl->loadMapData(mapFile); } NavResult Navigator::navigate(string start, string end, vector<NavSegment>& directions) const { return m_impl->navigate(start, end, directions); }
[ "katiecai@g.ucla.edu" ]
katiecai@g.ucla.edu
f755445951474a6ee0a31b6be7648a7779e11d7c
b4828cf9403fedde5dd346b3338a5f4bf0f1eb96
/codeforces_sol/B-Vanya_and_Lanterns.cpp
0661110efd8633ad95e532f4e24c7e19e01beffa
[]
no_license
Masters-Akt/CS_codes
9ab3d87ca384ebd364c7b87c8da94b753082a7e3
1aaa107439f2e208bb67b0bcca676f90b6bc6a11
refs/heads/master
2023-01-24T00:11:05.151592
2023-01-21T18:45:57
2023-01-21T18:45:57
292,529,160
6
7
null
null
null
null
UTF-8
C++
false
false
476
cpp
#include <bits/stdc++.h> using namespace std; int main() { // your code goes here int n; long long int l; cin>>n>>l; double a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } sort(a, a+n); // for(int i=0;i<n;i++) cout<<a[i]<<" "; // cout<<"\n"; double m=0; if(a[0]>m) m=a[0]; if(l-a[n-1]>m) m=l-a[n-1]; for(int i=1;i<n;i++){ if((a[i]-a[i-1])/2>m) m = (a[i]-a[i-1])/2; // printf("%.10f ",(a[i]-a[i-1])/2); } // cout<<"\n"; printf("%.10f",m); return 0; }
[ "64123046+Masters-Akt@users.noreply.github.com" ]
64123046+Masters-Akt@users.noreply.github.com
f9e5b73d7faa5011f4f6c11a4c394244ed544880
632516b82a6d662ab0d542190759f4620cf98d14
/tests/unit_tests/address_from_url.cpp
71b6c54b3a1447fe918ab457de073321a9f4134c
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
creddit-project/creddit
cf5adca578d778d4bb9352ecfd416f7bf4953e27
4b76b4e26076d778f0ffa451104c420cd1a5cc64
refs/heads/master
2020-06-25T01:57:29.958980
2019-07-27T12:40:27
2019-07-27T12:40:27
198,517,938
0
0
null
null
null
null
UTF-8
C++
false
false
3,921
cpp
// Copyright (c) 2014-2019, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // FIXME: move this into a full wallet2 unit test suite, if possible #include "gtest/gtest.h" #include "wallet/wallet2.h" #include "common/dns_utils.h" #include "simplewallet/simplewallet.h" #include <string> TEST(AddressFromTXT, Success) { std::string addr = "46BeWrHpwXmHDpDEUmZBWZfoQpdc6HaERCNmx1pEYL2rAcuwufPN9rXHHtyUA4QVy66qeFQkn6sfK8aHYjA3jk3o1Bv16em"; std::string txtr = "oa1:xmr"; txtr += " recipient_address="; txtr += addr; txtr += ";"; std::string res = tools::dns_utils::address_from_txt_record(txtr); EXPECT_STREQ(addr.c_str(), res.c_str()); std::string txtr2 = "foobar"; txtr2 += txtr; txtr2 += "more foobar"; res = tools::dns_utils::address_from_txt_record(txtr2); EXPECT_STREQ(addr.c_str(), res.c_str()); std::string txtr3 = "foobar oa1:xmr tx_description=\"Donation for Creddit Development Fund\"; "; txtr3 += "recipient_address="; txtr3 += addr; txtr3 += "; foobar"; res = tools::dns_utils::address_from_txt_record(txtr3); EXPECT_STREQ(addr.c_str(), res.c_str()); } TEST(AddressFromTXT, Failure) { std::string txtr = "oa1:xmr recipient_address=not a real address"; std::string res = tools::dns_utils::address_from_txt_record(txtr); ASSERT_STREQ("", res.c_str()); txtr += ";"; res = tools::dns_utils::address_from_txt_record(txtr); ASSERT_STREQ("", res.c_str()); } TEST(AddressFromURL, Success) { const std::string addr = MONERO_DONATION_ADDR; bool dnssec_result = false; std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("donate.getmonero.org", dnssec_result); EXPECT_EQ(1, addresses.size()); if (addresses.size() == 1) { EXPECT_STREQ(addr.c_str(), addresses[0].c_str()); } // OpenAlias address with an @ instead of first . addresses = tools::dns_utils::addresses_from_url("donate@getmonero.org", dnssec_result); EXPECT_EQ(1, addresses.size()); if (addresses.size() == 1) { EXPECT_STREQ(addr.c_str(), addresses[0].c_str()); } } TEST(AddressFromURL, Failure) { bool dnssec_result = false; std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("example.veryinvalid", dnssec_result); // for a non-existing domain such as "example.invalid", the non-existence is proved with NSEC records ASSERT_TRUE(dnssec_result); ASSERT_EQ(0, addresses.size()); }
[ "jedibear@protonmail.com" ]
jedibear@protonmail.com
899e49a875596c2a867dc61e0afa93e4da45c5b7
6f4dbb99df537ff0f86bbc323e30371f2a4521d2
/easy-as-pie/funcs/source/stores.cpp
0198161be108d3614f0c65a7e0f0ab089aaac5e0
[ "Unlicense" ]
permissive
rodrigobmg/psx
0e54d12aba6a25987274e1cf81a18019e367eafe
34ca33d2254958963026d1719c31cfc69bfaaf7b
refs/heads/master
2020-04-03T19:13:11.007887
2018-08-20T16:12:49
2018-08-20T16:12:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,049
cpp
// C:\diabpsx\SOURCE\STORES.CPP #include "types.h" // address: 0x800633E8 void FreeStoreMem__Fv() { } // address: 0x800633F0 void DrawSTextBack__Fv() { } // address: 0x80063460 void PrintSString__FiiUcPcci(int x, int y, unsigned char cjustflag, char *str, int col, int val) { // register: 21 register int xx; // register: 19 register int yy; // address: 0xFFFFFFB0 // size: 0x20 auto char valstr[32]; // register: 30 register int SpinnerY; // register: 20 register unsigned char R; // register: 18 register unsigned char G; // register: 17 register unsigned char B; // address: 0x8012B508 static unsigned char DaveFix; } // address: 0x80063838 void DrawSLine__Fi(int y) { // register: 16 register int yy; } // address: 0x800638CC void ClearSText__Fii(int s, int e) { // register: 4 register int i; } // address: 0x80063964 void AddSLine__Fi(int y) { } // address: 0x800639B4 void AddSTextVal__Fii(int y, int val) { } // address: 0x800639DC void AddSText__FiiUcPccUc(int x, int y, unsigned char j, char *str, int clr, int sel) { } // address: 0x80063A90 void PrintStoreItem__FPC10ItemStructic(struct ItemStruct *x, int l, char iclr) { // address: 0xFFFFFF58 // size: 0x80 auto char sstr[128]; // register: 21 register int li; } // address: 0x80063F18 void StoreAutoPlace__Fv() { // register: 16 register int i; // register: 18 register int w; // register: 19 register int h; // register: 3 register int idx; // register: 4 register unsigned char done; } // address: 0x80064538 void S_StartSmith__Fv() { } // address: 0x800646C0 void S_ScrollSBuy__Fi(int idx) { // register: 17 register int l; // register: 20 register int ls; // register: 18 register char iclr; } // address: 0x80064878 void S_StartSBuy__Fv() { } // address: 0x800649A8 void S_ScrollSPBuy__Fi(int idx) { // register: 17 register int l; // register: 22 register int ls; // register: 16 register char iclr; // register: 3 register int boughtitems; { { { { // register: 16 register char *StrPtr; } } } } } // address: 0x80064BC8 unsigned char S_StartSPBuy__Fv() { // register: 4 register int i; } // address: 0x80064D18 unsigned char SmithSellOk__Fi(int i) { } // address: 0x80064DFC void S_ScrollSSell__Fi(int idx) { // register: 19 register int l; // register: 23 register int ls; // register: 20 register int v; // register: 18 register char iclr; { { { { // register: 17 register char *StrPtr; } } } } } // address: 0x80065024 void S_StartSSell__Fv() { // register: 16 register int i; // register: 18 register unsigned char sellok; } // address: 0x80065454 unsigned char SmithRepairOk__Fi(int i) { } // address: 0x800654F8 void AddStoreHoldRepair__FP10ItemStructi(struct ItemStruct *itm, int i) { // register: 4 register int v; } // address: 0x800656D8 void S_StartSRepair__Fv() { // register: 16 register int i; // register: 18 register unsigned char repairok; } // address: 0x80065BA8 void S_StartWitch__Fv() { } // address: 0x80065CE8 void S_ScrollWBuy__Fi(int idx) { // register: 19 register int l; // register: 21 register int ls; // register: 18 register char iclr; { { { { // register: 17 register char *StrPtr; } } } } } // address: 0x80065EC0 void S_StartWBuy__Fv() { } // address: 0x80065FEC unsigned char WitchSellOk__Fi(int i) { // register: 5 register unsigned char rv; // register: 3 // size: 0x98 register struct ItemStruct *pI; } // address: 0x80066110 void S_StartWSell__Fv() { // register: 16 register int i; // register: 19 register unsigned char sellok; } // address: 0x80066768 unsigned char WitchRechargeOk__Fi(int i) { // register: 6 register unsigned char rv; } // address: 0x800667F0 void AddStoreHoldRecharge__FG10ItemStructi(struct ItemStruct itm, int i) { } // address: 0x80066970 void S_StartWRecharge__Fv() { // register: 16 register int i; // register: 18 register unsigned char rechargeok; } // address: 0x80066D90 void S_StartNoMoney__Fv() { } // address: 0x80066DF8 void S_StartNoRoom__Fv() { } // address: 0x80066E58 void S_StartConfirm__Fv() { // register: 16 register char iclr; // register: 3 register unsigned char idprint; } // address: 0x800671A8 void S_StartBoy__Fv() { } // address: 0x80067338 void S_StartBBoy__Fv() { // register: 17 register int iclr; } // address: 0x80067494 void S_StartHealer__Fv() { } // address: 0x80067668 void S_ScrollHBuy__Fi(int idx) { // register: 19 register int l; } // address: 0x800677D4 void S_StartHBuy__Fv() { } // address: 0x800678F4 void S_StartStory__Fv() { } // address: 0x800679E4 unsigned char IdItemOk__FP10ItemStruct(struct ItemStruct *i) { } // address: 0x80067A18 void AddStoreHoldId__FG10ItemStructi(struct ItemStruct itm, int i) { } // address: 0x80067AEC void S_StartSIdentify__Fv() { // register: 16 register int i; // register: 19 register unsigned char idok; } // address: 0x8006854C void S_StartIdShow__Fv() { // register: 17 register char iclr; // register: 16 register char *StrPtr; } // address: 0x80068720 void S_StartTalk__Fv() { // register: 18 register int i; // register: 5 register int tq; // register: 17 register int sn; // register: 22 register int la; // register: 20 register int gl; } // address: 0x80068950 void S_StartTavern__Fv() { } // address: 0x80068A48 void S_StartBarMaid__Fv() { } // address: 0x80068B1C void S_StartDrunk__Fv() { } // address: 0x80068BF0 void StartStore__Fc(char s) { // register: 3 register int i; } // address: 0x80068EE0 void DrawSText__Fv() { } // address: 0x80068F20 void DrawSTextTSK__FP4TASK(struct TASK *T) { } // address: 0x80068FE8 void DoThatDrawSText__Fv() { // register: 17 register int i; } // address: 0x80069194 void STextESC__Fv() { } // address: 0x80069310 void STextUp__Fv() { } // address: 0x80069498 void STextDown__Fv() { } // address: 0x80069630 void S_SmithEnter__Fv() { } // address: 0x80069704 void SetGoldCurs__Fii(int pnum, int i) { } // address: 0x80069780 void SetSpdbarGoldCurs__Fii(int pnum, int i) { } // address: 0x800697FC void TakePlrsMoney__Fl(long cost) { // register: 16 register int i; } // address: 0x80069C48 void SmithBuyItem__Fv() { // register: 10 register int idx; } // address: 0x80069E3C void S_SBuyEnter__Fv() { // register: 4 register int idx; // register: 16 register int i; // register: 3 register unsigned char done; } // address: 0x8006A060 void SmithBuyPItem__Fv() { // register: 6 register int idx; // register: 5 register int i; // register: 3 register int xx; } // address: 0x8006A1E8 void S_SPBuyEnter__Fv() { // register: 5 register int idx; // register: 16 register int i; // register: 3 register unsigned char done; { // register: 3 register int xx; } } // address: 0x8006A418 unsigned char StoreGoldFit__Fi(int idx) { // register: 18 register int sz; // register: 16 register int numsqrs; // register: 4 register int i; // register: 17 register long cost; } // address: 0x8006A6D0 void PlaceStoreGold__Fl(long v) { // register: 16 register int i; // register: 18 register int ii; // register: 19 register int xx; // register: 17 register int yy; // register: 5 register unsigned char done; { { { { } } } } } // address: 0x8006A934 void StoreSellItem__Fv() { // register: 16 register int idx; // register: 16 register int i; // register: 17 register long cost; } // address: 0x8006AC28 void S_SSellEnter__Fv() { // register: 8 register int idx; } // address: 0x8006AD2C void SmithRepairItem__Fv() { // register: 5 register int i; // register: 4 register int idx; } // address: 0x8006AF9C void S_SRepairEnter__Fv() { // register: 8 register int idx; } // address: 0x8006B0F8 void S_WitchEnter__Fv() { } // address: 0x8006B1A8 void WitchBuyItem__Fv() { // register: 16 register int idx; } // address: 0x8006B3A8 void S_WBuyEnter__Fv() { // register: 4 register int idx; // register: 16 register int i; // register: 3 register unsigned char done; } // address: 0x8006B594 void S_WSellEnter__Fv() { // register: 8 register int idx; } // address: 0x8006B698 void WitchRechargeItem__Fv() { // register: 2 register int i; // register: 4 register int idx; } // address: 0x8006B810 void S_WRechargeEnter__Fv() { // register: 8 register int idx; } // address: 0x8006B96C void S_BoyEnter__Fv() { } // address: 0x8006BAA4 void BoyBuyItem__Fv() { } // address: 0x8006BB28 void HealerBuyItem__Fv() { // register: 16 register int idx; } // address: 0x8006BDCC void S_BBuyEnter__Fv() { // register: 16 register int i; // register: 3 register unsigned char done; } // address: 0x8006BFA4 void StoryIdItem__Fv() { // register: 5 register int i; // register: 2 register int idx; } // address: 0x8006C2F0 void S_ConfirmEnter__Fv() { } // address: 0x8006C40C void S_HealerEnter__Fv() { } // address: 0x8006C4A4 void S_HBuyEnter__Fv() { // register: 4 register int idx; // register: 16 register int i; // register: 3 register unsigned char done; } // address: 0x8006C6B0 void S_StoryEnter__Fv() { } // address: 0x8006C748 void S_SIDEnter__Fv() { // register: 8 register int idx; } // address: 0x8006C8C4 void S_TalkEnter__Fv() { // register: 16 register int i; // register: 5 register int tq; // register: 18 register int sn; // register: 21 register int la; { { { { } } } } } // address: 0x8006CABC void S_TavernEnter__Fv() { } // address: 0x8006CB2C void S_BarmaidEnter__Fv() { } // address: 0x8006CB9C void S_DrunkEnter__Fv() { } // address: 0x8006CC0C void STextEnter__Fv() { } // address: 0x8006CE0C void CheckStoreBtn__Fv() { // register: 16 // size: 0x6C register struct CPad *Pad; } // address: 0x8006CF28 void ReleaseStoreBtn__Fv() { } // address: 0x8006CF3C void _GLOBAL__D_pSTextBoxCels() { } // address: 0x8006CF64 void _GLOBAL__I_pSTextBoxCels() { }
[ "rnd0x00@gmail.com" ]
rnd0x00@gmail.com
7c9f9ea25e4c7e945c96f04cf3044bffc189fdc4
669951b6fc45543581f452a75831eaae77c3627c
/1114E.cpp
19c4628f41b3f6914332f9bfa8a94d04d8e6501e
[]
no_license
atharva-sarage/Codeforces-Competitive-Programming
4c0d65cb7f892ba8fa9fc58e539d1b50d0d7a9cb
c718f0693e905e97fbb48eb05981eeddafde108e
refs/heads/master
2020-06-10T01:12:17.336028
2019-06-24T16:43:32
2019-06-24T16:43:32
193,542,627
0
0
null
null
null
null
UTF-8
C++
false
false
1,301
cpp
/************************** * Author-Atharva Sarage * * IIT HYDERABAD * **************************/ #include<bits/stdc++.h> #warning Check Max_Limit,Overflows using namespace std; # define ff first # define ss second # define pb push_back # define mod 1000000007 # define mx 100005 # define ll long long # define db double # define inf 1e9 # define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); mt19937 rng64(chrono::steady_clock::now().time_since_epoch().count()); ll query1(ll x) { cout<<">"<<" "<<x<<endl; ll ans; cin>>ans; return ans; } ll query2(ll x) { cout<<"?"<<" "<<x<<endl; ll ans; cin>>ans; return ans; } int main() { srand(rand()); IOS; ll n; cin>>n; ll low=0; ll high=inf; ll mid; while(high>=low) { mid=low+(high-low)/2; if(query1(mid)) low=mid+1; else high=mid-1; } ll maxi=low; set <ll> s; set <ll> :: iterator itr,itr1,itr2; s.insert(maxi); int RandomRange=n; for(ll i=0;i<30;i++) { int k = rng64() % RandomRange+1; ll l=query2(k); s.insert(l); if(s.size()==n) break; } ll g=0; itr2=s.end(); itr2--; for(itr=s.begin();itr!=itr2;itr++) { itr1=itr; itr1++; g=__gcd(g,*itr1-*itr); } cout<<"! "<<maxi-(n-1)*g<<" "<<g<<endl; }
[ "atharva.sarage@gmail.com" ]
atharva.sarage@gmail.com
a3161a696f06976f5cdf56940f749e1be38b1185
55f945f29f78c0c0c6ac110df808126a38999be5
/devel/.private/mavros_msgs/include/mavros_msgs/RTCM.h
cbb34b1a8be801f6433a7ad02fdfd39339312ba2
[]
no_license
aarchilla/NodeROS
43e9f0d6931d1eb11057d229e20e2911fba943c2
4d79e3ffbbb19c11535613249fed2191ada63000
refs/heads/master
2020-06-16T20:00:39.218889
2019-07-07T18:36:17
2019-07-07T18:36:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,397
h
// Generated by gencpp from file mavros_msgs/RTCM.msg // DO NOT EDIT! #ifndef MAVROS_MSGS_MESSAGE_RTCM_H #define MAVROS_MSGS_MESSAGE_RTCM_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <std_msgs/Header.h> namespace mavros_msgs { template <class ContainerAllocator> struct RTCM_ { typedef RTCM_<ContainerAllocator> Type; RTCM_() : header() , data() { } RTCM_(const ContainerAllocator& _alloc) : header(_alloc) , data(_alloc) { (void)_alloc; } typedef ::std_msgs::Header_<ContainerAllocator> _header_type; _header_type header; typedef std::vector<uint8_t, typename ContainerAllocator::template rebind<uint8_t>::other > _data_type; _data_type data; typedef boost::shared_ptr< ::mavros_msgs::RTCM_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::mavros_msgs::RTCM_<ContainerAllocator> const> ConstPtr; }; // struct RTCM_ typedef ::mavros_msgs::RTCM_<std::allocator<void> > RTCM; typedef boost::shared_ptr< ::mavros_msgs::RTCM > RTCMPtr; typedef boost::shared_ptr< ::mavros_msgs::RTCM const> RTCMConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::mavros_msgs::RTCM_<ContainerAllocator> & v) { ros::message_operations::Printer< ::mavros_msgs::RTCM_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace mavros_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True} // {'geographic_msgs': ['/opt/ros/kinetic/share/geographic_msgs/cmake/../msg'], 'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'mavros_msgs': ['/home/esaii-admin/catkin_ws/src/mavros/mavros_msgs/msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'uuid_msgs': ['/opt/ros/kinetic/share/uuid_msgs/cmake/../msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::mavros_msgs::RTCM_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::mavros_msgs::RTCM_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::mavros_msgs::RTCM_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::mavros_msgs::RTCM_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::mavros_msgs::RTCM_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::mavros_msgs::RTCM_<ContainerAllocator> const> : TrueType { }; template<class ContainerAllocator> struct MD5Sum< ::mavros_msgs::RTCM_<ContainerAllocator> > { static const char* value() { return "8903b686ebe5db3477e83c6d0bb149f8"; } static const char* value(const ::mavros_msgs::RTCM_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x8903b686ebe5db34ULL; static const uint64_t static_value2 = 0x77e83c6d0bb149f8ULL; }; template<class ContainerAllocator> struct DataType< ::mavros_msgs::RTCM_<ContainerAllocator> > { static const char* value() { return "mavros_msgs/RTCM"; } static const char* value(const ::mavros_msgs::RTCM_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::mavros_msgs::RTCM_<ContainerAllocator> > { static const char* value() { return "# RTCM message for the gps_rtk plugin\n\ # The gps_rtk plugin will fragment the data if necessary and \n\ # forward it to the FCU via Mavlink through the available link.\n\ # data should be <= 4*180, higher will be discarded.\n\ std_msgs/Header header\n\ uint8[] data\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ "; } static const char* value(const ::mavros_msgs::RTCM_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::mavros_msgs::RTCM_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.header); stream.next(m.data); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct RTCM_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::mavros_msgs::RTCM_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::mavros_msgs::RTCM_<ContainerAllocator>& v) { s << indent << "header: "; s << std::endl; Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header); s << indent << "data[]" << std::endl; for (size_t i = 0; i < v.data.size(); ++i) { s << indent << " data[" << i << "]: "; Printer<uint8_t>::stream(s, indent + " ", v.data[i]); } } }; } // namespace message_operations } // namespace ros #endif // MAVROS_MSGS_MESSAGE_RTCM_H
[ "aarchilla21@gmail.com" ]
aarchilla21@gmail.com
8ca29d213b3aa587db1a02a738cd86f355599b3b
89016fcda83d19cf880a3671e7923d69b8cb7c39
/spriterengine/objectref/spriterefinstance.cpp
76d48689b0e2f7b04fd7c5ca65c9f03279aeb0e5
[ "Zlib" ]
permissive
lucidspriter/SpriterPlusPlus
9f83e68cd81295642dd3814ab800cd92967ee6c0
8fb550e1633036b42acd1cce0e05cfe60a3041c0
refs/heads/master
2023-08-10T10:29:03.386422
2021-02-17T22:13:10
2021-02-17T22:13:10
45,448,363
97
55
NOASSERTION
2023-07-23T13:17:31
2015-11-03T07:09:45
C++
UTF-8
C++
false
false
903
cpp
#include "spriterefinstance.h" #include "../objectinfo/universalobjectinterface.h" #include "../file/filereference.h" #include "../override/imagefile.h" namespace SpriterEngine { SpriteRefInstance::SpriteRefInstance(UniversalObjectInterface *initialResultObject, TransformProcessor *initialParentTransformer, TimelineKey *initialKey, FileReference *initialImageRef, bool initialUseDefaultPivotPoint) : ObjectRefInstance(initialResultObject, initialParentTransformer, initialKey), imageRef(initialImageRef), useDefaultPivot(initialUseDefaultPivotPoint) { } void SpriteRefInstance::preProcess() { resultObject()->setImage(imageRef->image()); if (useDefaultPivot && imageRef->image()) { resultObject()->setPivot(imageRef->image()->defaultPivot); } } void SpriteRefInstance::process(real currentTime) { preProcess(); ObjectRefInstance::process(currentTime); } }
[ "lucid@brashmonkey.com" ]
lucid@brashmonkey.com
b0f07196a8f2a746cfb2231cbcaf528ebcb10933
eec816ee04e0c5fa8aa050d182a687c5e90fbbd7
/device/source/Main/ServerCommunication.h
c058f235dd36d49fcdfc14149ca4fa55ee282ebf
[]
no_license
HAL-RO-Developer/iot_platform
d7e9112aba330e41590244c0dab50e694c5b0b52
d14f8617cc33f2cec8b265110142a91908699626
refs/heads/master
2021-01-22T11:29:00.934570
2018-01-15T04:22:50
2018-01-15T04:22:50
92,702,104
3
0
null
2017-12-10T22:09:11
2017-05-29T03:00:33
JavaScript
UTF-8
C++
false
false
792
h
#ifndef __SERVER_COMMUNICATION_H_ #define __SERVER_COMMUNICATION_H_ /* --- includeファイル --- */ #include "ArduinoLibrary.h" #include "System.h" #include "InfoStruct.h" #define SERVER_SUCCESS ( 1 ) #define SERVER_CONNECT_ERROR ( -1 ) /* --- HTTPステータスコード --- */ #define HTTP_STATUS_OK ( 200 ) #define HTTP_STATUS_FORBIDDEN ( 403 ) #define HTTP_STATUS_NOT_FOUND ( 404 ) class ServerCommunication{ private: WiFiClient client; String host; String port; String url; SINT status; public: ServerCommunication(String host=""); ~ServerCommunication(); SSHT connect(String host, String port); void request(String url, String json); SINT response(String json[]); void setUrl(String url); SINT getStatus(); }; #endif /* __SERVER_COMMUNICATION_H_ */
[ "tanaka.shogo2@gmail.com" ]
tanaka.shogo2@gmail.com
d0839a1c5979eac2ea688f3d8f1391e97155d0ca
5c0cde9516179e199beda1104a329b252c7684b7
/Graphics/Middleware/QT/include/QtPrintSupport/qprintengine.h
2abf3dda74beff151f31cba1f0251d6f8ccdf307
[]
no_license
herocrx/OpenGLMatrices
3f8ff924e7160e76464d9480af7cf5652954622b
ca532ebba199945813a563fe2fbadc2f408e9f4b
refs/heads/master
2021-05-07T08:28:21.614604
2017-12-17T19:45:40
2017-12-17T19:45:40
109,338,861
0
0
null
2017-12-17T19:45:41
2017-11-03T01:47:27
HTML
UTF-8
C++
false
false
3,445
h
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QPRINTENGINE_H #define QPRINTENGINE_H #include <QtCore/qvariant.h> #include <QtPrintSupport/qprinter.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER class Q_PRINTSUPPORT_EXPORT QPrintEngine { public: virtual ~QPrintEngine() {} enum PrintEnginePropertyKey { PPK_CollateCopies, PPK_ColorMode, PPK_Creator, PPK_DocumentName, PPK_FullPage, PPK_NumberOfCopies, PPK_Orientation, PPK_OutputFileName, PPK_PageOrder, PPK_PageRect, PPK_PageSize, PPK_PaperRect, PPK_PaperSource, PPK_PrinterName, PPK_PrinterProgram, PPK_Resolution, PPK_SelectionOption, PPK_SupportedResolutions, PPK_WindowsPageSize, PPK_FontEmbedding, PPK_Duplex, PPK_PaperSources, PPK_CustomPaperSize, PPK_PageMargins, PPK_CopyCount, PPK_SupportsMultipleCopies, PPK_PaperSize = PPK_PageSize, PPK_CustomBase = 0xff00 }; virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value) = 0; virtual QVariant property(PrintEnginePropertyKey key) const = 0; virtual bool newPage() = 0; virtual bool abort() = 0; virtual int metric(QPaintDevice::PaintDeviceMetric) const = 0; virtual QPrinter::PrinterState printerState() const = 0; }; #endif // QT_NO_PRINTER QT_END_NAMESPACE QT_END_HEADER #endif // QPRINTENGINE_H
[ "hubertkuc13@gmail.com" ]
hubertkuc13@gmail.com
a7004c103c75751cc8695e8a8ab861ef83fc2c51
a7cd1fc70b9c87fc35ec3c3be5d4d3332e7ff9da
/RayTracer/PointLight.cpp
a973e88f2909295c49384e124949b9e5a6287224
[]
no_license
Thomas92330/2021_Classes
0deca281df37bc3597036ec512fa0c253b2771f0
fd6456399ba26e87964e827c060d164a772add25
refs/heads/master
2023-03-13T07:34:24.982300
2021-02-25T12:50:17
2021-02-25T12:50:17
342,186,741
0
0
null
null
null
null
UTF-8
C++
false
false
260
cpp
#include "PointLight.h" PointLight::PointLight(Vector _origine) :Light(), origine(_origine) { } PointLight::~PointLight() { } Vector PointLight::VectorL(const Vector& point) { Vector vectorL = (point - origine); vectorL.normalize(); return vectorL; }
[ "toto.tranchet@gmail.com" ]
toto.tranchet@gmail.com
13786c3a61c242a91a5d523a6a8a14c16ed8aa5f
92fc392b5e3b7517ea7535fa6986aa63cd204b8c
/CaptureGifEncoder/GifEncoder.cpp
4c9642b733c7e17dad68a2eea439bc6ee1243399
[ "MIT" ]
permissive
robmikh/CaptureGifEncoder
1709bb45a10079d8f01894908af3863a5e546daa
005771f83a36cf3b6a9549a1887cd51634dfd8f2
refs/heads/master
2023-01-12T09:05:03.069616
2022-12-27T01:52:13
2022-12-27T01:52:13
245,104,898
23
3
null
null
null
null
UTF-8
C++
false
false
8,033
cpp
#include "pch.h" #include "GifEncoder.h" namespace winrt { using namespace Windows::Graphics; using namespace Windows::Graphics::Capture; using namespace Windows::Storage::Streams; } namespace util { using namespace robmikh::common::uwp; } GifEncoder::GifEncoder( winrt::com_ptr<ID3D11Device> const& d3dDevice, winrt::com_ptr<ID3D11DeviceContext> const& d3dContext, winrt::com_ptr<ID2D1Device> const& d2dDevice, winrt::com_ptr<IWICImagingFactory2> const& wicFactory, winrt::IRandomAccessStream const& stream, winrt::SizeInt32 gifSize) { m_gifSize = gifSize; m_d3dDevice = d3dDevice; winrt::check_hresult(d2dDevice->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_NONE, m_d2dContext.put())); auto abiStream = util::CreateStreamFromRandomAccessStream(stream); // Setup WIC to encode a gif winrt::check_hresult(wicFactory->CreateEncoder(GUID_ContainerFormatGif, nullptr, m_encoder.put())); winrt::check_hresult(m_encoder->Initialize(abiStream.get(), WICBitmapEncoderNoCache)); winrt::check_hresult(wicFactory->CreateImageEncoder(d2dDevice.get(), m_imageEncoder.put())); // Write the application block // http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension winrt::com_ptr<IWICMetadataQueryWriter> metadata; winrt::check_hresult(m_encoder->GetMetadataQueryWriter(metadata.put())); { PROPVARIANT value = {}; value.vt = VT_UI1 | VT_VECTOR; value.caub.cElems = 11; std::string text("NETSCAPE2.0"); std::vector<uint8_t> chars(text.begin(), text.end()); WINRT_VERIFY(chars.size() == 11); value.caub.pElems = chars.data(); winrt::check_hresult(metadata->SetMetadataByName(L"/appext/application", &value)); } { PROPVARIANT value = {}; value.vt = VT_UI1 | VT_VECTOR; value.caub.cElems = 5; // The first value is the size of the block, which is the fixed value 3. // The second value is the looping extension, which is the fixed value 1. // The third and fourth values comprise an unsigned 2-byte integer (little endian). // The value of 0 means to loop infinitely. // The final value is the block terminator, which is the fixed value 0. std::vector<uint8_t> data({ 3, 1, 0, 0, 0 }); value.caub.pElems = data.data(); winrt::check_hresult(metadata->SetMetadataByName(L"/appext/data", &value)); } // Setup our frame compositor and texture differ m_frameCompositor = std::make_unique<FrameCompositor>(d3dDevice, d3dContext, gifSize); m_textureDiffer = std::make_unique<TextureDiffer>(d3dDevice, d3dContext, gifSize); } bool GifEncoder::ProcessFrame(winrt::Direct3D11CaptureFrame const& frame) { auto timeStamp = frame.SystemRelativeTime(); auto firstFrame = false; // Compute frame delta if (m_lastTimeStamp.count() == 0) { m_lastTimeStamp = timeStamp; firstFrame = true; } auto timeStampDelta = timeStamp - m_lastTimeStamp; // Throttle frame processing to 30fps if (!firstFrame && timeStampDelta < std::chrono::milliseconds(33)) { return false; } m_lastCandidateTimeStamp = timeStamp; auto composedFrame = m_frameCompositor->ProcessFrame(frame); return ProcessFrame(composedFrame, false); } void GifEncoder::StopEncoding() { // Repeat the last frame auto composedFrame = m_frameCompositor->RepeatFrame(m_lastCandidateTimeStamp); ProcessFrame(composedFrame, true); winrt::check_hresult(m_encoder->Commit()); } bool GifEncoder::ProcessFrame(ComposedFrame const& composedFrame, bool force) { bool updated = false; auto diff = m_textureDiffer->ProcessFrame(composedFrame.Texture); if (force && !diff.has_value()) { // Since there's no change, pick a small random part of the frame. diff = std::optional(DiffRect{ 0, 0, 5, 5 }); } if (auto diffRect = diff) { auto timeStampDelta = composedFrame.SystemRelativeTime - m_lastTimeStamp; m_lastTimeStamp = composedFrame.SystemRelativeTime; // Inflate our rect to eliminate artifacts auto inflateAmount = 1; auto left = static_cast<uint32_t>(std::max(static_cast<int32_t>(diffRect->Left) - inflateAmount, 0)); auto top = static_cast<uint32_t>(std::max(static_cast<int32_t>(diffRect->Top) - inflateAmount, 0)); auto right = static_cast<uint32_t>(std::min(static_cast<int32_t>(diffRect->Right) + inflateAmount, m_gifSize.Width)); auto bottom = static_cast<uint32_t>(std::min(static_cast<int32_t>(diffRect->Bottom) + inflateAmount, m_gifSize.Height)); // Create the frame auto textureCopy = util::CopyD3DTexture(m_d3dDevice, composedFrame.Texture, false); auto frame = std::make_shared<GifFrameImage>(textureCopy, DiffRect { left, top, right, bottom }, composedFrame.SystemRelativeTime); // Encode the frame m_previousFrame.swap(frame); if (frame != nullptr) { auto currentTime = composedFrame.SystemRelativeTime; if (force) { currentTime += timeStampDelta; } EncodeFrame(frame, currentTime); } updated = true; } return updated; } void GifEncoder::EncodeFrame(std::shared_ptr<GifFrameImage> const& frame, winrt::Windows::Foundation::TimeSpan const& currentTime) { auto diffWidth = frame->Rect.Right - frame->Rect.Left; auto diffHeight = frame->Rect.Bottom - frame->Rect.Top; auto frameDuration = currentTime - frame->TimeStamp; // Compute the frame delay auto millisconds = std::chrono::duration_cast<std::chrono::milliseconds>(frameDuration); // Use 10ms units auto frameDelay = millisconds.count() / 10; // Create a D2D bitmap winrt::com_ptr<ID2D1Bitmap1> d2dBitmap; winrt::check_hresult(m_d2dContext->CreateBitmapFromDxgiSurface(frame->Texture.as<IDXGISurface>().get(), nullptr, d2dBitmap.put())); // Setup our WIC frame (note the matching pixel format) winrt::com_ptr<IWICBitmapFrameEncode> wicFrame; winrt::check_hresult(m_encoder->CreateNewFrame(wicFrame.put(), nullptr)); winrt::check_hresult(wicFrame->Initialize(nullptr)); auto wicPixelFormat = GUID_WICPixelFormat32bppBGRA; winrt::check_hresult(wicFrame->SetPixelFormat(&wicPixelFormat)); // Write frame metadata winrt::com_ptr<IWICMetadataQueryWriter> metadata; winrt::check_hresult(wicFrame->GetMetadataQueryWriter(metadata.put())); // Delay { PROPVARIANT delayValue = {}; delayValue.vt = VT_UI2; delayValue.uiVal = static_cast<unsigned short>(frameDelay); winrt::check_hresult(metadata->SetMetadataByName(L"/grctlext/Delay", &delayValue)); } // Left { PROPVARIANT metadataValue = {}; metadataValue.vt = VT_UI2; metadataValue.uiVal = static_cast<unsigned short>(frame->Rect.Left); winrt::check_hresult(metadata->SetMetadataByName(L"/imgdesc/Left", &metadataValue)); } // Top { PROPVARIANT metadataValue = {}; metadataValue.vt = VT_UI2; metadataValue.uiVal = static_cast<unsigned short>(frame->Rect.Top); winrt::check_hresult(metadata->SetMetadataByName(L"/imgdesc/Top", &metadataValue)); } // Write the frame to our image (this must come after you write the metadata) WICImageParameters frameParams = {}; frameParams.PixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; frameParams.PixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; frameParams.DpiX = 96.0f; frameParams.DpiY = 96.0f; frameParams.Left = static_cast<float>(frame->Rect.Left); frameParams.Top = static_cast<float>(frame->Rect.Top); frameParams.PixelWidth = diffWidth; frameParams.PixelHeight = diffHeight; winrt::check_hresult(m_imageEncoder->WriteFrame(d2dBitmap.get(), wicFrame.get(), &frameParams)); winrt::check_hresult(wicFrame->Commit()); }
[ "rob.mikh@outlook.com" ]
rob.mikh@outlook.com
1eab6819a9b14a91e24f1ba29e824bcbbe55ab1b
836bebf3b9451308f6b66266323fdec68f37852f
/Tip distribution program/functions.cpp
259924ec90ad51d3b2542ea002332b558dbb2e78
[]
no_license
DaegilPyo/C-Programs
e50a0ad1e21f237e2eaad5dc973c7f1ff8b446fb
e193787f485d45fa6d7247d289eaf6787912c11d
refs/heads/master
2020-07-31T03:36:15.931632
2019-10-10T18:57:05
2019-10-10T18:57:05
210,470,805
0
0
null
null
null
null
UTF-8
C++
false
false
11,318
cpp
#include"functions.h" using namespace std; namespace function { bool Yes_Or_No() { char YON = '\0'; bool result = false; cout << " Would you like to exit Tip Rating program?(Y(y)/N(n)) : "; do { cin >> YON; clearKeyboard(); if (YON != 'N' && YON != 'n' && YON != 'Y' && YON != 'y') { cout << "Invalid value, please enter Y(y)/N(n) : "; } if (YON != 'Y' && YON != 'y') { result = true; } else if (YON != 'N' && YON != 'n') { result = false; } } while (YON != 'N' && YON != 'n' && YON != 'Y' && YON != 'y'); return result; } void clearKeyboard(void) { while (getchar() != '\n'); // empty execution code block on purpose } void pause_() { cout << "Press enter to continue ... "; cin.ignore(1000, '\n'); cout << endl; } //--------------------------------------------------------------------- void AddStaff(const res::Empinfo* emp, res::Empinfo* emp_on_shift, int NumOfStaff) { int Staff_Count = 0; int StaffNumber = 0; int StaffNumber_on_Shift[MAX_STAFF] = { 0 }; int StaffAdd = 0; int Stime = 0; int Etime = 0; for (int k = 0; k < NumOfStaff; k++) { bool This_Staff_On_Shift = false; cout << "\n ** Staff list **\n\n"; for (int i = 0; i < MAX_STAFF; i++) { if (!emp[i].isEmpty()) { This_Staff_On_Shift = false; for (int j = 0; j < MAX_STAFF; j++) { if (emp[i].getSnumber() == StaffNumber_on_Shift[i]) { This_Staff_On_Shift = true; } } if (!This_Staff_On_Shift) { cout << " - Staff Num : " << emp[i].getSnumber() << " | Name : " << setw(10) << left << emp[i].getName() << " | TipRating : " << emp[i].getTiprating() << "\n"; } Staff_Count++; } else { i = MAX_STAFF; } } //---------------------------------------------------------------------------------------------------- cout << "\n-------------------------------------------- \n"; cout << " Which staff do you want to add? \n Please enter the Staff Number : "; StaffNumber = function::getNumber(1, Staff_Count); for (int i = 0; i < MAX_STAFF; i++) { if (StaffNumber_on_Shift[i] == 0) { StaffNumber_on_Shift[i] = StaffNumber; i = MAX_STAFF; } } //---------------------------------------------------------------------------------------------------- for (int i = 0; i < MAX_STAFF; i++) { if (!emp[i].isEmpty()) { if (emp[i].getSnumber() == StaffNumber) { system("CLS"); cout << " *** Shift ***" << endl; cout <<" " << emp[i].getName() << "`s Start time : "; Stime = function::getNumber(11, 22); cout << " " << emp[i].getName() << "`s End time : "; Etime = function::getNumber(12, 23); cout << "\n\n ******* SECCESS!! *******" << endl; cout << " " << emp[i].getName() << " is added on shift.\n" << endl; pause_(); system("CLS"); res::Empinfo copy = emp[i]; emp_on_shift[StaffAdd] = copy; emp_on_shift[i].setStimeEtime(Stime, Etime); StaffAdd++; } } else { i = MAX_STAFF; } } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- void InsertMorningTips(double* Morningtips) { int M_startTime = 11; for (int i = 0; i < 6; i++) { do { cout << "--------------------\n" << " Restaurant \n" << " Mornig \n" << " Tip Inserting \n" << "--------------------" << endl; cout << " " << M_startTime << " - " << M_startTime + 1 << " Tips($) : "; cin >> Morningtips[i]; clearKeyboard(); if (Morningtips[i] < 0) { system("CLS"); cout << "**** Entered Tip amount is wrong, please enter again ****\n"; } else { system("CLS"); } } while (Morningtips[i] < 0); M_startTime++; } pause_(); system("CLS"); } void InsertNightTips(double* Nighttips) { int N_startTime = 17; for (int i = 0; i < 6; i++) { do { cout << "--------------------\n" << " Restaurant \n" << " Night \n" << " Tip Inserting \n" << "--------------------" << endl; cout << " " << N_startTime << " - " << N_startTime + 1 << " Tips($) : "; cin >> Nighttips[i]; clearKeyboard(); if (Nighttips[i] < 0) { system("CLS"); cout << "**** Entered Tip amount is wrong, please enter again ****\n"; } else { system("CLS"); } } while (Nighttips[i] < 0); N_startTime++; system("CLS"); } } void intro() { cout << "--------------------\n" << " Restaurant \n" << " Tip \n" << " Rating System \n" << "--------------------" << endl; cout<< " 1. Add staff on the shift\n" << " 2. Tip Inserting\n" << " 3. Display Tips\n" << " 4. Display all the staffs\n" << " 5. Display Time schedule\n" << " 0. exit\n" << " Enter the option : "; } void displayTips(const double* morning, const double* night, const res::Empinfo* emp, int NumOfStaff) { int option; double Mtotal = 0.0; double Ntotal = 0.0; cout << "--------------------\n" << " Restaurant \n" << " Tips \n" << " Display \n" << "--------------------" << endl; cout << "1.Display Morning Shift tips\n" << "2.Display Night Shift Tips\n" << "Enter the Option : "; option = getNumber(1, 2); if (morning[0] < 0 || night[0] < 0) { cout << "\n *****Error***** \n" << " Tips have not added yet. Please add tips first.\n" << endl; } else { if (option == 1) { int mornigStart = 11; for (int i = 0; i < 6; i++) { cout << mornigStart << " - " << mornigStart+1 << " : " << morning[i] << "$" << endl; mornigStart++; Mtotal += morning[i]; } cout << "\nTotal Morning Tips Amount : " << Mtotal << "$\n" << endl; for (int i = 0; i < NumOfStaff; i++) { if (!emp[i].isEmpty()) { if (emp[i].getEtime() <= 17) { cout << emp[i].getName() << " : " << emp[i].getTotalTip() << "$\n" << endl; } } else { i = NumOfStaff; } } } else if (option == 2) { int nightStart = 17; for (int i = 0; i < 6; i++) { cout << nightStart << " - " << nightStart + 1 << " : " << night[i] << "$" << endl; nightStart++; Ntotal += night[i]; } cout << "\nTotal Night Tips Amount : " << Ntotal << "$\n" << endl; for (int i = 0; i < NumOfStaff; i++) { if (!emp[i].isEmpty()) { if (emp[i].getStime() >= 17) { cout << emp[i].getName() << " : " << emp[i].getTotalTip() << "$\n" << endl; } } else { i = NumOfStaff; } } } } } int getNumber(int min, int max) { int Number; do { std::cin >> Number; clearKeyboard(); if (Number < min || Number > max) { cout << "*****Warning******\n" << "Please enter the number within in range ( " << min << " and " << max << " ) : "; } } while (Number < min || Number > max); return Number; } void TimeSchedule(const res::Empinfo* emp, int NumOfStaff) { cout<<"----------------------\n" << " Time Schedule \n" << " \n" << " Diplay \n" << "----------------------" << endl; int option = 0 ; cout << "1.Morning Schedule\n" << "2.Night Schedule\n" << " Enter the option : "; option = getNumber(1, 2); switch (option) { case 1: system("CLS"); cout << "----------------------\n" << " Morning Schedule \n" << " \n" << " Diplay \n" << "-----------------------\n" << endl; cout << " Name | Time shift\n"; for (int i = 0; i < NumOfStaff; i++) { if (!emp[i].isEmpty()) { if (emp[i].getStime() >= 11 && emp[i].getEtime() <= 17) { cout << "-----------------------------------------------\n" << " " << setw(11) << left << emp[i].getName() << "|" << " " << emp[i].getStime() << " - " << emp[i].getEtime() << endl; cout << endl; } }else{ i = NumOfStaff; } } cout << "-----------------------------------------------" << endl; function::pause_(); system("CLS"); break; case 2: system("CLS"); cout << "----------------------\n" << " Night Schedule \n" << " \n" << " Diplay \n" << "-----------------------\n" << endl; cout << " Name | Time shift\n"; for (int i = 0; i < NumOfStaff; i++) { if (!emp[i].isEmpty() ) { if (emp[i].getStime() >= 17) { cout << "-----------------------------------------------\n" << " " << setw(11) << left << emp[i].getName() << "|" << " " << emp[i].getStime() << " - " << emp[i].getEtime() << endl; cout << endl; } } else { i = NumOfStaff; } } cout << "-----------------------------------------------" << endl; function::pause_(); system("CLS"); break; default: break; } } //--------------------------------------------------------------------- void addTips( res::Empinfo* emp, double* morning, double* night) { int Mshift[6][MAX_STAFF] = { 0 }; int Nshift[6][MAX_STAFF] = { 0 }; double MTiprateSum[6] = { 0 }; double NTiprateSum[6] = { 0 }; //----------------------------------------------------------------- for (int i = 0; i < 6; i++) { for (int j = 0; j < MAX_STAFF; j++) { if (!emp[j].isEmpty()) { if (emp[j].getEtime() <= 17) { if (emp[j].getStime() <= i + 12 && emp[j].getEtime() >= i + 12) { Mshift[i][j] = emp[j].getSnumber(); MTiprateSum[i] += emp[j].getTiprating(); } } else if (emp[j].getStime() >= 17) { if (emp[j].getStime() <= i + 17 && emp[j].getEtime() >= i + 17) { Nshift[i][j] = emp[j].getSnumber(); NTiprateSum[i] += emp[j].getTiprating(); } } } else { j = MAX_STAFF; } } } //----------------------------------------------------------------- for (int i = 0; i < 6; i++) { for (int j = 0; j < MAX_STAFF; j++) { for (int k = 0; k < MAX_STAFF; k++) { if (Mshift[i][j] == emp[k].getSnumber() ) { emp[k].addTotalTip((morning[i]/MTiprateSum[i])*emp[k].getTiprating()); k = MAX_STAFF; } } } } for (int i = 0; i < 6; i++) { for (int j = 0; j < MAX_STAFF; j++) { for (int k = 0; k < MAX_STAFF; k++) { if (Nshift[i][j] == emp[k].getSnumber()) { emp[k].addTotalTip((night[i] / NTiprateSum[i]) * emp[k].getTiprating()); k = MAX_STAFF; } } } } //----------------------------------------------------------------- } }
[ "noreply@github.com" ]
DaegilPyo.noreply@github.com
d23b5f1c74655ec67782169a182ddeffce6d17a0
56148fb60af13e0b7464bf19248ee019998be461
/Delta-2A_Windows_Demo/sdk/app/frame_grabber/SerialSelDlg.cpp
005701fa42121c8f35ae93d563a3edef727fc304
[]
no_license
shuimuyangsha/Lider_Delta2A
14a99cd31b783adb8d02c85aea7c119d931db370
452b1df04bbc7f3b35d856bc3d7628b8b409e1a5
refs/heads/master
2022-11-08T05:59:07.940341
2020-07-04T08:41:35
2020-07-04T08:41:35
276,083,115
1
1
null
null
null
null
UTF-8
C++
false
false
1,808
cpp
/* * RSLIDAR System * Driver Interface * * Copyright 2015 RS Team * All rights reserved. * * Author: ruishi, Data:2015-12-25 * */ // SerialSelDlg.cpp : implementation of the CSerialSelDlg class // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "SerialSelDlg.h" UINT16 CSerialSelDlg::FindSerialPort() { CRegKey RegKey; if (RegKey.Open(HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm") == ERROR_SUCCESS) { while (true) { char ValueName[_MAX_PATH]; unsigned char ValueData[_MAX_PATH]; DWORD nValueSize = _MAX_PATH; DWORD nDataSize = _MAX_PATH; DWORD nType; if (::RegEnumValue(HKEY(RegKey), SerialNumber, ValueName, &nValueSize, NULL, &nType, ValueData, &nDataSize) == ERROR_NO_MORE_ITEMS) { break; } PortList[SerialNumber++] = ValueData; } } return SerialNumber; } CSerialSelDlg::CSerialSelDlg() : selectedID(-1) { } LRESULT CSerialSelDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { CenterWindow(GetParent()); this->DoDataExchange(); char buf[100]; SerialNumber = 0; FindSerialPort(); for (int pos = 0; pos < SerialNumber; ++pos) { sprintf(buf, "%s", PortList[pos]); m_sel_box.AddString(buf); } m_sel_box.SetCurSel(0); selectedID = 0; return TRUE; } LRESULT CSerialSelDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { EndDialog(wID); return 0; } LRESULT CSerialSelDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { EndDialog(wID); return 0; } LRESULT CSerialSelDlg::OnCbnSelchangeCombSerialSel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { selectedID = m_sel_box.GetCurSel(); return 0; }
[ "dongxh@dadaoii.com" ]
dongxh@dadaoii.com
5c7c21b9bf44653a775253b4dcb1de82a82ea07f
1ae7e3c269e0bd2df0bc725a33f307971816d40d
/app/src/main/cpp/boost/range/detail/value_type.hpp
033783fe8cae2ef10f1b8c0e958c093f975ceedf
[]
no_license
HOTFIGHTER/XmLogger
347902372bf2afc88cf26d2342434c1ea556201f
433a0420c99a883bd65e99fd5f04ac353ac6d7b6
refs/heads/master
2021-02-18T08:46:12.122640
2020-03-05T14:16:39
2020-03-05T14:16:39
245,178,943
2
0
null
null
null
null
UTF-8
C++
false
false
1,723
hpp
// Boost.Range library // // Copyright Thorsten Ottosen 2003-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // For more information, see http://www.boost.org/libs/range/ // #ifndef BOOST_RANGE_DETAIL_VALUE_TYPE_HPP #define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP #include <boost/range/detail/common.hpp> #include <boost/range/detail/remove_extent.hpp> #include <boost/iterator/iterator_traits.hpp> ////////////////////////////////////////////////////////////////////////////// // missing partial specialization workaround. ////////////////////////////////////////////////////////////////////////////// namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace range_detail { template<typename T> struct range_value_type_; template<> struct range_value_type_<std_container_> { template<typename C> struct pts { typedef BOOST_RANGE_DEDUCED_TYPENAME C ::value_type type; }; }; template<> struct range_value_type_<std_pair_> { template<typename P> struct pts { typedef BOOST_RANGE_DEDUCED_TYPENAME mars_boost ::iterator_value<BOOST_RANGE_DEDUCED_TYPENAME P::first_type>::type type; }; }; template<> struct range_value_type_<array_> { template<typename T> struct pts { typedef BOOST_DEDUCED_TYPENAME remove_extent <T>::type type; }; }; } template<typename C> class range_value { typedef BOOST_DEDUCED_TYPENAME range_detail ::range<C>::type c_type; public: typedef BOOST_DEDUCED_TYPENAME range_detail ::range_value_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; }; } #endif
[ "linfeng.yu@ximalaya.com" ]
linfeng.yu@ximalaya.com
9447dccb97b4bddebcb7a3a839647d688c044c39
50d821d66784a620b6c37af7314e27fdcef25b73
/src/Renderer.cpp
b292672b0e21b701dfbd20e4684bb2d7b6356240
[]
no_license
Munstar/VisRTX
6b22fa3097dddc24521b5812b697c01b5f66113c
bacc0c85467cf4c82a9b844e9a0e46ba248d08d2
refs/heads/master
2020-07-06T11:05:58.550967
2019-08-13T14:01:46
2019-08-13T14:01:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
32,271
cpp
/* * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of NVIDIA CORPORATION nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "Renderer.h" #include "FrameBuffer.h" #include "Model.h" #include "ProgramLoader.h" #include "Camera.h" #include "Texture.h" #include "Material.h" #include "Light.h" #include "Geometry.h" #include "Config.h" #include "Pathtracer/Light.h" #include "Pathtracer/Pick.h" #include <fstream> #include <algorithm> #include <cstring> #define UPDATE_LAUNCH_PARAMETER(src, dst) if (src != dst) { dst = src; this->launchParametersDirty = true; } namespace VisRTX { namespace Impl { Renderer::Renderer() { // Load programs ProgramLoader& loader = ProgramLoader::Get(); this->rayGenProgram = loader.LoadPathtracerProgram("RayGen"); this->rayGenPickProgram = loader.LoadPathtracerProgram("RayGenPick"); this->missProgram = loader.LoadPathtracerProgram("Miss"); this->missPickProgram = loader.LoadPathtracerProgram("MissPick"); this->bufferCastProgram = loader.LoadPathtracerProgram("BufferCast"); // Defaults this->SetSamplesPerPixel(1); this->SetAlphaCutoff(1e-3f); this->SetWriteBackground(true); this->SetClippingPlanes(0, nullptr); uint32_t minBounces = 4; uint32_t maxBounces = 8; bool toneMapping = true; DenoiserType denoiser = DenoiserType::NONE; float clampDirect = 0.0f; float clampIndirect = 1e20f; bool sampleAllLights = true; // Env var overrides if (const char* str = std::getenv("VISRTX_MIN_BOUNCES")) { minBounces = (uint32_t)atoi(str); this->minBouncesFixed = true; } if (const char* str = std::getenv("VISRTX_MAX_BOUNCES")) { maxBounces = (uint32_t)atoi(str); this->maxBouncesFixed = true; } if (const char* str = std::getenv("VISRTX_TONE_MAPPING")) { toneMapping = atoi(str) > 0; this->toneMappingFixed = true; } if (const char* str = std::getenv("VISRTX_DENOISER")) { denoiser = (atoi(str) > 0) ? DenoiserType::AI : DenoiserType::NONE; this->denoiserFixed = true; } if (const char* str = std::getenv("VISRTX_CLAMP_DIRECT")) { clampDirect = (float)atof(str); this->clampDirectFixed = true; } if (const char* str = std::getenv("VISRTX_CLAMP_INDIRECT")) { clampIndirect = (float)atof(str); this->clampIndirectFixed = true; } if (const char* str = std::getenv("VISRTX_SAMPLE_ALL_LIGHTS")) { sampleAllLights = atoi(str) > 0; this->sampleAllLightsFixed = true; } this->ignoreOverrides = true; this->SetNumBounces(minBounces, maxBounces); this->SetToneMapping(toneMapping, 2.2f, Vec3f(1.0f, 1.0f, 1.0f), 1.0f, 0.8f, 0.2f, 1.2f, 0.8f); this->SetDenoiser(denoiser); this->SetFireflyClamping(clampDirect, clampIndirect); this->SetSampleAllLights(sampleAllLights); this->ignoreOverrides = false; // Debug warnings #ifdef TEST_DIRECT_ONLY std::cout << "*** Warning: Testing mode! Brute force (light evaluation) only ***" << std::endl; #endif #ifdef TEST_NEE_ONLY std::cout << "*** Warning: Testing mode! Next event estimation (light sampling) only ***" << std::endl; #endif #ifdef TEST_MIS std::cout << "*** Warning: Testing mode! Multiple importance sampling ***" << std::endl; #endif } Renderer::~Renderer() { if (this->model) this->model->Release(); if (this->camera) this->camera->Release(); for (VisRTX::Light* light : this->lights) if (light) light->Release(); Destroy(rayGenProgram.get()); Destroy(rayGenPickProgram.get()); Destroy(missProgram.get()); Destroy(missPickProgram.get()); Destroy(bufferCastProgram.get()); Destroy(basicMaterialParametersBuffer.get()); Destroy(mdlMaterialParametersBuffer.get()); Destroy(directLightsBuffer.get()); Destroy(missLightsBuffer.get()); Destroy(clippingPlanesBuffer.get()); Destroy(pickBuffer.get()); Destroy(launchParametersBuffer.get()); } void Renderer::Render(VisRTX::FrameBuffer* frameBuffer) { if (!frameBuffer) return; // Initialization prepass if (!this->Init()) return; optix::Context context = OptiXContext::Get(); // Framebuffer VisRTX::Impl::FrameBuffer* fb = dynamic_cast<VisRTX::Impl::FrameBuffer*>(frameBuffer); const int accumulationBufferId = fb->accumulationBuffer->getId(); const int frameBufferId = fb->frameBuffer->getId(); const int ucharFrameBufferId = fb->ucharFrameBuffer->getId(); const int depthBufferId = fb->depthBuffer->getId(); const int useAIDenoiser = ((this->denoiser == DenoiserType::AI) && fb->denoiserStage) ? 1 : 0; const int writeFrameBuffer = (fb->format == FrameBufferFormat::RGBA32F || useAIDenoiser) ? 1 : 0; const int writeUcharFrameBuffer = (fb->format == FrameBufferFormat::RGBA8 && !useAIDenoiser) ? 1 : 0; UPDATE_LAUNCH_PARAMETER((int) fb->width, this->launchParameters.width); UPDATE_LAUNCH_PARAMETER((int) fb->height, this->launchParameters.height); UPDATE_LAUNCH_PARAMETER(accumulationBufferId, this->launchParameters.accumulationBuffer); UPDATE_LAUNCH_PARAMETER(frameBufferId, this->launchParameters.frameBuffer); UPDATE_LAUNCH_PARAMETER(ucharFrameBufferId, this->launchParameters.ucharFrameBuffer); UPDATE_LAUNCH_PARAMETER(depthBufferId, this->launchParameters.depthBuffer); UPDATE_LAUNCH_PARAMETER(fb->depthClipMin, this->launchParameters.clipMin); UPDATE_LAUNCH_PARAMETER(fb->depthClipMax, this->launchParameters.clipMax); UPDATE_LAUNCH_PARAMETER(fb->depthClipDiv, this->launchParameters.clipDiv); UPDATE_LAUNCH_PARAMETER(useAIDenoiser, this->launchParameters.useAIDenoiser); UPDATE_LAUNCH_PARAMETER(writeFrameBuffer, this->launchParameters.writeFrameBuffer); UPDATE_LAUNCH_PARAMETER(writeUcharFrameBuffer, this->launchParameters.writeUcharFrameBuffer); // Material buffers if (BasicMaterial::parametersDirty) { this->basicMaterialParametersBuffer->setSize(BasicMaterial::parameters.GetNumElements()); const uint32_t numBytes = BasicMaterial::parameters.GetNumBytes(); if (numBytes > 0) { memcpy(this->basicMaterialParametersBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD), BasicMaterial::parameters.GetData(), numBytes); this->basicMaterialParametersBuffer->unmap(); } BasicMaterial::parametersDirty = false; } if (MDLMaterial::parametersDirty) { this->mdlMaterialParametersBuffer->setSize(MDLMaterial::parameters.GetNumElements()); const uint32_t numBytes = MDLMaterial::parameters.GetNumBytes(); if (numBytes > 0) { memcpy(this->mdlMaterialParametersBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD), MDLMaterial::parameters.GetData(), numBytes); this->mdlMaterialParametersBuffer->unmap(); } MDLMaterial::parametersDirty = false; } // Camera VisRTX::Impl::Camera* camera = dynamic_cast<VisRTX::Impl::Camera*>(this->camera); if (camera->dirty) { const optix::float3 cam_W = optix::normalize(camera->direction); const optix::float3 cam_U = optix::normalize(optix::cross(camera->direction, camera->up)); const optix::float3 cam_V = optix::normalize(optix::cross(cam_U, cam_W)); if (this->camera->GetType() == CameraType::PERSPECTIVE) { VisRTX::Impl::PerspectiveCamera* perspectiveCam = dynamic_cast<VisRTX::Impl::PerspectiveCamera*>(this->camera); const float vlen = tanf(0.5f * perspectiveCam->fovy * M_PIf / 180.0f); const float ulen = vlen * perspectiveCam->aspect; this->launchParameters.cameraType = PERSPECTIVE_CAMERA; this->launchParameters.pos = perspectiveCam->position; this->launchParameters.U = cam_U * ulen; this->launchParameters.V = cam_V * vlen; this->launchParameters.W = cam_W; this->launchParameters.focalDistance = perspectiveCam->focalDistance; this->launchParameters.apertureRadius = perspectiveCam->apertureRadius; } else if (this->camera->GetType() == CameraType::ORTHOGRAPHIC) { VisRTX::Impl::OrthographicCamera* orthoCam = dynamic_cast<VisRTX::Impl::OrthographicCamera*>(this->camera); this->launchParameters.cameraType = ORTHOGRAPHIC_CAMERA; this->launchParameters.pos = orthoCam->position; this->launchParameters.U = cam_U; this->launchParameters.V = cam_V; this->launchParameters.W = cam_W; this->launchParameters.orthoWidth = orthoCam->height * orthoCam->aspect; this->launchParameters.orthoHeight = orthoCam->height; } this->launchParameters.imageBegin = camera->imageBegin; this->launchParameters.imageSize = camera->imageEnd - camera->imageBegin; camera->dirty = false; this->launchParametersDirty = true; } // Launch context for (uint32_t i = 0; i < this->samplesPerPixel; ++i) { UPDATE_LAUNCH_PARAMETER((int) fb->frameNumber, this->launchParameters.frameNumber); if (this->launchParametersDirty) { memcpy(this->launchParametersBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD), &this->launchParameters, sizeof(LaunchParameters)); this->launchParametersBuffer->unmap(); this->launchParametersDirty = false; } // Validate only after all nodes have completed the prepass so all context subcomponents have been initialized if (!this->contextValidated) { try { context->validate(); } catch (optix::Exception& e) { throw VisRTX::Exception(Error::UNKNOWN_ERROR, e.getErrorString().c_str()); } this->contextValidated = true; } // Render frame #ifdef VISRTX_USE_DEBUG_EXCEPTIONS try { #endif const bool lastSample = (i == samplesPerPixel - 1); if (lastSample && useAIDenoiser && fb->frameNumber < this->blendDelay + this->blendDuration) { float blend = 0.0f; if (fb->frameNumber >= this->blendDelay) blend = (float)(fb->frameNumber - this->blendDelay) / (float)this->blendDuration; fb->denoiserBlend->setFloat(blend); fb->denoiserCommandList->execute(); } else { context->launch(RENDER_ENTRY_POINT, fb->width, fb->height); } #ifdef VISRTX_USE_DEBUG_EXCEPTIONS } catch (optix::Exception& e) { throw VisRTX::Exception(Error::UNKNOWN_ERROR, e.getErrorString().c_str()); } #endif // Increase frame number fb->frameNumber++; } } /* * Common per-frame initialization used by both render and pick. */ bool Renderer::Init() { if (!this->model) return false; if (!this->camera) return false; optix::Context context = OptiXContext::Get(); /* * On-demand initialization */ if (!this->initialized) { #ifdef VISRTX_USE_DEBUG_EXCEPTIONS context->setExceptionProgram(RENDER_ENTRY_POINT, ProgramLoader::Get().exceptionProgram); #endif // Launch parameters this->launchParametersBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->launchParametersBuffer->setElementSize(sizeof(LaunchParameters)); this->launchParametersBuffer->setSize(1); context["launchParameters"]->setBuffer(this->launchParametersBuffer); //this->rayGenProgram["launchParameters"]->setBuffer(this->launchParametersBuffer); //this->rayGenPickProgram["launchParameters"]->setBuffer(this->launchParametersBuffer); //this->bufferCastProgram["launchParameters"]->setBuffer(this->launchParametersBuffer); //this->missProgram["launchParameters"]->setBuffer(this->launchParametersBuffer); //this->missPickProgram["launchParameters"]->setBuffer(this->launchParametersBuffer); // Material buffers (global buffers shared across renderers/materials) this->basicMaterialParametersBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->basicMaterialParametersBuffer->setElementSize(sizeof(BasicMaterialParameters)); this->basicMaterialParametersBuffer->setSize(0); context["basicMaterialParameters"]->setBuffer(this->basicMaterialParametersBuffer); this->mdlMaterialParametersBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->mdlMaterialParametersBuffer->setElementSize(sizeof(MDLMaterialParameters)); this->mdlMaterialParametersBuffer->setSize(0); context["mdlMaterialParameters"]->setBuffer(this->mdlMaterialParametersBuffer); // Light buffers this->directLightsBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->directLightsBuffer->setElementSize(sizeof(::Light)); this->directLightsBuffer->setSize(0); this->missLightsBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->missLightsBuffer->setElementSize(sizeof(::Light)); this->missLightsBuffer->setSize(0); this->rayGenProgram["lights"]->setBuffer(this->directLightsBuffer); this->missProgram["lights"]->setBuffer(this->missLightsBuffer); this->missPickProgram["lights"]->setBuffer(this->missLightsBuffer); // Clipping planes buffer this->clippingPlanesBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_USER); this->clippingPlanesBuffer->setElementSize(sizeof(::ClippingPlane)); this->clippingPlanesBuffer->setSize(0); // TODO bigger? this->launchParameters.clippingPlanesBuffer = this->clippingPlanesBuffer->getId(); // Pick buffer this->pickBuffer = context->createBuffer(RT_BUFFER_OUTPUT, RT_FORMAT_USER); this->pickBuffer->setElementSize(sizeof(PickStruct)); this->pickBuffer->setSize(1); this->rayGenPickProgram["pickResult"]->setBuffer(this->pickBuffer); this->initialized = true; } /* * Programs */ context->setRayGenerationProgram(RENDER_ENTRY_POINT, this->rayGenProgram); context->setMissProgram(RADIANCE_RAY_TYPE, this->missProgram); context->setRayGenerationProgram(BUFFER_CAST_ENTRY_POINT, this->bufferCastProgram); context->setRayGenerationProgram(PICK_ENTRY_POINT, this->rayGenPickProgram); context->setMissProgram(PICK_RAY_TYPE, this->missPickProgram); /* * Lights */ // Update dirty lights for (VisRTX::Light* light : this->lights) { VisRTX::Impl::Light* l = dynamic_cast<VisRTX::Impl::Light*>(light); if (l->dirty) { this->lightsNeedUpdate = true; l->dirty = false; } } // Keep list of light geometries up to date VisRTX::Impl::Model* modelImpl = dynamic_cast<VisRTX::Impl::Model*>(this->model); modelImpl->UpdateLightGeometries(&this->lights); // Update light buffers if (this->lightsNeedUpdate) { this->lightsNeedUpdate = false; std::vector<::Light> activeDirectLights; std::vector<::Light> activeMissLights; this->pickLights.clear(); for (VisRTX::Light* light : this->lights) { ::Light tmp; if (dynamic_cast<VisRTX::Impl::Light*>(light)->Set(tmp)) { // Add light to light buffer if (tmp.type == ::Light::POSITIONAL || tmp.type == ::Light::QUAD || tmp.type == ::Light::SPOT || tmp.type == ::Light::DIRECTIONAL) { activeDirectLights.push_back(tmp); } if (tmp.type == ::Light::AMBIENT || tmp.type == ::Light::HDRI || (tmp.type == ::Light::DIRECTIONAL && tmp.angularDiameter > 0.0f)) { activeMissLights.push_back(tmp); } // Update pick lights this->pickLights[tmp.id] = light; } } // Update buffers this->directLightsBuffer->setSize(activeDirectLights.size()); if (!activeDirectLights.empty()) { memcpy(this->directLightsBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD), &activeDirectLights[0], activeDirectLights.size() * sizeof(::Light)); this->directLightsBuffer->unmap(); } this->missLightsBuffer->setSize(activeMissLights.size()); if (!activeMissLights.empty()) { memcpy(this->missLightsBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD), &activeMissLights[0], activeMissLights.size() * sizeof(::Light)); this->missLightsBuffer->unmap(); } UPDATE_LAUNCH_PARAMETER((int)activeDirectLights.size(), this->launchParameters.numLightsDirect); UPDATE_LAUNCH_PARAMETER((int)activeMissLights.size(), this->launchParameters.numLightsMiss); } // Check if any hit is required int disableAnyHit = (this->launchParameters.numClippingPlanes <= 0) ? 1 : 0; if (disableAnyHit) { for (VisRTX::Light* light : this->lights) { VisRTX::Impl::Light* l = dynamic_cast<VisRTX::Impl::Light*>(light); if (!l->visible || l->GetType() == VisRTX::LightType::SPOT) { disableAnyHit = 0; break; } if (l->GetType() == VisRTX::LightType::QUAD) { // Only need anyhit for one-sided quad lights (spot lights are always one-sided) VisRTX::Impl::QuadLight* q = dynamic_cast<VisRTX::Impl::QuadLight*>(light); if (!q->twoSided) { disableAnyHit = 0; break; } } } } UPDATE_LAUNCH_PARAMETER(disableAnyHit, this->launchParameters.disableAnyHit); return true; } bool Renderer::Pick(const Vec2f& screenPos, PickResult& result) { if (!this->Init()) return false; optix::Context context = OptiXContext::Get(); // Compute camera ray VisRTX::Impl::Camera* camera = dynamic_cast<VisRTX::Impl::Camera*>(this->camera); optix::float3 rayOrigin; optix::float3 rayDirection; const Vec2f pixel(2.0f * screenPos.x - 1.0f, 2.0f * (1.0f - screenPos.y) - 1.0f); const optix::float3 W = optix::normalize(camera->direction); const optix::float3 U = optix::normalize(optix::cross(camera->direction, camera->up)); const optix::float3 V = optix::normalize(optix::cross(U, W)); if (this->camera->GetType() == CameraType::PERSPECTIVE) { VisRTX::Impl::PerspectiveCamera* perspectiveCam = dynamic_cast<VisRTX::Impl::PerspectiveCamera*>(this->camera); const float vlen = tanf(0.5f * perspectiveCam->fovy * M_PIf / 180.0f); const float ulen = vlen * perspectiveCam->aspect; rayOrigin = perspectiveCam->position; rayDirection = optix::normalize(pixel.x * ulen * U + pixel.y * vlen * V + W); } else if (this->camera->GetType() == CameraType::ORTHOGRAPHIC) { VisRTX::Impl::OrthographicCamera* orthoCam = dynamic_cast<VisRTX::Impl::OrthographicCamera*>(this->camera); rayOrigin = orthoCam->position + 0.5f * (pixel.x * orthoCam->height * orthoCam->aspect * U + pixel.y * orthoCam->height * V); rayDirection = W; } this->rayGenPickProgram["rayOrigin"]->setFloat(rayOrigin); this->rayGenPickProgram["rayDirection"]->setFloat(rayDirection); context->launch(PICK_ENTRY_POINT, 1); // Extract result bool hit = false; result.geometry = nullptr; result.geometryHit = false; result.light = nullptr; result.lightHit = false; result.primitiveIndex = 0; result.position = Vec3f(0.0f, 0.0f, 0.0f); PickStruct* pick = static_cast<PickStruct*>(this->pickBuffer->map(0, RT_BUFFER_MAP_READ)); if (pick->geometryId != 0) { result.geometry = dynamic_cast<VisRTX::Impl::Model*>(this->model)->pickGeometries[pick->geometryId]; result.geometryHit = true; result.primitiveIndex = pick->primIndex; hit = true; } if (pick->lightId != 0) { result.lightHit = true; result.light = this->pickLights[pick->lightId]; hit = true; } if (hit) { optix::float3 pos = rayOrigin + pick->t * rayDirection; result.position = Vec3f(pos.x, pos.y, pos.z); } this->pickBuffer->unmap(); return hit; } void Renderer::SetCamera(VisRTX::Camera* camera) { if (camera != this->camera) { if (this->camera) this->camera->Release(); this->camera = camera; if (this->camera) { this->camera->Retain(); // Mark this camera as dirty to enforce update dynamic_cast<VisRTX::Impl::Camera*>(this->camera)->dirty = true; } } } void Renderer::SetModel(VisRTX::Model* model) { if (model != this->model) { // Remove lights from current model before losing it if (this->model) { dynamic_cast<VisRTX::Impl::Model*>(this->model)->UpdateLightGeometries(nullptr); this->model->Release(); } this->model = model; if (this->model) { this->model->Retain(); optix::Context context = OptiXContext::Get(); VisRTX::Impl::Model* m = dynamic_cast<VisRTX::Impl::Model*>(this->model); this->rayGenProgram["topObject"]->set(m->superGroup); this->rayGenPickProgram["topObject"]->set(m->superGroup); } } } void Renderer::AddLight(VisRTX::Light* light) { if (!light) return; auto it = this->lights.find(light); if (it == this->lights.end()) { this->lights.insert(light); light->Retain(); } } void Renderer::RemoveLight(VisRTX::Light* light) { if (!light) return; auto it = this->lights.find(light); if (it != this->lights.end()) { this->lights.erase(it); light->Release(); } } void Renderer::SetClippingPlanes(uint32_t numPlanes, ClippingPlane* planes) { UPDATE_LAUNCH_PARAMETER(numPlanes, this->launchParameters.numClippingPlanes); if (numPlanes > 0) { this->clippingPlanesBuffer->setSize(numPlanes); ::ClippingPlane* dst = static_cast<::ClippingPlane*>(this->clippingPlanesBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD)); for (uint32_t i = 0; i < numPlanes; ++i) { dst[i].coefficients.x = planes[i].normal.x; // a dst[i].coefficients.y = planes[i].normal.y; // b dst[i].coefficients.z = planes[i].normal.z; // c dst[i].coefficients.w = -optix::dot(make_float3(planes[i].position), make_float3(planes[i].normal)); // d dst[i].primaryRaysOnly = planes[i].primaryRaysOnly ? 1 : 0; } this->clippingPlanesBuffer->unmap(); } } void Renderer::SetToneMapping(bool enabled, float gamma, const Vec3f& colorBalance, float whitePoint, float burnHighlights, float crushBlacks, float saturation, float brightness) { if (this->toneMappingFixed && !this->ignoreOverrides) return; const int toneMapping = enabled ? 1 : 0; UPDATE_LAUNCH_PARAMETER(toneMapping, this->launchParameters.toneMapping); if (toneMapping) { const optix::float3 colorBalance2 = optix::make_float3(colorBalance.x, colorBalance.y, colorBalance.z); const float invGamma = 1.0f / gamma; const float invWhitePoint = brightness / whitePoint; const float crushBlacks2 = crushBlacks + crushBlacks + 1.0f; UPDATE_LAUNCH_PARAMETER(colorBalance2, this->launchParameters.colorBalance); UPDATE_LAUNCH_PARAMETER(invGamma, this->launchParameters.invGamma); UPDATE_LAUNCH_PARAMETER(invWhitePoint, this->launchParameters.invWhitePoint); UPDATE_LAUNCH_PARAMETER(burnHighlights, this->launchParameters.burnHighlights); UPDATE_LAUNCH_PARAMETER(crushBlacks2, this->launchParameters.crushBlacks); UPDATE_LAUNCH_PARAMETER(saturation, this->launchParameters.saturation); } } void Renderer::SetDenoiser(DenoiserType denoiser) { if (this->denoiserFixed && !this->ignoreOverrides) return; this->denoiser = denoiser; // TODO expose in API? this->blendDelay = 20; this->blendDuration = 1000; } void Renderer::SetSamplesPerPixel(uint32_t spp) { this->samplesPerPixel = spp; } void Renderer::SetAlphaCutoff(float alphaCutoff) { UPDATE_LAUNCH_PARAMETER(alphaCutoff, this->launchParameters.alphaCutoff); } void Renderer::SetNumBounces(uint32_t minBounces, uint32_t maxBounces) { if (!this->minBouncesFixed || this->ignoreOverrides) UPDATE_LAUNCH_PARAMETER((int) minBounces, this->launchParameters.numBouncesMin); if (!this->maxBouncesFixed || this->ignoreOverrides) UPDATE_LAUNCH_PARAMETER((int) maxBounces, this->launchParameters.numBouncesMax); } void Renderer::SetWriteBackground(bool writeBackground) { const int wb = writeBackground ? 1 : 0; UPDATE_LAUNCH_PARAMETER(wb, this->launchParameters.writeBackground); } void Renderer::SetFireflyClamping(float direct, float indirect) { if (!this->clampDirectFixed || this->ignoreOverrides) UPDATE_LAUNCH_PARAMETER(direct, this->launchParameters.fireflyClampingDirect); if (!this->clampIndirectFixed || this->ignoreOverrides) UPDATE_LAUNCH_PARAMETER(indirect, this->launchParameters.fireflyClampingIndirect); } void Renderer::SetSampleAllLights(bool sampleAllLights) { if (!this->sampleAllLightsFixed || this->ignoreOverrides) { const int all = sampleAllLights ? 1 : 0; UPDATE_LAUNCH_PARAMETER(all, this->launchParameters.sampleAllLights); } } } }
[ "tbiedert@nvidia.com" ]
tbiedert@nvidia.com
aef45e542988c33f7dce842357a162004bd58fc7
c90ce2d1e2b96409e20fef94af1207d5543cddec
/sw/src/sw/ctrl/RootControl.cpp
9bcf606e2fefbde4c03382c2e25336b502e763e3
[]
no_license
definedD4/SlickWindows
2f58407a14088117683df073bdd5d83fc686d47f
4e538f6447acc8ec923ad297ab08eb814b74ddd8
refs/heads/master
2021-01-21T11:44:54.781130
2016-05-11T16:04:04
2016-05-11T16:04:04
49,780,757
0
0
null
null
null
null
UTF-8
C++
false
false
1,026
cpp
#include "RootControl.h" namespace sw { RootControl::RootControl(Window* owner) : ControlParrent(), m_Owner(owner) { } RootControl::~RootControl() { delete m_Content; } Size RootControl::getContainerArea(ControlBase* control) const { ASSERT(m_Owner != nullptr) ASSERT(control == m_Content) return m_Owner->getSize(); } //Point RootControl::transformToWindowSpace(Point point, const ControlBase* const control) const { // return point; //} Renderer RootControl::getRenderer(ControlBase* control) const { ASSERT(control == m_Content) ASSERT(m_Owner != nullptr) return Renderer(m_Owner->getRenderTarget()); } void RootControl::setContent(ControlBase* content) { if (m_Content != nullptr) { delete m_Content; } ASSERT(content != nullptr) m_Content = content; m_Content->setParrent(static_cast<ControlParrent*>(this)); } void RootControl::render() { m_Content->render(); } void RootControl::resize() { m_Content->resize(); } }
[ "definedd4@gmail.com" ]
definedd4@gmail.com
b4a0faec69758bffd52705708585f1b0ae4fcb07
74abda4c78e009363a64dbca2747ff8c44d406b1
/Exercicios_Aulas/Exercicios extras/Exercicio3.cpp
3c42a23cdafa17907396d6714a2d8af84f0923d5
[]
no_license
JonasAntonio/Algoritmos
12863b1f954fb51a8f676e872931780ac5e35ad0
cd9f69f3233cc1b03c33f4af182f3d83b477ac4b
refs/heads/master
2020-03-10T17:53:31.892145
2018-04-14T11:58:42
2018-04-14T11:58:42
129,511,366
0
0
null
null
null
null
UTF-8
C++
false
false
1,815
cpp
#include<stdio.h> int main() { int p,s,be; int a,b,c; p=1,2,3,4; s=1,2,3,4; b=1,2,3,4; //Prato principal printf("Prato principal: \n"); printf("1.Vegetariano\n"); printf("2.Peixe\n"); printf("3.Frango\n"); printf("4.Carne de Porco\n"); scanf("%d",&p); if(p>4 || p<1) { printf("Comando invalido\n\n"); a=0; } else if(p==1) { printf("Vegetariano, 180 cal.\n\n"); a=180; } else if(p==2) { printf("Peixe, 230 cal.\n\n"); a=230; } else if(p==3) { printf("Frango, 250 cal.\n\n"); a=250; } else if(p==4) { printf("Carne de Porco, 350 cal.\n\n"); a=350; } //Sobremesa printf("Sobremesa: \n"); printf("1.Aacaxi\n"); printf("2.Sorvete diet\n"); printf("3.Mousse diet\n"); printf("4.Mousse chocolate\n"); scanf("%d", &s); if(s>4 || s<1) { printf("Comando invalido\n\n"); b=0; } else if(s==1) { printf("Abacaxi, 75 cal.\n\n"); b=75; } else if(s==2) { printf("Sorvete diet, 110 cal.\n\n"); b=110; } else if(s==3) { printf("Mousse diet, 170 cal.\n\n"); b=170; } else if(s==4) { printf("Mousse chocolate, 200 cal.\n\n"); b=200; } //Bebida printf("Bebida\n"); printf("1.cha\n"); printf("2.Suco de Laranja\n"); printf("3.Suco de Melao\n"); printf("4.Refrigerante\n"); scanf("%d",&be); if(be>4 || be<1) { printf("Comando invalido\n\n"); c=0; } else if(be==1) { printf("Cha, 20 cal.\n\n"); c=20; } else if(be==2) { printf("Suco de Laranja, 70 cal.\n\n"); c=70; } else if(be==3) { printf("Suco de Melao, 100 cal.\n\n"); c=100; } else if(be==4) { printf("Refrigerante, 120 cal.\n\n"); c=120; } //Total de calorias printf("Total de calorias: %d calorias.\n",a+b+c); }
[ "noreply@github.com" ]
JonasAntonio.noreply@github.com
9bc55e00cde41bfa922e87e1a4abb1144c50deb1
6ced41da926682548df646099662e79d7a6022c5
/aws-cpp-sdk-redshift-serverless/source/model/GetWorkgroupResult.cpp
5423e1060b3005216804a527c1842d584f9ea94a
[ "Apache-2.0", "MIT", "JSON" ]
permissive
irods/aws-sdk-cpp
139104843de529f615defa4f6b8e20bc95a6be05
2c7fb1a048c96713a28b730e1f48096bd231e932
refs/heads/main
2023-07-25T12:12:04.363757
2022-08-26T15:33:31
2022-08-26T15:33:31
141,315,346
0
1
Apache-2.0
2022-08-26T17:45:09
2018-07-17T16:24:06
C++
UTF-8
C++
false
false
959
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/redshift-serverless/model/GetWorkgroupResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::RedshiftServerless::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; GetWorkgroupResult::GetWorkgroupResult() { } GetWorkgroupResult::GetWorkgroupResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } GetWorkgroupResult& GetWorkgroupResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("workgroup")) { m_workgroup = jsonValue.GetObject("workgroup"); } return *this; }
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
d42698b9cee689e9138b7e5321007a0406cd3aaf
686f674dd3c28e1a9fd1518c2dab134d77f4828e
/main85.cpp
327c7033742ecbd59e29727e8dc8c5ca1f263de9
[]
no_license
jack-Dong/NubtOj
8aa452f44a0ef1ba7bb7be4e211fa28a4dbf1fa2
7cecf56289b247dd85625bc9102141324ff81a8b
refs/heads/master
2021-01-23T07:44:55.374580
2017-03-28T09:52:27
2017-03-28T09:52:27
86,443,612
0
0
null
null
null
null
GB18030
C++
false
false
1,331
cpp
#include <iostream> #include <vector> #include <math.h> using namespace std; //点的结构体 typedef struct Point { double x,y; }Point; //判断是否在一条直线上 inline bool jugleOnALine(Point p1,Point p2,Point p3) { double det = (p2.y - p1.y)*(p3.x - p1.x) - (p2.x - p1.x)*(p3.y - p1.y); if( fabs(det) < 0.0001 ) { return true; } return false; } int main() { int caseN; cin>>caseN; //得到测试用例个数 vector<Point> nums; vector<string> rts; //结果 int numN; Point temp; for(int i = 0; i < caseN;i++) { cin>>numN;//得到单个测试用例参数个数 //得到所有的坐标 for(int j = 0; j < numN;j++) { cin>>temp.x>>temp.y; nums.push_back(temp); } //计算任意三个坐标是否在一条直线上 bool flag = false; for(int m = 0; m < nums.size();++m) { for(int n = 0; n < nums.size() && n != m ; ++n) { for(int k = 0; k < nums.size() && k != m && k != n; ++k) { if( jugleOnALine(nums[m],nums[n],nums[k]) ) { flag = true; break; } } if(flag) { break; } } if(flag) { break; } } if(flag) { rts.push_back("Yes"); }else { rts.push_back("No"); } nums.clear(); } //输出答案 for(int i = 0; i < rts.size();i++) { cout << rts[i]<<endl; } }
[ "1099633787@qq.com" ]
1099633787@qq.com
43411e54ae745b73cff4d6c1545e99d176aff307
11cd4f066c28c0b23272b6724f741dd6231c5614
/Matka Codechef.cpp
ec24b8c47518bbfe851b3332514b0d52edca1ef1
[]
no_license
Maruf089/Competitive-Programming
155161c95a7a517cdbf7e59242c6e3fc25dd02b7
26ce0d2884842d4db787b5770c10d7959245086e
refs/heads/master
2021-06-24T11:00:55.928489
2021-06-01T05:45:58
2021-06-01T05:45:58
222,057,521
0
0
null
null
null
null
UTF-8
C++
false
false
6,159
cpp
///*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/// //#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; #define ln '\n' #define inp(x) scanf("%lld",&x) #define inp2(a,b) scanf("%lld %lld",&a,&b) #define f0(i,b) for(int i=0;i<(b);i++) #define f1(i,b) for(int i=1;i<=(b);i++) #define MOD 1000000007 #define PI acos(-1) #define ll long long int typedef pair<int,int> pii; typedef pair<ll, ll> pll; #define pb push_back #define F first #define S second #define sz size() #define LCM(a,b) (a*(b/__gcd(a,b))) //#define harmonic(n) 0.57721566490153286060651209+log(n)+1.0/(2*n) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define all(v) v.begin(),v.end() #define MEM(a, b) memset(a, b, sizeof(a)) #define fastio ios_base::sync_with_stdio(false) ///Inline functions inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; } //inline bool isLeapYearll year) { return (year%400==0) | (year%4==0 && year%100!=0); } inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); } inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; } inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; } inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; } inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } inline ll modInverse(ll a) { return modPow(a, MOD-2); } inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } inline bool isInside(pii p,ll n,ll m){ return (p.first>=0&&p.first<n&&p.second>=0&&p.second<m); } inline bool isInside(pii p,ll n){ return (p.first>=0&&p.first<n&&p.second>=0&&p.second<n); } inline bool isSquare(ll x){ ll s = sqrt(x); return (s*s==x); } inline bool isFib(ll x) { return isSquare(5*x*x+4)|| isSquare(5*x*x-4); } inline bool isPowerOfTwo(ll x){ return ((1LL<<(ll)log2(x))==x); } /// DEBUG --------------------------------------------------------------------------------->>>>>> ///** template < typename F, typename S > ostream& operator << ( ostream& os, const pair< F, S > & p ) { return os << "(" << p.first << ", " << p.second << ")"; } template < typename T > ostream &operator << ( ostream & os, const vector< T > &v ) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if ( it != v.begin() ) os << ", "; os << *it; } return os << "}"; } template < typename T > ostream &operator << ( ostream & os, const set< T > &v ) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if ( it != v.begin()) os << ", "; os << *it; } return os << "]"; } template < typename F, typename S > ostream &operator << ( ostream & os, const map< F, S > &v ) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if ( it != v.begin() ) os << ", "; os << it -> first << " = " << it -> second ; } return os << "]"; } #define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0) clock_t tStart = clock(); #define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC) void faltu () { cerr << endl; } template <typename T> void faltu( T a[], int n ) { for (int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << endl; } template <typename T, typename ... hello> void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); } /// TEMPLATE ----------------------------------------------------------------------->>>>>> struct func { //this is a sample overloading function for sorting stl bool operator()(pii const &a, pii const &b) { if(a.F==b.F) return (a.S<b.S); return (a.F<b.F); } }; /*------------------------------Graph Moves----------------------------*/ //Rotation: S -> E -> N -> W //const int fx[] = {0, +1, 0, -1}; //const int fy[] = {-1, 0, +1, 0}; //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move /*---------------------------------------------------------------------*/ /// Bit Operations /// count set bit C = (num * 0x200040008001ULL & 0x111111111111111ULL) % 0xf; /// 32 bit integer /// inline bool checkBit(ll n, int i) { return n&(1LL<<i); } /// inline ll setBit(ll n, int i) { return n|(1LL<<i); } /// inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); } /// ************************************** Code starts here ****************************************** */ const ll INF = 0x3f3f3f3f3f3f3f3f; const long double EPS = 1e-9; const int inf = 0x3f3f3f3f; const int mx = (int)1e5+9; ll n,m,a,b,t,i,j,d,cs=0,counT=0,k,ans=0,l=0,sum1=0,sum=0,Max,Min,num; vector<ll>vc,ss; map<ll,ll>mp; int main() { // freopen("in.txt","r",stdin); fastio; cin >> n ; f0(i,n) { cin >> a ; vc.pb(a); } ll total = 0 , sum = 0 ; f0(i,n) { ss.pb(vc[i]); int size = ss.size(); total += vc[i]; //dbg(ss,total); while(size>2 and ss[size-2]>=ss[size-1] and ss[size-2]>=ss[size-3]) { ll next = ss[size-1] + ss[size-3] - ss[size-2] ; for(j=0;j<3;j++) { ss.pop_back(); } ss.pb(next); size -= 2; } } ll sign = 1,i=0,j=ss.size()-1; while(i<=j) { if(ss[i]>=ss[j]) sum += sign*ss[i] , i++; else sum += sign*ss[j] , j--; sign *= -1; } cout << (total+sum)/2 << endl; }
[ "noreply@github.com" ]
Maruf089.noreply@github.com
7fa7a63706605fc3267d6e2d8d1cde03caeca3c8
d9167eaed1bc14c7cf3ba8555e241c4ca2fd9d1b
/KernelMonitor/context.cpp
6e9c4340c1fe61195119b6019d4e3c399b1120c0
[]
no_license
yuaom/KernelMon
8301af36c34d05e13b306f9ea4b4a67fba644018
4f545da24980c72e6e9f6dcc9ad78fceb45d37b7
refs/heads/master
2023-06-07T11:17:40.826321
2021-03-05T12:24:37
2021-03-05T12:24:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,923
cpp
#include "context.h" #include "ept.h" static vmx::Vmxon* alloc_vmxon(); static vmx::Vmcs* alloc_vmcs(); static unsigned __int64 virtual_to_physical(PVOID vaddr); vmx::VmmContext* vmx::alloc_vmm_context() { PHYSICAL_ADDRESS physical_max; physical_max.QuadPart = ~0ULL; auto vmm_context = new(NonPagedPool) VmmContext{ 0 }; RtlSecureZeroMemory(vmm_context, sizeof(VmmContext)); if (!vmm_context) return nullptr; vmm_context->processor_count = KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS); vmm_context->vcpu_table = new(NonPagedPool) VCpu[vmm_context->processor_count]{ 0 }; if (!vmm_context->vcpu_table) { delete vmm_context; return nullptr; } RtlSecureZeroMemory(vmm_context->vcpu_table, sizeof(VCpu) * vmm_context->processor_count); auto msr_bitmap = MmAllocateContiguousMemory(PAGE_SIZE, physical_max); if (!msr_bitmap) { delete[] vmm_context->vcpu_table; delete vmm_context; return nullptr; } RtlSecureZeroMemory(msr_bitmap, PAGE_SIZE); for (unsigned __int32 i = 0; i < vmm_context->processor_count; i++) { vmm_context->vcpu_table[i].vmxon = alloc_vmxon(); vmm_context->vcpu_table[i].vmcs = alloc_vmcs(); vmm_context->vcpu_table[i].msr_bitmap = msr_bitmap; vmm_context->vcpu_table[i].stack = MmAllocateNonCachedMemory(VMM_STACK_SIZE); if (!ept::setup_ept(&vmm_context->vcpu_table[i]) || vmm_context->vcpu_table[i].vmcs == nullptr || vmm_context->vcpu_table[i].vmxon == nullptr || vmm_context->vcpu_table[i].stack == nullptr) { cleanup_vmm_context(vmm_context); return nullptr; } vmm_context->vcpu_table[i].vmxon_physical = virtual_to_physical(vmm_context->vcpu_table[i].vmxon); vmm_context->vcpu_table[i].vmcs_physical = virtual_to_physical(vmm_context->vcpu_table[i].vmcs); vmm_context->vcpu_table[i].msr_bitmap_physical = virtual_to_physical(vmm_context->vcpu_table[i].msr_bitmap); } return vmm_context; } static vmx::Vmxon* alloc_vmxon() { arch::Ia32VmxBasicMsr vmx_basic_msr{ 0 }; vmx::Vmxon* vmxon; PHYSICAL_ADDRESS physical_max; physical_max.QuadPart = ~0ULL; vmx_basic_msr.control = __readmsr(static_cast<unsigned __int64>(arch::Msr::MSR_IA32_VMX_BASIC)); if (vmx_basic_msr.fields.vmxon_region_size > PAGE_SIZE) vmxon = static_cast<vmx::Vmxon*>(MmAllocateContiguousMemory(PAGE_SIZE, physical_max)); else vmxon = static_cast<vmx::Vmxon*>(MmAllocateContiguousMemory(vmx_basic_msr.fields.vmxon_region_size, physical_max)); if (!vmxon) return nullptr; RtlSecureZeroMemory(vmxon, vmx::VMXON_REGION_SIZE); vmxon->revision_identifier = vmx_basic_msr.fields.vmcs_revision_identifier; return vmxon; } static vmx::Vmcs* alloc_vmcs() { arch::Ia32VmxBasicMsr vmx_basic_msr{ 0 }; vmx_basic_msr.control = __readmsr(static_cast<unsigned __int64>(arch::Msr::MSR_IA32_VMX_BASIC)); PHYSICAL_ADDRESS physical_max; physical_max.QuadPart = ~0ULL; auto vmcs = static_cast<vmx::Vmcs*>(MmAllocateContiguousMemory(PAGE_SIZE, physical_max)); RtlSecureZeroMemory(vmcs, vmx::VMCS_REGION_SIZE); vmcs->revision_identifier = vmx_basic_msr.fields.vmcs_revision_identifier; vmcs->shadow_vmcs_indicator = 0; return vmcs; } static unsigned __int64 virtual_to_physical(PVOID vaddr) { return MmGetPhysicalAddress(vaddr).QuadPart; } void vmx::cleanup_vmm_context(vmx::VmmContext* vmm_context) { if (!vmm_context) return; if (vmm_context->vcpu_table) { MmFreeContiguousMemory(vmm_context->vcpu_table[0].msr_bitmap); for (unsigned __int32 i = 0; i < vmm_context->processor_count; i++) { if (vmm_context->vcpu_table[i].vmxon) MmFreeContiguousMemory(vmm_context->vcpu_table[i].vmxon); if (vmm_context->vcpu_table[i].vmcs) MmFreeContiguousMemory(vmm_context->vcpu_table[i].vmcs); if (vmm_context->vcpu_table[i].stack) MmFreeNonCachedMemory(vmm_context->vcpu_table[i].stack, VMM_STACK_SIZE); ept::cleanup_ept(&vmm_context->vcpu_table[i]); } } delete[] vmm_context->vcpu_table; delete vmm_context; }
[ "alonbenti@gmail.com" ]
alonbenti@gmail.com
4ac0f3c41d2b7d82a0a417aa007341f7895efad9
9056dcc0298c2c9142ceb070bafaec52a75e13a9
/Cpp-version/libs/map.cpp
f829b2c6d0cdfb2e11ab58b0d123a44544ecd706
[]
no_license
vwdorsey/dungeon
641597439d2da7adc16cf42230d72fc717cd05bd
ad5c315ea3a95a66f52aef530c5795123acc6705
refs/heads/master
2020-05-29T14:16:34.788538
2015-04-26T02:56:50
2015-04-26T02:56:50
82,594,383
0
0
null
null
null
null
UTF-8
C++
false
false
6,818
cpp
/* * map.cpp - Contains all the classes and functions necessary to * create and maintain a map for the dungeon crawler * */ #include <iostream> #include <cstdlib> #include <random> #include "values.hpp" #include "dijkstra.hpp" #include "map.hpp" map::map(){ room_count = min_rooms + (random() % ((max_rooms - min_rooms) + 1)); random.seed(rand()); column_dist = std::uniform_int_distribution<int>(0, columns-1); row_dist = std::uniform_int_distribution<int>(0, rows-1); init_map(); place_rooms(); determine_paths(); } map::~map(){ } void map::init_map(){ int x = 0; int y = 0; for(y = 0; y < columns; y++){ for(x = 0; x < rows; x++){ if(y == 0 || y == columns-1){ layout[y][x].type = tile_type_immutable; layout[y][x].hardness = 9; layout[y][x].pc = NULL; layout[y][x].mon = NULL; layout[y][x].obj = NULL; } else if(x == 0 || x == rows-1){ layout[y][x].type = tile_type_immutable; layout[y][x].hardness = 9; layout[y][x].pc = NULL; layout[y][x].mon = NULL; layout[y][x].obj = NULL; } else{ layout[y][x].type = tile_type_empty; layout[y][x].hardness = (rand() % 8) + 1; layout[y][x].pc = NULL; layout[y][x].mon = NULL; layout[y][x].obj = NULL; } } } } void map::design_output(){ int x = 0; int y = 0; for(y = 0; y < columns; y++){ for(x = 0; x < rows; x++){ std::cout << layout[y][x].type; } std::cout << '\n'; } } void map::place_rooms(){ int i = 0; std::uniform_int_distribution<int> room_x(min_room_x, max_room_x); std::uniform_int_distribution<int> room_y(min_room_y, max_room_y); while(i < room_count) { int start_y = column_dist(random); int start_x = row_dist(random); int y_dim = room_y(random); int x_dim = room_x(random); if(layout[start_y][start_x].type == tile_type_empty){ if(check_room_placement(y_dim, x_dim, start_y, start_x) == 0){ for(int j = 0; j < y_dim+1; j++){ for(int k = 0; k < x_dim+1; k++){ if(j == 0 || j == y_dim){ layout[start_y+j][start_x+k].type = tile_type_wall; layout[start_y+j][start_x+k].is_room = 1; } else if(k == 0 || k == x_dim){ layout[start_y+j][start_x+k].type = tile_type_wall; layout[start_y+j][start_x+k].is_room = 1; } else{ layout[start_y+j][start_x+k].type = tile_type_floor; layout[start_y+j][start_x+k].is_room = 1; layout[start_y+j][start_x+k].hardness = 0; } } } room_info[i].x_dim = x_dim; room_info[i].y_dim = y_dim; room_info[i].x_start = start_x; room_info[i].y_start = start_y; i++; } } } } char map::check_room_placement(int y_dim, int x_dim, int y, int x){ for(int i = 0; i < y_dim; i++){ if(x+i > 152 || x+i < 6) return -1; for(int j = 0; j < x_dim; j++){ if(y+j > 91|| y+j < 5) return -1; if(layout[y+i][x+j].type != tile_type_empty) return -1; if(layout[y+i+4][x+j].type != tile_type_empty) return -1; if(layout[y+i-4][x+j].type != tile_type_empty) return -1; if(layout[y+i][x+j+4].type != tile_type_empty) return -1; if(layout[y+i][x+j-4].type != tile_type_empty) return -1; if(layout[y+i+4][x+j+4].type != tile_type_empty) return -1; if(layout[y+i-4][x+j+4].type != tile_type_empty) return -1; if(layout[y+i+4][x+j-4].type != tile_type_empty) return -1; if(layout[y+i-4][x+j-4].type != tile_type_empty) return -1; } } return 0; } void map::determine_paths(){ for(int i = 0; i < room_count-1; i++){ int src_panel_select = (rand() % 2)+1; int src_x, src_y, des_x, des_y; if(src_panel_select == 1){ //Right Panel src_y = (room_info[i].y_start + 2 + (rand() % (room_info[i].y_dim)/2)); src_x = (room_info[i].x_start - 1 + room_info[i].x_dim); } else{ //Left Panel src_y = (room_info[i].y_start + 2 + (rand() % (room_info[i].y_dim)/2)); src_x = (room_info[i].x_start); } des_x = (room_info[i+1].x_start + (room_info[i+1].x_dim / 2)); des_y = (room_info[i+1].y_start + (room_info[i+1].y_dim / 2)); generate_corridors(src_y, src_x, src_panel_select, des_y, des_x); } } void map::generate_corridors(int s_y, int s_x, int src_pnl, int d_y, int d_x){ int cur_x = s_x; int cur_y = s_y; int i; for(i = 0; i < 3; i++){ if(src_pnl == 1){ //right side if (i != 0) cur_x++; layout[cur_y][cur_x].type = tile_type_floor; if(layout[cur_y+1][cur_x].type == tile_type_empty) layout[cur_y+1][cur_x].type = tile_type_wall; if(layout[cur_y+1][cur_x+1].type == tile_type_empty) layout[cur_y+1][cur_x+1].type = tile_type_wall; if(layout[cur_y][cur_x+1].type == tile_type_empty) layout[cur_y][cur_x+1].type = tile_type_wall; if(layout[cur_y-1][cur_x+1].type == tile_type_empty) layout[cur_y-1][cur_x+1].type = tile_type_wall; } else{ //left side if (i != 0) cur_x--; layout[cur_y][cur_x].type = tile_type_floor; if(layout[cur_y+1][cur_x].type == tile_type_empty) layout[cur_y+1][cur_x].type = tile_type_wall; if(layout[cur_y][cur_x-1].type == tile_type_empty) layout[cur_y][cur_x-1].type = tile_type_wall; if(layout[cur_y+1][cur_x-1].type == tile_type_empty) layout[cur_y+1][cur_x-1].type = tile_type_wall; if(layout[cur_y-1][cur_x-1].type == tile_type_empty) layout[cur_y-1][cur_x-1].type = tile_type_wall; } } if(cur_y < d_y){ while(cur_y != d_y){ cur_y++; layout[cur_y][cur_x].type = tile_type_floor; wall_stamp(cur_y, cur_x); } } else{ while(cur_y != d_y){ cur_y--; layout[cur_y][cur_x].type = tile_type_floor; wall_stamp(cur_y, cur_x); } } if(cur_x < d_x){ while(cur_x != d_x){ //moves down cur_x++; layout[cur_y][cur_x].type = tile_type_floor; wall_stamp(cur_y, cur_x); } } else{ while(cur_x != d_x){ //moves up cur_x--; layout[cur_y][cur_x].type = tile_type_floor; wall_stamp(cur_y, cur_x); } } } void map::wall_stamp(int cur_y, int cur_x){ if(layout[cur_y][cur_x-1].type == tile_type_empty) layout[cur_y][cur_x-1].type = tile_type_wall; if(layout[cur_y+1][cur_x-1].type == tile_type_empty) layout[cur_y+1][cur_x-1].type = tile_type_wall; if(layout[cur_y-1][cur_x-1].type == tile_type_empty) layout[cur_y-1][cur_x-1].type = tile_type_wall; if(layout[cur_y+1][cur_x].type == tile_type_empty) layout[cur_y+1][cur_x].type = tile_type_wall; if(layout[cur_y-1][cur_x].type == tile_type_empty) layout[cur_y-1][cur_x].type = tile_type_wall; if(layout[cur_y+1][cur_x+1].type == tile_type_empty) layout[cur_y+1][cur_x+1].type = tile_type_wall; if(layout[cur_y][cur_x+1].type == tile_type_empty) layout[cur_y][cur_x+1].type = tile_type_wall; if(layout[cur_y-1][cur_x+1].type == tile_type_empty) layout[cur_y-1][cur_x+1].type = tile_type_wall; }
[ "vwdorsey@iastate.edu" ]
vwdorsey@iastate.edu
9544de486ebc10609f6b066923b9020d781b8938
5e2e27daacfddfe119015736fcc6e9a864d66c49
/GameEngine/Graphics/Anim2Bone.cpp
db53db079308dd27a65033a6f9aab04f82670dd4
[]
no_license
mdubovoy/Animation_System
17ddc22740962209e7edbd8ea85bec108499f3e2
b356d0ea6812e0548336bc4813662463e786de93
refs/heads/master
2021-01-22T11:41:13.637727
2014-09-22T14:01:20
2014-09-22T14:01:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,129
cpp
#include "OpenGLWrapper.h" #include "Pyramid.h" #include "PyramidObject.h" #include "GraphicsObjectManager.h" #include "Anim.h" #include "Constants.h" #define BONE_ANIM 0 #if BONE_ANIM // temporary hack Frame_Bucket *pHead = 0; PyramidObject *firstBone; // PyramidObject *p1; Pyramid *pPyramid; #define BONE_WIDTH 13.0f void walk_anim_node( GraphicsObject *node ); // move to Anim.h? void SetAnimationHierarchy() { // setup the bone model, this case we are using pyramid // todo - create a cool Bone Object, ball(drk blue) + pyramid arm (dark yellow) pPyramid = new Pyramid(); pPyramid->loadTexture(); pPyramid->createVAO(); // Get the manager GraphicsObjectManager *goMgr = GraphicsObjectManager::getInstance(); // create two bones PyramidObject* p0 = new PyramidObject( "Bone_0", pPyramid ); p0->setPos( Vect(0.0f, 0.0f, 0.0f) ); p0->setLightPos( Vect(50.0f, 50.0f, 0.0f) ); p0->setLightColor( Vect(1.5f, 0.5f, 0.5f) ); // RED // p0->setTexture(TEX1); // goMgr->addObject(p0); p0->setIndex(0); PyramidObject* p1 = new PyramidObject( "Bone_1", pPyramid ); p1->setPos( Vect(1.0f, 1.0f, 0.0f) ); p1->setLightPos( Vect(50.0f, 50.0f, 0.0f) ); p1->setLightColor( Vect(0.5f, 1.5f, 0.5f) ); // Green // p1->setTexture(TEX1); // goMgr->addObject(p1); p1->setIndex(1); // here we insert bones directly into tree - // vs calling goMgr->addObject which inserts every node with root as parent PCSTree *tree = goMgr->getTree(); PCSNode *root = tree->getRoot(); // Add 1st two bones tree->insert( p0, root ); tree->insert( p1, p0 ); firstBone = p0; // Debug // tree->dumpTree(); } // picture: double-linked list with Result at head, followed by each frame // Each node's pBone points to an array of size NUM_Bones (all the bones) // we fill each bone's data with the matrices provided by FBX output void SetAnimationData() { // ------------- Result Frame ----------------------------- // create head bucket - the head of our list points to the bone_result array pHead = new Frame_Bucket(); pHead->prevBucket = 0; pHead->nextBucket = 0; pHead->KeyTime = Time(TIME_ZERO); pHead->pBone = new Bone[NUM_BONES]; // --------------- Frame 0 ------------------------------------ Frame_Bucket *pTmp = new Frame_Bucket(); pTmp->prevBucket = pHead; pTmp->nextBucket = 0; pTmp->KeyTime = 0 * Time(TIME_NTSC_30_FRAME); pTmp->pBone = new Bone[NUM_BONES]; pHead->nextBucket = pTmp; // Bone 0 --------------------------------- //Local matrix //Trans: -113.894875, 0.000000, 0.000000 //Rot: -0.000000, -0.000000, 0.005445 //Scale: 1.000000, 1.000000, 1.000000 pTmp->pBone[0].T = Vect(-113.894875f, 0.000000f, 0.000000f); pTmp->pBone[0].Q = Quat(ROT_XYZ, 0.0f* MATH_PI_180 , 0.0f* MATH_PI_180, 0.005445f * MATH_PI_180 ); pTmp->pBone[0].S = Vect(1.0f, 1.0f, 1.0f); // Bone 1 -------------------------------------- // Trans: 114.826065, -0.000016, 0.000000 // Rot: 0.000000, 0.000000, -0.005444 // Scale: 1.000000, 1.000000, 1.000000 pTmp->pBone[1].T = Vect(114.826065f, -0.000016f, 0.000000f); pTmp->pBone[1].Q = Quat(ROT_XYZ, 0.000000f * MATH_PI_180, 0.000000f* MATH_PI_180, -0.005444f * MATH_PI_180); pTmp->pBone[1].S = Vect(1.0f, 1.0f, 1.0f); // --------------- Frame 35 ----------------------------- Frame_Bucket *pTmp2 = new Frame_Bucket(); pTmp2->prevBucket = pTmp; pTmp2->nextBucket = 0; pTmp2->KeyTime = 35 * Time(TIME_NTSC_30_FRAME); pTmp2->pBone = new Bone[NUM_BONES]; pTmp->nextBucket = pTmp2; // Bone 0 ------------------------------- //Trans: -69.141525, 0.000000, 0.000000 //Rot: -0.000000, -0.000000, 35.000000 //Scale: 1.000000, 1.000000, 1.000000 pTmp2->pBone[0].T = Vect(-69.141525f, 0.000000f, 0.000000f); pTmp2->pBone[0].Q = Quat(ROT_XYZ, 0.0f* MATH_PI_180, 0.0f* MATH_PI_180, 35.0f * MATH_PI_180); pTmp2->pBone[0].S = Vect(1.0f, 1.0f, 1.0f); // Bone 1 --------------------------------- //Trans: 114.826065, -0.000016, 0.000000 // Rot: -0.000000, 0.000000, -69.954391 //Scale: 1.000000, 1.000000, 1.000000 pTmp2->pBone[1].T = Vect(114.826065f, -0.000016f, 0.000000f); pTmp2->pBone[1].Q = Quat(ROT_XYZ, 0.000000f* MATH_PI_180 , 0.000000f* MATH_PI_180, -69.954391f * MATH_PI_180); pTmp2->pBone[1].S = Vect(1.0f, 1.0f, 1.0f); //------------------------- Frame 70 ----------------------------------- Frame_Bucket *pTmp3 = new Frame_Bucket(); pTmp3->prevBucket = pTmp2; pTmp3->nextBucket = 0; pTmp3->KeyTime = 70 * Time(TIME_NTSC_30_FRAME); pTmp3->pBone = new Bone[NUM_BONES]; pTmp2->nextBucket = pTmp3; // Bone 0 --------------------------------------- //Trans: -39.924347, 0.000000, 0.000000 //Rot: 0.000000, -0.000000, 0.000003 //Scale: 1.000000, 1.000000, 1.000000 pTmp3->pBone[0].T = Vect(-39.924347f, 0.000000f, 0.000000f); pTmp3->pBone[0].Q = Quat(ROT_XYZ, 0.0f* MATH_PI_180,0.0f* MATH_PI_180 ,0.000003f * MATH_PI_180); pTmp3->pBone[0].S = Vect(1.0f, 1.0f, 1.0f); // Bone 1-------------------------------------- //Trans: 114.826065, -0.000016, 0.000000 //Rot: 0.000000, 0.000000, -0.000000 //Scale: 1.000000, 1.000000, 1.000000 pTmp3->pBone[1].T = Vect(114.826065f, -0.000016f, 0.000000f); pTmp3->pBone[1].Q = Quat(ROT_XYZ, 0.000000f * MATH_PI_180, 0.000000f* MATH_PI_180, 0.0f * MATH_PI_180); pTmp3->pBone[1].S = Vect( 1.0f, 1.0f, 1.0f); } void SetAnimationPose(GraphicsObject* root) { // First thing, get the first frame of animation Time tCurr(TIME_ZERO); // IS THIS NEEDED? Already called via GameLoop at Time Zero by now ProcessAnimation( tCurr ); // fills result array with bone's position at time 0 // walks the anim node does the pose for everything that walk_anim_node( root ); } void setBonePose(GraphicsObject * node) { // Now get the world matrices GraphicsObject *childNode = (GraphicsObject *)node->getChild(); GraphicsObject *parentNode = node; if( parentNode != 0 && childNode != 0 ) { // starting point Vect start(0.0f,0.0f,0.0f); // calling transform first to evaluate an up-to-date world, then get starting point in World coords // ***ORDER*** do this for parent first, then child - in transform, p1 will get parent's world matrix parentNode->transform(); Vect ptA = start * parentNode->getWorld(); childNode->transform(); Vect ptB = start * childNode->getWorld(); // At this point, we have the two bones initial positions in world space // Now get the direction between two anchor points of respective bones, and direction Vect dir = ptB- ptA; float mag = dir.mag(); Matrix S( SCALE, BONE_WIDTH, BONE_WIDTH, mag); // rotate along dir or DOF Quat Q( ROT_ORIENT, dir.getNorm(), Vect( 0.0f, 1.0f, 0.0f) ); Matrix BoneOrient = S * Q; parentNode->setBoneOrientation(BoneOrient); } // deal with last node, when there isn't a terminal node // copy orientation matrix from grandparent to set Parent's orientation if( parentNode != 0 && childNode == 0 ) { // get the parent's parent -> grandParent GraphicsObject *grandParentNode = (GraphicsObject *)parentNode->getParent(); Matrix BoneOrient = grandParentNode->getBoneOrientation(); parentNode->setBoneOrientation( BoneOrient ); } } void walk_anim_node( GraphicsObject *node ) { // --------- Do pose stuff here ----------------------- setBonePose(node); // iterate through all of the active children - copied from GOM, will it work here??? GraphicsObject *child = 0; if (node->getChild() != 0) { child = (GraphicsObject *)node->getChild(); // make sure that allocation is not a child node while (child != 0) { walk_anim_node( child ); // goto next sibling - node's child, but now we are iterating SIBLINGS child = (GraphicsObject *)child->getSibling(); } } else { // bye bye exit condition } } #else // #endif
[ "michel.dubovoy@gmail.com" ]
michel.dubovoy@gmail.com
e8ef9f37e0485f383e9b869a5c93eb1aadac2844
917370624ba324c5a04996b3d68f31e9f0c1b5f9
/lib/Sema/SemaDecl.cpp
83ec34448fa8418aee2822696eb4630e8e7ee970
[ "NCSA" ]
permissive
yuankong11/Clang-elementWise
0137101a0adad425d464e0b801d9ee9e7ea1daf3
892ba3b080e34d5c7fd8da7a94832414d689da8d
refs/heads/master
2022-01-24T21:17:41.683108
2019-07-07T12:52:33
2019-07-07T12:52:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
474,103
cpp
//===--- SemaDecl.cpp - Semantic Analysis for Declarations ----------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements semantic analysis for declarations. // //===----------------------------------------------------------------------===// #include "clang/Sema/SemaInternal.h" #include "TypeLocBuilder.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/CharUnits.h" #include "clang/AST/CommentDiagnostic.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/EvaluatedExprVisitor.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/Lex/HeaderSearch.h" // FIXME: Sema shouldn't depend on Lex #include "clang/Lex/ModuleLoader.h" // FIXME: Sema shouldn't depend on Lex #include "clang/Lex/Preprocessor.h" // FIXME: Sema shouldn't depend on Lex #include "clang/Parse/ParseDiagnostic.h" #include "clang/Sema/CXXFieldCollector.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/DelayedDiagnostic.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/ParsedTemplate.h" #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Triple.h" #include <algorithm> #include <cstring> #include <functional> using namespace clang; using namespace sema; Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType) { if (OwnedType) { Decl *Group[2] = { OwnedType, Ptr }; return DeclGroupPtrTy::make(DeclGroupRef::Create(Context, Group, 2)); } return DeclGroupPtrTy::make(DeclGroupRef(Ptr)); } namespace { class TypeNameValidatorCCC : public CorrectionCandidateCallback { public: TypeNameValidatorCCC(bool AllowInvalid, bool WantClass=false) : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass) { WantExpressionKeywords = false; WantCXXNamedCasts = false; WantRemainingKeywords = false; } virtual bool ValidateCandidate(const TypoCorrection &candidate) { if (NamedDecl *ND = candidate.getCorrectionDecl()) return (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) && (AllowInvalidDecl || !ND->isInvalidDecl()); else return !WantClassName && candidate.isKeyword(); } private: bool AllowInvalidDecl; bool WantClassName; }; } /// \brief Determine whether the token kind starts a simple-type-specifier. bool Sema::isSimpleTypeSpecifier(tok::TokenKind Kind) const { switch (Kind) { // FIXME: Take into account the current language when deciding whether a // token kind is a valid type specifier case tok::kw_short: case tok::kw_long: case tok::kw___int64: case tok::kw___int128: case tok::kw_signed: case tok::kw_unsigned: case tok::kw_void: case tok::kw_char: case tok::kw_int: case tok::kw_half: case tok::kw_float: case tok::kw_double: case tok::kw_wchar_t: case tok::kw_bool: case tok::kw___underlying_type: return true; case tok::annot_typename: case tok::kw_char16_t: case tok::kw_char32_t: case tok::kw_typeof: case tok::kw_decltype: return getLangOpts().CPlusPlus; default: break; } return false; } /// \brief If the identifier refers to a type name within this scope, /// return the declaration of that type. /// /// This routine performs ordinary name lookup of the identifier II /// within the given scope, with optional C++ scope specifier SS, to /// determine whether the name refers to a type. If so, returns an /// opaque pointer (actually a QualType) corresponding to that /// type. Otherwise, returns NULL. /// /// If name lookup results in an ambiguity, this routine will complain /// and then return NULL. ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS, bool isClassName, bool HasTrailingDot, ParsedType ObjectTypePtr, bool IsCtorOrDtorName, bool WantNontrivialTypeSourceInfo, IdentifierInfo **CorrectedII) { // Determine where we will perform name lookup. DeclContext *LookupCtx = 0; if (ObjectTypePtr) { QualType ObjectType = ObjectTypePtr.get(); if (ObjectType->isRecordType()) LookupCtx = computeDeclContext(ObjectType); } else if (SS && SS->isNotEmpty()) { LookupCtx = computeDeclContext(*SS, false); if (!LookupCtx) { if (isDependentScopeSpecifier(*SS)) { // C++ [temp.res]p3: // A qualified-id that refers to a type and in which the // nested-name-specifier depends on a template-parameter (14.6.2) // shall be prefixed by the keyword typename to indicate that the // qualified-id denotes a type, forming an // elaborated-type-specifier (7.1.5.3). // // We therefore do not perform any name lookup if the result would // refer to a member of an unknown specialization. if (!isClassName && !IsCtorOrDtorName) return ParsedType(); // We know from the grammar that this name refers to a type, // so build a dependent node to describe the type. if (WantNontrivialTypeSourceInfo) return ActOnTypenameType(S, SourceLocation(), *SS, II, NameLoc).get(); NestedNameSpecifierLoc QualifierLoc = SS->getWithLocInContext(Context); QualType T = CheckTypenameType(ETK_None, SourceLocation(), QualifierLoc, II, NameLoc); return ParsedType::make(T); } return ParsedType(); } if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(*SS, LookupCtx)) return ParsedType(); } // FIXME: LookupNestedNameSpecifierName isn't the right kind of // lookup for class-names. LookupNameKind Kind = isClassName ? LookupNestedNameSpecifierName : LookupOrdinaryName; LookupResult Result(*this, &II, NameLoc, Kind); if (LookupCtx) { // Perform "qualified" name lookup into the declaration context we // computed, which is either the type of the base of a member access // expression or the declaration context associated with a prior // nested-name-specifier. LookupQualifiedName(Result, LookupCtx); if (ObjectTypePtr && Result.empty()) { // C++ [basic.lookup.classref]p3: // If the unqualified-id is ~type-name, the type-name is looked up // in the context of the entire postfix-expression. If the type T of // the object expression is of a class type C, the type-name is also // looked up in the scope of class C. At least one of the lookups shall // find a name that refers to (possibly cv-qualified) T. LookupName(Result, S); } } else { // Perform unqualified name lookup. LookupName(Result, S); } NamedDecl *IIDecl = 0; switch (Result.getResultKind()) { case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: if (CorrectedII) { TypeNameValidatorCCC Validator(true, isClassName); TypoCorrection Correction = CorrectTypo(Result.getLookupNameInfo(), Kind, S, SS, Validator); IdentifierInfo *NewII = Correction.getCorrectionAsIdentifierInfo(); TemplateTy Template; bool MemberOfUnknownSpecialization; UnqualifiedId TemplateName; TemplateName.setIdentifier(NewII, NameLoc); NestedNameSpecifier *NNS = Correction.getCorrectionSpecifier(); CXXScopeSpec NewSS, *NewSSPtr = SS; if (SS && NNS) { NewSS.MakeTrivial(Context, NNS, SourceRange(NameLoc)); NewSSPtr = &NewSS; } if (Correction && (NNS || NewII != &II) && // Ignore a correction to a template type as the to-be-corrected // identifier is not a template (typo correction for template names // is handled elsewhere). !(getLangOpts().CPlusPlus && NewSSPtr && isTemplateName(S, *NewSSPtr, false, TemplateName, ParsedType(), false, Template, MemberOfUnknownSpecialization))) { ParsedType Ty = getTypeName(*NewII, NameLoc, S, NewSSPtr, isClassName, HasTrailingDot, ObjectTypePtr, IsCtorOrDtorName, WantNontrivialTypeSourceInfo); if (Ty) { std::string CorrectedStr(Correction.getAsString(getLangOpts())); std::string CorrectedQuotedStr( Correction.getQuoted(getLangOpts())); Diag(NameLoc, diag::err_unknown_type_or_class_name_suggest) << Result.getLookupName() << CorrectedQuotedStr << isClassName << FixItHint::CreateReplacement(SourceRange(NameLoc), CorrectedStr); if (NamedDecl *FirstDecl = Correction.getCorrectionDecl()) Diag(FirstDecl->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr; if (SS && NNS) SS->MakeTrivial(Context, NNS, SourceRange(NameLoc)); *CorrectedII = NewII; return Ty; } } } // If typo correction failed or was not performed, fall through case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: Result.suppressDiagnostics(); return ParsedType(); case LookupResult::Ambiguous: // Recover from type-hiding ambiguities by hiding the type. We'll // do the lookup again when looking for an object, and we can // diagnose the error then. If we don't do this, then the error // about hiding the type will be immediately followed by an error // that only makes sense if the identifier was treated like a type. if (Result.getAmbiguityKind() == LookupResult::AmbiguousTagHiding) { Result.suppressDiagnostics(); return ParsedType(); } // Look to see if we have a type anywhere in the list of results. for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end(); Res != ResEnd; ++Res) { if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) { if (!IIDecl || (*Res)->getLocation().getRawEncoding() < IIDecl->getLocation().getRawEncoding()) IIDecl = *Res; } } if (!IIDecl) { // None of the entities we found is a type, so there is no way // to even assume that the result is a type. In this case, don't // complain about the ambiguity. The parser will either try to // perform this lookup again (e.g., as an object name), which // will produce the ambiguity, or will complain that it expected // a type name. Result.suppressDiagnostics(); return ParsedType(); } // We found a type within the ambiguous lookup; diagnose the // ambiguity and then return that type. This might be the right // answer, or it might not be, but it suppresses any attempt to // perform the name lookup again. break; case LookupResult::Found: IIDecl = Result.getFoundDecl(); break; } assert(IIDecl && "Didn't find decl"); QualType T; if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) { DiagnoseUseOfDecl(IIDecl, NameLoc); if (T.isNull()) T = Context.getTypeDeclType(TD); // NOTE: avoid constructing an ElaboratedType(Loc) if this is a // constructor or destructor name (in such a case, the scope specifier // will be attached to the enclosing Expr or Decl node). if (SS && SS->isNotEmpty() && !IsCtorOrDtorName) { if (WantNontrivialTypeSourceInfo) { // Construct a type with type-source information. TypeLocBuilder Builder; Builder.pushTypeSpec(T).setNameLoc(NameLoc); T = getElaboratedType(ETK_None, *SS, T); ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc>(T); ElabTL.setElaboratedKeywordLoc(SourceLocation()); ElabTL.setQualifierLoc(SS->getWithLocInContext(Context)); return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); } else { T = getElaboratedType(ETK_None, *SS, T); } } } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { (void)DiagnoseUseOfDecl(IDecl, NameLoc); if (!HasTrailingDot) T = Context.getObjCInterfaceType(IDecl); } if (T.isNull()) { // If it's not plausibly a type, suppress diagnostics. Result.suppressDiagnostics(); return ParsedType(); } return ParsedType::make(T); } /// isTagName() - This method is called *for error recovery purposes only* /// to determine if the specified name is a valid tag name ("struct foo"). If /// so, this returns the TST for the tag corresponding to it (TST_enum, /// TST_union, TST_struct, TST_interface, TST_class). This is used to diagnose /// cases in C where the user forgot to specify the tag. DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) { // Do a tag name lookup in this scope. LookupResult R(*this, &II, SourceLocation(), LookupTagName); LookupName(R, S, false); R.suppressDiagnostics(); if (R.getResultKind() == LookupResult::Found) if (const TagDecl *TD = R.getAsSingle<TagDecl>()) { switch (TD->getTagKind()) { case TTK_Struct: return DeclSpec::TST_struct; case TTK_Interface: return DeclSpec::TST_interface; case TTK_Union: return DeclSpec::TST_union; case TTK_Class: return DeclSpec::TST_class; case TTK_Enum: return DeclSpec::TST_enum; } } return DeclSpec::TST_unspecified; } /// isMicrosoftMissingTypename - In Microsoft mode, within class scope, /// if a CXXScopeSpec's type is equal to the type of one of the base classes /// then downgrade the missing typename error to a warning. /// This is needed for MSVC compatibility; Example: /// @code /// template<class T> class A { /// public: /// typedef int TYPE; /// }; /// template<class T> class B : public A<T> { /// public: /// A<T>::TYPE a; // no typename required because A<T> is a base class. /// }; /// @endcode bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S) { if (CurContext->isRecord()) { const Type *Ty = SS->getScopeRep()->getAsType(); CXXRecordDecl *RD = cast<CXXRecordDecl>(CurContext); for (CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(), BaseEnd = RD->bases_end(); Base != BaseEnd; ++Base) if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base->getType())) return true; return S->isFunctionPrototypeScope(); } return CurContext->isFunctionOrMethod() || S->isFunctionPrototypeScope(); } bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType) { // We don't have anything to suggest (yet). SuggestedType = ParsedType(); // There may have been a typo in the name of the type. Look up typo // results, in case we have something that we can suggest. TypeNameValidatorCCC Validator(false); if (TypoCorrection Corrected = CorrectTypo(DeclarationNameInfo(II, IILoc), LookupOrdinaryName, S, SS, Validator)) { std::string CorrectedStr(Corrected.getAsString(getLangOpts())); std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOpts())); if (Corrected.isKeyword()) { // We corrected to a keyword. IdentifierInfo *NewII = Corrected.getCorrectionAsIdentifierInfo(); if (!isSimpleTypeSpecifier(NewII->getTokenID())) CorrectedQuotedStr = "the keyword " + CorrectedQuotedStr; Diag(IILoc, diag::err_unknown_typename_suggest) << II << CorrectedQuotedStr << FixItHint::CreateReplacement(SourceRange(IILoc), CorrectedStr); II = NewII; } else { NamedDecl *Result = Corrected.getCorrectionDecl(); // We found a similarly-named type or interface; suggest that. if (!SS || !SS->isSet()) Diag(IILoc, diag::err_unknown_typename_suggest) << II << CorrectedQuotedStr << FixItHint::CreateReplacement(SourceRange(IILoc), CorrectedStr); else if (DeclContext *DC = computeDeclContext(*SS, false)) Diag(IILoc, diag::err_unknown_nested_typename_suggest) << II << DC << CorrectedQuotedStr << SS->getRange() << FixItHint::CreateReplacement(Corrected.getCorrectionRange(), CorrectedStr); else llvm_unreachable("could not have corrected a typo here"); Diag(Result->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr; SuggestedType = getTypeName(*Result->getIdentifier(), IILoc, S, SS, false, false, ParsedType(), /*IsCtorOrDtorName=*/false, /*NonTrivialTypeSourceInfo=*/true); } return true; } if (getLangOpts().CPlusPlus) { // See if II is a class template that the user forgot to pass arguments to. UnqualifiedId Name; Name.setIdentifier(II, IILoc); CXXScopeSpec EmptySS; TemplateTy TemplateResult; bool MemberOfUnknownSpecialization; if (isTemplateName(S, SS ? *SS : EmptySS, /*hasTemplateKeyword=*/false, Name, ParsedType(), true, TemplateResult, MemberOfUnknownSpecialization) == TNK_Type_template) { TemplateName TplName = TemplateResult.getAsVal<TemplateName>(); Diag(IILoc, diag::err_template_missing_args) << TplName; if (TemplateDecl *TplDecl = TplName.getAsTemplateDecl()) { Diag(TplDecl->getLocation(), diag::note_template_decl_here) << TplDecl->getTemplateParameters()->getSourceRange(); } return true; } } // FIXME: Should we move the logic that tries to recover from a missing tag // (struct, union, enum) from Parser::ParseImplicitInt here, instead? if (!SS || (!SS->isSet() && !SS->isInvalid())) Diag(IILoc, diag::err_unknown_typename) << II; else if (DeclContext *DC = computeDeclContext(*SS, false)) Diag(IILoc, diag::err_typename_nested_not_found) << II << DC << SS->getRange(); else if (isDependentScopeSpecifier(*SS)) { unsigned DiagID = diag::err_typename_missing; if (getLangOpts().MicrosoftMode && isMicrosoftMissingTypename(SS, S)) DiagID = diag::warn_typename_missing; Diag(SS->getRange().getBegin(), DiagID) << (NestedNameSpecifier *)SS->getScopeRep() << II->getName() << SourceRange(SS->getRange().getBegin(), IILoc) << FixItHint::CreateInsertion(SS->getRange().getBegin(), "typename "); SuggestedType = ActOnTypenameType(S, SourceLocation(), *SS, *II, IILoc).get(); } else { assert(SS && SS->isInvalid() && "Invalid scope specifier has already been diagnosed"); } return true; } /// \brief Determine whether the given result set contains either a type name /// or static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken) { bool CheckTemplate = R.getSema().getLangOpts().CPlusPlus && NextToken.is(tok::less); for (LookupResult::iterator I = R.begin(), IEnd = R.end(); I != IEnd; ++I) { if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I)) return true; if (CheckTemplate && isa<TemplateDecl>(*I)) return true; } return false; } static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc) { LookupResult R(SemaRef, Name, NameLoc, Sema::LookupTagName); SemaRef.LookupParsedName(R, S, &SS); if (TagDecl *Tag = R.getAsSingle<TagDecl>()) { const char *TagName = 0; const char *FixItTagName = 0; switch (Tag->getTagKind()) { case TTK_Class: TagName = "class"; FixItTagName = "class "; break; case TTK_Enum: TagName = "enum"; FixItTagName = "enum "; break; case TTK_Struct: TagName = "struct"; FixItTagName = "struct "; break; case TTK_Interface: TagName = "__interface"; FixItTagName = "__interface "; break; case TTK_Union: TagName = "union"; FixItTagName = "union "; break; } SemaRef.Diag(NameLoc, diag::err_use_of_tag_name_without_tag) << Name << TagName << SemaRef.getLangOpts().CPlusPlus << FixItHint::CreateInsertion(NameLoc, FixItTagName); for (LookupResult::iterator I = Result.begin(), IEnd = Result.end(); I != IEnd; ++I) SemaRef.Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type) << Name << TagName; // Replace lookup results with just the tag decl. Result.clear(Sema::LookupTagName); SemaRef.LookupParsedName(Result, S, &SS); return true; } return false; } /// Build a ParsedType for a simple-type-specifier with a nested-name-specifier. static ParsedType buildNestedType(Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc) { ASTContext &Context = S.Context; TypeLocBuilder Builder; Builder.pushTypeSpec(T).setNameLoc(NameLoc); T = S.getElaboratedType(ETK_None, SS, T); ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc>(T); ElabTL.setElaboratedKeywordLoc(SourceLocation()); ElabTL.setQualifierLoc(SS.getWithLocInContext(Context)); return S.CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); } Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC) { DeclarationNameInfo NameInfo(Name, NameLoc); ObjCMethodDecl *CurMethod = getCurMethodDecl(); if (NextToken.is(tok::coloncolon)) { BuildCXXNestedNameSpecifier(S, *Name, NameLoc, NextToken.getLocation(), QualType(), false, SS, 0, false); } LookupResult Result(*this, Name, NameLoc, LookupOrdinaryName); LookupParsedName(Result, S, &SS, !CurMethod); // Perform lookup for Objective-C instance variables (including automatically // synthesized instance variables), if we're in an Objective-C method. // FIXME: This lookup really, really needs to be folded in to the normal // unqualified lookup mechanism. if (!SS.isSet() && CurMethod && !isResultTypeOrTemplate(Result, NextToken)) { ExprResult E = LookupInObjCMethod(Result, S, Name, true); if (E.get() || E.isInvalid()) return E; } bool SecondTry = false; bool IsFilteredTemplateName = false; Corrected: switch (Result.getResultKind()) { case LookupResult::NotFound: // If an unqualified-id is followed by a '(', then we have a function // call. if (!SS.isSet() && NextToken.is(tok::l_paren)) { // In C++, this is an ADL-only call. // FIXME: Reference? if (getLangOpts().CPlusPlus) return BuildDeclarationNameExpr(SS, Result, /*ADL=*/true); // C90 6.3.2.2: // If the expression that precedes the parenthesized argument list in a // function call consists solely of an identifier, and if no // declaration is visible for this identifier, the identifier is // implicitly declared exactly as if, in the innermost block containing // the function call, the declaration // // extern int identifier (); // // appeared. // // We also allow this in C99 as an extension. if (NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) { Result.addDecl(D); Result.resolveKind(); return BuildDeclarationNameExpr(SS, Result, /*ADL=*/false); } } // In C, we first see whether there is a tag type by the same name, in // which case it's likely that the user just forget to write "enum", // "struct", or "union". if (!getLangOpts().CPlusPlus && !SecondTry && isTagTypeWithMissingTag(*this, Result, S, SS, Name, NameLoc)) { break; } // Perform typo correction to determine if there is another name that is // close to this name. if (!SecondTry && CCC) { SecondTry = true; if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(), Result.getLookupKind(), S, &SS, *CCC)) { unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest; unsigned QualifiedDiag = diag::err_no_member_suggest; std::string CorrectedStr(Corrected.getAsString(getLangOpts())); std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOpts())); NamedDecl *FirstDecl = Corrected.getCorrectionDecl(); NamedDecl *UnderlyingFirstDecl = FirstDecl? FirstDecl->getUnderlyingDecl() : 0; if (getLangOpts().CPlusPlus && NextToken.is(tok::less) && UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) { UnqualifiedDiag = diag::err_no_template_suggest; QualifiedDiag = diag::err_no_member_template_suggest; } else if (UnderlyingFirstDecl && (isa<TypeDecl>(UnderlyingFirstDecl) || isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) || isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) { UnqualifiedDiag = diag::err_unknown_typename_suggest; QualifiedDiag = diag::err_unknown_nested_typename_suggest; } if (SS.isEmpty()) Diag(NameLoc, UnqualifiedDiag) << Name << CorrectedQuotedStr << FixItHint::CreateReplacement(NameLoc, CorrectedStr); else // FIXME: is this even reachable? Test it. Diag(NameLoc, QualifiedDiag) << Name << computeDeclContext(SS, false) << CorrectedQuotedStr << SS.getRange() << FixItHint::CreateReplacement(Corrected.getCorrectionRange(), CorrectedStr); // Update the name, so that the caller has the new name. Name = Corrected.getCorrectionAsIdentifierInfo(); // Typo correction corrected to a keyword. if (Corrected.isKeyword()) return Corrected.getCorrectionAsIdentifierInfo(); // Also update the LookupResult... // FIXME: This should probably go away at some point Result.clear(); Result.setLookupName(Corrected.getCorrection()); if (FirstDecl) { Result.addDecl(FirstDecl); Diag(FirstDecl->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr; } // If we found an Objective-C instance variable, let // LookupInObjCMethod build the appropriate expression to // reference the ivar. // FIXME: This is a gross hack. if (ObjCIvarDecl *Ivar = Result.getAsSingle<ObjCIvarDecl>()) { Result.clear(); ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier())); return E; } goto Corrected; } } // We failed to correct; just fall through and let the parser deal with it. Result.suppressDiagnostics(); return NameClassification::Unknown(); case LookupResult::NotFoundInCurrentInstantiation: { // We performed name lookup into the current instantiation, and there were // dependent bases, so we treat this result the same way as any other // dependent nested-name-specifier. // C++ [temp.res]p2: // A name used in a template declaration or definition and that is // dependent on a template-parameter is assumed not to name a type // unless the applicable name lookup finds a type name or the name is // qualified by the keyword typename. // // FIXME: If the next token is '<', we might want to ask the parser to // perform some heroics to see if we actually have a // template-argument-list, which would indicate a missing 'template' // keyword here. return ActOnDependentIdExpression(SS, /*TemplateKWLoc=*/SourceLocation(), NameInfo, IsAddressOfOperand, /*TemplateArgs=*/0); } case LookupResult::Found: case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: break; case LookupResult::Ambiguous: if (getLangOpts().CPlusPlus && NextToken.is(tok::less) && hasAnyAcceptableTemplateNames(Result)) { // C++ [temp.local]p3: // A lookup that finds an injected-class-name (10.2) can result in an // ambiguity in certain cases (for example, if it is found in more than // one base class). If all of the injected-class-names that are found // refer to specializations of the same class template, and if the name // is followed by a template-argument-list, the reference refers to the // class template itself and not a specialization thereof, and is not // ambiguous. // // This filtering can make an ambiguous result into an unambiguous one, // so try again after filtering out template names. FilterAcceptableTemplateNames(Result); if (!Result.isAmbiguous()) { IsFilteredTemplateName = true; break; } } // Diagnose the ambiguity and return an error. return NameClassification::Error(); } if (getLangOpts().CPlusPlus && NextToken.is(tok::less) && (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) { // C++ [temp.names]p3: // After name lookup (3.4) finds that a name is a template-name or that // an operator-function-id or a literal- operator-id refers to a set of // overloaded functions any member of which is a function template if // this is followed by a <, the < is always taken as the delimiter of a // template-argument-list and never as the less-than operator. if (!IsFilteredTemplateName) FilterAcceptableTemplateNames(Result); if (!Result.empty()) { bool IsFunctionTemplate; TemplateName Template; if (Result.end() - Result.begin() > 1) { IsFunctionTemplate = true; Template = Context.getOverloadedTemplateName(Result.begin(), Result.end()); } else { TemplateDecl *TD = cast<TemplateDecl>((*Result.begin())->getUnderlyingDecl()); IsFunctionTemplate = isa<FunctionTemplateDecl>(TD); if (SS.isSet() && !SS.isInvalid()) Template = Context.getQualifiedTemplateName(SS.getScopeRep(), /*TemplateKeyword=*/false, TD); else Template = TemplateName(TD); } if (IsFunctionTemplate) { // Function templates always go through overload resolution, at which // point we'll perform the various checks (e.g., accessibility) we need // to based on which function we selected. Result.suppressDiagnostics(); return NameClassification::FunctionTemplate(Template); } return NameClassification::TypeTemplate(Template); } } NamedDecl *FirstDecl = (*Result.begin())->getUnderlyingDecl(); if (TypeDecl *Type = dyn_cast<TypeDecl>(FirstDecl)) { DiagnoseUseOfDecl(Type, NameLoc); QualType T = Context.getTypeDeclType(Type); if (SS.isNotEmpty()) return buildNestedType(*this, SS, T, NameLoc); return ParsedType::make(T); } ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(FirstDecl); if (!Class) { // FIXME: It's unfortunate that we don't have a Type node for handling this. if (ObjCCompatibleAliasDecl *Alias = dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl)) Class = Alias->getClassInterface(); } if (Class) { DiagnoseUseOfDecl(Class, NameLoc); if (NextToken.is(tok::period)) { // Interface. <something> is parsed as a property reference expression. // Just return "unknown" as a fall-through for now. Result.suppressDiagnostics(); return NameClassification::Unknown(); } QualType T = Context.getObjCInterfaceType(Class); return ParsedType::make(T); } // We can have a type template here if we're classifying a template argument. if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl)) return NameClassification::TypeTemplate( TemplateName(cast<TemplateDecl>(FirstDecl))); // Check for a tag type hidden by a non-type decl in a few cases where it // seems likely a type is wanted instead of the non-type that was found. if (!getLangOpts().ObjC1) { bool NextIsOp = NextToken.is(tok::amp) || NextToken.is(tok::star); if ((NextToken.is(tok::identifier) || (NextIsOp && FirstDecl->isFunctionOrFunctionTemplate())) && isTagTypeWithMissingTag(*this, Result, S, SS, Name, NameLoc)) { TypeDecl *Type = Result.getAsSingle<TypeDecl>(); DiagnoseUseOfDecl(Type, NameLoc); QualType T = Context.getTypeDeclType(Type); if (SS.isNotEmpty()) return buildNestedType(*this, SS, T, NameLoc); return ParsedType::make(T); } } if (FirstDecl->isCXXClassMember()) return BuildPossibleImplicitMemberExpr(SS, SourceLocation(), Result, 0); bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.is(tok::l_paren)); return BuildDeclarationNameExpr(SS, Result, ADL); } // Determines the context to return to after temporarily entering a // context. This depends in an unnecessarily complicated way on the // exact ordering of callbacks from the parser. DeclContext *Sema::getContainingDC(DeclContext *DC) { // Functions defined inline within classes aren't parsed until we've // finished parsing the top-level class, so the top-level class is // the context we'll need to return to. if (isa<FunctionDecl>(DC)) { DC = DC->getLexicalParent(); // A function not defined within a class will always return to its // lexical context. if (!isa<CXXRecordDecl>(DC)) return DC; // A C++ inline method/friend is parsed *after* the topmost class // it was declared in is fully parsed ("complete"); the topmost // class is the context we need to return to. while (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC->getLexicalParent())) DC = RD; // Return the declaration context of the topmost class the inline method is // declared in. return DC; } return DC->getLexicalParent(); } void Sema::PushDeclContext(Scope *S, DeclContext *DC) { assert(getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."); CurContext = DC; S->setEntity(DC); } void Sema::PopDeclContext() { assert(CurContext && "DeclContext imbalance!"); CurContext = getContainingDC(CurContext); assert(CurContext && "Popped translation unit!"); } /// EnterDeclaratorContext - Used when we must lookup names in the context /// of a declarator's nested name specifier. /// void Sema::EnterDeclaratorContext(Scope *S, DeclContext *DC) { // C++0x [basic.lookup.unqual]p13: // A name used in the definition of a static data member of class // X (after the qualified-id of the static member) is looked up as // if the name was used in a member function of X. // C++0x [basic.lookup.unqual]p14: // If a variable member of a namespace is defined outside of the // scope of its namespace then any name used in the definition of // the variable member (after the declarator-id) is looked up as // if the definition of the variable member occurred in its // namespace. // Both of these imply that we should push a scope whose context // is the semantic context of the declaration. We can't use // PushDeclContext here because that context is not necessarily // lexically contained in the current context. Fortunately, // the containing scope should have the appropriate information. assert(!S->getEntity() && "scope already has entity"); #ifndef NDEBUG Scope *Ancestor = S->getParent(); while (!Ancestor->getEntity()) Ancestor = Ancestor->getParent(); assert(Ancestor->getEntity() == CurContext && "ancestor context mismatch"); #endif CurContext = DC; S->setEntity(DC); } void Sema::ExitDeclaratorContext(Scope *S) { assert(S->getEntity() == CurContext && "Context imbalance!"); // Switch back to the lexical context. The safety of this is // enforced by an assert in EnterDeclaratorContext. Scope *Ancestor = S->getParent(); while (!Ancestor->getEntity()) Ancestor = Ancestor->getParent(); CurContext = (DeclContext*) Ancestor->getEntity(); // We don't need to do anything with the scope, which is going to // disappear. } void Sema::ActOnReenterFunctionContext(Scope* S, Decl *D) { FunctionDecl *FD = dyn_cast<FunctionDecl>(D); if (FunctionTemplateDecl *TFD = dyn_cast_or_null<FunctionTemplateDecl>(D)) { // We assume that the caller has already called // ActOnReenterTemplateScope FD = TFD->getTemplatedDecl(); } if (!FD) return; // Same implementation as PushDeclContext, but enters the context // from the lexical parent, rather than the top-level class. assert(CurContext == FD->getLexicalParent() && "The next DeclContext should be lexically contained in the current one."); CurContext = FD; S->setEntity(CurContext); for (unsigned P = 0, NumParams = FD->getNumParams(); P < NumParams; ++P) { ParmVarDecl *Param = FD->getParamDecl(P); // If the parameter has an identifier, then add it to the scope if (Param->getIdentifier()) { S->AddDecl(Param); IdResolver.AddDecl(Param); } } } void Sema::ActOnExitFunctionContext() { // Same implementation as PopDeclContext, but returns to the lexical parent, // rather than the top-level class. assert(CurContext && "DeclContext imbalance!"); CurContext = CurContext->getLexicalParent(); assert(CurContext && "Popped translation unit!"); } /// \brief Determine whether we allow overloading of the function /// PrevDecl with another declaration. /// /// This routine determines whether overloading is possible, not /// whether some new function is actually an overload. It will return /// true in C++ (where we can always provide overloads) or, as an /// extension, in C when the previous function is already an /// overloaded function declaration or has the "overloadable" /// attribute. static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context) { if (Context.getLangOpts().CPlusPlus) return true; if (Previous.getResultKind() == LookupResult::FoundOverloaded) return true; return (Previous.getResultKind() == LookupResult::Found && Previous.getFoundDecl()->hasAttr<OverloadableAttr>()); } /// Add this decl to the scope shadowed decl chains. void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // Move up the scope chain until we find the nearest enclosing // non-transparent context. The declaration will be introduced into this // scope. while (S->getEntity() && ((DeclContext *)S->getEntity())->isTransparentContext()) S = S->getParent(); // Add scoped declarations into their context, so that they can be // found later. Declarations without a context won't be inserted // into any context. if (AddToContext) CurContext->addDecl(D); // Out-of-line definitions shouldn't be pushed into scope in C++. // Out-of-line variable and function definitions shouldn't even in C. if ((getLangOpts().CPlusPlus || isa<VarDecl>(D) || isa<FunctionDecl>(D)) && D->isOutOfLine() && !D->getDeclContext()->getRedeclContext()->Equals( D->getLexicalDeclContext()->getRedeclContext())) return; // Template instantiations should also not be pushed into scope. if (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isFunctionTemplateSpecialization()) return; // If this replaces anything in the current scope, IdentifierResolver::iterator I = IdResolver.begin(D->getDeclName()), IEnd = IdResolver.end(); for (; I != IEnd; ++I) { if (S->isDeclScope(*I) && D->declarationReplaces(*I)) { S->RemoveDecl(*I); IdResolver.RemoveDecl(*I); // Should only need to replace one decl. break; } } S->AddDecl(D); if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) { // Implicitly-generated labels may end up getting generated in an order that // isn't strictly lexical, which breaks name lookup. Be careful to insert // the label at the appropriate place in the identifier chain. for (I = IdResolver.begin(D->getDeclName()); I != IEnd; ++I) { DeclContext *IDC = (*I)->getLexicalDeclContext()->getRedeclContext(); if (IDC == CurContext) { if (!S->isDeclScope(*I)) continue; } else if (IDC->Encloses(CurContext)) break; } IdResolver.InsertDeclAfter(I, D); } else { IdResolver.AddDecl(D); } } void Sema::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) { if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope) TUScope->AddDecl(D); } bool Sema::isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S, bool ExplicitInstantiationOrSpecialization) { return IdResolver.isDeclInScope(D, Ctx, S, ExplicitInstantiationOrSpecialization); } Scope *Sema::getScopeForDeclContext(Scope *S, DeclContext *DC) { DeclContext *TargetDC = DC->getPrimaryContext(); do { if (DeclContext *ScopeDC = (DeclContext*) S->getEntity()) if (ScopeDC->getPrimaryContext() == TargetDC) return S; } while ((S = S->getParent())); return 0; } static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext*, ASTContext&); /// Filters out lookup results that don't fall within the given scope /// as determined by isDeclInScope. void Sema::FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool ExplicitInstantiationOrSpecialization) { LookupResult::Filter F = R.makeFilter(); while (F.hasNext()) { NamedDecl *D = F.next(); if (isDeclInScope(D, Ctx, S, ExplicitInstantiationOrSpecialization)) continue; if (ConsiderLinkage && isOutOfScopePreviousDeclaration(D, Ctx, Context)) continue; F.erase(); } F.done(); } static bool isUsingDecl(NamedDecl *D) { return isa<UsingShadowDecl>(D) || isa<UnresolvedUsingTypenameDecl>(D) || isa<UnresolvedUsingValueDecl>(D); } /// Removes using shadow declarations from the lookup results. static void RemoveUsingDecls(LookupResult &R) { LookupResult::Filter F = R.makeFilter(); while (F.hasNext()) if (isUsingDecl(F.next())) F.erase(); F.done(); } /// \brief Check for this common pattern: /// @code /// class S { /// S(const S&); // DO NOT IMPLEMENT /// void operator=(const S&); // DO NOT IMPLEMENT /// }; /// @endcode static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D) { // FIXME: Should check for private access too but access is set after we get // the decl here. if (D->doesThisDeclarationHaveABody()) return false; if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D)) return CD->isCopyConstructor(); if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) return Method->isCopyAssignmentOperator(); return false; } // We need this to handle // // typedef struct { // void *foo() { return 0; } // } A; // // When we see foo we don't know if after the typedef we will get 'A' or '*A' // for example. If 'A', foo will have external linkage. If we have '*A', // foo will have no linkage. Since we can't know untill we get to the end // of the typedef, this function finds out if D might have non external linkage. // Callers should verify at the end of the TU if it D has external linkage or // not. bool Sema::mightHaveNonExternalLinkage(const DeclaratorDecl *D) { const DeclContext *DC = D->getDeclContext(); while (!DC->isTranslationUnit()) { if (const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){ if (!RD->hasNameForLinkage()) return true; } DC = DC->getParent(); } return !D->hasExternalLinkage(); } bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const { assert(D); if (D->isInvalidDecl() || D->isUsed() || D->hasAttr<UnusedAttr>()) return false; // Ignore class templates. if (D->getDeclContext()->isDependentContext() || D->getLexicalDeclContext()->isDependentContext()) return false; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) return false; if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) { if (MD->isVirtual() || IsDisallowedCopyOrAssign(MD)) return false; } else { // 'static inline' functions are used in headers; don't warn. // Make sure we get the storage class from the canonical declaration, // since otherwise we will get spurious warnings on specialized // static template functions. if (FD->getCanonicalDecl()->getStorageClass() == SC_Static && FD->isInlineSpecified()) return false; } if (FD->doesThisDeclarationHaveABody() && Context.DeclMustBeEmitted(FD)) return false; } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { // Don't warn on variables of const-qualified or reference type, since their // values can be used even if though they're not odr-used, and because const // qualified variables can appear in headers in contexts where they're not // intended to be used. // FIXME: Use more principled rules for these exemptions. if (!VD->isFileVarDecl() || VD->getType().isConstQualified() || VD->getType()->isReferenceType() || Context.DeclMustBeEmitted(VD)) return false; if (VD->isStaticDataMember() && VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) return false; } else { return false; } // Only warn for unused decls internal to the translation unit. return mightHaveNonExternalLinkage(D); } void Sema::MarkUnusedFileScopedDecl(const DeclaratorDecl *D) { if (!D) return; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { const FunctionDecl *First = FD->getFirstDeclaration(); if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First)) return; // First should already be in the vector. } if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { const VarDecl *First = VD->getFirstDeclaration(); if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First)) return; // First should already be in the vector. } if (ShouldWarnIfUnusedFileScopedDecl(D)) UnusedFileScopedDecls.push_back(D); } static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) { if (D->isInvalidDecl()) return false; if (D->isReferenced() || D->isUsed() || D->hasAttr<UnusedAttr>()) return false; if (isa<LabelDecl>(D)) return true; // White-list anything that isn't a local variable. if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) || !D->getDeclContext()->isFunctionOrMethod()) return false; // Types of valid local variables should be complete, so this should succeed. if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { // White-list anything with an __attribute__((unused)) type. QualType Ty = VD->getType(); // Only look at the outermost level of typedef. if (const TypedefType *TT = Ty->getAs<TypedefType>()) { if (TT->getDecl()->hasAttr<UnusedAttr>()) return false; } // If we failed to complete the type for some reason, or if the type is // dependent, don't diagnose the variable. if (Ty->isIncompleteType() || Ty->isDependentType()) return false; if (const TagType *TT = Ty->getAs<TagType>()) { const TagDecl *Tag = TT->getDecl(); if (Tag->hasAttr<UnusedAttr>()) return false; if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) { if (!RD->hasTrivialDestructor()) return false; if (const Expr *Init = VD->getInit()) { if (const ExprWithCleanups *Cleanups = dyn_cast<ExprWithCleanups>(Init)) Init = Cleanups->getSubExpr(); const CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init); if (Construct && !Construct->isElidable()) { CXXConstructorDecl *CD = Construct->getConstructor(); if (!CD->isTrivial()) return false; } } } } // TODO: __attribute__((unused)) templates? } return true; } static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint) { if (isa<LabelDecl>(D)) { SourceLocation AfterColon = Lexer::findLocationAfterToken(D->getLocEnd(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(), true); if (AfterColon.isInvalid()) return; Hint = FixItHint::CreateRemoval(CharSourceRange:: getCharRange(D->getLocStart(), AfterColon)); } return; } /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used /// unless they are marked attr(unused). void Sema::DiagnoseUnusedDecl(const NamedDecl *D) { FixItHint Hint; if (!ShouldDiagnoseUnusedDecl(D)) return; GenerateFixForUnusedDecl(D, Context, Hint); unsigned DiagID; if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable()) DiagID = diag::warn_unused_exception_param; else if (isa<LabelDecl>(D)) DiagID = diag::warn_unused_label; else DiagID = diag::warn_unused_variable; Diag(D->getLocation(), DiagID) << D->getDeclName() << Hint; } static void CheckPoppedLabel(LabelDecl *L, Sema &S) { // Verify that we have no forward references left. If so, there was a goto // or address of a label taken, but no definition of it. Label fwd // definitions are indicated with a null substmt. if (L->getStmt() == 0) S.Diag(L->getLocation(), diag::err_undeclared_label_use) <<L->getDeclName(); } void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { if (S->decl_empty()) return; assert((S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) && "Scope shouldn't contain decls!"); for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end(); I != E; ++I) { Decl *TmpD = (*I); assert(TmpD && "This decl didn't get pushed??"); assert(isa<NamedDecl>(TmpD) && "Decl isn't NamedDecl?"); NamedDecl *D = cast<NamedDecl>(TmpD); if (!D->getDeclName()) continue; // Diagnose unused variables in this scope. if (!S->hasUnrecoverableErrorOccurred()) DiagnoseUnusedDecl(D); // If this was a forward reference to a label, verify it was defined. if (LabelDecl *LD = dyn_cast<LabelDecl>(D)) CheckPoppedLabel(LD, *this); // Remove this name from our lexical scope. IdResolver.RemoveDecl(D); } } void Sema::ActOnStartFunctionDeclarator() { ++InFunctionDeclarator; } void Sema::ActOnEndFunctionDeclarator() { assert(InFunctionDeclarator); --InFunctionDeclarator; } /// \brief Look for an Objective-C class in the translation unit. /// /// \param Id The name of the Objective-C class we're looking for. If /// typo-correction fixes this name, the Id will be updated /// to the fixed name. /// /// \param IdLoc The location of the name in the translation unit. /// /// \param DoTypoCorrection If true, this routine will attempt typo correction /// if there is no class with the given name. /// /// \returns The declaration of the named Objective-C class, or NULL if the /// class could not be found. ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool DoTypoCorrection) { // The third "scope" argument is 0 since we aren't enabling lazy built-in // creation from this context. NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName); if (!IDecl && DoTypoCorrection) { // Perform typo correction at the given location, but only if we // find an Objective-C class name. DeclFilterCCC<ObjCInterfaceDecl> Validator; if (TypoCorrection C = CorrectTypo(DeclarationNameInfo(Id, IdLoc), LookupOrdinaryName, TUScope, NULL, Validator)) { IDecl = C.getCorrectionDeclAs<ObjCInterfaceDecl>(); Diag(IdLoc, diag::err_undef_interface_suggest) << Id << IDecl->getDeclName() << FixItHint::CreateReplacement(IdLoc, IDecl->getNameAsString()); Diag(IDecl->getLocation(), diag::note_previous_decl) << IDecl->getDeclName(); Id = IDecl->getIdentifier(); } } ObjCInterfaceDecl *Def = dyn_cast_or_null<ObjCInterfaceDecl>(IDecl); // This routine must always return a class definition, if any. if (Def && Def->getDefinition()) Def = Def->getDefinition(); return Def; } /// getNonFieldDeclScope - Retrieves the innermost scope, starting /// from S, where a non-field would be declared. This routine copes /// with the difference between C and C++ scoping rules in structs and /// unions. For example, the following code is well-formed in C but /// ill-formed in C++: /// @code /// struct S6 { /// enum { BAR } e; /// }; /// /// void test_S6() { /// struct S6 a; /// a.e = BAR; /// } /// @endcode /// For the declaration of BAR, this routine will return a different /// scope. The scope S will be the scope of the unnamed enumeration /// within S6. In C++, this routine will return the scope associated /// with S6, because the enumeration's scope is a transparent /// context but structures can contain non-field names. In C, this /// routine will return the translation unit scope, since the /// enumeration's scope is a transparent context and structures cannot /// contain non-field names. Scope *Sema::getNonFieldDeclScope(Scope *S) { while (((S->getFlags() & Scope::DeclScope) == 0) || (S->getEntity() && ((DeclContext *)S->getEntity())->isTransparentContext()) || (S->isClassScope() && !getLangOpts().CPlusPlus)) S = S->getParent(); return S; } /// \brief Looks up the declaration of "struct objc_super" and /// saves it for later use in building builtin declaration of /// objc_msgSendSuper and objc_msgSendSuper_stret. If no such /// pre-existing declaration exists no action takes place. static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S, IdentifierInfo *II) { if (!II->isStr("objc_msgSendSuper")) return; ASTContext &Context = ThisSema.Context; LookupResult Result(ThisSema, &Context.Idents.get("objc_super"), SourceLocation(), Sema::LookupTagName); ThisSema.LookupName(Result, S); if (Result.getResultKind() == LookupResult::Found) if (const TagDecl *TD = Result.getAsSingle<TagDecl>()) Context.setObjCSuperType(Context.getTagDeclType(TD)); } /// LazilyCreateBuiltin - The specified Builtin-ID was first used at /// file scope. lazily create a decl for it. ForRedeclaration is true /// if we're creating this built-in in anticipation of redeclaring the /// built-in. NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, Scope *S, bool ForRedeclaration, SourceLocation Loc) { LookupPredefedObjCSuperType(*this, S, II); Builtin::ID BID = (Builtin::ID)bid; ASTContext::GetBuiltinTypeError Error; QualType R = Context.GetBuiltinType(BID, Error); switch (Error) { case ASTContext::GE_None: // Okay break; case ASTContext::GE_Missing_stdio: if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_stdio) << Context.BuiltinInfo.GetName(BID); return 0; case ASTContext::GE_Missing_setjmp: if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_setjmp) << Context.BuiltinInfo.GetName(BID); return 0; case ASTContext::GE_Missing_ucontext: if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_ucontext) << Context.BuiltinInfo.GetName(BID); return 0; } if (!ForRedeclaration && Context.BuiltinInfo.isPredefinedLibFunction(BID)) { Diag(Loc, diag::ext_implicit_lib_function_decl) << Context.BuiltinInfo.GetName(BID) << R; if (Context.BuiltinInfo.getHeaderName(BID) && Diags.getDiagnosticLevel(diag::ext_implicit_lib_function_decl, Loc) != DiagnosticsEngine::Ignored) Diag(Loc, diag::note_please_include_header) << Context.BuiltinInfo.getHeaderName(BID) << Context.BuiltinInfo.GetName(BID); } FunctionDecl *New = FunctionDecl::Create(Context, Context.getTranslationUnitDecl(), Loc, Loc, II, R, /*TInfo=*/0, SC_Extern, false, /*hasPrototype=*/true); New->setImplicit(); // Create Decl objects for each parameter, adding them to the // FunctionDecl. if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(R)) { SmallVector<ParmVarDecl*, 16> Params; for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) { ParmVarDecl *parm = ParmVarDecl::Create(Context, New, SourceLocation(), SourceLocation(), 0, FT->getArgType(i), /*TInfo=*/0, SC_None, 0); parm->setScopeInfo(0, i); Params.push_back(parm); } New->setParams(Params); } AddKnownFunctionAttributes(New); // TUScope is the translation-unit scope to insert this function into. // FIXME: This is hideous. We need to teach PushOnScopeChains to // relate Scopes to DeclContexts, and probably eliminate CurContext // entirely, but we're not there yet. DeclContext *SavedContext = CurContext; CurContext = Context.getTranslationUnitDecl(); PushOnScopeChains(New, TUScope); CurContext = SavedContext; return New; } /// \brief Filter out any previous declarations that the given declaration /// should not consider because they are not permitted to conflict, e.g., /// because they come from hidden sub-modules and do not refer to the same /// entity. static void filterNonConflictingPreviousDecls(ASTContext &context, NamedDecl *decl, LookupResult &previous){ // This is only interesting when modules are enabled. if (!context.getLangOpts().Modules) return; // Empty sets are uninteresting. if (previous.empty()) return; LookupResult::Filter filter = previous.makeFilter(); while (filter.hasNext()) { NamedDecl *old = filter.next(); // Non-hidden declarations are never ignored. if (!old->isHidden()) continue; if (old->getLinkage() != ExternalLinkage) filter.erase(); } filter.done(); } bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) { QualType OldType; if (TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old)) OldType = OldTypedef->getUnderlyingType(); else OldType = Context.getTypeDeclType(Old); QualType NewType = New->getUnderlyingType(); if (NewType->isVariablyModifiedType()) { // Must not redefine a typedef with a variably-modified type. int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0; Diag(New->getLocation(), diag::err_redefinition_variably_modified_typedef) << Kind << NewType; if (Old->getLocation().isValid()) Diag(Old->getLocation(), diag::note_previous_definition); New->setInvalidDecl(); return true; } if (OldType != NewType && !OldType->isDependentType() && !NewType->isDependentType() && !Context.hasSameType(OldType, NewType)) { int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0; Diag(New->getLocation(), diag::err_redefinition_different_typedef) << Kind << NewType << OldType; if (Old->getLocation().isValid()) Diag(Old->getLocation(), diag::note_previous_definition); New->setInvalidDecl(); return true; } return false; } /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the /// same name and scope as a previous declaration 'Old'. Figure out /// how to resolve this situation, merging decls or emitting /// diagnostics as appropriate. If there was an error, set New to be invalid. /// void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) { // If the new decl is known invalid already, don't bother doing any // merging checks. if (New->isInvalidDecl()) return; // Allow multiple definitions for ObjC built-in typedefs. // FIXME: Verify the underlying types are equivalent! if (getLangOpts().ObjC1) { const IdentifierInfo *TypeID = New->getIdentifier(); switch (TypeID->getLength()) { default: break; case 2: { if (!TypeID->isStr("id")) break; QualType T = New->getUnderlyingType(); if (!T->isPointerType()) break; if (!T->isVoidPointerType()) { QualType PT = T->getAs<PointerType>()->getPointeeType(); if (!PT->isStructureType()) break; } Context.setObjCIdRedefinitionType(T); // Install the built-in type for 'id', ignoring the current definition. New->setTypeForDecl(Context.getObjCIdType().getTypePtr()); return; } case 5: if (!TypeID->isStr("Class")) break; Context.setObjCClassRedefinitionType(New->getUnderlyingType()); // Install the built-in type for 'Class', ignoring the current definition. New->setTypeForDecl(Context.getObjCClassType().getTypePtr()); return; case 3: if (!TypeID->isStr("SEL")) break; Context.setObjCSelRedefinitionType(New->getUnderlyingType()); // Install the built-in type for 'SEL', ignoring the current definition. New->setTypeForDecl(Context.getObjCSelType().getTypePtr()); return; } // Fall through - the typedef name was not a builtin type. } // Verify the old decl was also a type. TypeDecl *Old = OldDecls.getAsSingle<TypeDecl>(); if (!Old) { Diag(New->getLocation(), diag::err_redefinition_different_kind) << New->getDeclName(); NamedDecl *OldD = OldDecls.getRepresentativeDecl(); if (OldD->getLocation().isValid()) Diag(OldD->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // If the old declaration is invalid, just give up here. if (Old->isInvalidDecl()) return New->setInvalidDecl(); // If the typedef types are not identical, reject them in all languages and // with any extensions enabled. if (isIncompatibleTypedef(Old, New)) return; // The types match. Link up the redeclaration chain if the old // declaration was a typedef. if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old)) New->setPreviousDeclaration(Typedef); if (getLangOpts().MicrosoftExt) return; if (getLangOpts().CPlusPlus) { // C++ [dcl.typedef]p2: // In a given non-class scope, a typedef specifier can be used to // redefine the name of any type declared in that scope to refer // to the type to which it already refers. if (!isa<CXXRecordDecl>(CurContext)) return; // C++0x [dcl.typedef]p4: // In a given class scope, a typedef specifier can be used to redefine // any class-name declared in that scope that is not also a typedef-name // to refer to the type to which it already refers. // // This wording came in via DR424, which was a correction to the // wording in DR56, which accidentally banned code like: // // struct S { // typedef struct A { } A; // }; // // in the C++03 standard. We implement the C++0x semantics, which // allow the above but disallow // // struct S { // typedef int I; // typedef int I; // }; // // since that was the intent of DR56. if (!isa<TypedefNameDecl>(Old)) return; Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // Modules always permit redefinition of typedefs, as does C11. if (getLangOpts().Modules || getLangOpts().C11) return; // If we have a redefinition of a typedef in C, emit a warning. This warning // is normally mapped to an error, but can be controlled with // -Wtypedef-redefinition. If either the original or the redefinition is // in a system header, don't emit this for compatibility with GCC. if (getDiagnostics().getSuppressSystemWarnings() && (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation()))) return; Diag(New->getLocation(), diag::warn_redefinition_of_typedef) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return; } /// DeclhasAttr - returns true if decl Declaration already has the target /// attribute. static bool DeclHasAttr(const Decl *D, const Attr *A) { // There can be multiple AvailabilityAttr in a Decl. Make sure we copy // all of them. It is mergeAvailabilityAttr in SemaDeclAttr.cpp that is // responsible for making sure they are consistent. const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(A); if (AA) return false; // The following thread safety attributes can also be duplicated. switch (A->getKind()) { case attr::ExclusiveLocksRequired: case attr::SharedLocksRequired: case attr::LocksExcluded: case attr::ExclusiveLockFunction: case attr::SharedLockFunction: case attr::UnlockFunction: case attr::ExclusiveTrylockFunction: case attr::SharedTrylockFunction: case attr::GuardedBy: case attr::PtGuardedBy: case attr::AcquiredBefore: case attr::AcquiredAfter: return false; default: ; } const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A); const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A); for (Decl::attr_iterator i = D->attr_begin(), e = D->attr_end(); i != e; ++i) if ((*i)->getKind() == A->getKind()) { if (Ann) { if (Ann->getAnnotation() == cast<AnnotateAttr>(*i)->getAnnotation()) return true; continue; } // FIXME: Don't hardcode this check if (OA && isa<OwnershipAttr>(*i)) return OA->getOwnKind() == cast<OwnershipAttr>(*i)->getOwnKind(); return true; } return false; } static bool isAttributeTargetADefinition(Decl *D) { if (VarDecl *VD = dyn_cast<VarDecl>(D)) return VD->isThisDeclarationADefinition(); if (TagDecl *TD = dyn_cast<TagDecl>(D)) return TD->isCompleteDefinition() || TD->isBeingDefined(); return true; } /// Merge alignment attributes from \p Old to \p New, taking into account the /// special semantics of C11's _Alignas specifier and C++11's alignas attribute. /// /// \return \c true if any attributes were added to \p New. static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) { // Look for alignas attributes on Old, and pick out whichever attribute // specifies the strictest alignment requirement. AlignedAttr *OldAlignasAttr = 0; AlignedAttr *OldStrictestAlignAttr = 0; unsigned OldAlign = 0; for (specific_attr_iterator<AlignedAttr> I = Old->specific_attr_begin<AlignedAttr>(), E = Old->specific_attr_end<AlignedAttr>(); I != E; ++I) { // FIXME: We have no way of representing inherited dependent alignments // in a case like: // template<int A, int B> struct alignas(A) X; // template<int A, int B> struct alignas(B) X {}; // For now, we just ignore any alignas attributes which are not on the // definition in such a case. if (I->isAlignmentDependent()) return false; if (I->isAlignas()) OldAlignasAttr = *I; unsigned Align = I->getAlignment(S.Context); if (Align > OldAlign) { OldAlign = Align; OldStrictestAlignAttr = *I; } } // Look for alignas attributes on New. AlignedAttr *NewAlignasAttr = 0; unsigned NewAlign = 0; for (specific_attr_iterator<AlignedAttr> I = New->specific_attr_begin<AlignedAttr>(), E = New->specific_attr_end<AlignedAttr>(); I != E; ++I) { if (I->isAlignmentDependent()) return false; if (I->isAlignas()) NewAlignasAttr = *I; unsigned Align = I->getAlignment(S.Context); if (Align > NewAlign) NewAlign = Align; } if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) { // Both declarations have 'alignas' attributes. We require them to match. // C++11 [dcl.align]p6 and C11 6.7.5/7 both come close to saying this, but // fall short. (If two declarations both have alignas, they must both match // every definition, and so must match each other if there is a definition.) // If either declaration only contains 'alignas(0)' specifiers, then it // specifies the natural alignment for the type. if (OldAlign == 0 || NewAlign == 0) { QualType Ty; if (ValueDecl *VD = dyn_cast<ValueDecl>(New)) Ty = VD->getType(); else Ty = S.Context.getTagDeclType(cast<TagDecl>(New)); if (OldAlign == 0) OldAlign = S.Context.getTypeAlign(Ty); if (NewAlign == 0) NewAlign = S.Context.getTypeAlign(Ty); } if (OldAlign != NewAlign) { S.Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch) << (unsigned)S.Context.toCharUnitsFromBits(OldAlign).getQuantity() << (unsigned)S.Context.toCharUnitsFromBits(NewAlign).getQuantity(); S.Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration); } } if (OldAlignasAttr && !NewAlignasAttr && isAttributeTargetADefinition(New)) { // C++11 [dcl.align]p6: // if any declaration of an entity has an alignment-specifier, // every defining declaration of that entity shall specify an // equivalent alignment. // C11 6.7.5/7: // If the definition of an object does not have an alignment // specifier, any other declaration of that object shall also // have no alignment specifier. S.Diag(New->getLocation(), diag::err_alignas_missing_on_definition) << OldAlignasAttr->isC11(); S.Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration) << OldAlignasAttr->isC11(); } bool AnyAdded = false; // Ensure we have an attribute representing the strictest alignment. if (OldAlign > NewAlign) { AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.Context); Clone->setInherited(true); New->addAttr(Clone); AnyAdded = true; } // Ensure we have an alignas attribute if the old declaration had one. if (OldAlignasAttr && !NewAlignasAttr && !(AnyAdded && OldStrictestAlignAttr->isAlignas())) { AlignedAttr *Clone = OldAlignasAttr->clone(S.Context); Clone->setInherited(true); New->addAttr(Clone); AnyAdded = true; } return AnyAdded; } static bool mergeDeclAttribute(Sema &S, NamedDecl *D, InheritableAttr *Attr, bool Override) { InheritableAttr *NewAttr = NULL; unsigned AttrSpellingListIndex = Attr->getSpellingListIndex(); if (AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attr)) NewAttr = S.mergeAvailabilityAttr(D, AA->getRange(), AA->getPlatform(), AA->getIntroduced(), AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(), AA->getMessage(), Override, AttrSpellingListIndex); else if (VisibilityAttr *VA = dyn_cast<VisibilityAttr>(Attr)) NewAttr = S.mergeVisibilityAttr(D, VA->getRange(), VA->getVisibility(), AttrSpellingListIndex); else if (TypeVisibilityAttr *VA = dyn_cast<TypeVisibilityAttr>(Attr)) NewAttr = S.mergeTypeVisibilityAttr(D, VA->getRange(), VA->getVisibility(), AttrSpellingListIndex); else if (DLLImportAttr *ImportA = dyn_cast<DLLImportAttr>(Attr)) NewAttr = S.mergeDLLImportAttr(D, ImportA->getRange(), AttrSpellingListIndex); else if (DLLExportAttr *ExportA = dyn_cast<DLLExportAttr>(Attr)) NewAttr = S.mergeDLLExportAttr(D, ExportA->getRange(), AttrSpellingListIndex); else if (FormatAttr *FA = dyn_cast<FormatAttr>(Attr)) NewAttr = S.mergeFormatAttr(D, FA->getRange(), FA->getType(), FA->getFormatIdx(), FA->getFirstArg(), AttrSpellingListIndex); else if (SectionAttr *SA = dyn_cast<SectionAttr>(Attr)) NewAttr = S.mergeSectionAttr(D, SA->getRange(), SA->getName(), AttrSpellingListIndex); else if (isa<AlignedAttr>(Attr)) // AlignedAttrs are handled separately, because we need to handle all // such attributes on a declaration at the same time. NewAttr = 0; else if (!DeclHasAttr(D, Attr)) NewAttr = cast<InheritableAttr>(Attr->clone(S.Context)); if (NewAttr) { NewAttr->setInherited(true); D->addAttr(NewAttr); return true; } return false; } static const Decl *getDefinition(const Decl *D) { if (const TagDecl *TD = dyn_cast<TagDecl>(D)) return TD->getDefinition(); if (const VarDecl *VD = dyn_cast<VarDecl>(D)) return VD->getDefinition(); if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { const FunctionDecl* Def; if (FD->hasBody(Def)) return Def; } return NULL; } static bool hasAttribute(const Decl *D, attr::Kind Kind) { for (Decl::attr_iterator I = D->attr_begin(), E = D->attr_end(); I != E; ++I) { Attr *Attribute = *I; if (Attribute->getKind() == Kind) return true; } return false; } /// checkNewAttributesAfterDef - If we already have a definition, check that /// there are no new attributes in this declaration. static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) { if (!New->hasAttrs()) return; const Decl *Def = getDefinition(Old); if (!Def || Def == New) return; AttrVec &NewAttributes = New->getAttrs(); for (unsigned I = 0, E = NewAttributes.size(); I != E;) { const Attr *NewAttribute = NewAttributes[I]; if (hasAttribute(Def, NewAttribute->getKind())) { ++I; continue; // regular attr merging will take care of validating this. } if (isa<C11NoReturnAttr>(NewAttribute)) { // C's _Noreturn is allowed to be added to a function after it is defined. ++I; continue; } else if (const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) { if (AA->isAlignas()) { // C++11 [dcl.align]p6: // if any declaration of an entity has an alignment-specifier, // every defining declaration of that entity shall specify an // equivalent alignment. // C11 6.7.5/7: // If the definition of an object does not have an alignment // specifier, any other declaration of that object shall also // have no alignment specifier. S.Diag(Def->getLocation(), diag::err_alignas_missing_on_definition) << AA->isC11(); S.Diag(NewAttribute->getLocation(), diag::note_alignas_on_declaration) << AA->isC11(); NewAttributes.erase(NewAttributes.begin() + I); --E; continue; } } S.Diag(NewAttribute->getLocation(), diag::warn_attribute_precede_definition); S.Diag(Def->getLocation(), diag::note_previous_definition); NewAttributes.erase(NewAttributes.begin() + I); --E; } } /// mergeDeclAttributes - Copy attributes from the Old decl to the New one. void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK) { if (!Old->hasAttrs() && !New->hasAttrs()) return; // attributes declared post-definition are currently ignored checkNewAttributesAfterDef(*this, New, Old); if (!Old->hasAttrs()) return; bool foundAny = New->hasAttrs(); // Ensure that any moving of objects within the allocated map is done before // we process them. if (!foundAny) New->setAttrs(AttrVec()); for (specific_attr_iterator<InheritableAttr> i = Old->specific_attr_begin<InheritableAttr>(), e = Old->specific_attr_end<InheritableAttr>(); i != e; ++i) { bool Override = false; // Ignore deprecated/unavailable/availability attributes if requested. if (isa<DeprecatedAttr>(*i) || isa<UnavailableAttr>(*i) || isa<AvailabilityAttr>(*i)) { switch (AMK) { case AMK_None: continue; case AMK_Redeclaration: break; case AMK_Override: Override = true; break; } } if (mergeDeclAttribute(*this, New, *i, Override)) foundAny = true; } if (mergeAlignedAttrs(*this, New, Old)) foundAny = true; if (!foundAny) New->dropAttrs(); } /// mergeParamDeclAttributes - Copy attributes from the old parameter /// to the new one. static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S) { // C++11 [dcl.attr.depend]p2: // The first declaration of a function shall specify the // carries_dependency attribute for its declarator-id if any declaration // of the function specifies the carries_dependency attribute. if (newDecl->hasAttr<CarriesDependencyAttr>() && !oldDecl->hasAttr<CarriesDependencyAttr>()) { S.Diag(newDecl->getAttr<CarriesDependencyAttr>()->getLocation(), diag::err_carries_dependency_missing_on_first_decl) << 1/*Param*/; // Find the first declaration of the parameter. // FIXME: Should we build redeclaration chains for function parameters? const FunctionDecl *FirstFD = cast<FunctionDecl>(oldDecl->getDeclContext())->getFirstDeclaration(); const ParmVarDecl *FirstVD = FirstFD->getParamDecl(oldDecl->getFunctionScopeIndex()); S.Diag(FirstVD->getLocation(), diag::note_carries_dependency_missing_first_decl) << 1/*Param*/; } if (!oldDecl->hasAttrs()) return; bool foundAny = newDecl->hasAttrs(); // Ensure that any moving of objects within the allocated map is // done before we process them. if (!foundAny) newDecl->setAttrs(AttrVec()); for (specific_attr_iterator<InheritableParamAttr> i = oldDecl->specific_attr_begin<InheritableParamAttr>(), e = oldDecl->specific_attr_end<InheritableParamAttr>(); i != e; ++i) { if (!DeclHasAttr(newDecl, *i)) { InheritableAttr *newAttr = cast<InheritableParamAttr>((*i)->clone(S.Context)); newAttr->setInherited(true); newDecl->addAttr(newAttr); foundAny = true; } } if (!foundAny) newDecl->dropAttrs(); } namespace { /// Used in MergeFunctionDecl to keep track of function parameters in /// C. struct GNUCompatibleParamWarning { ParmVarDecl *OldParm; ParmVarDecl *NewParm; QualType PromotedType; }; } /// getSpecialMember - get the special member enum for a method. Sema::CXXSpecialMember Sema::getSpecialMember(const CXXMethodDecl *MD) { if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(MD)) { if (Ctor->isDefaultConstructor()) return Sema::CXXDefaultConstructor; if (Ctor->isCopyConstructor()) return Sema::CXXCopyConstructor; if (Ctor->isMoveConstructor()) return Sema::CXXMoveConstructor; } else if (isa<CXXDestructorDecl>(MD)) { return Sema::CXXDestructor; } else if (MD->isCopyAssignmentOperator()) { return Sema::CXXCopyAssignment; } else if (MD->isMoveAssignmentOperator()) { return Sema::CXXMoveAssignment; } return Sema::CXXInvalid; } /// canRedefineFunction - checks if a function can be redefined. Currently, /// only extern inline functions can be redefined, and even then only in /// GNU89 mode. static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions& LangOpts) { return ((FD->hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) && !LangOpts.CPlusPlus && FD->isInlineSpecified() && FD->getStorageClass() == SC_Extern); } /// Is the given calling convention the ABI default for the given /// declaration? static bool isABIDefaultCC(Sema &S, CallingConv CC, FunctionDecl *D) { CallingConv ABIDefaultCC; if (isa<CXXMethodDecl>(D) && cast<CXXMethodDecl>(D)->isInstance()) { ABIDefaultCC = S.Context.getDefaultCXXMethodCallConv(D->isVariadic()); } else { // Free C function or a static method. ABIDefaultCC = (S.Context.getLangOpts().MRTD ? CC_X86StdCall : CC_C); } return ABIDefaultCC == CC; } template <typename T> static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) { const DeclContext *DC = Old->getDeclContext(); if (DC->isRecord()) return false; LanguageLinkage OldLinkage = Old->getLanguageLinkage(); if (OldLinkage == CXXLanguageLinkage && New->isInExternCContext()) return true; if (OldLinkage == CLanguageLinkage && New->isInExternCXXContext()) return true; return false; } /// MergeFunctionDecl - We just parsed a function 'New' from /// declarator D which has the same name and scope as a previous /// declaration 'Old'. Figure out how to resolve this situation, /// merging decls or emitting diagnostics as appropriate. /// /// In C++, New and Old must be declarations that are not /// overloaded. Use IsOverload to determine whether New and Old are /// overloaded, and to select the Old declaration that New should be /// merged with. /// /// Returns true if there was an error, false otherwise. bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S) { // Verify the old decl was also a function. FunctionDecl *Old = 0; if (FunctionTemplateDecl *OldFunctionTemplate = dyn_cast<FunctionTemplateDecl>(OldD)) Old = OldFunctionTemplate->getTemplatedDecl(); else Old = dyn_cast<FunctionDecl>(OldD); if (!Old) { if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(OldD)) { if (New->getFriendObjectKind()) { Diag(New->getLocation(), diag::err_using_decl_friend); Diag(Shadow->getTargetDecl()->getLocation(), diag::note_using_decl_target); Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0; return true; } Diag(New->getLocation(), diag::err_using_decl_conflict_reverse); Diag(Shadow->getTargetDecl()->getLocation(), diag::note_using_decl_target); Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl) << 0; return true; } Diag(New->getLocation(), diag::err_redefinition_different_kind) << New->getDeclName(); Diag(OldD->getLocation(), diag::note_previous_definition); return true; } // Determine whether the previous declaration was a definition, // implicit declaration, or a declaration. diag::kind PrevDiag; if (Old->isThisDeclarationADefinition()) PrevDiag = diag::note_previous_definition; else if (Old->isImplicit()) PrevDiag = diag::note_previous_implicit_declaration; else PrevDiag = diag::note_previous_declaration; QualType OldQType = Context.getCanonicalType(Old->getType()); QualType NewQType = Context.getCanonicalType(New->getType()); // Don't complain about this if we're in GNU89 mode and the old function // is an extern inline function. // Don't complain about specializations. They are not supposed to have // storage classes. if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) && New->getStorageClass() == SC_Static && isExternalLinkage(Old->getLinkage()) && !New->getTemplateSpecializationInfo() && !canRedefineFunction(Old, getLangOpts())) { if (getLangOpts().MicrosoftExt) { Diag(New->getLocation(), diag::warn_static_non_static) << New; Diag(Old->getLocation(), PrevDiag); } else { Diag(New->getLocation(), diag::err_static_non_static) << New; Diag(Old->getLocation(), PrevDiag); return true; } } // If a function is first declared with a calling convention, but is // later declared or defined without one, the second decl assumes the // calling convention of the first. // // It's OK if a function is first declared without a calling convention, // but is later declared or defined with the default calling convention. // // For the new decl, we have to look at the NON-canonical type to tell the // difference between a function that really doesn't have a calling // convention and one that is declared cdecl. That's because in // canonicalization (see ASTContext.cpp), cdecl is canonicalized away // because it is the default calling convention. // // Note also that we DO NOT return at this point, because we still have // other tests to run. const FunctionType *OldType = cast<FunctionType>(OldQType); const FunctionType *NewType = New->getType()->getAs<FunctionType>(); FunctionType::ExtInfo OldTypeInfo = OldType->getExtInfo(); FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo(); bool RequiresAdjustment = false; if (OldTypeInfo.getCC() == NewTypeInfo.getCC()) { // Fast path: nothing to do. // Inherit the CC from the previous declaration if it was specified // there but not here. } else if (NewTypeInfo.getCC() == CC_Default) { NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC()); RequiresAdjustment = true; // Don't complain about mismatches when the default CC is // effectively the same as the explict one. Only Old decl contains correct // information about storage class of CXXMethod. } else if (OldTypeInfo.getCC() == CC_Default && isABIDefaultCC(*this, NewTypeInfo.getCC(), Old)) { NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC()); RequiresAdjustment = true; } else if (!Context.isSameCallConv(OldTypeInfo.getCC(), NewTypeInfo.getCC())) { // Calling conventions really aren't compatible, so complain. Diag(New->getLocation(), diag::err_cconv_change) << FunctionType::getNameForCallConv(NewTypeInfo.getCC()) << (OldTypeInfo.getCC() == CC_Default) << (OldTypeInfo.getCC() == CC_Default ? "" : FunctionType::getNameForCallConv(OldTypeInfo.getCC())); Diag(Old->getLocation(), diag::note_previous_declaration); return true; } // FIXME: diagnose the other way around? if (OldTypeInfo.getNoReturn() && !NewTypeInfo.getNoReturn()) { NewTypeInfo = NewTypeInfo.withNoReturn(true); RequiresAdjustment = true; } // Merge regparm attribute. if (OldTypeInfo.getHasRegParm() != NewTypeInfo.getHasRegParm() || OldTypeInfo.getRegParm() != NewTypeInfo.getRegParm()) { if (NewTypeInfo.getHasRegParm()) { Diag(New->getLocation(), diag::err_regparm_mismatch) << NewType->getRegParmType() << OldType->getRegParmType(); Diag(Old->getLocation(), diag::note_previous_declaration); return true; } NewTypeInfo = NewTypeInfo.withRegParm(OldTypeInfo.getRegParm()); RequiresAdjustment = true; } // Merge ns_returns_retained attribute. if (OldTypeInfo.getProducesResult() != NewTypeInfo.getProducesResult()) { if (NewTypeInfo.getProducesResult()) { Diag(New->getLocation(), diag::err_returns_retained_mismatch); Diag(Old->getLocation(), diag::note_previous_declaration); return true; } NewTypeInfo = NewTypeInfo.withProducesResult(true); RequiresAdjustment = true; } if (RequiresAdjustment) { NewType = Context.adjustFunctionType(NewType, NewTypeInfo); New->setType(QualType(NewType, 0)); NewQType = Context.getCanonicalType(New->getType()); } // If this redeclaration makes the function inline, we may need to add it to // UndefinedButUsed. if (!Old->isInlined() && New->isInlined() && !New->hasAttr<GNUInlineAttr>() && (getLangOpts().CPlusPlus || !getLangOpts().GNUInline) && Old->isUsed(false) && !Old->isDefined() && !New->isThisDeclarationADefinition()) UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(), SourceLocation())); // If this redeclaration makes it newly gnu_inline, we don't want to warn // about it. if (New->hasAttr<GNUInlineAttr>() && Old->isInlined() && !Old->hasAttr<GNUInlineAttr>()) { UndefinedButUsed.erase(Old->getCanonicalDecl()); } if (getLangOpts().CPlusPlus) { // (C++98 13.1p2): // Certain function declarations cannot be overloaded: // -- Function declarations that differ only in the return type // cannot be overloaded. // Go back to the type source info to compare the declared return types, // per C++1y [dcl.type.auto]p??: // Redeclarations or specializations of a function or function template // with a declared return type that uses a placeholder type shall also // use that placeholder, not a deduced type. QualType OldDeclaredReturnType = (Old->getTypeSourceInfo() ? Old->getTypeSourceInfo()->getType()->castAs<FunctionType>() : OldType)->getResultType(); QualType NewDeclaredReturnType = (New->getTypeSourceInfo() ? New->getTypeSourceInfo()->getType()->castAs<FunctionType>() : NewType)->getResultType(); QualType ResQT; if (!Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType)) { if (NewDeclaredReturnType->isObjCObjectPointerType() && OldDeclaredReturnType->isObjCObjectPointerType()) ResQT = Context.mergeObjCGCQualifiers(NewQType, OldQType); if (ResQT.isNull()) { if (New->isCXXClassMember() && New->isOutOfLine()) Diag(New->getLocation(), diag::err_member_def_does_not_match_ret_type) << New; else Diag(New->getLocation(), diag::err_ovl_diff_return_type); Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); return true; } else NewQType = ResQT; } QualType OldReturnType = OldType->getResultType(); QualType NewReturnType = cast<FunctionType>(NewQType)->getResultType(); if (OldReturnType != NewReturnType) { // If this function has a deduced return type and has already been // defined, copy the deduced value from the old declaration. AutoType *OldAT = Old->getResultType()->getContainedAutoType(); if (OldAT && OldAT->isDeduced()) { New->setType(SubstAutoType(New->getType(), OldAT->getDeducedType())); NewQType = Context.getCanonicalType( SubstAutoType(NewQType, OldAT->getDeducedType())); } } const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old); CXXMethodDecl *NewMethod = dyn_cast<CXXMethodDecl>(New); if (OldMethod && NewMethod) { // Preserve triviality. NewMethod->setTrivial(OldMethod->isTrivial()); // MSVC allows explicit template specialization at class scope: // 2 CXMethodDecls referring to the same function will be injected. // We don't want a redeclartion error. bool IsClassScopeExplicitSpecialization = OldMethod->isFunctionTemplateSpecialization() && NewMethod->isFunctionTemplateSpecialization(); bool isFriend = NewMethod->getFriendObjectKind(); if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() && !IsClassScopeExplicitSpecialization) { // -- Member function declarations with the same name and the // same parameter types cannot be overloaded if any of them // is a static member function declaration. if (OldMethod->isStatic() || NewMethod->isStatic()) { Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member); Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); return true; } // C++ [class.mem]p1: // [...] A member shall not be declared twice in the // member-specification, except that a nested class or member // class template can be declared and then later defined. if (ActiveTemplateInstantiations.empty()) { unsigned NewDiag; if (isa<CXXConstructorDecl>(OldMethod)) NewDiag = diag::err_constructor_redeclared; else if (isa<CXXDestructorDecl>(NewMethod)) NewDiag = diag::err_destructor_redeclared; else if (isa<CXXConversionDecl>(NewMethod)) NewDiag = diag::err_conv_function_redeclared; else NewDiag = diag::err_member_redeclared; Diag(New->getLocation(), NewDiag); } else { Diag(New->getLocation(), diag::err_member_redeclared_in_instantiation) << New << New->getType(); } Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); // Complain if this is an explicit declaration of a special // member that was initially declared implicitly. // // As an exception, it's okay to befriend such methods in order // to permit the implicit constructor/destructor/operator calls. } else if (OldMethod->isImplicit()) { if (isFriend) { NewMethod->setImplicit(); } else { Diag(NewMethod->getLocation(), diag::err_definition_of_implicitly_declared_member) << New << getSpecialMember(OldMethod); return true; } } else if (OldMethod->isExplicitlyDefaulted() && !isFriend) { Diag(NewMethod->getLocation(), diag::err_definition_of_explicitly_defaulted_member) << getSpecialMember(OldMethod); return true; } } // C++11 [dcl.attr.noreturn]p1: // The first declaration of a function shall specify the noreturn // attribute if any declaration of that function specifies the noreturn // attribute. if (New->hasAttr<CXX11NoReturnAttr>() && !Old->hasAttr<CXX11NoReturnAttr>()) { Diag(New->getAttr<CXX11NoReturnAttr>()->getLocation(), diag::err_noreturn_missing_on_first_decl); Diag(Old->getFirstDeclaration()->getLocation(), diag::note_noreturn_missing_first_decl); } // C++11 [dcl.attr.depend]p2: // The first declaration of a function shall specify the // carries_dependency attribute for its declarator-id if any declaration // of the function specifies the carries_dependency attribute. if (New->hasAttr<CarriesDependencyAttr>() && !Old->hasAttr<CarriesDependencyAttr>()) { Diag(New->getAttr<CarriesDependencyAttr>()->getLocation(), diag::err_carries_dependency_missing_on_first_decl) << 0/*Function*/; Diag(Old->getFirstDeclaration()->getLocation(), diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } // (C++98 8.3.5p3): // All declarations for a function shall agree exactly in both the // return type and the parameter-type-list. // We also want to respect all the extended bits except noreturn. // noreturn should now match unless the old type info didn't have it. QualType OldQTypeForComparison = OldQType; if (!OldTypeInfo.getNoReturn() && NewTypeInfo.getNoReturn()) { assert(OldQType == QualType(OldType, 0)); const FunctionType *OldTypeForComparison = Context.adjustFunctionType(OldType, OldTypeInfo.withNoReturn(true)); OldQTypeForComparison = QualType(OldTypeForComparison, 0); assert(OldQTypeForComparison.isCanonical()); } if (haveIncompatibleLanguageLinkages(Old, New)) { Diag(New->getLocation(), diag::err_different_language_linkage) << New; Diag(Old->getLocation(), PrevDiag); return true; } if (OldQTypeForComparison == NewQType) return MergeCompatibleFunctionDecls(New, Old, S); // Fall through for conflicting redeclarations and redefinitions. } // C: Function types need to be compatible, not identical. This handles // duplicate function decls like "void f(int); void f(enum X);" properly. if (!getLangOpts().CPlusPlus && Context.typesAreCompatible(OldQType, NewQType)) { const FunctionType *OldFuncType = OldQType->getAs<FunctionType>(); const FunctionType *NewFuncType = NewQType->getAs<FunctionType>(); const FunctionProtoType *OldProto = 0; if (isa<FunctionNoProtoType>(NewFuncType) && (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) { // The old declaration provided a function prototype, but the // new declaration does not. Merge in the prototype. assert(!OldProto->hasExceptionSpec() && "Exception spec in C"); SmallVector<QualType, 16> ParamTypes(OldProto->arg_type_begin(), OldProto->arg_type_end()); NewQType = Context.getFunctionType(NewFuncType->getResultType(), ParamTypes, OldProto->getExtProtoInfo()); New->setType(NewQType); New->setHasInheritedPrototype(); // Synthesize a parameter for each argument type. SmallVector<ParmVarDecl*, 16> Params; for (FunctionProtoType::arg_type_iterator ParamType = OldProto->arg_type_begin(), ParamEnd = OldProto->arg_type_end(); ParamType != ParamEnd; ++ParamType) { ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(), SourceLocation(), 0, *ParamType, /*TInfo=*/0, SC_None, 0); Param->setScopeInfo(0, Params.size()); Param->setImplicit(); Params.push_back(Param); } New->setParams(Params); } return MergeCompatibleFunctionDecls(New, Old, S); } // GNU C permits a K&R definition to follow a prototype declaration // if the declared types of the parameters in the K&R definition // match the types in the prototype declaration, even when the // promoted types of the parameters from the K&R definition differ // from the types in the prototype. GCC then keeps the types from // the prototype. // // If a variadic prototype is followed by a non-variadic K&R definition, // the K&R definition becomes variadic. This is sort of an edge case, but // it's legal per the standard depending on how you read C99 6.7.5.3p15 and // C99 6.9.1p8. if (!getLangOpts().CPlusPlus && Old->hasPrototype() && !New->hasPrototype() && New->getType()->getAs<FunctionProtoType>() && Old->getNumParams() == New->getNumParams()) { SmallVector<QualType, 16> ArgTypes; SmallVector<GNUCompatibleParamWarning, 16> Warnings; const FunctionProtoType *OldProto = Old->getType()->getAs<FunctionProtoType>(); const FunctionProtoType *NewProto = New->getType()->getAs<FunctionProtoType>(); // Determine whether this is the GNU C extension. QualType MergedReturn = Context.mergeTypes(OldProto->getResultType(), NewProto->getResultType()); bool LooseCompatible = !MergedReturn.isNull(); for (unsigned Idx = 0, End = Old->getNumParams(); LooseCompatible && Idx != End; ++Idx) { ParmVarDecl *OldParm = Old->getParamDecl(Idx); ParmVarDecl *NewParm = New->getParamDecl(Idx); if (Context.typesAreCompatible(OldParm->getType(), NewProto->getArgType(Idx))) { ArgTypes.push_back(NewParm->getType()); } else if (Context.typesAreCompatible(OldParm->getType(), NewParm->getType(), /*CompareUnqualified=*/true)) { GNUCompatibleParamWarning Warn = { OldParm, NewParm, NewProto->getArgType(Idx) }; Warnings.push_back(Warn); ArgTypes.push_back(NewParm->getType()); } else LooseCompatible = false; } if (LooseCompatible) { for (unsigned Warn = 0; Warn < Warnings.size(); ++Warn) { Diag(Warnings[Warn].NewParm->getLocation(), diag::ext_param_promoted_not_compatible_with_prototype) << Warnings[Warn].PromotedType << Warnings[Warn].OldParm->getType(); if (Warnings[Warn].OldParm->getLocation().isValid()) Diag(Warnings[Warn].OldParm->getLocation(), diag::note_previous_declaration); } New->setType(Context.getFunctionType(MergedReturn, ArgTypes, OldProto->getExtProtoInfo())); return MergeCompatibleFunctionDecls(New, Old, S); } // Fall through to diagnose conflicting types. } // A function that has already been declared has been redeclared or // defined with a different type; show an appropriate diagnostic. // If the previous declaration was an implicitly-generated builtin // declaration, then at the very least we should use a specialized note. unsigned BuiltinID; if (Old->isImplicit() && (BuiltinID = Old->getBuiltinID())) { // If it's actually a library-defined builtin function like 'malloc' // or 'printf', just warn about the incompatible redeclaration. if (Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) { Diag(New->getLocation(), diag::warn_redecl_library_builtin) << New; Diag(Old->getLocation(), diag::note_previous_builtin_declaration) << Old << Old->getType(); // If this is a global redeclaration, just forget hereafter // about the "builtin-ness" of the function. // // Doing this for local extern declarations is problematic. If // the builtin declaration remains visible, a second invalid // local declaration will produce a hard error; if it doesn't // remain visible, a single bogus local redeclaration (which is // actually only a warning) could break all the downstream code. if (!New->getDeclContext()->isFunctionOrMethod()) New->getIdentifier()->setBuiltinID(Builtin::NotBuiltin); return false; } PrevDiag = diag::note_previous_builtin_declaration; } Diag(New->getLocation(), diag::err_conflicting_types) << New->getDeclName(); Diag(Old->getLocation(), PrevDiag) << Old << Old->getType(); return true; } /// \brief Completes the merge of two function declarations that are /// known to be compatible. /// /// This routine handles the merging of attributes and other /// properties of function declarations form the old declaration to /// the new declaration, once we know that New is in fact a /// redeclaration of Old. /// /// \returns false bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S) { // Merge the attributes mergeDeclAttributes(New, Old); // Merge "pure" flag. if (Old->isPure()) New->setPure(); // Merge "used" flag. if (Old->isUsed(false)) New->setUsed(); // Merge attributes from the parameters. These can mismatch with K&R // declarations. if (New->getNumParams() == Old->getNumParams()) for (unsigned i = 0, e = New->getNumParams(); i != e; ++i) mergeParamDeclAttributes(New->getParamDecl(i), Old->getParamDecl(i), *this); if (getLangOpts().CPlusPlus) return MergeCXXFunctionDecl(New, Old, S); // Merge the function types so the we get the composite types for the return // and argument types. QualType Merged = Context.mergeTypes(Old->getType(), New->getType()); if (!Merged.isNull()) New->setType(Merged); return false; } void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod, ObjCMethodDecl *oldMethod) { // Merge the attributes, including deprecated/unavailable AvailabilityMergeKind MergeKind = isa<ObjCImplDecl>(newMethod->getDeclContext()) ? AMK_Redeclaration : AMK_Override; mergeDeclAttributes(newMethod, oldMethod, MergeKind); // Merge attributes from the parameters. ObjCMethodDecl::param_const_iterator oi = oldMethod->param_begin(), oe = oldMethod->param_end(); for (ObjCMethodDecl::param_iterator ni = newMethod->param_begin(), ne = newMethod->param_end(); ni != ne && oi != oe; ++ni, ++oi) mergeParamDeclAttributes(*ni, *oi, *this); CheckObjCMethodOverride(newMethod, oldMethod); } /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and /// scope as a previous declaration 'Old'. Figure out how to merge their types, /// emitting diagnostics as appropriate. /// /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call back /// to here in AddInitializerToDecl. We can't check them before the initializer /// is attached. void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool OldWasHidden) { if (New->isInvalidDecl() || Old->isInvalidDecl()) return; QualType MergedT; if (getLangOpts().CPlusPlus) { if (New->getType()->isUndeducedType()) { // We don't know what the new type is until the initializer is attached. return; } else if (Context.hasSameType(New->getType(), Old->getType())) { // These could still be something that needs exception specs checked. return MergeVarDeclExceptionSpecs(New, Old); } // C++ [basic.link]p10: // [...] the types specified by all declarations referring to a given // object or function shall be identical, except that declarations for an // array object can specify array types that differ by the presence or // absence of a major array bound (8.3.4). else if (Old->getType()->isIncompleteArrayType() && New->getType()->isArrayType()) { const ArrayType *OldArray = Context.getAsArrayType(Old->getType()); const ArrayType *NewArray = Context.getAsArrayType(New->getType()); if (Context.hasSameType(OldArray->getElementType(), NewArray->getElementType())) MergedT = New->getType(); } else if (Old->getType()->isArrayType() && New->getType()->isIncompleteArrayType()) { const ArrayType *OldArray = Context.getAsArrayType(Old->getType()); const ArrayType *NewArray = Context.getAsArrayType(New->getType()); if (Context.hasSameType(OldArray->getElementType(), NewArray->getElementType())) MergedT = Old->getType(); } else if (New->getType()->isObjCObjectPointerType() && Old->getType()->isObjCObjectPointerType()) { MergedT = Context.mergeObjCGCQualifiers(New->getType(), Old->getType()); } } else { MergedT = Context.mergeTypes(New->getType(), Old->getType()); } if (MergedT.isNull()) { Diag(New->getLocation(), diag::err_redefinition_different_type) << New->getDeclName() << New->getType() << Old->getType(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // Don't actually update the type on the new declaration if the old // declaration was a extern declaration in a different scope. if (!OldWasHidden) New->setType(MergedT); } /// MergeVarDecl - We just parsed a variable 'New' which has the same name /// and scope as a previous declaration 'Old'. Figure out how to resolve this /// situation, merging decls or emitting diagnostics as appropriate. /// /// Tentative definition rules (C99 6.9.2p2) are checked by /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative /// definitions here, since the initializer hasn't been attached. /// void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous, bool PreviousWasHidden) { // If the new decl is already invalid, don't do any other checking. if (New->isInvalidDecl()) return; // Verify the old decl was also a variable. VarDecl *Old = 0; if (!Previous.isSingleResult() || !(Old = dyn_cast<VarDecl>(Previous.getFoundDecl()))) { Diag(New->getLocation(), diag::err_redefinition_different_kind) << New->getDeclName(); Diag(Previous.getRepresentativeDecl()->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } if (!shouldLinkPossiblyHiddenDecl(Old, New)) return; // C++ [class.mem]p1: // A member shall not be declared twice in the member-specification [...] // // Here, we need only consider static data members. if (Old->isStaticDataMember() && !New->isOutOfLine()) { Diag(New->getLocation(), diag::err_duplicate_member) << New->getIdentifier(); Diag(Old->getLocation(), diag::note_previous_declaration); New->setInvalidDecl(); } mergeDeclAttributes(New, Old); // Warn if an already-declared variable is made a weak_import in a subsequent // declaration if (New->getAttr<WeakImportAttr>() && Old->getStorageClass() == SC_None && !Old->getAttr<WeakImportAttr>()) { Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); // Remove weak_import attribute on new declaration. New->dropAttr<WeakImportAttr>(); } // Merge the types. MergeVarDeclTypes(New, Old, PreviousWasHidden); if (New->isInvalidDecl()) return; // [dcl.stc]p8: Check if we have a non-static decl followed by a static. if (New->getStorageClass() == SC_Static && !New->isStaticDataMember() && isExternalLinkage(Old->getLinkage())) { Diag(New->getLocation(), diag::err_static_non_static) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // C99 6.2.2p4: // For an identifier declared with the storage-class specifier // extern in a scope in which a prior declaration of that // identifier is visible,23) if the prior declaration specifies // internal or external linkage, the linkage of the identifier at // the later declaration is the same as the linkage specified at // the prior declaration. If no prior declaration is visible, or // if the prior declaration specifies no linkage, then the // identifier has external linkage. if (New->hasExternalStorage() && Old->hasLinkage()) /* Okay */; else if (New->getCanonicalDecl()->getStorageClass() != SC_Static && !New->isStaticDataMember() && Old->getCanonicalDecl()->getStorageClass() == SC_Static) { Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // Check if extern is followed by non-extern and vice-versa. if (New->hasExternalStorage() && !Old->hasLinkage() && Old->isLocalVarDecl()) { Diag(New->getLocation(), diag::err_extern_non_extern) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } if (Old->hasLinkage() && New->isLocalVarDecl() && !New->hasExternalStorage()) { Diag(New->getLocation(), diag::err_non_extern_extern) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } // Variables with external linkage are analyzed in FinalizeDeclaratorGroup. // FIXME: The test for external storage here seems wrong? We still // need to check for mismatches. if (!New->hasExternalStorage() && !New->isFileVarDecl() && // Don't complain about out-of-line definitions of static members. !(Old->getLexicalDeclContext()->isRecord() && !New->getLexicalDeclContext()->isRecord())) { Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } if (New->getTLSKind() != Old->getTLSKind()) { if (!Old->getTLSKind()) { Diag(New->getLocation(), diag::err_thread_non_thread) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_declaration); } else if (!New->getTLSKind()) { Diag(New->getLocation(), diag::err_non_thread_thread) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_declaration); } else { // Do not allow redeclaration to change the variable between requiring // static and dynamic initialization. // FIXME: GCC allows this, but uses the TLS keyword on the first // declaration to determine the kind. Do we need to be compatible here? Diag(New->getLocation(), diag::err_thread_thread_different_kind) << New->getDeclName() << (New->getTLSKind() == VarDecl::TLS_Dynamic); Diag(Old->getLocation(), diag::note_previous_declaration); } } // C++ doesn't have tentative definitions, so go right ahead and check here. const VarDecl *Def; if (getLangOpts().CPlusPlus && New->isThisDeclarationADefinition() == VarDecl::Definition && (Def = Old->getDefinition())) { Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName(); Diag(Def->getLocation(), diag::note_previous_definition); New->setInvalidDecl(); return; } if (haveIncompatibleLanguageLinkages(Old, New)) { Diag(New->getLocation(), diag::err_different_language_linkage) << New; Diag(Old->getLocation(), diag::note_previous_definition); New->setInvalidDecl(); return; } // Merge "used" flag. if (Old->isUsed(false)) New->setUsed(); // Keep a chain of previous declarations. New->setPreviousDeclaration(Old); // Inherit access appropriately. New->setAccess(Old->getAccess()); } /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with /// no declarator (e.g. "struct foo;") is parsed. Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS) { return ParsedFreeStandingDeclSpec(S, AS, DS, MultiTemplateParamsArg()); } /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with /// no declarator (e.g. "struct foo;") is parsed. It also accepts template /// parameters to cope with template friend declarations. Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, MultiTemplateParamsArg TemplateParams, bool IsExplicitInstantiation) { Decl *TagD = 0; TagDecl *Tag = 0; if (DS.getTypeSpecType() == DeclSpec::TST_class || DS.getTypeSpecType() == DeclSpec::TST_struct || DS.getTypeSpecType() == DeclSpec::TST_interface || DS.getTypeSpecType() == DeclSpec::TST_union || DS.getTypeSpecType() == DeclSpec::TST_enum) { TagD = DS.getRepAsDecl(); if (!TagD) // We probably had an error return 0; // Note that the above type specs guarantee that the // type rep is a Decl, whereas in many of the others // it's a Type. if (isa<TagDecl>(TagD)) Tag = cast<TagDecl>(TagD); else if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(TagD)) Tag = CTD->getTemplatedDecl(); } if (Tag) { getASTContext().addUnnamedTag(Tag); Tag->setFreeStanding(); if (Tag->isInvalidDecl()) return Tag; } if (unsigned TypeQuals = DS.getTypeQualifiers()) { // Enforce C99 6.7.3p2: "Types other than pointer types derived from object // or incomplete types shall not be restrict-qualified." if (TypeQuals & DeclSpec::TQ_restrict) Diag(DS.getRestrictSpecLoc(), diag::err_typecheck_invalid_restrict_not_pointer_noarg) << DS.getSourceRange(); } if (DS.isConstexprSpecified()) { // C++0x [dcl.constexpr]p1: constexpr can only be applied to declarations // and definitions of functions and variables. if (Tag) Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_tag) << (DS.getTypeSpecType() == DeclSpec::TST_class ? 0 : DS.getTypeSpecType() == DeclSpec::TST_struct ? 1 : DS.getTypeSpecType() == DeclSpec::TST_interface ? 2 : DS.getTypeSpecType() == DeclSpec::TST_union ? 3 : 4); else Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_no_declarators); // Don't emit warnings after this error. return TagD; } DiagnoseFunctionSpecifiers(DS); if (DS.isFriendSpecified()) { // If we're dealing with a decl but not a TagDecl, assume that // whatever routines created it handled the friendship aspect. if (TagD && !Tag) return 0; return ActOnFriendTypeDecl(S, DS, TemplateParams); } CXXScopeSpec &SS = DS.getTypeSpecScope(); bool IsExplicitSpecialization = !TemplateParams.empty() && TemplateParams.back()->size() == 0; if (Tag && SS.isNotEmpty() && !Tag->isCompleteDefinition() && !IsExplicitInstantiation && !IsExplicitSpecialization) { // Per C++ [dcl.type.elab]p1, a class declaration cannot have a // nested-name-specifier unless it is an explicit instantiation // or an explicit specialization. // Per C++ [dcl.enum]p1, an opaque-enum-declaration can't either. Diag(SS.getBeginLoc(), diag::err_standalone_class_nested_name_specifier) << (DS.getTypeSpecType() == DeclSpec::TST_class ? 0 : DS.getTypeSpecType() == DeclSpec::TST_struct ? 1 : DS.getTypeSpecType() == DeclSpec::TST_interface ? 2 : DS.getTypeSpecType() == DeclSpec::TST_union ? 3 : 4) << SS.getRange(); return 0; } // Track whether this decl-specifier declares anything. bool DeclaresAnything = true; // Handle anonymous struct definitions. if (RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) { if (!Record->getDeclName() && Record->isCompleteDefinition() && DS.getStorageClassSpec() != DeclSpec::SCS_typedef) { if (getLangOpts().CPlusPlus || Record->getDeclContext()->isRecord()) return BuildAnonymousStructOrUnion(S, DS, AS, Record); DeclaresAnything = false; } } // Check for Microsoft C extension: anonymous struct member. if (getLangOpts().MicrosoftExt && !getLangOpts().CPlusPlus && CurContext->isRecord() && DS.getStorageClassSpec() == DeclSpec::SCS_unspecified) { // Handle 2 kinds of anonymous struct: // struct STRUCT; // and // STRUCT_TYPE; <- where STRUCT_TYPE is a typedef struct. RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag); if ((Record && Record->getDeclName() && !Record->isCompleteDefinition()) || (DS.getTypeSpecType() == DeclSpec::TST_typename && DS.getRepAsType().get()->isStructureType())) { Diag(DS.getLocStart(), diag::ext_ms_anonymous_struct) << DS.getSourceRange(); return BuildMicrosoftCAnonymousStruct(S, DS, Record); } } // Skip all the checks below if we have a type error. if (DS.getTypeSpecType() == DeclSpec::TST_error || (TagD && TagD->isInvalidDecl())) return TagD; if (getLangOpts().CPlusPlus && DS.getStorageClassSpec() != DeclSpec::SCS_typedef) if (EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag)) if (Enum->enumerator_begin() == Enum->enumerator_end() && !Enum->getIdentifier() && !Enum->isInvalidDecl()) DeclaresAnything = false; if (!DS.isMissingDeclaratorOk()) { // Customize diagnostic for a typedef missing a name. if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) Diag(DS.getLocStart(), diag::ext_typedef_without_a_name) << DS.getSourceRange(); else DeclaresAnything = false; } if (DS.isModulePrivateSpecified() && Tag && Tag->getDeclContext()->isFunctionOrMethod()) Diag(DS.getModulePrivateSpecLoc(), diag::err_module_private_local_class) << Tag->getTagKind() << FixItHint::CreateRemoval(DS.getModulePrivateSpecLoc()); ActOnDocumentableDecl(TagD); // C 6.7/2: // A declaration [...] shall declare at least a declarator [...], a tag, // or the members of an enumeration. // C++ [dcl.dcl]p3: // [If there are no declarators], and except for the declaration of an // unnamed bit-field, the decl-specifier-seq shall introduce one or more // names into the program, or shall redeclare a name introduced by a // previous declaration. if (!DeclaresAnything) { // In C, we allow this as a (popular) extension / bug. Don't bother // producing further diagnostics for redundant qualifiers after this. Diag(DS.getLocStart(), diag::ext_no_declarators) << DS.getSourceRange(); return TagD; } // C++ [dcl.stc]p1: // If a storage-class-specifier appears in a decl-specifier-seq, [...] the // init-declarator-list of the declaration shall not be empty. // C++ [dcl.fct.spec]p1: // If a cv-qualifier appears in a decl-specifier-seq, the // init-declarator-list of the declaration shall not be empty. // // Spurious qualifiers here appear to be valid in C. unsigned DiagID = diag::warn_standalone_specifier; if (getLangOpts().CPlusPlus) DiagID = diag::ext_standalone_specifier; // Note that a linkage-specification sets a storage class, but // 'extern "C" struct foo;' is actually valid and not theoretically // useless. if (DeclSpec::SCS SCS = DS.getStorageClassSpec()) if (!DS.isExternInLinkageSpec() && SCS != DeclSpec::SCS_typedef) Diag(DS.getStorageClassSpecLoc(), DiagID) << DeclSpec::getSpecifierName(SCS); if (DeclSpec::TSCS TSCS = DS.getThreadStorageClassSpec()) Diag(DS.getThreadStorageClassSpecLoc(), DiagID) << DeclSpec::getSpecifierName(TSCS); if (DS.getTypeQualifiers()) { if (DS.getTypeQualifiers() & DeclSpec::TQ_const) Diag(DS.getConstSpecLoc(), DiagID) << "const"; if (DS.getTypeQualifiers() & DeclSpec::TQ_volatile) Diag(DS.getConstSpecLoc(), DiagID) << "volatile"; // Restrict is covered above. if (DS.getTypeQualifiers() & DeclSpec::TQ_atomic) Diag(DS.getAtomicSpecLoc(), DiagID) << "_Atomic"; } // Warn about ignored type attributes, for example: // __attribute__((aligned)) struct A; // Attributes should be placed after tag to apply to type declaration. if (!DS.getAttributes().empty()) { DeclSpec::TST TypeSpecType = DS.getTypeSpecType(); if (TypeSpecType == DeclSpec::TST_class || TypeSpecType == DeclSpec::TST_struct || TypeSpecType == DeclSpec::TST_interface || TypeSpecType == DeclSpec::TST_union || TypeSpecType == DeclSpec::TST_enum) { AttributeList* attrs = DS.getAttributes().getList(); while (attrs) { Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored) << attrs->getName() << (TypeSpecType == DeclSpec::TST_class ? 0 : TypeSpecType == DeclSpec::TST_struct ? 1 : TypeSpecType == DeclSpec::TST_union ? 2 : TypeSpecType == DeclSpec::TST_interface ? 3 : 4); attrs = attrs->getNext(); } } } return TagD; } /// We are trying to inject an anonymous member into the given scope; /// check if there's an existing declaration that can't be overloaded. /// /// \return true if this is a forbidden redeclaration static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, unsigned diagnostic) { LookupResult R(SemaRef, Name, NameLoc, Sema::LookupMemberName, Sema::ForRedeclaration); if (!SemaRef.LookupName(R, S)) return false; if (R.getAsSingle<TagDecl>()) return false; // Pick a representative declaration. NamedDecl *PrevDecl = R.getRepresentativeDecl()->getUnderlyingDecl(); assert(PrevDecl && "Expected a non-null Decl"); if (!SemaRef.isDeclInScope(PrevDecl, Owner, S)) return false; SemaRef.Diag(NameLoc, diagnostic) << Name; SemaRef.Diag(PrevDecl->getLocation(), diag::note_previous_declaration); return true; } /// InjectAnonymousStructOrUnionMembers - Inject the members of the /// anonymous struct or union AnonRecord into the owning context Owner /// and scope S. This routine will be invoked just after we realize /// that an unnamed union or struct is actually an anonymous union or /// struct, e.g., /// /// @code /// union { /// int i; /// float f; /// }; // InjectAnonymousStructOrUnionMembers called here to inject i and /// // f into the surrounding scope.x /// @endcode /// /// This routine is recursive, injecting the names of nested anonymous /// structs/unions into the owning context and scope as well. static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVector<NamedDecl*, 2> &Chaining, bool MSAnonStruct) { unsigned diagKind = AnonRecord->isUnion() ? diag::err_anonymous_union_member_redecl : diag::err_anonymous_struct_member_redecl; bool Invalid = false; // Look every FieldDecl and IndirectFieldDecl with a name. for (RecordDecl::decl_iterator D = AnonRecord->decls_begin(), DEnd = AnonRecord->decls_end(); D != DEnd; ++D) { if ((isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D)) && cast<NamedDecl>(*D)->getDeclName()) { ValueDecl *VD = cast<ValueDecl>(*D); if (CheckAnonMemberRedeclaration(SemaRef, S, Owner, VD->getDeclName(), VD->getLocation(), diagKind)) { // C++ [class.union]p2: // The names of the members of an anonymous union shall be // distinct from the names of any other entity in the // scope in which the anonymous union is declared. Invalid = true; } else { // C++ [class.union]p2: // For the purpose of name lookup, after the anonymous union // definition, the members of the anonymous union are // considered to have been defined in the scope in which the // anonymous union is declared. unsigned OldChainingSize = Chaining.size(); if (IndirectFieldDecl *IF = dyn_cast<IndirectFieldDecl>(VD)) for (IndirectFieldDecl::chain_iterator PI = IF->chain_begin(), PE = IF->chain_end(); PI != PE; ++PI) Chaining.push_back(*PI); else Chaining.push_back(VD); assert(Chaining.size() >= 2); NamedDecl **NamedChain = new (SemaRef.Context)NamedDecl*[Chaining.size()]; for (unsigned i = 0; i < Chaining.size(); i++) NamedChain[i] = Chaining[i]; IndirectFieldDecl* IndirectField = IndirectFieldDecl::Create(SemaRef.Context, Owner, VD->getLocation(), VD->getIdentifier(), VD->getType(), NamedChain, Chaining.size()); IndirectField->setAccess(AS); IndirectField->setImplicit(); SemaRef.PushOnScopeChains(IndirectField, S); // That includes picking up the appropriate access specifier. if (AS != AS_none) IndirectField->setAccess(AS); Chaining.resize(OldChainingSize); } } } return Invalid; } /// StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to /// a VarDecl::StorageClass. Any error reporting is up to the caller: /// illegal input values are mapped to SC_None. static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS) { DeclSpec::SCS StorageClassSpec = DS.getStorageClassSpec(); assert(StorageClassSpec != DeclSpec::SCS_typedef && "Parser allowed 'typedef' as storage class VarDecl."); switch (StorageClassSpec) { case DeclSpec::SCS_unspecified: return SC_None; case DeclSpec::SCS_extern: if (DS.isExternInLinkageSpec()) return SC_None; return SC_Extern; case DeclSpec::SCS_static: return SC_Static; case DeclSpec::SCS_auto: return SC_Auto; case DeclSpec::SCS_register: return SC_Register; case DeclSpec::SCS_private_extern: return SC_PrivateExtern; // Illegal SCSs map to None: error reporting is up to the caller. case DeclSpec::SCS_mutable: // Fall through. case DeclSpec::SCS_typedef: return SC_None; } llvm_unreachable("unknown storage class specifier"); } /// BuildAnonymousStructOrUnion - Handle the declaration of an /// anonymous structure or union. Anonymous unions are a C++ feature /// (C++ [class.union]) and a C11 feature; anonymous structures /// are a C11 feature and GNU C++ extension. Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record) { DeclContext *Owner = Record->getDeclContext(); // Diagnose whether this anonymous struct/union is an extension. if (Record->isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11) Diag(Record->getLocation(), diag::ext_anonymous_union); else if (!Record->isUnion() && getLangOpts().CPlusPlus) Diag(Record->getLocation(), diag::ext_gnu_anonymous_struct); else if (!Record->isUnion() && !getLangOpts().C11) Diag(Record->getLocation(), diag::ext_c11_anonymous_struct); // C and C++ require different kinds of checks for anonymous // structs/unions. bool Invalid = false; if (getLangOpts().CPlusPlus) { const char* PrevSpec = 0; unsigned DiagID; if (Record->isUnion()) { // C++ [class.union]p6: // Anonymous unions declared in a named namespace or in the // global namespace shall be declared static. if (DS.getStorageClassSpec() != DeclSpec::SCS_static && (isa<TranslationUnitDecl>(Owner) || (isa<NamespaceDecl>(Owner) && cast<NamespaceDecl>(Owner)->getDeclName()))) { Diag(Record->getLocation(), diag::err_anonymous_union_not_static) << FixItHint::CreateInsertion(Record->getLocation(), "static "); // Recover by adding 'static'. DS.SetStorageClassSpec(*this, DeclSpec::SCS_static, SourceLocation(), PrevSpec, DiagID); } // C++ [class.union]p6: // A storage class is not allowed in a declaration of an // anonymous union in a class scope. else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified && isa<RecordDecl>(Owner)) { Diag(DS.getStorageClassSpecLoc(), diag::err_anonymous_union_with_storage_spec) << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc()); // Recover by removing the storage specifier. DS.SetStorageClassSpec(*this, DeclSpec::SCS_unspecified, SourceLocation(), PrevSpec, DiagID); } } // Ignore const/volatile/restrict qualifiers. if (DS.getTypeQualifiers()) { if (DS.getTypeQualifiers() & DeclSpec::TQ_const) Diag(DS.getConstSpecLoc(), diag::ext_anonymous_struct_union_qualified) << Record->isUnion() << "const" << FixItHint::CreateRemoval(DS.getConstSpecLoc()); if (DS.getTypeQualifiers() & DeclSpec::TQ_volatile) Diag(DS.getVolatileSpecLoc(), diag::ext_anonymous_struct_union_qualified) << Record->isUnion() << "volatile" << FixItHint::CreateRemoval(DS.getVolatileSpecLoc()); if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict) Diag(DS.getRestrictSpecLoc(), diag::ext_anonymous_struct_union_qualified) << Record->isUnion() << "restrict" << FixItHint::CreateRemoval(DS.getRestrictSpecLoc()); if (DS.getTypeQualifiers() & DeclSpec::TQ_atomic) Diag(DS.getAtomicSpecLoc(), diag::ext_anonymous_struct_union_qualified) << Record->isUnion() << "_Atomic" << FixItHint::CreateRemoval(DS.getAtomicSpecLoc()); DS.ClearTypeQualifiers(); } // C++ [class.union]p2: // The member-specification of an anonymous union shall only // define non-static data members. [Note: nested types and // functions cannot be declared within an anonymous union. ] for (DeclContext::decl_iterator Mem = Record->decls_begin(), MemEnd = Record->decls_end(); Mem != MemEnd; ++Mem) { if (FieldDecl *FD = dyn_cast<FieldDecl>(*Mem)) { // C++ [class.union]p3: // An anonymous union shall not have private or protected // members (clause 11). assert(FD->getAccess() != AS_none); if (FD->getAccess() != AS_public) { Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member) << (int)Record->isUnion() << (int)(FD->getAccess() == AS_protected); Invalid = true; } // C++ [class.union]p1 // An object of a class with a non-trivial constructor, a non-trivial // copy constructor, a non-trivial destructor, or a non-trivial copy // assignment operator cannot be a member of a union, nor can an // array of such objects. if (CheckNontrivialField(FD)) Invalid = true; } else if ((*Mem)->isImplicit()) { // Any implicit members are fine. } else if (isa<TagDecl>(*Mem) && (*Mem)->getDeclContext() != Record) { // This is a type that showed up in an // elaborated-type-specifier inside the anonymous struct or // union, but which actually declares a type outside of the // anonymous struct or union. It's okay. } else if (RecordDecl *MemRecord = dyn_cast<RecordDecl>(*Mem)) { if (!MemRecord->isAnonymousStructOrUnion() && MemRecord->getDeclName()) { // Visual C++ allows type definition in anonymous struct or union. if (getLangOpts().MicrosoftExt) Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type) << (int)Record->isUnion(); else { // This is a nested type declaration. Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type) << (int)Record->isUnion(); Invalid = true; } } else { // This is an anonymous type definition within another anonymous type. // This is a popular extension, provided by Plan9, MSVC and GCC, but // not part of standard C++. Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_anonymous_type) << (int)Record->isUnion(); } } else if (isa<AccessSpecDecl>(*Mem)) { // Any access specifier is fine. } else { // We have something that isn't a non-static data // member. Complain about it. unsigned DK = diag::err_anonymous_record_bad_member; if (isa<TypeDecl>(*Mem)) DK = diag::err_anonymous_record_with_type; else if (isa<FunctionDecl>(*Mem)) DK = diag::err_anonymous_record_with_function; else if (isa<VarDecl>(*Mem)) DK = diag::err_anonymous_record_with_static; // Visual C++ allows type definition in anonymous struct or union. if (getLangOpts().MicrosoftExt && DK == diag::err_anonymous_record_with_type) Diag((*Mem)->getLocation(), diag::ext_anonymous_record_with_type) << (int)Record->isUnion(); else { Diag((*Mem)->getLocation(), DK) << (int)Record->isUnion(); Invalid = true; } } } } if (!Record->isUnion() && !Owner->isRecord()) { Diag(Record->getLocation(), diag::err_anonymous_struct_not_member) << (int)getLangOpts().CPlusPlus; Invalid = true; } // Mock up a declarator. Declarator Dc(DS, Declarator::MemberContext); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct/union"); // Create a declaration for this anonymous struct/union. NamedDecl *Anon = 0; if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, DS.getLocStart(), Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), TInfo, /*BitWidth=*/0, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit); Anon->setAccess(AS); if (getLangOpts().CPlusPlus) FieldCollector->Add(cast<FieldDecl>(Anon)); } else { DeclSpec::SCS SCSpec = DS.getStorageClassSpec(); VarDecl::StorageClass SC = StorageClassSpecToVarDeclStorageClass(DS); if (SCSpec == DeclSpec::SCS_mutable) { // mutable can only appear on non-static class members, so it's always // an error here Diag(Record->getLocation(), diag::err_mutable_nonmember); Invalid = true; SC = SC_None; } Anon = VarDecl::Create(Context, Owner, DS.getLocStart(), Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), TInfo, SC); // Default-initialize the implicit variable. This initialization will be // trivial in almost all cases, except if a union member has an in-class // initializer: // union { int n = 0; }; ActOnUninitializedDecl(Anon, /*TypeMayContainAuto=*/false); } Anon->setImplicit(); // Add the anonymous struct/union object to the current // context. We'll be referencing this object when we refer to one of // its members. Owner->addDecl(Anon); // Inject the members of the anonymous struct/union into the owning // context and into the identifier resolver chain for name lookup // purposes. SmallVector<NamedDecl*, 2> Chain; Chain.push_back(Anon); if (InjectAnonymousStructOrUnionMembers(*this, S, Owner, Record, AS, Chain, false)) Invalid = true; // Mark this as an anonymous struct/union type. Note that we do not // do this until after we have already checked and injected the // members of this anonymous struct/union type, because otherwise // the members could be injected twice: once by DeclContext when it // builds its lookup table, and once by // InjectAnonymousStructOrUnionMembers. Record->setAnonymousStructOrUnion(true); if (Invalid) Anon->setInvalidDecl(); return Anon; } /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an /// Microsoft C anonymous structure. /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx /// Example: /// /// struct A { int a; }; /// struct B { struct A; int b; }; /// /// void foo() { /// B var; /// var.a = 3; /// } /// Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record) { // If there is no Record, get the record via the typedef. if (!Record) Record = DS.getRepAsType().get()->getAsStructureType()->getDecl(); // Mock up a declarator. Declarator Dc(DS, Declarator::TypeNameContext); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct"); // Create a declaration for this anonymous struct. NamedDecl* Anon = FieldDecl::Create(Context, cast<RecordDecl>(CurContext), DS.getLocStart(), DS.getLocStart(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), TInfo, /*BitWidth=*/0, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit); Anon->setImplicit(); // Add the anonymous struct object to the current context. CurContext->addDecl(Anon); // Inject the members of the anonymous struct into the current // context and into the identifier resolver chain for name lookup // purposes. SmallVector<NamedDecl*, 2> Chain; Chain.push_back(Anon); RecordDecl *RecordDef = Record->getDefinition(); if (!RecordDef || InjectAnonymousStructOrUnionMembers(*this, S, CurContext, RecordDef, AS_none, Chain, true)) Anon->setInvalidDecl(); return Anon; } /// GetNameForDeclarator - Determine the full declaration name for the /// given Declarator. DeclarationNameInfo Sema::GetNameForDeclarator(Declarator &D) { return GetNameFromUnqualifiedId(D.getName()); } /// \brief Retrieves the declaration name from a parsed unqualified-id. DeclarationNameInfo Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) { DeclarationNameInfo NameInfo; NameInfo.setLoc(Name.StartLocation); switch (Name.getKind()) { case UnqualifiedId::IK_ImplicitSelfParam: case UnqualifiedId::IK_Identifier: NameInfo.setName(Name.Identifier); NameInfo.setLoc(Name.StartLocation); return NameInfo; case UnqualifiedId::IK_OperatorFunctionId: NameInfo.setName(Context.DeclarationNames.getCXXOperatorName( Name.OperatorFunctionId.Operator)); NameInfo.setLoc(Name.StartLocation); NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc = Name.OperatorFunctionId.SymbolLocations[0]; NameInfo.getInfo().CXXOperatorName.EndOpNameLoc = Name.EndLocation.getRawEncoding(); return NameInfo; case UnqualifiedId::IK_LiteralOperatorId: NameInfo.setName(Context.DeclarationNames.getCXXLiteralOperatorName( Name.Identifier)); NameInfo.setLoc(Name.StartLocation); NameInfo.setCXXLiteralOperatorNameLoc(Name.EndLocation); return NameInfo; case UnqualifiedId::IK_ConversionFunctionId: { TypeSourceInfo *TInfo; QualType Ty = GetTypeFromParser(Name.ConversionFunctionId, &TInfo); if (Ty.isNull()) return DeclarationNameInfo(); NameInfo.setName(Context.DeclarationNames.getCXXConversionFunctionName( Context.getCanonicalType(Ty))); NameInfo.setLoc(Name.StartLocation); NameInfo.setNamedTypeInfo(TInfo); return NameInfo; } case UnqualifiedId::IK_ConstructorName: { TypeSourceInfo *TInfo; QualType Ty = GetTypeFromParser(Name.ConstructorName, &TInfo); if (Ty.isNull()) return DeclarationNameInfo(); NameInfo.setName(Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(Ty))); NameInfo.setLoc(Name.StartLocation); NameInfo.setNamedTypeInfo(TInfo); return NameInfo; } case UnqualifiedId::IK_ConstructorTemplateId: { // In well-formed code, we can only have a constructor // template-id that refers to the current context, so go there // to find the actual type being constructed. CXXRecordDecl *CurClass = dyn_cast<CXXRecordDecl>(CurContext); if (!CurClass || CurClass->getIdentifier() != Name.TemplateId->Name) return DeclarationNameInfo(); // Determine the type of the class being constructed. QualType CurClassType = Context.getTypeDeclType(CurClass); // FIXME: Check two things: that the template-id names the same type as // CurClassType, and that the template-id does not occur when the name // was qualified. NameInfo.setName(Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(CurClassType))); NameInfo.setLoc(Name.StartLocation); // FIXME: should we retrieve TypeSourceInfo? NameInfo.setNamedTypeInfo(0); return NameInfo; } case UnqualifiedId::IK_DestructorName: { TypeSourceInfo *TInfo; QualType Ty = GetTypeFromParser(Name.DestructorName, &TInfo); if (Ty.isNull()) return DeclarationNameInfo(); NameInfo.setName(Context.DeclarationNames.getCXXDestructorName( Context.getCanonicalType(Ty))); NameInfo.setLoc(Name.StartLocation); NameInfo.setNamedTypeInfo(TInfo); return NameInfo; } case UnqualifiedId::IK_TemplateId: { TemplateName TName = Name.TemplateId->Template.get(); SourceLocation TNameLoc = Name.TemplateId->TemplateNameLoc; return Context.getNameForTemplate(TName, TNameLoc); } } // switch (Name.getKind()) llvm_unreachable("Unknown name kind"); } static QualType getCoreType(QualType Ty) { do { if (Ty->isPointerType() || Ty->isReferenceType()) Ty = Ty->getPointeeType(); else if (Ty->isArrayType()) Ty = Ty->castAsArrayTypeUnsafe()->getElementType(); else return Ty.withoutLocalFastQualifiers(); } while (true); } /// hasSimilarParameters - Determine whether the C++ functions Declaration /// and Definition have "nearly" matching parameters. This heuristic is /// used to improve diagnostics in the case where an out-of-line function /// definition doesn't match any declaration within the class or namespace. /// Also sets Params to the list of indices to the parameters that differ /// between the declaration and the definition. If hasSimilarParameters /// returns true and Params is empty, then all of the parameters match. static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl<unsigned> &Params) { Params.clear(); if (Declaration->param_size() != Definition->param_size()) return false; for (unsigned Idx = 0; Idx < Declaration->param_size(); ++Idx) { QualType DeclParamTy = Declaration->getParamDecl(Idx)->getType(); QualType DefParamTy = Definition->getParamDecl(Idx)->getType(); // The parameter types are identical if (Context.hasSameType(DefParamTy, DeclParamTy)) continue; QualType DeclParamBaseTy = getCoreType(DeclParamTy); QualType DefParamBaseTy = getCoreType(DefParamTy); const IdentifierInfo *DeclTyName = DeclParamBaseTy.getBaseTypeIdentifier(); const IdentifierInfo *DefTyName = DefParamBaseTy.getBaseTypeIdentifier(); if (Context.hasSameUnqualifiedType(DeclParamBaseTy, DefParamBaseTy) || (DeclTyName && DeclTyName == DefTyName)) Params.push_back(Idx); else // The two parameters aren't even close return false; } return true; } /// NeedsRebuildingInCurrentInstantiation - Checks whether the given /// declarator needs to be rebuilt in the current instantiation. /// Any bits of declarator which appear before the name are valid for /// consideration here. That's specifically the type in the decl spec /// and the base type in any member-pointer chunks. static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name) { // The types we specifically need to rebuild are: // - typenames, typeofs, and decltypes // - types which will become injected class names // Of course, we also need to rebuild any type referencing such a // type. It's safest to just say "dependent", but we call out a // few cases here. DeclSpec &DS = D.getMutableDeclSpec(); switch (DS.getTypeSpecType()) { case DeclSpec::TST_typename: case DeclSpec::TST_typeofType: case DeclSpec::TST_underlyingType: case DeclSpec::TST_atomic: { // Grab the type from the parser. TypeSourceInfo *TSI = 0; QualType T = S.GetTypeFromParser(DS.getRepAsType(), &TSI); if (T.isNull() || !T->isDependentType()) break; // Make sure there's a type source info. This isn't really much // of a waste; most dependent types should have type source info // attached already. if (!TSI) TSI = S.Context.getTrivialTypeSourceInfo(T, DS.getTypeSpecTypeLoc()); // Rebuild the type in the current instantiation. TSI = S.RebuildTypeInCurrentInstantiation(TSI, D.getIdentifierLoc(), Name); if (!TSI) return true; // Store the new type back in the decl spec. ParsedType LocType = S.CreateParsedType(TSI->getType(), TSI); DS.UpdateTypeRep(LocType); break; } case DeclSpec::TST_decltype: case DeclSpec::TST_typeofExpr: { Expr *E = DS.getRepAsExpr(); ExprResult Result = S.RebuildExprInCurrentInstantiation(E); if (Result.isInvalid()) return true; DS.UpdateExprRep(Result.get()); break; } default: // Nothing to do for these decl specs. break; } // It doesn't matter what order we do this in. for (unsigned I = 0, E = D.getNumTypeObjects(); I != E; ++I) { DeclaratorChunk &Chunk = D.getTypeObject(I); // The only type information in the declarator which can come // before the declaration name is the base type of a member // pointer. if (Chunk.Kind != DeclaratorChunk::MemberPointer) continue; // Rebuild the scope specifier in-place. CXXScopeSpec &SS = Chunk.Mem.Scope(); if (S.RebuildNestedNameSpecifierInCurrentInstantiation(SS)) return true; } return false; } Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) { D.setFunctionDefinitionKind(FDK_Declaration); Decl *Dcl = HandleDeclarator(S, D, MultiTemplateParamsArg()); if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() && Dcl && Dcl->getDeclContext()->isFileContext()) Dcl->setTopLevelDeclInObjCContainer(); return Dcl; } /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13: /// If T is the name of a class, then each of the following shall have a /// name different from T: /// - every static data member of class T; /// - every member function of class T /// - every member of class T that is itself a type; /// \returns true if the declaration name violates these rules. bool Sema::DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo NameInfo) { DeclarationName Name = NameInfo.getName(); if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) if (Record->getIdentifier() && Record->getDeclName() == Name) { Diag(NameInfo.getLoc(), diag::err_member_name_of_class) << Name; return true; } return false; } /// \brief Diagnose a declaration whose declarator-id has the given /// nested-name-specifier. /// /// \param SS The nested-name-specifier of the declarator-id. /// /// \param DC The declaration context to which the nested-name-specifier /// resolves. /// /// \param Name The name of the entity being declared. /// /// \param Loc The location of the name of the entity being declared. /// /// \returns true if we cannot safely recover from this error, false otherwise. bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc) { DeclContext *Cur = CurContext; while (isa<LinkageSpecDecl>(Cur)) Cur = Cur->getParent(); // C++ [dcl.meaning]p1: // A declarator-id shall not be qualified except for the definition // of a member function (9.3) or static data member (9.4) outside of // its class, the definition or explicit instantiation of a function // or variable member of a namespace outside of its namespace, or the // definition of an explicit specialization outside of its namespace, // or the declaration of a friend function that is a member of // another class or namespace (11.3). [...] // The user provided a superfluous scope specifier that refers back to the // class or namespaces in which the entity is already declared. // // class X { // void X::f(); // }; if (Cur->Equals(DC)) { Diag(Loc, LangOpts.MicrosoftExt? diag::warn_member_extra_qualification : diag::err_member_extra_qualification) << Name << FixItHint::CreateRemoval(SS.getRange()); SS.clear(); return false; } // Check whether the qualifying scope encloses the scope of the original // declaration. if (!Cur->Encloses(DC)) { if (Cur->isRecord()) Diag(Loc, diag::err_member_qualification) << Name << SS.getRange(); else if (isa<TranslationUnitDecl>(DC)) Diag(Loc, diag::err_invalid_declarator_global_scope) << Name << SS.getRange(); else if (isa<FunctionDecl>(Cur)) Diag(Loc, diag::err_invalid_declarator_in_function) << Name << SS.getRange(); else Diag(Loc, diag::err_invalid_declarator_scope) << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.getRange(); return true; } if (Cur->isRecord()) { // Cannot qualify members within a class. Diag(Loc, diag::err_member_qualification) << Name << SS.getRange(); SS.clear(); // C++ constructors and destructors with incorrect scopes can break // our AST invariants by having the wrong underlying types. If // that's the case, then drop this declaration entirely. if ((Name.getNameKind() == DeclarationName::CXXConstructorName || Name.getNameKind() == DeclarationName::CXXDestructorName) && !Context.hasSameType(Name.getCXXNameType(), Context.getTypeDeclType(cast<CXXRecordDecl>(Cur)))) return true; return false; } // C++11 [dcl.meaning]p1: // [...] "The nested-name-specifier of the qualified declarator-id shall // not begin with a decltype-specifer" NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data()); while (SpecLoc.getPrefix()) SpecLoc = SpecLoc.getPrefix(); if (dyn_cast_or_null<DecltypeType>( SpecLoc.getNestedNameSpecifier()->getAsType())) Diag(Loc, diag::err_decltype_in_declarator) << SpecLoc.getTypeLoc().getSourceRange(); return false; } NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists) { // TODO: consider using NameInfo for diagnostic. DeclarationNameInfo NameInfo = GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); // All of these full declarators require an identifier. If it doesn't have // one, the ParsedFreeStandingDeclSpec action should be used. if (!Name) { if (!D.isInvalidType()) // Reject this if we think it is valid. Diag(D.getDeclSpec().getLocStart(), diag::err_declarator_need_ident) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); return 0; } else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType)) return 0; // The scope passed in may not be a decl scope. Zip up the scope tree until // we find one that is. while ((S->getFlags() & Scope::DeclScope) == 0 || (S->getFlags() & Scope::TemplateParamScope) != 0) S = S->getParent(); DeclContext *DC = CurContext; if (D.getCXXScopeSpec().isInvalid()) D.setInvalidType(); else if (D.getCXXScopeSpec().isSet()) { if (DiagnoseUnexpandedParameterPack(D.getCXXScopeSpec(), UPPC_DeclarationQualifier)) return 0; bool EnteringContext = !D.getDeclSpec().isFriendSpecified(); DC = computeDeclContext(D.getCXXScopeSpec(), EnteringContext); if (!DC) { // If we could not compute the declaration context, it's because the // declaration context is dependent but does not refer to a class, // class template, or class template partial specialization. Complain // and return early, to avoid the coming semantic disaster. Diag(D.getIdentifierLoc(), diag::err_template_qualified_declarator_no_match) << (NestedNameSpecifier*)D.getCXXScopeSpec().getScopeRep() << D.getCXXScopeSpec().getRange(); return 0; } bool IsDependentContext = DC->isDependentContext(); if (!IsDependentContext && RequireCompleteDeclContext(D.getCXXScopeSpec(), DC)) return 0; if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->hasDefinition()) { Diag(D.getIdentifierLoc(), diag::err_member_def_undefined_record) << Name << DC << D.getCXXScopeSpec().getRange(); D.setInvalidType(); } else if (!D.getDeclSpec().isFriendSpecified()) { if (diagnoseQualifiedDeclaration(D.getCXXScopeSpec(), DC, Name, D.getIdentifierLoc())) { if (DC->isRecord()) return 0; D.setInvalidType(); } } // Check whether we need to rebuild the type of the given // declaration in the current instantiation. if (EnteringContext && IsDependentContext && TemplateParamLists.size() != 0) { ContextRAII SavedContext(*this, DC); if (RebuildDeclaratorInCurrentInstantiation(*this, D, Name)) D.setInvalidType(); } } if (DiagnoseClassNameShadow(DC, NameInfo)) // If this is a typedef, we'll end up spewing multiple diagnostics. // Just return early; it's safer. if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) return 0; TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType R = TInfo->getType(); if (DiagnoseUnexpandedParameterPack(D.getIdentifierLoc(), TInfo, UPPC_DeclarationType)) D.setInvalidType(); LookupResult Previous(*this, NameInfo, LookupOrdinaryName, ForRedeclaration); // See if this is a redefinition of a variable in the same scope. if (!D.getCXXScopeSpec().isSet()) { bool IsLinkageLookup = false; // If the declaration we're planning to build will be a function // or object with linkage, then look for another declaration with // linkage (C99 6.2.2p4-5 and C++ [basic.link]p6). if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) /* Do nothing*/; else if (R->isFunctionType()) { if (CurContext->isFunctionOrMethod() || D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) IsLinkageLookup = true; } else if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern) IsLinkageLookup = true; else if (CurContext->getRedeclContext()->isTranslationUnit() && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) IsLinkageLookup = true; if (IsLinkageLookup) Previous.clear(LookupRedeclarationWithLinkage); LookupName(Previous, S, /* CreateBuiltins = */ IsLinkageLookup); } else { // Something like "int foo::x;" LookupQualifiedName(Previous, DC); // C++ [dcl.meaning]p1: // When the declarator-id is qualified, the declaration shall refer to a // previously declared member of the class or namespace to which the // qualifier refers (or, in the case of a namespace, of an element of the // inline namespace set of that namespace (7.3.1)) or to a specialization // thereof; [...] // // Note that we already checked the context above, and that we do not have // enough information to make sure that Previous contains the declaration // we want to match. For example, given: // // class X { // void f(); // void f(float); // }; // // void X::f(int) { } // ill-formed // // In this case, Previous will point to the overload set // containing the two f's declared in X, but neither of them // matches. // C++ [dcl.meaning]p1: // [...] the member shall not merely have been introduced by a // using-declaration in the scope of the class or namespace nominated by // the nested-name-specifier of the declarator-id. RemoveUsingDecls(Previous); } if (Previous.isSingleResult() && Previous.getFoundDecl()->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. if (!D.isInvalidType()) DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), Previous.getFoundDecl()); // Just pretend that we didn't see the previous declaration. Previous.clear(); } // In C++, the previous declaration we find might be a tag type // (class or enum). In this case, the new declaration will hide the // tag type. Note that this does does not apply if we're declaring a // typedef (C++ [dcl.typedef]p4). if (Previous.isSingleTagDecl() && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef) Previous.clear(); // Check that there are no default arguments other than in the parameters // of a function declaration (C++ only). if (getLangOpts().CPlusPlus) CheckExtraCXXDefaultArguments(D); NamedDecl *New; bool AddToScope = true; if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) { if (TemplateParamLists.size()) { Diag(D.getIdentifierLoc(), diag::err_template_typedef); return 0; } New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous); } else if (R->isFunctionType()) { New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists, AddToScope); } else { New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists); } if (New == 0) return 0; // If this has an identifier and is not an invalid redeclaration or // function template specialization, add it to the scope stack. if (New->getDeclName() && AddToScope && !(D.isRedeclaration() && New->isInvalidDecl())) PushOnScopeChains(New, S); return New; } /// Helper method to turn variable array types into constant array /// types in certain situations which would otherwise be errors (for /// GCC compatibility). static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized) { // This method tries to turn a variable array into a constant // array even when the size isn't an ICE. This is necessary // for compatibility with code that depends on gcc's buggy // constant expression folding, like struct {char x[(int)(char*)2];} SizeIsNegative = false; Oversized = 0; if (T->isDependentType()) return QualType(); QualifierCollector Qs; const Type *Ty = Qs.strip(T); if (const PointerType* PTy = dyn_cast<PointerType>(Ty)) { QualType Pointee = PTy->getPointeeType(); QualType FixedType = TryToFixInvalidVariablyModifiedType(Pointee, Context, SizeIsNegative, Oversized); if (FixedType.isNull()) return FixedType; FixedType = Context.getPointerType(FixedType); return Qs.apply(Context, FixedType); } if (const ParenType* PTy = dyn_cast<ParenType>(Ty)) { QualType Inner = PTy->getInnerType(); QualType FixedType = TryToFixInvalidVariablyModifiedType(Inner, Context, SizeIsNegative, Oversized); if (FixedType.isNull()) return FixedType; FixedType = Context.getParenType(FixedType); return Qs.apply(Context, FixedType); } const VariableArrayType* VLATy = dyn_cast<VariableArrayType>(T); if (!VLATy) return QualType(); // FIXME: We should probably handle this case if (VLATy->getElementType()->isVariablyModifiedType()) return QualType(); llvm::APSInt Res; if (!VLATy->getSizeExpr() || !VLATy->getSizeExpr()->EvaluateAsInt(Res, Context)) return QualType(); // Check whether the array size is negative. if (Res.isSigned() && Res.isNegative()) { SizeIsNegative = true; return QualType(); } // Check whether the array is too large to be addressed. unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(Context, VLATy->getElementType(), Res); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) { Oversized = Res; return QualType(); } return Context.getConstantArrayType(VLATy->getElementType(), Res, ArrayType::Normal, 0); } static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL) { if (PointerTypeLoc SrcPTL = SrcTL.getAs<PointerTypeLoc>()) { PointerTypeLoc DstPTL = DstTL.castAs<PointerTypeLoc>(); FixInvalidVariablyModifiedTypeLoc(SrcPTL.getPointeeLoc(), DstPTL.getPointeeLoc()); DstPTL.setStarLoc(SrcPTL.getStarLoc()); return; } if (ParenTypeLoc SrcPTL = SrcTL.getAs<ParenTypeLoc>()) { ParenTypeLoc DstPTL = DstTL.castAs<ParenTypeLoc>(); FixInvalidVariablyModifiedTypeLoc(SrcPTL.getInnerLoc(), DstPTL.getInnerLoc()); DstPTL.setLParenLoc(SrcPTL.getLParenLoc()); DstPTL.setRParenLoc(SrcPTL.getRParenLoc()); return; } ArrayTypeLoc SrcATL = SrcTL.castAs<ArrayTypeLoc>(); ArrayTypeLoc DstATL = DstTL.castAs<ArrayTypeLoc>(); TypeLoc SrcElemTL = SrcATL.getElementLoc(); TypeLoc DstElemTL = DstATL.getElementLoc(); DstElemTL.initializeFullCopy(SrcElemTL); DstATL.setLBracketLoc(SrcATL.getLBracketLoc()); DstATL.setSizeExpr(SrcATL.getSizeExpr()); DstATL.setRBracketLoc(SrcATL.getRBracketLoc()); } /// Helper method to turn variable array types into constant array /// types in certain situations which would otherwise be errors (for /// GCC compatibility). static TypeSourceInfo* TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized) { QualType FixedTy = TryToFixInvalidVariablyModifiedType(TInfo->getType(), Context, SizeIsNegative, Oversized); if (FixedTy.isNull()) return 0; TypeSourceInfo *FixedTInfo = Context.getTrivialTypeSourceInfo(FixedTy); FixInvalidVariablyModifiedTypeLoc(TInfo->getTypeLoc(), FixedTInfo->getTypeLoc()); return FixedTInfo; } /// \brief Register the given locally-scoped extern "C" declaration so /// that it can be found later for redeclarations void Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, const LookupResult &Previous, Scope *S) { assert(ND->getLexicalDeclContext()->isFunctionOrMethod() && "Decl is not a locally-scoped decl!"); // Note that we have a locally-scoped external with this name. LocallyScopedExternCDecls[ND->getDeclName()] = ND; } llvm::DenseMap<DeclarationName, NamedDecl *>::iterator Sema::findLocallyScopedExternCDecl(DeclarationName Name) { if (ExternalSource) { // Load locally-scoped external decls from the external source. SmallVector<NamedDecl *, 4> Decls; ExternalSource->ReadLocallyScopedExternCDecls(Decls); for (unsigned I = 0, N = Decls.size(); I != N; ++I) { llvm::DenseMap<DeclarationName, NamedDecl *>::iterator Pos = LocallyScopedExternCDecls.find(Decls[I]->getDeclName()); if (Pos == LocallyScopedExternCDecls.end()) LocallyScopedExternCDecls[Decls[I]->getDeclName()] = Decls[I]; } } return LocallyScopedExternCDecls.find(Name); } /// \brief Diagnose function specifiers on a declaration of an identifier that /// does not identify a function. void Sema::DiagnoseFunctionSpecifiers(const DeclSpec &DS) { // FIXME: We should probably indicate the identifier in question to avoid // confusion for constructs like "inline int a(), b;" if (DS.isInlineSpecified()) Diag(DS.getInlineSpecLoc(), diag::err_inline_non_function); if (DS.isVirtualSpecified()) Diag(DS.getVirtualSpecLoc(), diag::err_virtual_non_function); if (DS.isExplicitSpecified()) Diag(DS.getExplicitSpecLoc(), diag::err_explicit_non_function); if (DS.isNoreturnSpecified()) Diag(DS.getNoreturnSpecLoc(), diag::err_noreturn_non_function); } NamedDecl* Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, TypeSourceInfo *TInfo, LookupResult &Previous) { // Typedef declarators cannot be qualified (C++ [dcl.meaning]p1). if (D.getCXXScopeSpec().isSet()) { Diag(D.getIdentifierLoc(), diag::err_qualified_typedef_declarator) << D.getCXXScopeSpec().getRange(); D.setInvalidType(); // Pretend we didn't see the scope specifier. DC = CurContext; Previous.clear(); } DiagnoseFunctionSpecifiers(D.getDeclSpec()); if (D.getDeclSpec().isConstexprSpecified()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr) << 1; if (D.getName().Kind != UnqualifiedId::IK_Identifier) { Diag(D.getName().StartLocation, diag::err_typedef_not_identifier) << D.getName().getSourceRange(); return 0; } TypedefDecl *NewTD = ParseTypedefDecl(S, D, TInfo->getType(), TInfo); if (!NewTD) return 0; // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(S, NewTD, D); CheckTypedefForVariablyModifiedType(S, NewTD); bool Redeclaration = D.isRedeclaration(); NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration); D.setRedeclaration(Redeclaration); return ND; } void Sema::CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *NewTD) { // C99 6.7.7p2: If a typedef name specifies a variably modified type // then it shall have block scope. // Note that variably modified types must be fixed before merging the decl so // that redeclarations will match. TypeSourceInfo *TInfo = NewTD->getTypeSourceInfo(); QualType T = TInfo->getType(); if (T->isVariablyModifiedType()) { getCurFunction()->setHasBranchProtectedScope(); if (S->getFnParent() == 0) { bool SizeIsNegative; llvm::APSInt Oversized; TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, SizeIsNegative, Oversized); if (FixedTInfo) { Diag(NewTD->getLocation(), diag::warn_illegal_constant_array_size); NewTD->setTypeSourceInfo(FixedTInfo); } else { if (SizeIsNegative) Diag(NewTD->getLocation(), diag::err_typecheck_negative_array_size); else if (T->isVariableArrayType()) Diag(NewTD->getLocation(), diag::err_vla_decl_in_file_scope); else if (Oversized.getBoolValue()) Diag(NewTD->getLocation(), diag::err_array_too_large) << Oversized.toString(10); else Diag(NewTD->getLocation(), diag::err_vm_decl_in_file_scope); NewTD->setInvalidDecl(); } } } } /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which /// declares a typedef-name, either using the 'typedef' type specifier or via /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'. NamedDecl* Sema::ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *NewTD, LookupResult &Previous, bool &Redeclaration) { // Merge the decl with the existing one if appropriate. If the decl is // in an outer scope, it isn't the same thing. FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage*/ false, /*ExplicitInstantiationOrSpecialization=*/false); filterNonConflictingPreviousDecls(Context, NewTD, Previous); if (!Previous.empty()) { Redeclaration = true; MergeTypedefNameDecl(NewTD, Previous); } // If this is the C FILE type, notify the AST context. if (IdentifierInfo *II = NewTD->getIdentifier()) if (!NewTD->isInvalidDecl() && NewTD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { if (II->isStr("FILE")) Context.setFILEDecl(NewTD); else if (II->isStr("jmp_buf")) Context.setjmp_bufDecl(NewTD); else if (II->isStr("sigjmp_buf")) Context.setsigjmp_bufDecl(NewTD); else if (II->isStr("ucontext_t")) Context.setucontext_tDecl(NewTD); } return NewTD; } /// \brief Determines whether the given declaration is an out-of-scope /// previous declaration. /// /// This routine should be invoked when name lookup has found a /// previous declaration (PrevDecl) that is not in the scope where a /// new declaration by the same name is being introduced. If the new /// declaration occurs in a local scope, previous declarations with /// linkage may still be considered previous declarations (C99 /// 6.2.2p4-5, C++ [basic.link]p6). /// /// \param PrevDecl the previous declaration found by name /// lookup /// /// \param DC the context in which the new declaration is being /// declared. /// /// \returns true if PrevDecl is an out-of-scope previous declaration /// for a new delcaration with the same name. static bool isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC, ASTContext &Context) { if (!PrevDecl) return false; if (!PrevDecl->hasLinkage()) return false; if (Context.getLangOpts().CPlusPlus) { // C++ [basic.link]p6: // If there is a visible declaration of an entity with linkage // having the same name and type, ignoring entities declared // outside the innermost enclosing namespace scope, the block // scope declaration declares that same entity and receives the // linkage of the previous declaration. DeclContext *OuterContext = DC->getRedeclContext(); if (!OuterContext->isFunctionOrMethod()) // This rule only applies to block-scope declarations. return false; DeclContext *PrevOuterContext = PrevDecl->getDeclContext(); if (PrevOuterContext->isRecord()) // We found a member function: ignore it. return false; // Find the innermost enclosing namespace for the new and // previous declarations. OuterContext = OuterContext->getEnclosingNamespaceContext(); PrevOuterContext = PrevOuterContext->getEnclosingNamespaceContext(); // The previous declaration is in a different namespace, so it // isn't the same function. if (!OuterContext->Equals(PrevOuterContext)) return false; } return true; } static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator &D) { CXXScopeSpec &SS = D.getCXXScopeSpec(); if (!SS.isSet()) return; DD->setQualifierInfo(SS.getWithLocInContext(DD->getASTContext())); } bool Sema::inferObjCARCLifetime(ValueDecl *decl) { QualType type = decl->getType(); Qualifiers::ObjCLifetime lifetime = type.getObjCLifetime(); if (lifetime == Qualifiers::OCL_Autoreleasing) { // Various kinds of declaration aren't allowed to be __autoreleasing. unsigned kind = -1U; if (VarDecl *var = dyn_cast<VarDecl>(decl)) { if (var->hasAttr<BlocksAttr>()) kind = 0; // __block else if (!var->hasLocalStorage()) kind = 1; // global } else if (isa<ObjCIvarDecl>(decl)) { kind = 3; // ivar } else if (isa<FieldDecl>(decl)) { kind = 2; // field } if (kind != -1U) { Diag(decl->getLocation(), diag::err_arc_autoreleasing_var) << kind; } } else if (lifetime == Qualifiers::OCL_None) { // Try to infer lifetime. if (!type->isObjCLifetimeType()) return false; lifetime = type->getObjCARCImplicitLifetime(); type = Context.getLifetimeQualifiedType(type, lifetime); decl->setType(type); } if (VarDecl *var = dyn_cast<VarDecl>(decl)) { // Thread-local variables cannot have lifetime. if (lifetime && lifetime != Qualifiers::OCL_ExplicitNone && var->getTLSKind()) { Diag(var->getLocation(), diag::err_arc_thread_ownership) << var->getType(); return true; } } return false; } static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { // 'weak' only applies to declarations with external linkage. if (WeakAttr *Attr = ND.getAttr<WeakAttr>()) { if (ND.getLinkage() != ExternalLinkage) { S.Diag(Attr->getLocation(), diag::err_attribute_weak_static); ND.dropAttr<WeakAttr>(); } } if (WeakRefAttr *Attr = ND.getAttr<WeakRefAttr>()) { if (ND.hasExternalLinkage()) { S.Diag(Attr->getLocation(), diag::err_attribute_weakref_not_static); ND.dropAttr<WeakRefAttr>(); } } } /// Given that we are within the definition of the given function, /// will that definition behave like C99's 'inline', where the /// definition is discarded except for optimization purposes? static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD) { // Try to avoid calling GetGVALinkageForFunction. // All cases of this require the 'inline' keyword. if (!FD->isInlined()) return false; // This is only possible in C++ with the gnu_inline attribute. if (S.getLangOpts().CPlusPlus && !FD->hasAttr<GNUInlineAttr>()) return false; // Okay, go ahead and call the relatively-more-expensive function. #ifndef NDEBUG // AST quite reasonably asserts that it's working on a function // definition. We don't really have a way to tell it that we're // currently defining the function, so just lie to it in +Asserts // builds. This is an awful hack. FD->setLazyBody(1); #endif bool isC99Inline = (S.Context.GetGVALinkageForFunction(FD) == GVA_C99Inline); #ifndef NDEBUG FD->setLazyBody(0); #endif return isC99Inline; } static bool shouldConsiderLinkage(const VarDecl *VD) { const DeclContext *DC = VD->getDeclContext()->getRedeclContext(); if (DC->isFunctionOrMethod()) return VD->hasExternalStorage(); if (DC->isFileContext()) return true; if (DC->isRecord()) return false; llvm_unreachable("Unexpected context"); } static bool shouldConsiderLinkage(const FunctionDecl *FD) { const DeclContext *DC = FD->getDeclContext()->getRedeclContext(); if (DC->isFileContext() || DC->isFunctionOrMethod()) return true; if (DC->isRecord()) return false; llvm_unreachable("Unexpected context"); } NamedDecl* Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists) { QualType R = TInfo->getType(); DeclarationName Name = GetNameForDeclarator(D).getName(); DeclSpec::SCS SCSpec = D.getDeclSpec().getStorageClassSpec(); VarDecl::StorageClass SC = StorageClassSpecToVarDeclStorageClass(D.getDeclSpec()); if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16) { // OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and // half array type (unless the cl_khr_fp16 extension is enabled). if (Context.getBaseElementType(R)->isHalfType()) { Diag(D.getIdentifierLoc(), diag::err_opencl_half_declaration) << R; D.setInvalidType(); } } if (SCSpec == DeclSpec::SCS_mutable) { // mutable can only appear on non-static class members, so it's always // an error here Diag(D.getIdentifierLoc(), diag::err_mutable_nonmember); D.setInvalidType(); SC = SC_None; } // C++11 [dcl.stc]p4: // When thread_local is applied to a variable of block scope the // storage-class-specifier static is implied if it does not appear // explicitly. // Core issue: 'static' is not implied if the variable is declared 'extern'. if (SCSpec == DeclSpec::SCS_unspecified && D.getDeclSpec().getThreadStorageClassSpec() == DeclSpec::TSCS_thread_local && DC->isFunctionOrMethod()) SC = SC_Static; IdentifierInfo *II = Name.getAsIdentifierInfo(); if (!II) { Diag(D.getIdentifierLoc(), diag::err_bad_variable_name) << Name; return 0; } DiagnoseFunctionSpecifiers(D.getDeclSpec()); if (!DC->isRecord() && S->getFnParent() == 0) { // C99 6.9p2: The storage-class specifiers auto and register shall not // appear in the declaration specifiers in an external declaration. if (SC == SC_Auto || SC == SC_Register) { // If this is a register variable with an asm label specified, then this // is a GNU extension. if (SC == SC_Register && D.getAsmLabel()) Diag(D.getIdentifierLoc(), diag::err_unsupported_global_register); else Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope); D.setInvalidType(); } } if (getLangOpts().OpenCL) { // Set up the special work-group-local storage class for variables in the // OpenCL __local address space. if (R.getAddressSpace() == LangAS::opencl_local) { SC = SC_OpenCLWorkGroupLocal; } // OpenCL v1.2 s6.9.b p4: // The sampler type cannot be used with the __local and __global address // space qualifiers. if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local || R.getAddressSpace() == LangAS::opencl_global)) { Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace); } // OpenCL 1.2 spec, p6.9 r: // The event type cannot be used to declare a program scope variable. // The event type cannot be used with the __local, __constant and __global // address space qualifiers. if (R->isEventT()) { if (S->getParent() == 0) { Diag(D.getLocStart(), diag::err_event_t_global_var); D.setInvalidType(); } if (R.getAddressSpace()) { Diag(D.getLocStart(), diag::err_event_t_addr_space_qual); D.setInvalidType(); } } } bool isExplicitSpecialization = false; VarDecl *NewVD; if (!getLangOpts().CPlusPlus) { NewVD = VarDecl::Create(Context, DC, D.getLocStart(), D.getIdentifierLoc(), II, R, TInfo, SC); if (D.isInvalidType()) NewVD->setInvalidDecl(); } else { if (DC->isRecord() && !CurContext->isRecord()) { // This is an out-of-line definition of a static data member. if (SC == SC_Static) { Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_static_out_of_line) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); } } if (SC == SC_Static && CurContext->isRecord()) { if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) { if (RD->isLocalClass()) Diag(D.getIdentifierLoc(), diag::err_static_data_member_not_allowed_in_local_class) << Name << RD->getDeclName(); // C++98 [class.union]p1: If a union contains a static data member, // the program is ill-formed. C++11 drops this restriction. if (RD->isUnion()) Diag(D.getIdentifierLoc(), getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_static_data_member_in_union : diag::ext_static_data_member_in_union) << Name; // We conservatively disallow static data members in anonymous structs. else if (!RD->getDeclName()) Diag(D.getIdentifierLoc(), diag::err_static_data_member_not_allowed_in_anon_struct) << Name << RD->isUnion(); } } // Match up the template parameter lists with the scope specifier, then // determine whether we have a template or a template specialization. isExplicitSpecialization = false; bool Invalid = false; if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( D.getDeclSpec().getLocStart(), D.getIdentifierLoc(), D.getCXXScopeSpec(), TemplateParamLists.data(), TemplateParamLists.size(), /*never a friend*/ false, isExplicitSpecialization, Invalid)) { if (TemplateParams->size() > 0) { // There is no such thing as a variable template. Diag(D.getIdentifierLoc(), diag::err_template_variable) << II << SourceRange(TemplateParams->getTemplateLoc(), TemplateParams->getRAngleLoc()); return 0; } else { // There is an extraneous 'template<>' for this variable. Complain // about it, but allow the declaration of the variable. Diag(TemplateParams->getTemplateLoc(), diag::err_template_variable_noparams) << II << SourceRange(TemplateParams->getTemplateLoc(), TemplateParams->getRAngleLoc()); } } NewVD = VarDecl::Create(Context, DC, D.getLocStart(), D.getIdentifierLoc(), II, R, TInfo, SC); // If this decl has an auto type in need of deduction, make a note of the // Decl so we can diagnose uses of it in its own initializer. if (D.getDeclSpec().containsPlaceholderType() && R->getContainedAutoType()) ParsingInitForAutoVars.insert(NewVD); if (D.isInvalidType() || Invalid) NewVD->setInvalidDecl(); SetNestedNameSpecifier(NewVD, D); if (TemplateParamLists.size() > 0 && D.getCXXScopeSpec().isSet()) { NewVD->setTemplateParameterListsInfo(Context, TemplateParamLists.size(), TemplateParamLists.data()); } if (D.getDeclSpec().isConstexprSpecified()) NewVD->setConstexpr(true); } // Set the lexical context. If the declarator has a C++ scope specifier, the // lexical context will be different from the semantic context. NewVD->setLexicalDeclContext(CurContext); if (DeclSpec::TSCS TSCS = D.getDeclSpec().getThreadStorageClassSpec()) { if (NewVD->hasLocalStorage()) Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_thread_non_global) << DeclSpec::getSpecifierName(TSCS); else if (!Context.getTargetInfo().isTLSSupported()) Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_thread_unsupported); else NewVD->setTSCSpec(TSCS); } // C99 6.7.4p3 // An inline definition of a function with external linkage shall // not contain a definition of a modifiable object with static or // thread storage duration... // We only apply this when the function is required to be defined // elsewhere, i.e. when the function is not 'extern inline'. Note // that a local variable with thread storage duration still has to // be marked 'static'. Also note that it's possible to get these // semantics in C++ using __attribute__((gnu_inline)). if (SC == SC_Static && S->getFnParent() != 0 && !NewVD->getType().isConstQualified()) { FunctionDecl *CurFD = getCurFunctionDecl(); if (CurFD && isFunctionDefinitionDiscarded(*this, CurFD)) { Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::warn_static_local_in_extern_inline); MaybeSuggestAddingStaticToDecl(CurFD); } } if (D.getDeclSpec().isModulePrivateSpecified()) { if (isExplicitSpecialization) Diag(NewVD->getLocation(), diag::err_module_private_specialization) << 2 << FixItHint::CreateRemoval(D.getDeclSpec().getModulePrivateSpecLoc()); else if (NewVD->hasLocalStorage()) Diag(NewVD->getLocation(), diag::err_module_private_local) << 0 << NewVD->getDeclName() << SourceRange(D.getDeclSpec().getModulePrivateSpecLoc()) << FixItHint::CreateRemoval(D.getDeclSpec().getModulePrivateSpecLoc()); else NewVD->setModulePrivate(); } // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(S, NewVD, D); if (NewVD->hasAttrs()) CheckAlignasUnderalignment(NewVD); if (getLangOpts().CUDA) { // CUDA B.2.5: "__shared__ and __constant__ variables have implied static // storage [duration]." if (SC == SC_None && S->getFnParent() != 0 && (NewVD->hasAttr<CUDASharedAttr>() || NewVD->hasAttr<CUDAConstantAttr>())) { NewVD->setStorageClass(SC_Static); } } // In auto-retain/release, infer strong retension for variables of // retainable type. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD)) NewVD->setInvalidDecl(); // Handle GNU asm-label extension (encoded as an attribute). if (Expr *E = (Expr*)D.getAsmLabel()) { // The parser guarantees this is a string. StringLiteral *SE = cast<StringLiteral>(E); StringRef Label = SE->getString(); if (S->getFnParent() != 0) { switch (SC) { case SC_None: case SC_Auto: Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label; break; case SC_Register: if (!Context.getTargetInfo().isValidGCCRegisterName(Label)) Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label; break; case SC_Static: case SC_Extern: case SC_PrivateExtern: case SC_OpenCLWorkGroupLocal: break; } } NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), Context, Label)); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier()); if (I != ExtnameUndeclaredIdentifiers.end()) { NewVD->addAttr(I->second); ExtnameUndeclaredIdentifiers.erase(I); } } // Diagnose shadowed variables before filtering for scope. if (!D.getCXXScopeSpec().isSet()) CheckShadow(S, NewVD, Previous); // Don't consider existing declarations that are in a different // scope and are out-of-semantic-context declarations (if the new // declaration has linkage). FilterLookupForScope(Previous, DC, S, shouldConsiderLinkage(NewVD), isExplicitSpecialization); if (!getLangOpts().CPlusPlus) { D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous)); } else { // Merge the decl with the existing one if appropriate. if (!Previous.empty()) { if (Previous.isSingleResult() && isa<FieldDecl>(Previous.getFoundDecl()) && D.getCXXScopeSpec().isSet()) { // The user tried to define a non-static data member // out-of-line (C++ [dcl.meaning]p1). Diag(NewVD->getLocation(), diag::err_nonstatic_member_out_of_line) << D.getCXXScopeSpec().getRange(); Previous.clear(); NewVD->setInvalidDecl(); } } else if (D.getCXXScopeSpec().isSet()) { // No previous declaration in the qualifying scope. Diag(D.getIdentifierLoc(), diag::err_no_member) << Name << computeDeclContext(D.getCXXScopeSpec(), true) << D.getCXXScopeSpec().getRange(); NewVD->setInvalidDecl(); } D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous)); // This is an explicit specialization of a static data member. Check it. if (isExplicitSpecialization && !NewVD->isInvalidDecl() && CheckMemberSpecialization(NewVD, Previous)) NewVD->setInvalidDecl(); } ProcessPragmaWeak(S, NewVD); checkAttributesAfterMerging(*this, *NewVD); // If this is a locally-scoped extern C variable, update the map of // such variables. if (CurContext->isFunctionOrMethod() && NewVD->isExternC() && !NewVD->isInvalidDecl()) RegisterLocallyScopedExternCDecl(NewVD, Previous, S); return NewVD; } /// \brief Diagnose variable or built-in function shadowing. Implements /// -Wshadow. /// /// This method is called whenever a VarDecl is added to a "useful" /// scope. /// /// \param S the scope in which the shadowing name is being declared /// \param R the lookup of the name /// void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) { // Return if warning is ignored. if (Diags.getDiagnosticLevel(diag::warn_decl_shadow, R.getNameLoc()) == DiagnosticsEngine::Ignored) return; // Don't diagnose declarations at file scope. if (D->hasGlobalStorage()) return; DeclContext *NewDC = D->getDeclContext(); // Only diagnose if we're shadowing an unambiguous field or variable. if (R.getResultKind() != LookupResult::Found) return; NamedDecl* ShadowedDecl = R.getFoundDecl(); if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl)) return; // Fields are not shadowed by variables in C++ static methods. if (isa<FieldDecl>(ShadowedDecl)) if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC)) if (MD->isStatic()) return; if (VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl)) if (shadowedVar->isExternC()) { // For shadowing external vars, make sure that we point to the global // declaration, not a locally scoped extern declaration. for (VarDecl::redecl_iterator I = shadowedVar->redecls_begin(), E = shadowedVar->redecls_end(); I != E; ++I) if (I->isFileVarDecl()) { ShadowedDecl = *I; break; } } DeclContext *OldDC = ShadowedDecl->getDeclContext(); // Only warn about certain kinds of shadowing for class members. if (NewDC && NewDC->isRecord()) { // In particular, don't warn about shadowing non-class members. if (!OldDC->isRecord()) return; // TODO: should we warn about static data members shadowing // static data members from base classes? // TODO: don't diagnose for inaccessible shadowed members. // This is hard to do perfectly because we might friend the // shadowing context, but that's just a false negative. } // Determine what kind of declaration we're shadowing. unsigned Kind; if (isa<RecordDecl>(OldDC)) { if (isa<FieldDecl>(ShadowedDecl)) Kind = 3; // field else Kind = 2; // static data member } else if (OldDC->isFileContext()) Kind = 1; // global else Kind = 0; // local DeclarationName Name = R.getLookupName(); // Emit warning and note. Diag(R.getNameLoc(), diag::warn_decl_shadow) << Name << Kind << OldDC; Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration); } /// \brief Check -Wshadow without the advantage of a previous lookup. void Sema::CheckShadow(Scope *S, VarDecl *D) { if (Diags.getDiagnosticLevel(diag::warn_decl_shadow, D->getLocation()) == DiagnosticsEngine::Ignored) return; LookupResult R(*this, D->getDeclName(), D->getLocation(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); LookupName(R, S); CheckShadow(S, D, R); } template<typename T> static bool mayConflictWithNonVisibleExternC(const T *ND) { const DeclContext *DC = ND->getDeclContext(); if (DC->getRedeclContext()->isTranslationUnit()) return true; // We know that is the first decl we see, other than function local // extern C ones. If this is C++ and the decl is not in a extern C context // it cannot have C language linkage. Avoid calling isExternC in that case. // We need to this because of code like // // namespace { struct bar {}; } // auto foo = bar(); // // This code runs before the init of foo is set, and therefore before // the type of foo is known. Not knowing the type we cannot know its linkage // unless it is in an extern C block. if (!ND->isInExternCContext()) { const ASTContext &Context = ND->getASTContext(); if (Context.getLangOpts().CPlusPlus) return false; } return ND->isExternC(); } void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { // If the decl is already known invalid, don't check it. if (NewVD->isInvalidDecl()) return; TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo(); QualType T = TInfo->getType(); // Defer checking an 'auto' type until its initializer is attached. if (T->isUndeducedType()) return; if (T->isObjCObjectType()) { Diag(NewVD->getLocation(), diag::err_statically_allocated_object) << FixItHint::CreateInsertion(NewVD->getLocation(), "*"); T = Context.getObjCObjectPointerType(T); NewVD->setType(T); } // Emit an error if an address space was applied to decl with local storage. // This includes arrays of objects with address space qualifiers, but not // automatic variables that point to other address spaces. // ISO/IEC TR 18037 S5.1.2 if (NewVD->hasLocalStorage() && T.getAddressSpace() != 0) { Diag(NewVD->getLocation(), diag::err_as_qualified_auto_decl); NewVD->setInvalidDecl(); return; } // OpenCL v1.2 s6.5 - All program scope variables must be declared in the // __constant address space. if (getLangOpts().OpenCL && NewVD->isFileVarDecl() && T.getAddressSpace() != LangAS::opencl_constant && !T->isSamplerT()){ Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space); NewVD->setInvalidDecl(); return; } // OpenCL v1.2 s6.8 -- The static qualifier is valid only in program // scope. if ((getLangOpts().OpenCLVersion >= 120) && NewVD->isStaticLocal()) { Diag(NewVD->getLocation(), diag::err_static_function_scope); NewVD->setInvalidDecl(); return; } if (NewVD->hasLocalStorage() && T.isObjCGCWeak() && !NewVD->hasAttr<BlocksAttr>()) { if (getLangOpts().getGC() != LangOptions::NonGC) Diag(NewVD->getLocation(), diag::warn_gc_attribute_weak_on_local); else { assert(!getLangOpts().ObjCAutoRefCount); Diag(NewVD->getLocation(), diag::warn_attribute_weak_on_local); } } bool isVM = T->isVariablyModifiedType(); if (isVM || NewVD->hasAttr<CleanupAttr>() || NewVD->hasAttr<BlocksAttr>()) getCurFunction()->setHasBranchProtectedScope(); if ((isVM && NewVD->hasLinkage()) || (T->isVariableArrayType() && NewVD->hasGlobalStorage())) { bool SizeIsNegative; llvm::APSInt Oversized; TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, SizeIsNegative, Oversized); if (FixedTInfo == 0 && T->isVariableArrayType()) { const VariableArrayType *VAT = Context.getAsVariableArrayType(T); // FIXME: This won't give the correct result for // int a[10][n]; SourceRange SizeRange = VAT->getSizeExpr()->getSourceRange(); if (NewVD->isFileVarDecl()) Diag(NewVD->getLocation(), diag::err_vla_decl_in_file_scope) << SizeRange; else if (NewVD->getStorageClass() == SC_Static) Diag(NewVD->getLocation(), diag::err_vla_decl_has_static_storage) << SizeRange; else Diag(NewVD->getLocation(), diag::err_vla_decl_has_extern_linkage) << SizeRange; NewVD->setInvalidDecl(); return; } if (FixedTInfo == 0) { if (NewVD->isFileVarDecl()) Diag(NewVD->getLocation(), diag::err_vm_decl_in_file_scope); else Diag(NewVD->getLocation(), diag::err_vm_decl_has_extern_linkage); NewVD->setInvalidDecl(); return; } Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size); NewVD->setType(FixedTInfo->getType()); NewVD->setTypeSourceInfo(FixedTInfo); } if (T->isVoidType() && NewVD->isThisDeclarationADefinition()) { Diag(NewVD->getLocation(), diag::err_typecheck_decl_incomplete_type) << T; NewVD->setInvalidDecl(); return; } if (!NewVD->hasLocalStorage() && NewVD->hasAttr<BlocksAttr>()) { Diag(NewVD->getLocation(), diag::err_block_on_nonlocal); NewVD->setInvalidDecl(); return; } if (isVM && NewVD->hasAttr<BlocksAttr>()) { Diag(NewVD->getLocation(), diag::err_block_on_vm); NewVD->setInvalidDecl(); return; } if (NewVD->isConstexpr() && !T->isDependentType() && RequireLiteralType(NewVD->getLocation(), T, diag::err_constexpr_var_non_literal)) { // Can't perform this check until the type is deduced. NewVD->setInvalidDecl(); return; } } /// \brief Perform semantic checking on a newly-created variable /// declaration. /// /// This routine performs all of the type-checking required for a /// variable declaration once it has been built. It is used both to /// check variables after they have been parsed and their declarators /// have been translated into a declaration, and to check variables /// that have been instantiated from a template. /// /// Sets NewVD->isInvalidDecl() if an error was encountered. /// /// Returns true if the variable declaration is a redeclaration. bool Sema::CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous) { CheckVariableDeclarationType(NewVD); // If the decl is already known invalid, don't check it. if (NewVD->isInvalidDecl()) return false; // If we did not find anything by this name, look for a non-visible // extern "C" declaration with the same name. // // Clang has a lot of problems with extern local declarations. // The actual standards text here is: // // C++11 [basic.link]p6: // The name of a function declared in block scope and the name // of a variable declared by a block scope extern declaration // have linkage. If there is a visible declaration of an entity // with linkage having the same name and type, ignoring entities // declared outside the innermost enclosing namespace scope, the // block scope declaration declares that same entity and // receives the linkage of the previous declaration. // // C11 6.2.7p4: // For an identifier with internal or external linkage declared // in a scope in which a prior declaration of that identifier is // visible, if the prior declaration specifies internal or // external linkage, the type of the identifier at the later // declaration becomes the composite type. // // The most important point here is that we're not allowed to // update our understanding of the type according to declarations // not in scope. bool PreviousWasHidden = false; if (Previous.empty() && mayConflictWithNonVisibleExternC(NewVD)) { llvm::DenseMap<DeclarationName, NamedDecl *>::iterator Pos = findLocallyScopedExternCDecl(NewVD->getDeclName()); if (Pos != LocallyScopedExternCDecls.end()) { Previous.addDecl(Pos->second); PreviousWasHidden = true; } } // Filter out any non-conflicting previous declarations. filterNonConflictingPreviousDecls(Context, NewVD, Previous); if (!Previous.empty()) { MergeVarDecl(NewVD, Previous, PreviousWasHidden); return true; } return false; } /// \brief Data used with FindOverriddenMethod struct FindOverriddenMethodData { Sema *S; CXXMethodDecl *Method; }; /// \brief Member lookup function that determines whether a given C++ /// method overrides a method in a base class, to be used with /// CXXRecordDecl::lookupInBases(). static bool FindOverriddenMethod(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *UserData) { RecordDecl *BaseRecord = Specifier->getType()->getAs<RecordType>()->getDecl(); FindOverriddenMethodData *Data = reinterpret_cast<FindOverriddenMethodData*>(UserData); DeclarationName Name = Data->Method->getDeclName(); // FIXME: Do we care about other names here too? if (Name.getNameKind() == DeclarationName::CXXDestructorName) { // We really want to find the base class destructor here. QualType T = Data->S->Context.getTypeDeclType(BaseRecord); CanQualType CT = Data->S->Context.getCanonicalType(T); Name = Data->S->Context.DeclarationNames.getCXXDestructorName(CT); } for (Path.Decls = BaseRecord->lookup(Name); !Path.Decls.empty(); Path.Decls = Path.Decls.slice(1)) { NamedDecl *D = Path.Decls.front(); if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) { if (MD->isVirtual() && !Data->S->IsOverload(Data->Method, MD, false)) return true; } } return false; } namespace { enum OverrideErrorKind { OEK_All, OEK_NonDeleted, OEK_Deleted }; } /// \brief Report an error regarding overriding, along with any relevant /// overriden methods. /// /// \param DiagID the primary error to report. /// \param MD the overriding method. /// \param OEK which overrides to include as notes. static void ReportOverrides(Sema& S, unsigned DiagID, const CXXMethodDecl *MD, OverrideErrorKind OEK = OEK_All) { S.Diag(MD->getLocation(), DiagID) << MD->getDeclName(); for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(), E = MD->end_overridden_methods(); I != E; ++I) { // This check (& the OEK parameter) could be replaced by a predicate, but // without lambdas that would be overkill. This is still nicer than writing // out the diag loop 3 times. if ((OEK == OEK_All) || (OEK == OEK_NonDeleted && !(*I)->isDeleted()) || (OEK == OEK_Deleted && (*I)->isDeleted())) S.Diag((*I)->getLocation(), diag::note_overridden_virtual_function); } } /// AddOverriddenMethods - See if a method overrides any in the base classes, /// and if so, check that it's a valid override and remember it. bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) { // Look for virtual methods in base classes that this method might override. CXXBasePaths Paths; FindOverriddenMethodData Data; Data.Method = MD; Data.S = this; bool hasDeletedOverridenMethods = false; bool hasNonDeletedOverridenMethods = false; bool AddedAny = false; if (DC->lookupInBases(&FindOverriddenMethod, &Data, Paths)) { for (CXXBasePaths::decl_iterator I = Paths.found_decls_begin(), E = Paths.found_decls_end(); I != E; ++I) { if (CXXMethodDecl *OldMD = dyn_cast<CXXMethodDecl>(*I)) { MD->addOverriddenMethod(OldMD->getCanonicalDecl()); if (!CheckOverridingFunctionReturnType(MD, OldMD) && !CheckOverridingFunctionAttributes(MD, OldMD) && !CheckOverridingFunctionExceptionSpec(MD, OldMD) && !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) { hasDeletedOverridenMethods |= OldMD->isDeleted(); hasNonDeletedOverridenMethods |= !OldMD->isDeleted(); AddedAny = true; } } } } if (hasDeletedOverridenMethods && !MD->isDeleted()) { ReportOverrides(*this, diag::err_non_deleted_override, MD, OEK_Deleted); } if (hasNonDeletedOverridenMethods && MD->isDeleted()) { ReportOverrides(*this, diag::err_deleted_override, MD, OEK_NonDeleted); } return AddedAny; } namespace { // Struct for holding all of the extra arguments needed by // DiagnoseInvalidRedeclaration to call Sema::ActOnFunctionDeclarator. struct ActOnFDArgs { Scope *S; Declarator &D; MultiTemplateParamsArg TemplateParamLists; bool AddToScope; }; } namespace { // Callback to only accept typo corrections that have a non-zero edit distance. // Also only accept corrections that have the same parent decl. class DifferentNameValidatorCCC : public CorrectionCandidateCallback { public: DifferentNameValidatorCCC(ASTContext &Context, FunctionDecl *TypoFD, CXXRecordDecl *Parent) : Context(Context), OriginalFD(TypoFD), ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {} virtual bool ValidateCandidate(const TypoCorrection &candidate) { if (candidate.getEditDistance() == 0) return false; SmallVector<unsigned, 1> MismatchedParams; for (TypoCorrection::const_decl_iterator CDecl = candidate.begin(), CDeclEnd = candidate.end(); CDecl != CDeclEnd; ++CDecl) { FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl); if (FD && !FD->hasBody() && hasSimilarParameters(Context, FD, OriginalFD, MismatchedParams)) { if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) { CXXRecordDecl *Parent = MD->getParent(); if (Parent && Parent->getCanonicalDecl() == ExpectedParent) return true; } else if (!ExpectedParent) { return true; } } } return false; } private: ASTContext &Context; FunctionDecl *OriginalFD; CXXRecordDecl *ExpectedParent; }; } /// \brief Generate diagnostics for an invalid function redeclaration. /// /// This routine handles generating the diagnostic messages for an invalid /// function redeclaration, including finding possible similar declarations /// or performing typo correction if there are no previous declarations with /// the same name. /// /// Returns a NamedDecl iff typo correction was performed and substituting in /// the new declaration name does not cause new errors. static NamedDecl* DiagnoseInvalidRedeclaration( Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs) { NamedDecl *Result = NULL; DeclarationName Name = NewFD->getDeclName(); DeclContext *NewDC = NewFD->getDeclContext(); LookupResult Prev(SemaRef, Name, NewFD->getLocation(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); SmallVector<unsigned, 1> MismatchedParams; SmallVector<std::pair<FunctionDecl *, unsigned>, 1> NearMatches; TypoCorrection Correction; bool isFriendDecl = (SemaRef.getLangOpts().CPlusPlus && ExtraArgs.D.getDeclSpec().isFriendSpecified()); unsigned DiagMsg = isFriendDecl ? diag::err_no_matching_local_friend : diag::err_member_def_does_not_match; NewFD->setInvalidDecl(); SemaRef.LookupQualifiedName(Prev, NewDC); assert(!Prev.isAmbiguous() && "Cannot have an ambiguity in previous-declaration lookup"); CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); DifferentNameValidatorCCC Validator(SemaRef.Context, NewFD, MD ? MD->getParent() : 0); if (!Prev.empty()) { for (LookupResult::iterator Func = Prev.begin(), FuncEnd = Prev.end(); Func != FuncEnd; ++Func) { FunctionDecl *FD = dyn_cast<FunctionDecl>(*Func); if (FD && hasSimilarParameters(SemaRef.Context, FD, NewFD, MismatchedParams)) { // Add 1 to the index so that 0 can mean the mismatch didn't // involve a parameter unsigned ParamNum = MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1; NearMatches.push_back(std::make_pair(FD, ParamNum)); } } // If the qualified name lookup yielded nothing, try typo correction } else if ((Correction = SemaRef.CorrectTypo(Prev.getLookupNameInfo(), Prev.getLookupKind(), 0, 0, Validator, NewDC))) { // Trap errors. Sema::SFINAETrap Trap(SemaRef); // Set up everything for the call to ActOnFunctionDeclarator ExtraArgs.D.SetIdentifier(Correction.getCorrectionAsIdentifierInfo(), ExtraArgs.D.getIdentifierLoc()); Previous.clear(); Previous.setLookupName(Correction.getCorrection()); for (TypoCorrection::decl_iterator CDecl = Correction.begin(), CDeclEnd = Correction.end(); CDecl != CDeclEnd; ++CDecl) { FunctionDecl *FD = dyn_cast<FunctionDecl>(*CDecl); if (FD && !FD->hasBody() && hasSimilarParameters(SemaRef.Context, FD, NewFD, MismatchedParams)) { Previous.addDecl(FD); } } bool wasRedeclaration = ExtraArgs.D.isRedeclaration(); // TODO: Refactor ActOnFunctionDeclarator so that we can call only the // pieces need to verify the typo-corrected C++ declaraction and hopefully // eliminate the need for the parameter pack ExtraArgs. Result = SemaRef.ActOnFunctionDeclarator( ExtraArgs.S, ExtraArgs.D, Correction.getCorrectionDecl()->getDeclContext(), NewFD->getTypeSourceInfo(), Previous, ExtraArgs.TemplateParamLists, ExtraArgs.AddToScope); if (Trap.hasErrorOccurred()) { // Pretend the typo correction never occurred ExtraArgs.D.SetIdentifier(Name.getAsIdentifierInfo(), ExtraArgs.D.getIdentifierLoc()); ExtraArgs.D.setRedeclaration(wasRedeclaration); Previous.clear(); Previous.setLookupName(Name); Result = NULL; } else { for (LookupResult::iterator Func = Previous.begin(), FuncEnd = Previous.end(); Func != FuncEnd; ++Func) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*Func)) NearMatches.push_back(std::make_pair(FD, 0)); } } if (NearMatches.empty()) { // Ignore the correction if it didn't yield any close FunctionDecl matches Correction = TypoCorrection(); } else { DiagMsg = isFriendDecl ? diag::err_no_matching_local_friend_suggest : diag::err_member_def_does_not_match_suggest; } } if (Correction) { // FIXME: use Correction.getCorrectionRange() instead of computing the range // here. This requires passing in the CXXScopeSpec to CorrectTypo which in // turn causes the correction to fully qualify the name. If we fix // CorrectTypo to minimally qualify then this change should be good. SourceRange FixItLoc(NewFD->getLocation()); CXXScopeSpec &SS = ExtraArgs.D.getCXXScopeSpec(); if (Correction.getCorrectionSpecifier() && SS.isValid()) FixItLoc.setBegin(SS.getBeginLoc()); SemaRef.Diag(NewFD->getLocStart(), DiagMsg) << Name << NewDC << Correction.getQuoted(SemaRef.getLangOpts()) << FixItHint::CreateReplacement( FixItLoc, Correction.getAsString(SemaRef.getLangOpts())); } else { SemaRef.Diag(NewFD->getLocation(), DiagMsg) << Name << NewDC << NewFD->getLocation(); } bool NewFDisConst = false; if (CXXMethodDecl *NewMD = dyn_cast<CXXMethodDecl>(NewFD)) NewFDisConst = NewMD->isConst(); for (SmallVector<std::pair<FunctionDecl *, unsigned>, 1>::iterator NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end(); NearMatch != NearMatchEnd; ++NearMatch) { FunctionDecl *FD = NearMatch->first; bool FDisConst = false; if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) FDisConst = MD->isConst(); if (unsigned Idx = NearMatch->second) { ParmVarDecl *FDParam = FD->getParamDecl(Idx-1); SourceLocation Loc = FDParam->getTypeSpecStartLoc(); if (Loc.isInvalid()) Loc = FD->getLocation(); SemaRef.Diag(Loc, diag::note_member_def_close_param_match) << Idx << FDParam->getType() << NewFD->getParamDecl(Idx-1)->getType(); } else if (Correction) { SemaRef.Diag(FD->getLocation(), diag::note_previous_decl) << Correction.getQuoted(SemaRef.getLangOpts()); } else if (FDisConst != NewFDisConst) { SemaRef.Diag(FD->getLocation(), diag::note_member_def_close_const_match) << NewFDisConst << FD->getSourceRange().getEnd(); } else SemaRef.Diag(FD->getLocation(), diag::note_member_def_close_match); } return Result; } static FunctionDecl::StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D) { switch (D.getDeclSpec().getStorageClassSpec()) { default: llvm_unreachable("Unknown storage class!"); case DeclSpec::SCS_auto: case DeclSpec::SCS_register: case DeclSpec::SCS_mutable: SemaRef.Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_typecheck_sclass_func); D.setInvalidType(); break; case DeclSpec::SCS_unspecified: break; case DeclSpec::SCS_extern: if (D.getDeclSpec().isExternInLinkageSpec()) return SC_None; return SC_Extern; case DeclSpec::SCS_static: { if (SemaRef.CurContext->getRedeclContext()->isFunctionOrMethod()) { // C99 6.7.1p5: // The declaration of an identifier for a function that has // block scope shall have no explicit storage-class specifier // other than extern // See also (C++ [dcl.stc]p4). SemaRef.Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_static_block_func); break; } else return SC_Static; } case DeclSpec::SCS_private_extern: return SC_PrivateExtern; } // No explicit storage class has already been returned return SC_None; } static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, FunctionDecl::StorageClass SC, bool &IsVirtualOkay) { DeclarationNameInfo NameInfo = SemaRef.GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); FunctionDecl *NewFD = 0; bool isInline = D.getDeclSpec().isInlineSpecified(); if (!SemaRef.getLangOpts().CPlusPlus) { // Determine whether the function was written with a // prototype. This true when: // - there is a prototype in the declarator, or // - the type R of the function is some kind of typedef or other reference // to a type name (which eventually refers to a function type). bool HasPrototype = (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) || (!isa<FunctionType>(R.getTypePtr()) && R->isFunctionProtoType()); NewFD = FunctionDecl::Create(SemaRef.Context, DC, D.getLocStart(), NameInfo, R, TInfo, SC, isInline, HasPrototype, false); if (D.isInvalidType()) NewFD->setInvalidDecl(); // Set the lexical context. NewFD->setLexicalDeclContext(SemaRef.CurContext); return NewFD; } bool isExplicit = D.getDeclSpec().isExplicitSpecified(); bool isConstexpr = D.getDeclSpec().isConstexprSpecified(); // Check that the return type is not an abstract class type. // For record types, this is done by the AbstractClassUsageDiagnoser once // the class has been completely parsed. if (!DC->isRecord() && SemaRef.RequireNonAbstractType(D.getIdentifierLoc(), R->getAs<FunctionType>()->getResultType(), diag::err_abstract_type_in_decl, SemaRef.AbstractReturnType)) D.setInvalidType(); if (Name.getNameKind() == DeclarationName::CXXConstructorName) { // This is a C++ constructor declaration. assert(DC->isRecord() && "Constructors can only be declared in a member context"); R = SemaRef.CheckConstructorDeclarator(D, R, SC); return CXXConstructorDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), D.getLocStart(), NameInfo, R, TInfo, isExplicit, isInline, /*isImplicitlyDeclared=*/false, isConstexpr); } else if (Name.getNameKind() == DeclarationName::CXXDestructorName) { // This is a C++ destructor declaration. if (DC->isRecord()) { R = SemaRef.CheckDestructorDeclarator(D, R, SC); CXXRecordDecl *Record = cast<CXXRecordDecl>(DC); CXXDestructorDecl *NewDD = CXXDestructorDecl::Create( SemaRef.Context, Record, D.getLocStart(), NameInfo, R, TInfo, isInline, /*isImplicitlyDeclared=*/false); // If the class is complete, then we now create the implicit exception // specification. If the class is incomplete or dependent, we can't do // it yet. if (SemaRef.getLangOpts().CPlusPlus11 && !Record->isDependentType() && Record->getDefinition() && !Record->isBeingDefined() && R->getAs<FunctionProtoType>()->getExceptionSpecType() == EST_None) { SemaRef.AdjustDestructorExceptionSpec(Record, NewDD); } IsVirtualOkay = true; return NewDD; } else { SemaRef.Diag(D.getIdentifierLoc(), diag::err_destructor_not_member); D.setInvalidType(); // Create a FunctionDecl to satisfy the function definition parsing // code path. return FunctionDecl::Create(SemaRef.Context, DC, D.getLocStart(), D.getIdentifierLoc(), Name, R, TInfo, SC, isInline, /*hasPrototype=*/true, isConstexpr); } } else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName) { if (!DC->isRecord()) { SemaRef.Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member); return 0; } SemaRef.CheckConversionDeclarator(D, R, SC); IsVirtualOkay = true; return CXXConversionDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), D.getLocStart(), NameInfo, R, TInfo, isInline, isExplicit, isConstexpr, SourceLocation()); } else if (DC->isRecord()) { // If the name of the function is the same as the name of the record, // then this must be an invalid constructor that has a return type. // (The parser checks for a return type and makes the declarator a // constructor if it has no return type). if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){ SemaRef.Diag(D.getIdentifierLoc(), diag::err_constructor_return_type) << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc()) << SourceRange(D.getIdentifierLoc()); return 0; } // This is a C++ method declaration. CXXMethodDecl *Ret = CXXMethodDecl::Create(SemaRef.Context, cast<CXXRecordDecl>(DC), D.getLocStart(), NameInfo, R, TInfo, SC, isInline, isConstexpr, SourceLocation()); IsVirtualOkay = !Ret->isStatic(); return Ret; } else { // Determine whether the function was written with a // prototype. This true when: // - we're in C++ (where every function has a prototype), return FunctionDecl::Create(SemaRef.Context, DC, D.getLocStart(), NameInfo, R, TInfo, SC, isInline, true/*HasPrototype*/, isConstexpr); } } void Sema::checkVoidParamDecl(ParmVarDecl *Param) { // In C++, the empty parameter-type-list must be spelled "void"; a // typedef of void is not permitted. if (getLangOpts().CPlusPlus && Param->getType().getUnqualifiedType() != Context.VoidTy) { bool IsTypeAlias = false; if (const TypedefType *TT = Param->getType()->getAs<TypedefType>()) IsTypeAlias = isa<TypeAliasDecl>(TT->getDecl()); else if (const TemplateSpecializationType *TST = Param->getType()->getAs<TemplateSpecializationType>()) IsTypeAlias = TST->isTypeAlias(); Diag(Param->getLocation(), diag::err_param_typedef_of_void) << IsTypeAlias; } } NamedDecl* Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope) { QualType R = TInfo->getType(); assert(R.getTypePtr()->isFunctionType()); // TODO: consider using NameInfo for diagnostic. DeclarationNameInfo NameInfo = GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); FunctionDecl::StorageClass SC = getFunctionStorageClass(*this, D); if (DeclSpec::TSCS TSCS = D.getDeclSpec().getThreadStorageClassSpec()) Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_invalid_thread) << DeclSpec::getSpecifierName(TSCS); // Do not allow returning a objc interface by-value. if (R->getAs<FunctionType>()->getResultType()->isObjCObjectType()) { Diag(D.getIdentifierLoc(), diag::err_object_cannot_be_passed_returned_by_value) << 0 << R->getAs<FunctionType>()->getResultType() << FixItHint::CreateInsertion(D.getIdentifierLoc(), "*"); QualType T = R->getAs<FunctionType>()->getResultType(); T = Context.getObjCObjectPointerType(T); if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(R)) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); R = Context.getFunctionType(T, ArrayRef<QualType>(FPT->arg_type_begin(), FPT->getNumArgs()), EPI); } else if (isa<FunctionNoProtoType>(R)) R = Context.getFunctionNoProtoType(T); } bool isFriend = false; FunctionTemplateDecl *FunctionTemplate = 0; bool isExplicitSpecialization = false; bool isFunctionTemplateSpecialization = false; bool isDependentClassScopeExplicitSpecialization = false; bool HasExplicitTemplateArgs = false; TemplateArgumentListInfo TemplateArgs; bool isVirtualOkay = false; FunctionDecl *NewFD = CreateNewFunctionDecl(*this, D, DC, R, TInfo, SC, isVirtualOkay); if (!NewFD) return 0; if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer()) NewFD->setTopLevelDeclInObjCContainer(); if (getLangOpts().CPlusPlus) { bool isInline = D.getDeclSpec().isInlineSpecified(); bool isVirtual = D.getDeclSpec().isVirtualSpecified(); bool isExplicit = D.getDeclSpec().isExplicitSpecified(); bool isConstexpr = D.getDeclSpec().isConstexprSpecified(); isFriend = D.getDeclSpec().isFriendSpecified(); if (isFriend && !isInline && D.isFunctionDefinition()) { // C++ [class.friend]p5 // A function can be defined in a friend declaration of a // class . . . . Such a function is implicitly inline. NewFD->setImplicitlyInline(); } // If this is a method defined in an __interface, and is not a constructor // or an overloaded operator, then set the pure flag (isVirtual will already // return true). if (const CXXRecordDecl *Parent = dyn_cast<CXXRecordDecl>(NewFD->getDeclContext())) { if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided()) NewFD->setPure(true); } SetNestedNameSpecifier(NewFD, D); isExplicitSpecialization = false; isFunctionTemplateSpecialization = false; if (D.isInvalidType()) NewFD->setInvalidDecl(); // Set the lexical context. If the declarator has a C++ // scope specifier, or is the object of a friend declaration, the // lexical context will be different from the semantic context. NewFD->setLexicalDeclContext(CurContext); // Match up the template parameter lists with the scope specifier, then // determine whether we have a template or a template specialization. bool Invalid = false; if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( D.getDeclSpec().getLocStart(), D.getIdentifierLoc(), D.getCXXScopeSpec(), TemplateParamLists.data(), TemplateParamLists.size(), isFriend, isExplicitSpecialization, Invalid)) { if (TemplateParams->size() > 0) { // This is a function template // Check that we can declare a template here. if (CheckTemplateDeclScope(S, TemplateParams)) return 0; // A destructor cannot be a template. if (Name.getNameKind() == DeclarationName::CXXDestructorName) { Diag(NewFD->getLocation(), diag::err_destructor_template); return 0; } // If we're adding a template to a dependent context, we may need to // rebuilding some of the types used within the template parameter list, // now that we know what the current instantiation is. if (DC->isDependentContext()) { ContextRAII SavedContext(*this, DC); if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams)) Invalid = true; } FunctionTemplate = FunctionTemplateDecl::Create(Context, DC, NewFD->getLocation(), Name, TemplateParams, NewFD); FunctionTemplate->setLexicalDeclContext(CurContext); NewFD->setDescribedFunctionTemplate(FunctionTemplate); // For source fidelity, store the other template param lists. if (TemplateParamLists.size() > 1) { NewFD->setTemplateParameterListsInfo(Context, TemplateParamLists.size() - 1, TemplateParamLists.data()); } } else { // This is a function template specialization. isFunctionTemplateSpecialization = true; // For source fidelity, store all the template param lists. NewFD->setTemplateParameterListsInfo(Context, TemplateParamLists.size(), TemplateParamLists.data()); // C++0x [temp.expl.spec]p20 forbids "template<> friend void foo(int);". if (isFriend) { // We want to remove the "template<>", found here. SourceRange RemoveRange = TemplateParams->getSourceRange(); // If we remove the template<> and the name is not a // template-id, we're actually silently creating a problem: // the friend declaration will refer to an untemplated decl, // and clearly the user wants a template specialization. So // we need to insert '<>' after the name. SourceLocation InsertLoc; if (D.getName().getKind() != UnqualifiedId::IK_TemplateId) { InsertLoc = D.getName().getSourceRange().getEnd(); InsertLoc = PP.getLocForEndOfToken(InsertLoc); } Diag(D.getIdentifierLoc(), diag::err_template_spec_decl_friend) << Name << RemoveRange << FixItHint::CreateRemoval(RemoveRange) << FixItHint::CreateInsertion(InsertLoc, "<>"); } } } else { // All template param lists were matched against the scope specifier: // this is NOT (an explicit specialization of) a template. if (TemplateParamLists.size() > 0) // For source fidelity, store all the template param lists. NewFD->setTemplateParameterListsInfo(Context, TemplateParamLists.size(), TemplateParamLists.data()); } if (Invalid) { NewFD->setInvalidDecl(); if (FunctionTemplate) FunctionTemplate->setInvalidDecl(); } // C++ [dcl.fct.spec]p5: // The virtual specifier shall only be used in declarations of // nonstatic class member functions that appear within a // member-specification of a class declaration; see 10.3. // if (isVirtual && !NewFD->isInvalidDecl()) { if (!isVirtualOkay) { Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_non_function); } else if (!CurContext->isRecord()) { // 'virtual' was specified outside of the class. Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_out_of_class) << FixItHint::CreateRemoval(D.getDeclSpec().getVirtualSpecLoc()); } else if (NewFD->getDescribedFunctionTemplate()) { // C++ [temp.mem]p3: // A member function template shall not be virtual. Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_member_function_template) << FixItHint::CreateRemoval(D.getDeclSpec().getVirtualSpecLoc()); } else { // Okay: Add virtual to the method. NewFD->setVirtualAsWritten(true); } if (getLangOpts().CPlusPlus1y && NewFD->getResultType()->isUndeducedType()) Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_auto_fn_virtual); } // C++ [dcl.fct.spec]p3: // The inline specifier shall not appear on a block scope function // declaration. if (isInline && !NewFD->isInvalidDecl()) { if (CurContext->isFunctionOrMethod()) { // 'inline' is not allowed on block scope function declaration. Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_declaration_block_scope) << Name << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc()); } } // C++ [dcl.fct.spec]p6: // The explicit specifier shall be used only in the declaration of a // constructor or conversion function within its class definition; // see 12.3.1 and 12.3.2. if (isExplicit && !NewFD->isInvalidDecl()) { if (!CurContext->isRecord()) { // 'explicit' was specified outside of the class. Diag(D.getDeclSpec().getExplicitSpecLoc(), diag::err_explicit_out_of_class) << FixItHint::CreateRemoval(D.getDeclSpec().getExplicitSpecLoc()); } else if (!isa<CXXConstructorDecl>(NewFD) && !isa<CXXConversionDecl>(NewFD)) { // 'explicit' was specified on a function that wasn't a constructor // or conversion function. Diag(D.getDeclSpec().getExplicitSpecLoc(), diag::err_explicit_non_ctor_or_conv_function) << FixItHint::CreateRemoval(D.getDeclSpec().getExplicitSpecLoc()); } } if (isConstexpr) { // C++11 [dcl.constexpr]p2: constexpr functions and constexpr constructors // are implicitly inline. NewFD->setImplicitlyInline(); // C++11 [dcl.constexpr]p3: functions declared constexpr are required to // be either constructors or to return a literal type. Therefore, // destructors cannot be declared constexpr. if (isa<CXXDestructorDecl>(NewFD)) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor); } // If __module_private__ was specified, mark the function accordingly. if (D.getDeclSpec().isModulePrivateSpecified()) { if (isFunctionTemplateSpecialization) { SourceLocation ModulePrivateLoc = D.getDeclSpec().getModulePrivateSpecLoc(); Diag(ModulePrivateLoc, diag::err_module_private_specialization) << 0 << FixItHint::CreateRemoval(ModulePrivateLoc); } else { NewFD->setModulePrivate(); if (FunctionTemplate) FunctionTemplate->setModulePrivate(); } } if (isFriend) { // For now, claim that the objects have no previous declaration. if (FunctionTemplate) { FunctionTemplate->setObjectOfFriendDecl(false); FunctionTemplate->setAccess(AS_public); } NewFD->setObjectOfFriendDecl(false); NewFD->setAccess(AS_public); } // If a function is defined as defaulted or deleted, mark it as such now. switch (D.getFunctionDefinitionKind()) { case FDK_Declaration: case FDK_Definition: break; case FDK_Defaulted: NewFD->setDefaulted(); break; case FDK_Deleted: NewFD->setDeletedAsWritten(); break; } if (isa<CXXMethodDecl>(NewFD) && DC == CurContext && D.isFunctionDefinition()) { // C++ [class.mfct]p2: // A member function may be defined (8.4) in its class definition, in // which case it is an inline member function (7.1.2) NewFD->setImplicitlyInline(); } if (SC == SC_Static && isa<CXXMethodDecl>(NewFD) && !CurContext->isRecord()) { // C++ [class.static]p1: // A data or function member of a class may be declared static // in a class definition, in which case it is a static member of // the class. // Complain about the 'static' specifier if it's on an out-of-line // member function definition. Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_static_out_of_line) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); } // C++11 [except.spec]p15: // A deallocation function with no exception-specification is treated // as if it were specified with noexcept(true). const FunctionProtoType *FPT = R->getAs<FunctionProtoType>(); if ((Name.getCXXOverloadedOperator() == OO_Delete || Name.getCXXOverloadedOperator() == OO_Array_Delete) && getLangOpts().CPlusPlus11 && FPT && !FPT->hasExceptionSpec()) { FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.ExceptionSpecType = EST_BasicNoexcept; NewFD->setType(Context.getFunctionType(FPT->getResultType(), ArrayRef<QualType>(FPT->arg_type_begin(), FPT->getNumArgs()), EPI)); } } // Filter out previous declarations that don't match the scope. FilterLookupForScope(Previous, DC, S, shouldConsiderLinkage(NewFD), isExplicitSpecialization || isFunctionTemplateSpecialization); // Handle GNU asm-label extension (encoded as an attribute). if (Expr *E = (Expr*) D.getAsmLabel()) { // The parser guarantees this is a string. StringLiteral *SE = cast<StringLiteral>(E); NewFD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), Context, SE->getString())); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier()); if (I != ExtnameUndeclaredIdentifiers.end()) { NewFD->addAttr(I->second); ExtnameUndeclaredIdentifiers.erase(I); } } // Copy the parameter declarations from the declarator D to the function // declaration NewFD, if they are available. First scavenge them into Params. SmallVector<ParmVarDecl*, 16> Params; if (D.isFunctionDeclarator()) { DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs // function that takes no arguments, not a function that takes a // single void argument. // We let through "const void" here because Sema::GetTypeForDeclarator // already checks for that case. if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 && FTI.ArgInfo[0].Param && cast<ParmVarDecl>(FTI.ArgInfo[0].Param)->getType()->isVoidType()) { // Empty arg list, don't push any params. checkVoidParamDecl(cast<ParmVarDecl>(FTI.ArgInfo[0].Param)); } else if (FTI.NumArgs > 0 && FTI.ArgInfo[0].Param != 0) { for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) { ParmVarDecl *Param = cast<ParmVarDecl>(FTI.ArgInfo[i].Param); assert(Param->getDeclContext() != NewFD && "Was set before ?"); Param->setDeclContext(NewFD); Params.push_back(Param); if (Param->isInvalidDecl()) NewFD->setInvalidDecl(); } } } else if (const FunctionProtoType *FT = R->getAs<FunctionProtoType>()) { // When we're declaring a function with a typedef, typeof, etc as in the // following example, we'll need to synthesize (unnamed) // parameters for use in the declaration. // // @code // typedef void fn(int); // fn f; // @endcode // Synthesize a parameter for each argument type. for (FunctionProtoType::arg_type_iterator AI = FT->arg_type_begin(), AE = FT->arg_type_end(); AI != AE; ++AI) { ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, D.getIdentifierLoc(), *AI); Param->setScopeInfo(0, Params.size()); Params.push_back(Param); } } else { assert(R->isFunctionNoProtoType() && NewFD->getNumParams() == 0 && "Should not need args for typedef of non-prototype fn"); } // Finally, we know we have the right number of parameters, install them. NewFD->setParams(Params); // Find all anonymous symbols defined during the declaration of this function // and add to NewFD. This lets us track decls such 'enum Y' in: // // void f(enum Y {AA} x) {} // // which would otherwise incorrectly end up in the translation unit scope. NewFD->setDeclsInPrototypeScope(DeclsInPrototypeScope); DeclsInPrototypeScope.clear(); if (D.getDeclSpec().isNoreturnSpecified()) NewFD->addAttr( ::new(Context) C11NoReturnAttr(D.getDeclSpec().getNoreturnSpecLoc(), Context)); // Process the non-inheritable attributes on this declaration. ProcessDeclAttributes(S, NewFD, D, /*NonInheritable=*/true, /*Inheritable=*/false); // Functions returning a variably modified type violate C99 6.7.5.2p2 // because all functions have linkage. if (!NewFD->isInvalidDecl() && NewFD->getResultType()->isVariablyModifiedType()) { Diag(NewFD->getLocation(), diag::err_vm_func_decl); NewFD->setInvalidDecl(); } // Handle attributes. ProcessDeclAttributes(S, NewFD, D, /*NonInheritable=*/false, /*Inheritable=*/true); QualType RetType = NewFD->getResultType(); const CXXRecordDecl *Ret = RetType->isRecordType() ? RetType->getAsCXXRecordDecl() : RetType->getPointeeCXXRecordDecl(); if (!NewFD->isInvalidDecl() && !NewFD->hasAttr<WarnUnusedResultAttr>() && Ret && Ret->hasAttr<WarnUnusedResultAttr>()) { const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); if (!(MD && MD->getCorrespondingMethodInClass(Ret, true))) { NewFD->addAttr(new (Context) WarnUnusedResultAttr(SourceRange(), Context)); } } if (!getLangOpts().CPlusPlus) { // Perform semantic checking on the function declaration. bool isExplicitSpecialization=false; if (!NewFD->isInvalidDecl()) { if (NewFD->isMain()) CheckMain(NewFD, D.getDeclSpec()); D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization)); } // Make graceful recovery from an invalid redeclaration. else if (!Previous.empty()) D.setRedeclaration(true); assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || Previous.getResultKind() != LookupResult::FoundOverloaded) && "previous declaration set still overloaded"); } else { // If the declarator is a template-id, translate the parser's template // argument list into our AST format. if (D.getName().getKind() == UnqualifiedId::IK_TemplateId) { TemplateIdAnnotation *TemplateId = D.getName().TemplateId; TemplateArgs.setLAngleLoc(TemplateId->LAngleLoc); TemplateArgs.setRAngleLoc(TemplateId->RAngleLoc); ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(), TemplateId->NumArgs); translateTemplateArguments(TemplateArgsPtr, TemplateArgs); HasExplicitTemplateArgs = true; if (NewFD->isInvalidDecl()) { HasExplicitTemplateArgs = false; } else if (FunctionTemplate) { // Function template with explicit template arguments. Diag(D.getIdentifierLoc(), diag::err_function_template_partial_spec) << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc); HasExplicitTemplateArgs = false; } else if (!isFunctionTemplateSpecialization && !D.getDeclSpec().isFriendSpecified()) { // We have encountered something that the user meant to be a // specialization (because it has explicitly-specified template // arguments) but that was not introduced with a "template<>" (or had // too few of them). Diag(D.getIdentifierLoc(), diag::err_template_spec_needs_header) << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc) << FixItHint::CreateInsertion( D.getDeclSpec().getLocStart(), "template<> "); isFunctionTemplateSpecialization = true; } else { // "friend void foo<>(int);" is an implicit specialization decl. isFunctionTemplateSpecialization = true; } } else if (isFriend && isFunctionTemplateSpecialization) { // This combination is only possible in a recovery case; the user // wrote something like: // template <> friend void foo(int); // which we're recovering from as if the user had written: // friend void foo<>(int); // Go ahead and fake up a template id. HasExplicitTemplateArgs = true; TemplateArgs.setLAngleLoc(D.getIdentifierLoc()); TemplateArgs.setRAngleLoc(D.getIdentifierLoc()); } // If it's a friend (and only if it's a friend), it's possible // that either the specialized function type or the specialized // template is dependent, and therefore matching will fail. In // this case, don't check the specialization yet. bool InstantiationDependent = false; if (isFunctionTemplateSpecialization && isFriend && (NewFD->getType()->isDependentType() || DC->isDependentContext() || TemplateSpecializationType::anyDependentTemplateArguments( TemplateArgs.getArgumentArray(), TemplateArgs.size(), InstantiationDependent))) { assert(HasExplicitTemplateArgs && "friend function specialization without template args"); if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs, Previous)) NewFD->setInvalidDecl(); } else if (isFunctionTemplateSpecialization) { if (CurContext->isDependentContext() && CurContext->isRecord() && !isFriend) { isDependentClassScopeExplicitSpecialization = true; Diag(NewFD->getLocation(), getLangOpts().MicrosoftExt ? diag::ext_function_specialization_in_class : diag::err_function_specialization_in_class) << NewFD->getDeclName(); } else if (CheckFunctionTemplateSpecialization(NewFD, (HasExplicitTemplateArgs ? &TemplateArgs : 0), Previous)) NewFD->setInvalidDecl(); // C++ [dcl.stc]p1: // A storage-class-specifier shall not be specified in an explicit // specialization (14.7.3) if (SC != SC_None) { if (SC != NewFD->getTemplateSpecializationInfo()->getTemplate()->getTemplatedDecl()->getStorageClass()) Diag(NewFD->getLocation(), diag::err_explicit_specialization_inconsistent_storage_class) << SC << FixItHint::CreateRemoval( D.getDeclSpec().getStorageClassSpecLoc()); else Diag(NewFD->getLocation(), diag::ext_explicit_specialization_storage_class) << FixItHint::CreateRemoval( D.getDeclSpec().getStorageClassSpecLoc()); } } else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD)) { if (CheckMemberSpecialization(NewFD, Previous)) NewFD->setInvalidDecl(); } // Perform semantic checking on the function declaration. if (!isDependentClassScopeExplicitSpecialization) { if (NewFD->isInvalidDecl()) { // If this is a class member, mark the class invalid immediately. // This avoids some consistency errors later. if (CXXMethodDecl* methodDecl = dyn_cast<CXXMethodDecl>(NewFD)) methodDecl->getParent()->setInvalidDecl(); } else { if (NewFD->isMain()) CheckMain(NewFD, D.getDeclSpec()); D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization)); } } assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || Previous.getResultKind() != LookupResult::FoundOverloaded) && "previous declaration set still overloaded"); NamedDecl *PrincipalDecl = (FunctionTemplate ? cast<NamedDecl>(FunctionTemplate) : NewFD); if (isFriend && D.isRedeclaration()) { AccessSpecifier Access = AS_public; if (!NewFD->isInvalidDecl()) Access = NewFD->getPreviousDecl()->getAccess(); NewFD->setAccess(Access); if (FunctionTemplate) FunctionTemplate->setAccess(Access); PrincipalDecl->setObjectOfFriendDecl(true); } if (NewFD->isOverloadedOperator() && !DC->isRecord() && PrincipalDecl->isInIdentifierNamespace(Decl::IDNS_Ordinary)) PrincipalDecl->setNonMemberOperator(); // If we have a function template, check the template parameter // list. This will check and merge default template arguments. if (FunctionTemplate) { FunctionTemplateDecl *PrevTemplate = FunctionTemplate->getPreviousDecl(); CheckTemplateParameterList(FunctionTemplate->getTemplateParameters(), PrevTemplate ? PrevTemplate->getTemplateParameters() : 0, D.getDeclSpec().isFriendSpecified() ? (D.isFunctionDefinition() ? TPC_FriendFunctionTemplateDefinition : TPC_FriendFunctionTemplate) : (D.getCXXScopeSpec().isSet() && DC && DC->isRecord() && DC->isDependentContext()) ? TPC_ClassTemplateMember : TPC_FunctionTemplate); } if (NewFD->isInvalidDecl()) { // Ignore all the rest of this. } else if (!D.isRedeclaration()) { struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists, AddToScope }; // Fake up an access specifier if it's supposed to be a class member. if (isa<CXXRecordDecl>(NewFD->getDeclContext())) NewFD->setAccess(AS_public); // Qualified decls generally require a previous declaration. if (D.getCXXScopeSpec().isSet()) { // ...with the major exception of templated-scope or // dependent-scope friend declarations. // TODO: we currently also suppress this check in dependent // contexts because (1) the parameter depth will be off when // matching friend templates and (2) we might actually be // selecting a friend based on a dependent factor. But there // are situations where these conditions don't apply and we // can actually do this check immediately. if (isFriend && (TemplateParamLists.size() || D.getCXXScopeSpec().getScopeRep()->isDependent() || CurContext->isDependentContext())) { // ignore these } else { // The user tried to provide an out-of-line definition for a // function that is a member of a class or namespace, but there // was no such member function declared (C++ [class.mfct]p2, // C++ [namespace.memdef]p2). For example: // // class X { // void f() const; // }; // // void X::f() { } // ill-formed // // Complain about this problem, and attempt to suggest close // matches (e.g., those that differ only in cv-qualifiers and // whether the parameter types are references). if (NamedDecl *Result = DiagnoseInvalidRedeclaration(*this, Previous, NewFD, ExtraArgs)) { AddToScope = ExtraArgs.AddToScope; return Result; } } // Unqualified local friend declarations are required to resolve // to something. } else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) { if (NamedDecl *Result = DiagnoseInvalidRedeclaration(*this, Previous, NewFD, ExtraArgs)) { AddToScope = ExtraArgs.AddToScope; return Result; } } } else if (!D.isFunctionDefinition() && D.getCXXScopeSpec().isSet() && !isFriend && !isFunctionTemplateSpecialization && !isExplicitSpecialization) { // An out-of-line member function declaration must also be a // definition (C++ [dcl.meaning]p1). // Note that this is not the case for explicit specializations of // function templates or member functions of class templates, per // C++ [temp.expl.spec]p2. We also allow these declarations as an // extension for compatibility with old SWIG code which likes to // generate them. Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration) << D.getCXXScopeSpec().getRange(); } } ProcessPragmaWeak(S, NewFD); checkAttributesAfterMerging(*this, *NewFD); AddKnownFunctionAttributes(NewFD); if (NewFD->hasAttr<OverloadableAttr>() && !NewFD->getType()->getAs<FunctionProtoType>()) { Diag(NewFD->getLocation(), diag::err_attribute_overloadable_no_prototype) << NewFD; // Turn this into a variadic function with no parameters. const FunctionType *FT = NewFD->getType()->getAs<FunctionType>(); FunctionProtoType::ExtProtoInfo EPI; EPI.Variadic = true; EPI.ExtInfo = FT->getExtInfo(); QualType R = Context.getFunctionType(FT->getResultType(), None, EPI); NewFD->setType(R); } // If there's a #pragma GCC visibility in scope, and this isn't a class // member, set the visibility of this function. if (!DC->isRecord() && NewFD->hasExternalLinkage()) AddPushedVisibilityAttribute(NewFD); // If there's a #pragma clang arc_cf_code_audited in scope, consider // marking the function. AddCFAuditedAttribute(NewFD); // If this is a locally-scoped extern C function, update the // map of such names. if (CurContext->isFunctionOrMethod() && NewFD->isExternC() && !NewFD->isInvalidDecl()) RegisterLocallyScopedExternCDecl(NewFD, Previous, S); // Set this FunctionDecl's range up to the right paren. NewFD->setRangeEnd(D.getSourceRange().getEnd()); if (getLangOpts().CPlusPlus) { if (FunctionTemplate) { if (NewFD->isInvalidDecl()) FunctionTemplate->setInvalidDecl(); return FunctionTemplate; } } if (NewFD->hasAttr<OpenCLKernelAttr>()) { // OpenCL v1.2 s6.8 static is invalid for kernel functions. if ((getLangOpts().OpenCLVersion >= 120) && (SC == SC_Static)) { Diag(D.getIdentifierLoc(), diag::err_static_kernel); D.setInvalidType(); } // OpenCL v1.2, s6.9 -- Kernels can only have return type void. if (!NewFD->getResultType()->isVoidType()) { Diag(D.getIdentifierLoc(), diag::err_expected_kernel_void_return_type); D.setInvalidType(); } for (FunctionDecl::param_iterator PI = NewFD->param_begin(), PE = NewFD->param_end(); PI != PE; ++PI) { ParmVarDecl *Param = *PI; QualType PT = Param->getType(); // OpenCL v1.2 s6.9.a: // A kernel function argument cannot be declared as a // pointer to a pointer type. if (PT->isPointerType() && PT->getPointeeType()->isPointerType()) { Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_arg); D.setInvalidType(); } // OpenCL v1.2 s6.8 n: // A kernel function argument cannot be declared // of event_t type. if (PT->isEventT()) { Diag(Param->getLocation(), diag::err_event_t_kernel_arg); D.setInvalidType(); } } } MarkUnusedFileScopedDecl(NewFD); if (getLangOpts().CUDA) if (IdentifierInfo *II = NewFD->getIdentifier()) if (!NewFD->isInvalidDecl() && NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { if (II->isStr("cudaConfigureCall")) { if (!R->getAs<FunctionType>()->getResultType()->isScalarType()) Diag(NewFD->getLocation(), diag::err_config_scalar_return); Context.setcudaConfigureCallDecl(NewFD); } } // Here we have an function template explicit specialization at class scope. // The actually specialization will be postponed to template instatiation // time via the ClassScopeFunctionSpecializationDecl node. if (isDependentClassScopeExplicitSpecialization) { ClassScopeFunctionSpecializationDecl *NewSpec = ClassScopeFunctionSpecializationDecl::Create( Context, CurContext, SourceLocation(), cast<CXXMethodDecl>(NewFD), HasExplicitTemplateArgs, TemplateArgs); CurContext->addDecl(NewSpec); AddToScope = false; } return NewFD; } /// \brief Perform semantic checking of a new function declaration. /// /// Performs semantic analysis of the new function declaration /// NewFD. This routine performs all semantic checking that does not /// require the actual declarator involved in the declaration, and is /// used both for the declaration of functions as they are parsed /// (called via ActOnDeclarator) and for the declaration of functions /// that have been instantiated via C++ template instantiation (called /// via InstantiateDecl). /// /// \param IsExplicitSpecialization whether this new function declaration is /// an explicit specialization of the previous declaration. /// /// This sets NewFD->isInvalidDecl() to true if there was an error. /// /// \returns true if the function declaration is a redeclaration. bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsExplicitSpecialization) { assert(!NewFD->getResultType()->isVariablyModifiedType() && "Variably modified return types are not handled here"); // Check for a previous declaration of this name. if (Previous.empty() && mayConflictWithNonVisibleExternC(NewFD)) { // Since we did not find anything by this name, look for a non-visible // extern "C" declaration with the same name. llvm::DenseMap<DeclarationName, NamedDecl *>::iterator Pos = findLocallyScopedExternCDecl(NewFD->getDeclName()); if (Pos != LocallyScopedExternCDecls.end()) Previous.addDecl(Pos->second); } // Filter out any non-conflicting previous declarations. filterNonConflictingPreviousDecls(Context, NewFD, Previous); bool Redeclaration = false; NamedDecl *OldDecl = 0; // Merge or overload the declaration with an existing declaration of // the same name, if appropriate. if (!Previous.empty()) { // Determine whether NewFD is an overload of PrevDecl or // a declaration that requires merging. If it's an overload, // there's no more work to do here; we'll just add the new // function to the scope. if (!AllowOverloadingOfFunction(Previous, Context)) { NamedDecl *Candidate = Previous.getFoundDecl(); if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) { Redeclaration = true; OldDecl = Candidate; } } else { switch (CheckOverload(S, NewFD, Previous, OldDecl, /*NewIsUsingDecl*/ false)) { case Ovl_Match: Redeclaration = true; break; case Ovl_NonFunction: Redeclaration = true; break; case Ovl_Overload: Redeclaration = false; break; } if (!getLangOpts().CPlusPlus && !NewFD->hasAttr<OverloadableAttr>()) { // If a function name is overloadable in C, then every function // with that name must be marked "overloadable". Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing) << Redeclaration << NewFD; NamedDecl *OverloadedDecl = 0; if (Redeclaration) OverloadedDecl = OldDecl; else if (!Previous.empty()) OverloadedDecl = Previous.getRepresentativeDecl(); if (OverloadedDecl) Diag(OverloadedDecl->getLocation(), diag::note_attribute_overloadable_prev_overload); NewFD->addAttr(::new (Context) OverloadableAttr(SourceLocation(), Context)); } } } // C++11 [dcl.constexpr]p8: // A constexpr specifier for a non-static member function that is not // a constructor declares that member function to be const. // // This needs to be delayed until we know whether this is an out-of-line // definition of a static member function. // // This rule is not present in C++1y, so we produce a backwards // compatibility warning whenever it happens in C++11. CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD); if (!getLangOpts().CPlusPlus1y && MD && MD->isConstexpr() && !MD->isStatic() && !isa<CXXConstructorDecl>(MD) && (MD->getTypeQualifiers() & Qualifiers::Const) == 0) { CXXMethodDecl *OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl); if (FunctionTemplateDecl *OldTD = dyn_cast_or_null<FunctionTemplateDecl>(OldDecl)) OldMD = dyn_cast<CXXMethodDecl>(OldTD->getTemplatedDecl()); if (!OldMD || !OldMD->isStatic()) { const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>(); FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); EPI.TypeQuals |= Qualifiers::Const; MD->setType(Context.getFunctionType(FPT->getResultType(), ArrayRef<QualType>(FPT->arg_type_begin(), FPT->getNumArgs()), EPI)); // Warn that we did this, if we're not performing template instantiation. // In that case, we'll have warned already when the template was defined. if (ActiveTemplateInstantiations.empty()) { SourceLocation AddConstLoc; if (FunctionTypeLoc FTL = MD->getTypeSourceInfo()->getTypeLoc() .IgnoreParens().getAs<FunctionTypeLoc>()) AddConstLoc = PP.getLocForEndOfToken(FTL.getRParenLoc()); Diag(MD->getLocation(), diag::warn_cxx1y_compat_constexpr_not_const) << FixItHint::CreateInsertion(AddConstLoc, " const"); } } } if (Redeclaration) { // NewFD and OldDecl represent declarations that need to be // merged. if (MergeFunctionDecl(NewFD, OldDecl, S)) { NewFD->setInvalidDecl(); return Redeclaration; } Previous.clear(); Previous.addDecl(OldDecl); if (FunctionTemplateDecl *OldTemplateDecl = dyn_cast<FunctionTemplateDecl>(OldDecl)) { NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl()); FunctionTemplateDecl *NewTemplateDecl = NewFD->getDescribedFunctionTemplate(); assert(NewTemplateDecl && "Template/non-template mismatch"); if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewTemplateDecl->getTemplatedDecl())) { Method->setAccess(OldTemplateDecl->getAccess()); NewTemplateDecl->setAccess(OldTemplateDecl->getAccess()); } // If this is an explicit specialization of a member that is a function // template, mark it as a member specialization. if (IsExplicitSpecialization && NewTemplateDecl->getInstantiatedFromMemberTemplate()) { NewTemplateDecl->setMemberSpecialization(); assert(OldTemplateDecl->isMemberSpecialization()); } } else { // This needs to happen first so that 'inline' propagates. NewFD->setPreviousDeclaration(cast<FunctionDecl>(OldDecl)); if (isa<CXXMethodDecl>(NewFD)) { // A valid redeclaration of a C++ method must be out-of-line, // but (unfortunately) it's not necessarily a definition // because of templates, which means that the previous // declaration is not necessarily from the class definition. // For just setting the access, that doesn't matter. CXXMethodDecl *oldMethod = cast<CXXMethodDecl>(OldDecl); NewFD->setAccess(oldMethod->getAccess()); // Update the key-function state if necessary for this ABI. if (NewFD->isInlined() && !Context.getTargetInfo().getCXXABI().canKeyFunctionBeInline()) { // setNonKeyFunction needs to work with the original // declaration from the class definition, and isVirtual() is // just faster in that case, so map back to that now. oldMethod = cast<CXXMethodDecl>(oldMethod->getFirstDeclaration()); if (oldMethod->isVirtual()) { Context.setNonKeyFunction(oldMethod); } } } } } // Semantic checking for this function declaration (in isolation). if (getLangOpts().CPlusPlus) { // C++-specific checks. if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD)) { CheckConstructor(Constructor); } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(NewFD)) { CXXRecordDecl *Record = Destructor->getParent(); QualType ClassType = Context.getTypeDeclType(Record); // FIXME: Shouldn't we be able to perform this check even when the class // type is dependent? Both gcc and edg can handle that. if (!ClassType->isDependentType()) { DeclarationName Name = Context.DeclarationNames.getCXXDestructorName( Context.getCanonicalType(ClassType)); if (NewFD->getDeclName() != Name) { Diag(NewFD->getLocation(), diag::err_destructor_name); NewFD->setInvalidDecl(); return Redeclaration; } } } else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(NewFD)) { ActOnConversionDeclarator(Conversion); } // Find any virtual functions that this function overrides. if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) { if (!Method->isFunctionTemplateSpecialization() && !Method->getDescribedFunctionTemplate() && Method->isCanonicalDecl()) { if (AddOverriddenMethods(Method->getParent(), Method)) { // If the function was marked as "static", we have a problem. if (NewFD->getStorageClass() == SC_Static) { ReportOverrides(*this, diag::err_static_overrides_virtual, Method); } } } if (Method->isStatic()) checkThisInStaticMemberFunctionType(Method); } // Extra checking for C++ overloaded operators (C++ [over.oper]). if (NewFD->isOverloadedOperator() && CheckOverloadedOperatorDeclaration(NewFD)) { NewFD->setInvalidDecl(); return Redeclaration; } // Extra checking for C++0x literal operators (C++0x [over.literal]). if (NewFD->getLiteralIdentifier() && CheckLiteralOperatorDeclaration(NewFD)) { NewFD->setInvalidDecl(); return Redeclaration; } // In C++, check default arguments now that we have merged decls. Unless // the lexical context is the class, because in this case this is done // during delayed parsing anyway. if (!CurContext->isRecord()) CheckCXXDefaultArguments(NewFD); // If this function declares a builtin function, check the type of this // declaration against the expected type for the builtin. if (unsigned BuiltinID = NewFD->getBuiltinID()) { ASTContext::GetBuiltinTypeError Error; LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier()); QualType T = Context.GetBuiltinType(BuiltinID, Error); if (!T.isNull() && !Context.hasSameType(T, NewFD->getType())) { // The type of this function differs from the type of the builtin, // so forget about the builtin entirely. Context.BuiltinInfo.ForgetBuiltin(BuiltinID, Context.Idents); } } // If this function is declared as being extern "C", then check to see if // the function returns a UDT (class, struct, or union type) that is not C // compatible, and if it does, warn the user. // But, issue any diagnostic on the first declaration only. if (NewFD->isExternC() && Previous.empty()) { QualType R = NewFD->getResultType(); if (R->isIncompleteType() && !R->isVoidType()) Diag(NewFD->getLocation(), diag::warn_return_value_udt_incomplete) << NewFD << R; else if (!R.isPODType(Context) && !R->isVoidType() && !R->isObjCObjectPointerType()) Diag(NewFD->getLocation(), diag::warn_return_value_udt) << NewFD << R; } } return Redeclaration; } static SourceRange getResultSourceRange(const FunctionDecl *FD) { const TypeSourceInfo *TSI = FD->getTypeSourceInfo(); if (!TSI) return SourceRange(); TypeLoc TL = TSI->getTypeLoc(); FunctionTypeLoc FunctionTL = TL.getAs<FunctionTypeLoc>(); if (!FunctionTL) return SourceRange(); TypeLoc ResultTL = FunctionTL.getResultLoc(); if (ResultTL.getUnqualifiedLoc().getAs<BuiltinTypeLoc>()) return ResultTL.getSourceRange(); return SourceRange(); } void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { // C++11 [basic.start.main]p3: A program that declares main to be inline, // static or constexpr is ill-formed. // C11 6.7.4p4: In a hosted environment, no function specifier(s) shall // appear in a declaration of main. // static main is not an error under C99, but we should warn about it. // We accept _Noreturn main as an extension. if (FD->getStorageClass() == SC_Static) Diag(DS.getStorageClassSpecLoc(), getLangOpts().CPlusPlus ? diag::err_static_main : diag::warn_static_main) << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc()); if (FD->isInlineSpecified()) Diag(DS.getInlineSpecLoc(), diag::err_inline_main) << FixItHint::CreateRemoval(DS.getInlineSpecLoc()); if (DS.isNoreturnSpecified()) { SourceLocation NoreturnLoc = DS.getNoreturnSpecLoc(); SourceRange NoreturnRange(NoreturnLoc, PP.getLocForEndOfToken(NoreturnLoc)); Diag(NoreturnLoc, diag::ext_noreturn_main); Diag(NoreturnLoc, diag::note_main_remove_noreturn) << FixItHint::CreateRemoval(NoreturnRange); } if (FD->isConstexpr()) { Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main) << FixItHint::CreateRemoval(DS.getConstexprSpecLoc()); FD->setConstexpr(false); } QualType T = FD->getType(); assert(T->isFunctionType() && "function decl is not of function type"); const FunctionType* FT = T->castAs<FunctionType>(); // All the standards say that main() should should return 'int'. if (Context.hasSameUnqualifiedType(FT->getResultType(), Context.IntTy)) { // In C and C++, main magically returns 0 if you fall off the end; // set the flag which tells us that. // This is C++ [basic.start.main]p5 and C99 5.1.2.2.3. FD->setHasImplicitReturnZero(true); // In C with GNU extensions we allow main() to have non-integer return // type, but we should warn about the extension, and we disable the // implicit-return-zero rule. } else if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) { Diag(FD->getTypeSpecStartLoc(), diag::ext_main_returns_nonint); SourceRange ResultRange = getResultSourceRange(FD); if (ResultRange.isValid()) Diag(ResultRange.getBegin(), diag::note_main_change_return_type) << FixItHint::CreateReplacement(ResultRange, "int"); // Otherwise, this is just a flat-out error. } else { SourceRange ResultRange = getResultSourceRange(FD); if (ResultRange.isValid()) Diag(FD->getTypeSpecStartLoc(), diag::err_main_returns_nonint) << FixItHint::CreateReplacement(ResultRange, "int"); else Diag(FD->getTypeSpecStartLoc(), diag::err_main_returns_nonint); FD->setInvalidDecl(true); } // Treat protoless main() as nullary. if (isa<FunctionNoProtoType>(FT)) return; const FunctionProtoType* FTP = cast<const FunctionProtoType>(FT); unsigned nparams = FTP->getNumArgs(); assert(FD->getNumParams() == nparams); bool HasExtraParameters = (nparams > 3); // Darwin passes an undocumented fourth argument of type char**. If // other platforms start sprouting these, the logic below will start // getting shifty. if (nparams == 4 && Context.getTargetInfo().getTriple().isOSDarwin()) HasExtraParameters = false; if (HasExtraParameters) { Diag(FD->getLocation(), diag::err_main_surplus_args) << nparams; FD->setInvalidDecl(true); nparams = 3; } // FIXME: a lot of the following diagnostics would be improved // if we had some location information about types. QualType CharPP = Context.getPointerType(Context.getPointerType(Context.CharTy)); QualType Expected[] = { Context.IntTy, CharPP, CharPP, CharPP }; for (unsigned i = 0; i < nparams; ++i) { QualType AT = FTP->getArgType(i); bool mismatch = true; if (Context.hasSameUnqualifiedType(AT, Expected[i])) mismatch = false; else if (Expected[i] == CharPP) { // As an extension, the following forms are okay: // char const ** // char const * const * // char * const * QualifierCollector qs; const PointerType* PT; if ((PT = qs.strip(AT)->getAs<PointerType>()) && (PT = qs.strip(PT->getPointeeType())->getAs<PointerType>()) && Context.hasSameType(QualType(qs.strip(PT->getPointeeType()), 0), Context.CharTy)) { qs.removeConst(); mismatch = !qs.empty(); } } if (mismatch) { Diag(FD->getLocation(), diag::err_main_arg_wrong) << i << Expected[i]; // TODO: suggest replacing given type with expected type FD->setInvalidDecl(true); } } if (nparams == 1 && !FD->isInvalidDecl()) { Diag(FD->getLocation(), diag::warn_main_one_arg); } if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) { Diag(FD->getLocation(), diag::err_main_template_decl); FD->setInvalidDecl(); } } bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) { // FIXME: Need strict checking. In C89, we need to check for // any assignment, increment, decrement, function-calls, or // commas outside of a sizeof. In C99, it's the same list, // except that the aforementioned are allowed in unevaluated // expressions. Everything else falls under the // "may accept other forms of constant expressions" exception. // (We never end up here for C++, so the constant expression // rules there don't matter.) if (Init->isConstantInitializer(Context, false)) return false; Diag(Init->getExprLoc(), diag::err_init_element_not_constant) << Init->getSourceRange(); return true; } namespace { // Visits an initialization expression to see if OrigDecl is evaluated in // its own initialization and throws a warning if it does. class SelfReferenceChecker : public EvaluatedExprVisitor<SelfReferenceChecker> { Sema &S; Decl *OrigDecl; bool isRecordType; bool isPODType; bool isReferenceType; public: typedef EvaluatedExprVisitor<SelfReferenceChecker> Inherited; SelfReferenceChecker(Sema &S, Decl *OrigDecl) : Inherited(S.Context), S(S), OrigDecl(OrigDecl) { isPODType = false; isRecordType = false; isReferenceType = false; if (ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) { isPODType = VD->getType().isPODType(S.Context); isRecordType = VD->getType()->isRecordType(); isReferenceType = VD->getType()->isReferenceType(); } } // For most expressions, the cast is directly above the DeclRefExpr. // For conditional operators, the cast can be outside the conditional // operator if both expressions are DeclRefExpr's. void HandleValue(Expr *E) { if (isReferenceType) return; E = E->IgnoreParenImpCasts(); if (DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) { HandleDeclRefExpr(DRE); return; } if (ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) { HandleValue(CO->getTrueExpr()); HandleValue(CO->getFalseExpr()); return; } if (isa<MemberExpr>(E)) { Expr *Base = E->IgnoreParenImpCasts(); while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) { // Check for static member variables and don't warn on them. if (!isa<FieldDecl>(ME->getMemberDecl())) return; Base = ME->getBase()->IgnoreParenImpCasts(); } if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) HandleDeclRefExpr(DRE); return; } } // Reference types are handled here since all uses of references are // bad, not just r-value uses. void VisitDeclRefExpr(DeclRefExpr *E) { if (isReferenceType) HandleDeclRefExpr(E); } void VisitImplicitCastExpr(ImplicitCastExpr *E) { if (E->getCastKind() == CK_LValueToRValue || (isRecordType && E->getCastKind() == CK_NoOp)) HandleValue(E->getSubExpr()); Inherited::VisitImplicitCastExpr(E); } void VisitMemberExpr(MemberExpr *E) { // Don't warn on arrays since they can be treated as pointers. if (E->getType()->canDecayToPointerType()) return; // Warn when a non-static method call is followed by non-static member // field accesses, which is followed by a DeclRefExpr. CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(E->getMemberDecl()); bool Warn = (MD && !MD->isStatic()); Expr *Base = E->getBase()->IgnoreParenImpCasts(); while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) { if (!isa<FieldDecl>(ME->getMemberDecl())) Warn = false; Base = ME->getBase()->IgnoreParenImpCasts(); } if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) { if (Warn) HandleDeclRefExpr(DRE); return; } // The base of a MemberExpr is not a MemberExpr or a DeclRefExpr. // Visit that expression. Visit(Base); } void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { if (E->getNumArgs() > 0) if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->getArg(0))) HandleDeclRefExpr(DRE); Inherited::VisitCXXOperatorCallExpr(E); } void VisitUnaryOperator(UnaryOperator *E) { // For POD record types, addresses of its own members are well-defined. if (E->getOpcode() == UO_AddrOf && isRecordType && isa<MemberExpr>(E->getSubExpr()->IgnoreParens())) { if (!isPODType) HandleValue(E->getSubExpr()); return; } Inherited::VisitUnaryOperator(E); } void VisitObjCMessageExpr(ObjCMessageExpr *E) { return; } void HandleDeclRefExpr(DeclRefExpr *DRE) { Decl* ReferenceDecl = DRE->getDecl(); if (OrigDecl != ReferenceDecl) return; unsigned diag; if (isReferenceType) { diag = diag::warn_uninit_self_reference_in_reference_init; } else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) { diag = diag::warn_static_self_reference_in_init; } else { diag = diag::warn_uninit_self_reference_in_init; } S.DiagRuntimeBehavior(DRE->getLocStart(), DRE, S.PDiag(diag) << DRE->getNameInfo().getName() << OrigDecl->getLocation() << DRE->getSourceRange()); } }; /// CheckSelfReference - Warns if OrigDecl is used in expression E. static void CheckSelfReference(Sema &S, Decl* OrigDecl, Expr *E, bool DirectInit) { // Parameters arguments are occassionially constructed with itself, // for instance, in recursive functions. Skip them. if (isa<ParmVarDecl>(OrigDecl)) return; E = E->IgnoreParens(); // Skip checking T a = a where T is not a record or reference type. // Doing so is a way to silence uninitialized warnings. if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->isRecordType()) if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) if (ICE->getCastKind() == CK_LValueToRValue) if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr())) if (DRE->getDecl() == OrigDecl) return; SelfReferenceChecker(S, OrigDecl).Visit(E); } } /// AddInitializerToDecl - Adds the initializer Init to the /// declaration dcl. If DirectInit is true, this is C++ direct /// initialization rather than copy initialization. void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit, bool TypeMayContainAuto) { // If there is no declaration, there was an error parsing it. Just ignore // the initializer. if (RealDecl == 0 || RealDecl->isInvalidDecl()) return; if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) { // With declarators parsed the way they are, the parser cannot // distinguish between a normal initializer and a pure-specifier. // Thus this grotesque test. IntegerLiteral *IL; if ((IL = dyn_cast<IntegerLiteral>(Init)) && IL->getValue() == 0 && Context.getCanonicalType(IL->getType()) == Context.IntTy) CheckPureMethod(Method, Init->getSourceRange()); else { Diag(Method->getLocation(), diag::err_member_function_initialization) << Method->getDeclName() << Init->getSourceRange(); Method->setInvalidDecl(); } return; } VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl); if (!VDecl) { assert(!isa<FieldDecl>(RealDecl) && "field init shouldn't get here"); Diag(RealDecl->getLocation(), diag::err_illegal_initializer); RealDecl->setInvalidDecl(); return; } ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init); // C++11 [decl.spec.auto]p6. Deduce the type which 'auto' stands in for. if (TypeMayContainAuto && VDecl->getType()->isUndeducedType()) { Expr *DeduceInit = Init; // Initializer could be a C++ direct-initializer. Deduction only works if it // contains exactly one expression. if (CXXDirectInit) { if (CXXDirectInit->getNumExprs() == 0) { // It isn't possible to write this directly, but it is possible to // end up in this situation with "auto x(some_pack...);" Diag(CXXDirectInit->getLocStart(), diag::err_auto_var_init_no_expression) << VDecl->getDeclName() << VDecl->getType() << VDecl->getSourceRange(); RealDecl->setInvalidDecl(); return; } else if (CXXDirectInit->getNumExprs() > 1) { Diag(CXXDirectInit->getExpr(1)->getLocStart(), diag::err_auto_var_init_multiple_expressions) << VDecl->getDeclName() << VDecl->getType() << VDecl->getSourceRange(); RealDecl->setInvalidDecl(); return; } else { DeduceInit = CXXDirectInit->getExpr(0); } } // Expressions default to 'id' when we're in a debugger. bool DefaultedToAuto = false; if (getLangOpts().DebuggerCastResultToId && Init->getType() == Context.UnknownAnyTy) { ExprResult Result = forceUnknownAnyToType(Init, Context.getObjCIdType()); if (Result.isInvalid()) { VDecl->setInvalidDecl(); return; } Init = Result.take(); DefaultedToAuto = true; } QualType DeducedType; if (DeduceAutoType(VDecl->getTypeSourceInfo(), DeduceInit, DeducedType) == DAR_Failed) DiagnoseAutoDeductionFailure(VDecl, DeduceInit); if (DeducedType.isNull()) { RealDecl->setInvalidDecl(); return; } VDecl->setType(DeducedType); assert(VDecl->isLinkageValid()); // In ARC, infer lifetime. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl)) VDecl->setInvalidDecl(); // Warn if we deduced 'id'. 'auto' usually implies type-safety, but using // 'id' instead of a specific object type prevents most of our usual checks. // We only want to warn outside of template instantiations, though: // inside a template, the 'id' could have come from a parameter. if (ActiveTemplateInstantiations.empty() && !DefaultedToAuto && DeducedType->isObjCIdType()) { SourceLocation Loc = VDecl->getTypeSourceInfo()->getTypeLoc().getBeginLoc(); Diag(Loc, diag::warn_auto_var_is_id) << VDecl->getDeclName() << DeduceInit->getSourceRange(); } // If this is a redeclaration, check that the type we just deduced matches // the previously declared type. if (VarDecl *Old = VDecl->getPreviousDecl()) MergeVarDeclTypes(VDecl, Old, /*OldWasHidden*/ false); // Check the deduced type is valid for a variable declaration. CheckVariableDeclarationType(VDecl); if (VDecl->isInvalidDecl()) return; } if (VDecl->isLocalVarDecl() && VDecl->hasExternalStorage()) { // C99 6.7.8p5. C++ has no such restriction, but that is a defect. Diag(VDecl->getLocation(), diag::err_block_extern_cant_init); VDecl->setInvalidDecl(); return; } if (!VDecl->getType()->isDependentType()) { // A definition must end up with a complete type, which means it must be // complete with the restriction that an array type might be completed by // the initializer; note that later code assumes this restriction. QualType BaseDeclType = VDecl->getType(); if (const ArrayType *Array = Context.getAsIncompleteArrayType(BaseDeclType)) BaseDeclType = Array->getElementType(); if (RequireCompleteType(VDecl->getLocation(), BaseDeclType, diag::err_typecheck_decl_incomplete_type)) { RealDecl->setInvalidDecl(); return; } // The variable can not have an abstract class type. if (RequireNonAbstractType(VDecl->getLocation(), VDecl->getType(), diag::err_abstract_type_in_decl, AbstractVariableType)) VDecl->setInvalidDecl(); } const VarDecl *Def; if ((Def = VDecl->getDefinition()) && Def != VDecl) { Diag(VDecl->getLocation(), diag::err_redefinition) << VDecl->getDeclName(); Diag(Def->getLocation(), diag::note_previous_definition); VDecl->setInvalidDecl(); return; } const VarDecl* PrevInit = 0; if (getLangOpts().CPlusPlus) { // C++ [class.static.data]p4 // If a static data member is of const integral or const // enumeration type, its declaration in the class definition can // specify a constant-initializer which shall be an integral // constant expression (5.19). In that case, the member can appear // in integral constant expressions. The member shall still be // defined in a namespace scope if it is used in the program and the // namespace scope definition shall not contain an initializer. // // We already performed a redefinition check above, but for static // data members we also need to check whether there was an in-class // declaration with an initializer. if (VDecl->isStaticDataMember() && VDecl->getAnyInitializer(PrevInit)) { Diag(VDecl->getLocation(), diag::err_redefinition) << VDecl->getDeclName(); Diag(PrevInit->getLocation(), diag::note_previous_definition); return; } if (VDecl->hasLocalStorage()) getCurFunction()->setHasBranchProtectedScope(); if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) { VDecl->setInvalidDecl(); return; } } // OpenCL 1.1 6.5.2: "Variables allocated in the __local address space inside // a kernel function cannot be initialized." if (VDecl->getStorageClass() == SC_OpenCLWorkGroupLocal) { Diag(VDecl->getLocation(), diag::err_local_cant_init); VDecl->setInvalidDecl(); return; } // Get the decls type and save a reference for later, since // CheckInitializerTypes may change it. QualType DclT = VDecl->getType(), SavT = DclT; // Expressions default to 'id' when we're in a debugger // and we are assigning it to a variable of Objective-C pointer type. if (getLangOpts().DebuggerCastResultToId && DclT->isObjCObjectPointerType() && Init->getType() == Context.UnknownAnyTy) { ExprResult Result = forceUnknownAnyToType(Init, Context.getObjCIdType()); if (Result.isInvalid()) { VDecl->setInvalidDecl(); return; } Init = Result.take(); } // Perform the initialization. if (!VDecl->isInvalidDecl()) { InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl); InitializationKind Kind = DirectInit ? CXXDirectInit ? InitializationKind::CreateDirect(VDecl->getLocation(), Init->getLocStart(), Init->getLocEnd()) : InitializationKind::CreateDirectList( VDecl->getLocation()) : InitializationKind::CreateCopy(VDecl->getLocation(), Init->getLocStart()); MultiExprArg Args = Init; if (CXXDirectInit) Args = MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs()); InitializationSequence InitSeq(*this, Entity, Kind, Args); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT); if (Result.isInvalid()) { VDecl->setInvalidDecl(); return; } Init = Result.takeAs<Expr>(); } // Check for self-references within variable initializers. // Variables declared within a function/method body (except for references) // are handled by a dataflow analysis. if (!VDecl->hasLocalStorage() || VDecl->getType()->isRecordType() || VDecl->getType()->isReferenceType()) { CheckSelfReference(*this, RealDecl, Init, DirectInit); } // If the type changed, it means we had an incomplete type that was // completed by the initializer. For example: // int ary[] = { 1, 3, 5 }; // "ary" transitions from an IncompleteArrayType to a ConstantArrayType. if (!VDecl->isInvalidDecl() && (DclT != SavT)) VDecl->setType(DclT); if (!VDecl->isInvalidDecl()) { checkUnsafeAssigns(VDecl->getLocation(), VDecl->getType(), Init); if (VDecl->hasAttr<BlocksAttr>()) checkRetainCycles(VDecl, Init); // It is safe to assign a weak reference into a strong variable. // Although this code can still have problems: // id x = self.weakProp; // id y = self.weakProp; // we do not warn to warn spuriously when 'x' and 'y' are on separate // paths through the function. This should be revisited if // -Wrepeated-use-of-weak is made flow-sensitive. if (VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong) { DiagnosticsEngine::Level Level = Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, Init->getLocStart()); if (Level != DiagnosticsEngine::Ignored) getCurFunction()->markSafeWeakUse(Init); } } // The initialization is usually a full-expression. // // FIXME: If this is a braced initialization of an aggregate, it is not // an expression, and each individual field initializer is a separate // full-expression. For instance, in: // // struct Temp { ~Temp(); }; // struct S { S(Temp); }; // struct T { S a, b; } t = { Temp(), Temp() } // // we should destroy the first Temp before constructing the second. ExprResult Result = ActOnFinishFullExpr(Init, VDecl->getLocation(), false, VDecl->isConstexpr()); if (Result.isInvalid()) { VDecl->setInvalidDecl(); return; } Init = Result.take(); // Attach the initializer to the decl. VDecl->setInit(Init); if (VDecl->isLocalVarDecl()) { // C99 6.7.8p4: All the expressions in an initializer for an object that has // static storage duration shall be constant expressions or string literals. // C++ does not have this restriction. if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl() && VDecl->getStorageClass() == SC_Static) CheckForConstantInitializer(Init, DclT); } else if (VDecl->isStaticDataMember() && VDecl->getLexicalDeclContext()->isRecord()) { // This is an in-class initialization for a static data member, e.g., // // struct S { // static const int value = 17; // }; // C++ [class.mem]p4: // A member-declarator can contain a constant-initializer only // if it declares a static member (9.4) of const integral or // const enumeration type, see 9.4.2. // // C++11 [class.static.data]p3: // If a non-volatile const static data member is of integral or // enumeration type, its declaration in the class definition can // specify a brace-or-equal-initializer in which every initalizer-clause // that is an assignment-expression is a constant expression. A static // data member of literal type can be declared in the class definition // with the constexpr specifier; if so, its declaration shall specify a // brace-or-equal-initializer in which every initializer-clause that is // an assignment-expression is a constant expression. // Do nothing on dependent types. if (DclT->isDependentType()) { // Allow any 'static constexpr' members, whether or not they are of literal // type. We separately check that every constexpr variable is of literal // type. } else if (VDecl->isConstexpr()) { // Require constness. } else if (!DclT.isConstQualified()) { Diag(VDecl->getLocation(), diag::err_in_class_initializer_non_const) << Init->getSourceRange(); VDecl->setInvalidDecl(); // We allow integer constant expressions in all cases. } else if (DclT->isIntegralOrEnumerationType()) { // Check whether the expression is a constant expression. SourceLocation Loc; if (getLangOpts().CPlusPlus11 && DclT.isVolatileQualified()) // In C++11, a non-constexpr const static data member with an // in-class initializer cannot be volatile. Diag(VDecl->getLocation(), diag::err_in_class_initializer_volatile); else if (Init->isValueDependent()) ; // Nothing to check. else if (Init->isIntegerConstantExpr(Context, &Loc)) ; // Ok, it's an ICE! else if (Init->isEvaluatable(Context)) { // If we can constant fold the initializer through heroics, accept it, // but report this as a use of an extension for -pedantic. Diag(Loc, diag::ext_in_class_initializer_non_constant) << Init->getSourceRange(); } else { // Otherwise, this is some crazy unknown case. Report the issue at the // location provided by the isIntegerConstantExpr failed check. Diag(Loc, diag::err_in_class_initializer_non_constant) << Init->getSourceRange(); VDecl->setInvalidDecl(); } // We allow foldable floating-point constants as an extension. } else if (DclT->isFloatingType()) { // also permits complex, which is ok // In C++98, this is a GNU extension. In C++11, it is not, but we support // it anyway and provide a fixit to add the 'constexpr'. if (getLangOpts().CPlusPlus11) { Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type_cxx11) << DclT << Init->getSourceRange(); Diag(VDecl->getLocStart(), diag::note_in_class_initializer_float_type_cxx11) << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr "); } else { Diag(VDecl->getLocation(), diag::ext_in_class_initializer_float_type) << DclT << Init->getSourceRange(); if (!Init->isValueDependent() && !Init->isEvaluatable(Context)) { Diag(Init->getExprLoc(), diag::err_in_class_initializer_non_constant) << Init->getSourceRange(); VDecl->setInvalidDecl(); } } // Suggest adding 'constexpr' in C++11 for literal types. } else if (getLangOpts().CPlusPlus11 && DclT->isLiteralType(Context)) { Diag(VDecl->getLocation(), diag::err_in_class_initializer_literal_type) << DclT << Init->getSourceRange() << FixItHint::CreateInsertion(VDecl->getLocStart(), "constexpr "); VDecl->setConstexpr(true); } else { Diag(VDecl->getLocation(), diag::err_in_class_initializer_bad_type) << DclT << Init->getSourceRange(); VDecl->setInvalidDecl(); } } else if (VDecl->isFileVarDecl()) { if (VDecl->getStorageClass() == SC_Extern && (!getLangOpts().CPlusPlus || !(Context.getBaseElementType(VDecl->getType()).isConstQualified() || VDecl->isExternC()))) Diag(VDecl->getLocation(), diag::warn_extern_init); // C99 6.7.8p4. All file scoped initializers need to be constant. if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl()) CheckForConstantInitializer(Init, DclT); else if (VDecl->getTLSKind() == VarDecl::TLS_Static && !VDecl->isInvalidDecl() && !DclT->isDependentType() && !Init->isValueDependent() && !VDecl->isConstexpr() && !Init->isConstantInitializer( Context, VDecl->getType()->isReferenceType())) { // GNU C++98 edits for __thread, [basic.start.init]p4: // An object of thread storage duration shall not require dynamic // initialization. // FIXME: Need strict checking here. Diag(VDecl->getLocation(), diag::err_thread_dynamic_init); if (getLangOpts().CPlusPlus11) Diag(VDecl->getLocation(), diag::note_use_thread_local); } } // We will represent direct-initialization similarly to copy-initialization: // int x(1); -as-> int x = 1; // ClassType x(a,b,c); -as-> ClassType x = ClassType(a,b,c); // // Clients that want to distinguish between the two forms, can check for // direct initializer using VarDecl::getInitStyle(). // A major benefit is that clients that don't particularly care about which // exactly form was it (like the CodeGen) can handle both cases without // special case code. // C++ 8.5p11: // The form of initialization (using parentheses or '=') is generally // insignificant, but does matter when the entity being initialized has a // class type. if (CXXDirectInit) { assert(DirectInit && "Call-style initializer must be direct init."); VDecl->setInitStyle(VarDecl::CallInit); } else if (DirectInit) { // This must be list-initialization. No other way is direct-initialization. VDecl->setInitStyle(VarDecl::ListInit); } CheckCompleteVariableDeclaration(VDecl); } /// ActOnInitializerError - Given that there was an error parsing an /// initializer for the given declaration, try to return to some form /// of sanity. void Sema::ActOnInitializerError(Decl *D) { // Our main concern here is re-establishing invariants like "a // variable's type is either dependent or complete". if (!D || D->isInvalidDecl()) return; VarDecl *VD = dyn_cast<VarDecl>(D); if (!VD) return; // Auto types are meaningless if we can't make sense of the initializer. if (ParsingInitForAutoVars.count(D)) { D->setInvalidDecl(); return; } QualType Ty = VD->getType(); if (Ty->isDependentType()) return; // Require a complete type. if (RequireCompleteType(VD->getLocation(), Context.getBaseElementType(Ty), diag::err_typecheck_decl_incomplete_type)) { VD->setInvalidDecl(); return; } // Require an abstract type. if (RequireNonAbstractType(VD->getLocation(), Ty, diag::err_abstract_type_in_decl, AbstractVariableType)) { VD->setInvalidDecl(); return; } // Don't bother complaining about constructors or destructors, // though. } void Sema::ActOnUninitializedDecl(Decl *RealDecl, bool TypeMayContainAuto) { // If there is no declaration, there was an error parsing it. Just ignore it. if (RealDecl == 0) return; if (VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) { QualType Type = Var->getType(); // C++11 [dcl.spec.auto]p3 if (TypeMayContainAuto && Type->getContainedAutoType()) { Diag(Var->getLocation(), diag::err_auto_var_requires_init) << Var->getDeclName() << Type; Var->setInvalidDecl(); return; } // C++11 [class.static.data]p3: A static data member can be declared with // the constexpr specifier; if so, its declaration shall specify // a brace-or-equal-initializer. // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only to // the definition of a variable [...] or the declaration of a static data // member. if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) { if (Var->isStaticDataMember()) Diag(Var->getLocation(), diag::err_constexpr_static_mem_var_requires_init) << Var->getDeclName(); else Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl); Var->setInvalidDecl(); return; } switch (Var->isThisDeclarationADefinition()) { case VarDecl::Definition: if (!Var->isStaticDataMember() || !Var->getAnyInitializer()) break; // We have an out-of-line definition of a static data member // that has an in-class initializer, so we type-check this like // a declaration. // // Fall through case VarDecl::DeclarationOnly: // It's only a declaration. // Block scope. C99 6.7p7: If an identifier for an object is // declared with no linkage (C99 6.2.2p6), the type for the // object shall be complete. if (!Type->isDependentType() && Var->isLocalVarDecl() && !Var->getLinkage() && !Var->isInvalidDecl() && RequireCompleteType(Var->getLocation(), Type, diag::err_typecheck_decl_incomplete_type)) Var->setInvalidDecl(); // Make sure that the type is not abstract. if (!Type->isDependentType() && !Var->isInvalidDecl() && RequireNonAbstractType(Var->getLocation(), Type, diag::err_abstract_type_in_decl, AbstractVariableType)) Var->setInvalidDecl(); if (!Type->isDependentType() && !Var->isInvalidDecl() && Var->getStorageClass() == SC_PrivateExtern) { Diag(Var->getLocation(), diag::warn_private_extern); Diag(Var->getLocation(), diag::note_private_extern); } return; case VarDecl::TentativeDefinition: // File scope. C99 6.9.2p2: A declaration of an identifier for an // object that has file scope without an initializer, and without a // storage-class specifier or with the storage-class specifier "static", // constitutes a tentative definition. Note: A tentative definition with // external linkage is valid (C99 6.2.2p5). if (!Var->isInvalidDecl()) { if (const IncompleteArrayType *ArrayT = Context.getAsIncompleteArrayType(Type)) { if (RequireCompleteType(Var->getLocation(), ArrayT->getElementType(), diag::err_illegal_decl_array_incomplete_type)) Var->setInvalidDecl(); } else if (Var->getStorageClass() == SC_Static) { // C99 6.9.2p3: If the declaration of an identifier for an object is // a tentative definition and has internal linkage (C99 6.2.2p3), the // declared type shall not be an incomplete type. // NOTE: code such as the following // static struct s; // struct s { int a; }; // is accepted by gcc. Hence here we issue a warning instead of // an error and we do not invalidate the static declaration. // NOTE: to avoid multiple warnings, only check the first declaration. if (Var->getPreviousDecl() == 0) RequireCompleteType(Var->getLocation(), Type, diag::ext_typecheck_decl_incomplete_type); } } // Record the tentative definition; we're done. if (!Var->isInvalidDecl()) TentativeDefinitions.push_back(Var); return; } // Provide a specific diagnostic for uninitialized variable // definitions with incomplete array type. if (Type->isIncompleteArrayType()) { Diag(Var->getLocation(), diag::err_typecheck_incomplete_array_needs_initializer); Var->setInvalidDecl(); return; } // Provide a specific diagnostic for uninitialized variable // definitions with reference type. if (Type->isReferenceType()) { Diag(Var->getLocation(), diag::err_reference_var_requires_init) << Var->getDeclName() << SourceRange(Var->getLocation(), Var->getLocation()); Var->setInvalidDecl(); return; } // Do not attempt to type-check the default initializer for a // variable with dependent type. if (Type->isDependentType()) return; if (Var->isInvalidDecl()) return; if (RequireCompleteType(Var->getLocation(), Context.getBaseElementType(Type), diag::err_typecheck_decl_incomplete_type)) { Var->setInvalidDecl(); return; } // The variable can not have an abstract class type. if (RequireNonAbstractType(Var->getLocation(), Type, diag::err_abstract_type_in_decl, AbstractVariableType)) { Var->setInvalidDecl(); return; } // Check for jumps past the implicit initializer. C++0x // clarifies that this applies to a "variable with automatic // storage duration", not a "local variable". // C++11 [stmt.dcl]p3 // A program that jumps from a point where a variable with automatic // storage duration is not in scope to a point where it is in scope is // ill-formed unless the variable has scalar type, class type with a // trivial default constructor and a trivial destructor, a cv-qualified // version of one of these types, or an array of one of the preceding // types and is declared without an initializer. if (getLangOpts().CPlusPlus && Var->hasLocalStorage()) { if (const RecordType *Record = Context.getBaseElementType(Type)->getAs<RecordType>()) { CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl()); // Mark the function for further checking even if the looser rules of // C++11 do not require such checks, so that we can diagnose // incompatibilities with C++98. if (!CXXRecord->isPOD()) getCurFunction()->setHasBranchProtectedScope(); } } // C++03 [dcl.init]p9: // If no initializer is specified for an object, and the // object is of (possibly cv-qualified) non-POD class type (or // array thereof), the object shall be default-initialized; if // the object is of const-qualified type, the underlying class // type shall have a user-declared default // constructor. Otherwise, if no initializer is specified for // a non- static object, the object and its subobjects, if // any, have an indeterminate initial value); if the object // or any of its subobjects are of const-qualified type, the // program is ill-formed. // C++0x [dcl.init]p11: // If no initializer is specified for an object, the object is // default-initialized; [...]. InitializedEntity Entity = InitializedEntity::InitializeVariable(Var); InitializationKind Kind = InitializationKind::CreateDefault(Var->getLocation()); InitializationSequence InitSeq(*this, Entity, Kind, None); ExprResult Init = InitSeq.Perform(*this, Entity, Kind, None); if (Init.isInvalid()) Var->setInvalidDecl(); else if (Init.get()) { Var->setInit(MaybeCreateExprWithCleanups(Init.get())); // This is important for template substitution. Var->setInitStyle(VarDecl::CallInit); } CheckCompleteVariableDeclaration(Var); } } void Sema::ActOnCXXForRangeDecl(Decl *D) { VarDecl *VD = dyn_cast<VarDecl>(D); if (!VD) { Diag(D->getLocation(), diag::err_for_range_decl_must_be_var); D->setInvalidDecl(); return; } VD->setCXXForRangeDecl(true); // for-range-declaration cannot be given a storage class specifier. int Error = -1; switch (VD->getStorageClass()) { case SC_None: break; case SC_Extern: Error = 0; break; case SC_Static: Error = 1; break; case SC_PrivateExtern: Error = 2; break; case SC_Auto: Error = 3; break; case SC_Register: Error = 4; break; case SC_OpenCLWorkGroupLocal: llvm_unreachable("Unexpected storage class"); } if (VD->isConstexpr()) Error = 5; if (Error != -1) { Diag(VD->getOuterLocStart(), diag::err_for_range_storage_class) << VD->getDeclName() << Error; D->setInvalidDecl(); } } void Sema::CheckCompleteVariableDeclaration(VarDecl *var) { if (var->isInvalidDecl()) return; // In ARC, don't allow jumps past the implicit initialization of a // local retaining variable. if (getLangOpts().ObjCAutoRefCount && var->hasLocalStorage()) { switch (var->getType().getObjCLifetime()) { case Qualifiers::OCL_None: case Qualifiers::OCL_ExplicitNone: case Qualifiers::OCL_Autoreleasing: break; case Qualifiers::OCL_Weak: case Qualifiers::OCL_Strong: getCurFunction()->setHasBranchProtectedScope(); break; } } if (var->isThisDeclarationADefinition() && var->hasExternalLinkage() && getDiagnostics().getDiagnosticLevel( diag::warn_missing_variable_declarations, var->getLocation())) { // Find a previous declaration that's not a definition. VarDecl *prev = var->getPreviousDecl(); while (prev && prev->isThisDeclarationADefinition()) prev = prev->getPreviousDecl(); if (!prev) Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var; } if (var->getTLSKind() == VarDecl::TLS_Static && var->getType().isDestructedType()) { // GNU C++98 edits for __thread, [basic.start.term]p3: // The type of an object with thread storage duration shall not // have a non-trivial destructor. Diag(var->getLocation(), diag::err_thread_nontrivial_dtor); if (getLangOpts().CPlusPlus11) Diag(var->getLocation(), diag::note_use_thread_local); } // All the following checks are C++ only. if (!getLangOpts().CPlusPlus) return; QualType type = var->getType(); if (type->isDependentType()) return; // __block variables might require us to capture a copy-initializer. if (var->hasAttr<BlocksAttr>()) { // It's currently invalid to ever have a __block variable with an // array type; should we diagnose that here? // Regardless, we don't want to ignore array nesting when // constructing this copy. if (type->isStructureOrClassType()) { EnterExpressionEvaluationContext scope(*this, PotentiallyEvaluated); SourceLocation poi = var->getLocation(); Expr *varRef =new (Context) DeclRefExpr(var, false, type, VK_LValue, poi); ExprResult result = PerformMoveOrCopyInitialization( InitializedEntity::InitializeBlock(poi, type, false), var, var->getType(), varRef, /*AllowNRVO=*/true); if (!result.isInvalid()) { result = MaybeCreateExprWithCleanups(result); Expr *init = result.takeAs<Expr>(); Context.setBlockVarCopyInits(var, init); } } } Expr *Init = var->getInit(); bool IsGlobal = var->hasGlobalStorage() && !var->isStaticLocal(); QualType baseType = Context.getBaseElementType(type); if (!var->getDeclContext()->isDependentContext() && Init && !Init->isValueDependent()) { if (IsGlobal && !var->isConstexpr() && getDiagnostics().getDiagnosticLevel(diag::warn_global_constructor, var->getLocation()) != DiagnosticsEngine::Ignored && !Init->isConstantInitializer(Context, baseType->isReferenceType())) Diag(var->getLocation(), diag::warn_global_constructor) << Init->getSourceRange(); if (var->isConstexpr()) { SmallVector<PartialDiagnosticAt, 8> Notes; if (!var->evaluateValue(Notes) || !var->isInitICE()) { SourceLocation DiagLoc = var->getLocation(); // If the note doesn't add any useful information other than a source // location, fold it into the primary diagnostic. if (Notes.size() == 1 && Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) { DiagLoc = Notes[0].first; Notes.clear(); } Diag(DiagLoc, diag::err_constexpr_var_requires_const_init) << var << Init->getSourceRange(); for (unsigned I = 0, N = Notes.size(); I != N; ++I) Diag(Notes[I].first, Notes[I].second); } } else if (var->isUsableInConstantExpressions(Context)) { // Check whether the initializer of a const variable of integral or // enumeration type is an ICE now, since we can't tell whether it was // initialized by a constant expression if we check later. var->checkInitIsICE(); } } // Require the destructor. if (const RecordType *recordType = baseType->getAs<RecordType>()) FinalizeVarWithDestructor(var, recordType); } /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform /// any semantic actions necessary after any initializer has been attached. void Sema::FinalizeDeclaration(Decl *ThisDecl) { // Note that we are no longer parsing the initializer for this declaration. ParsingInitForAutoVars.erase(ThisDecl); VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl); if (!VD) return; const DeclContext *DC = VD->getDeclContext(); // If there's a #pragma GCC visibility in scope, and this isn't a class // member, set the visibility of this variable. if (!DC->isRecord() && VD->hasExternalLinkage()) AddPushedVisibilityAttribute(VD); if (VD->isFileVarDecl()) MarkUnusedFileScopedDecl(VD); // Now we have parsed the initializer and can update the table of magic // tag values. if (!VD->hasAttr<TypeTagForDatatypeAttr>() || !VD->getType()->isIntegralOrEnumerationType()) return; for (specific_attr_iterator<TypeTagForDatatypeAttr> I = ThisDecl->specific_attr_begin<TypeTagForDatatypeAttr>(), E = ThisDecl->specific_attr_end<TypeTagForDatatypeAttr>(); I != E; ++I) { const Expr *MagicValueExpr = VD->getInit(); if (!MagicValueExpr) { continue; } llvm::APSInt MagicValueInt; if (!MagicValueExpr->isIntegerConstantExpr(MagicValueInt, Context)) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_not_ice) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } if (MagicValueInt.getActiveBits() > 64) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_too_large) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } uint64_t MagicValue = MagicValueInt.getZExtValue(); RegisterTypeTagForDatatype(I->getArgumentKind(), MagicValue, I->getMatchingCType(), I->getLayoutCompatible(), I->getMustBeNull()); } } Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, Decl **Group, unsigned NumDecls) { SmallVector<Decl*, 8> Decls; if (DS.isTypeSpecOwned()) Decls.push_back(DS.getRepAsDecl()); for (unsigned i = 0; i != NumDecls; ++i) if (Decl *D = Group[i]) Decls.push_back(D); if (DeclSpec::isDeclRep(DS.getTypeSpecType())) if (const TagDecl *Tag = dyn_cast_or_null<TagDecl>(DS.getRepAsDecl())) getASTContext().addUnnamedTag(Tag); return BuildDeclaratorGroup(Decls.data(), Decls.size(), DS.containsPlaceholderType()); } /// BuildDeclaratorGroup - convert a list of declarations into a declaration /// group, performing any necessary semantic checking. Sema::DeclGroupPtrTy Sema::BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, bool TypeMayContainAuto) { // C++0x [dcl.spec.auto]p7: // If the type deduced for the template parameter U is not the same in each // deduction, the program is ill-formed. // FIXME: When initializer-list support is added, a distinction is needed // between the deduced type U and the deduced type which 'auto' stands for. // auto a = 0, b = { 1, 2, 3 }; // is legal because the deduced type U is 'int' in both cases. if (TypeMayContainAuto && NumDecls > 1) { QualType Deduced; CanQualType DeducedCanon; VarDecl *DeducedDecl = 0; for (unsigned i = 0; i != NumDecls; ++i) { if (VarDecl *D = dyn_cast<VarDecl>(Group[i])) { AutoType *AT = D->getType()->getContainedAutoType(); // Don't reissue diagnostics when instantiating a template. if (AT && D->isInvalidDecl()) break; QualType U = AT ? AT->getDeducedType() : QualType(); if (!U.isNull()) { CanQualType UCanon = Context.getCanonicalType(U); if (Deduced.isNull()) { Deduced = U; DeducedCanon = UCanon; DeducedDecl = D; } else if (DeducedCanon != UCanon) { Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(), diag::err_auto_different_deductions) << (AT->isDecltypeAuto() ? 1 : 0) << Deduced << DeducedDecl->getDeclName() << U << D->getDeclName() << DeducedDecl->getInit()->getSourceRange() << D->getInit()->getSourceRange(); D->setInvalidDecl(); break; } } } } } ActOnDocumentableDecls(Group, NumDecls); return DeclGroupPtrTy::make(DeclGroupRef::Create(Context, Group, NumDecls)); } void Sema::ActOnDocumentableDecl(Decl *D) { ActOnDocumentableDecls(&D, 1); } void Sema::ActOnDocumentableDecls(Decl **Group, unsigned NumDecls) { // Don't parse the comment if Doxygen diagnostics are ignored. if (NumDecls == 0 || !Group[0]) return; if (Diags.getDiagnosticLevel(diag::warn_doc_param_not_found, Group[0]->getLocation()) == DiagnosticsEngine::Ignored) return; if (NumDecls >= 2) { // This is a decl group. Normally it will contain only declarations // procuded from declarator list. But in case we have any definitions or // additional declaration references: // 'typedef struct S {} S;' // 'typedef struct S *S;' // 'struct S *pS;' // FinalizeDeclaratorGroup adds these as separate declarations. Decl *MaybeTagDecl = Group[0]; if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) { Group++; NumDecls--; } } // See if there are any new comments that are not attached to a decl. ArrayRef<RawComment *> Comments = Context.getRawCommentList().getComments(); if (!Comments.empty() && !Comments.back()->isAttached()) { // There is at least one comment that not attached to a decl. // Maybe it should be attached to one of these decls? // // Note that this way we pick up not only comments that precede the // declaration, but also comments that *follow* the declaration -- thanks to // the lookahead in the lexer: we've consumed the semicolon and looked // ahead through comments. for (unsigned i = 0; i != NumDecls; ++i) Context.getCommentForDecl(Group[i], &PP); } } /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() /// to introduce parameters into function prototype scope. Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { const DeclSpec &DS = D.getDeclSpec(); // Verify C99 6.7.5.3p2: The only SCS allowed is 'register'. // C++03 [dcl.stc]p2 also permits 'auto'. VarDecl::StorageClass StorageClass = SC_None; if (DS.getStorageClassSpec() == DeclSpec::SCS_register) { StorageClass = SC_Register; } else if (getLangOpts().CPlusPlus && DS.getStorageClassSpec() == DeclSpec::SCS_auto) { StorageClass = SC_Auto; } else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) { Diag(DS.getStorageClassSpecLoc(), diag::err_invalid_storage_class_in_func_decl); D.getMutableDeclSpec().ClearStorageClassSpecs(); } if (DeclSpec::TSCS TSCS = DS.getThreadStorageClassSpec()) Diag(DS.getThreadStorageClassSpecLoc(), diag::err_invalid_thread) << DeclSpec::getSpecifierName(TSCS); if (DS.isConstexprSpecified()) Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr) << 0; DiagnoseFunctionSpecifiers(DS); TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType parmDeclType = TInfo->getType(); if (getLangOpts().CPlusPlus) { // Check that there are no default arguments inside the type of this // parameter. CheckExtraCXXDefaultArguments(D); // Parameter declarators cannot be qualified (C++ [dcl.meaning]p1). if (D.getCXXScopeSpec().isSet()) { Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator) << D.getCXXScopeSpec().getRange(); D.getCXXScopeSpec().clear(); } } // Ensure we have a valid name IdentifierInfo *II = 0; if (D.hasName()) { II = D.getIdentifier(); if (!II) { Diag(D.getIdentifierLoc(), diag::err_bad_parameter_name) << GetNameForDeclarator(D).getName().getAsString(); D.setInvalidType(true); } } // Check for redeclaration of parameters, e.g. int foo(int x, int x); if (II) { LookupResult R(*this, II, D.getIdentifierLoc(), LookupOrdinaryName, ForRedeclaration); LookupName(R, S); if (R.isSingleResult()) { NamedDecl *PrevDecl = R.getFoundDecl(); if (PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. PrevDecl = 0; } else if (S->isDeclScope(PrevDecl)) { Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II; Diag(PrevDecl->getLocation(), diag::note_previous_declaration); // Recover by removing the name II = 0; D.SetIdentifier(0, D.getIdentifierLoc()); D.setInvalidType(true); } } } // Temporarily put parameter variables in the translation unit, not // the enclosing context. This prevents them from accidentally // looking like class members in C++. ParmVarDecl *New = CheckParameter(Context.getTranslationUnitDecl(), D.getLocStart(), D.getIdentifierLoc(), II, parmDeclType, TInfo, StorageClass); if (D.isInvalidType()) New->setInvalidDecl(); assert(S->isFunctionPrototypeScope()); assert(S->getFunctionPrototypeDepth() >= 1); New->setScopeInfo(S->getFunctionPrototypeDepth() - 1, S->getNextFunctionPrototypeIndex()); // Add the parameter declaration into this scope. S->AddDecl(New); if (II) IdResolver.AddDecl(New); ProcessDeclAttributes(S, New, D); if (D.getDeclSpec().isModulePrivateSpecified()) Diag(New->getLocation(), diag::err_module_private_local) << 1 << New->getDeclName() << SourceRange(D.getDeclSpec().getModulePrivateSpecLoc()) << FixItHint::CreateRemoval(D.getDeclSpec().getModulePrivateSpecLoc()); if (New->hasAttr<BlocksAttr>()) { Diag(New->getLocation(), diag::err_block_on_nonlocal); } return New; } /// \brief Synthesizes a variable for a parameter arising from a /// typedef. ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T) { /* FIXME: setting StartLoc == Loc. Would it be worth to modify callers so as to provide proper source location for the unnamed parameters, embedding the parameter's type? */ ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, Loc, Loc, 0, T, Context.getTrivialTypeSourceInfo(T, Loc), SC_None, 0); Param->setImplicit(); return Param; } void Sema::DiagnoseUnusedParameters(ParmVarDecl * const *Param, ParmVarDecl * const *ParamEnd) { // Don't diagnose unused-parameter errors in template instantiations; we // will already have done so in the template itself. if (!ActiveTemplateInstantiations.empty()) return; for (; Param != ParamEnd; ++Param) { if (!(*Param)->isReferenced() && (*Param)->getDeclName() && !(*Param)->hasAttr<UnusedAttr>()) { Diag((*Param)->getLocation(), diag::warn_unused_parameter) << (*Param)->getDeclName(); } } } void Sema::DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Param, ParmVarDecl * const *ParamEnd, QualType ReturnTy, NamedDecl *D) { if (LangOpts.NumLargeByValueCopy == 0) // No check. return; // Warn if the return value is pass-by-value and larger than the specified // threshold. if (!ReturnTy->isDependentType() && ReturnTy.isPODType(Context)) { unsigned Size = Context.getTypeSizeInChars(ReturnTy).getQuantity(); if (Size > LangOpts.NumLargeByValueCopy) Diag(D->getLocation(), diag::warn_return_value_size) << D->getDeclName() << Size; } // Warn if any parameter is pass-by-value and larger than the specified // threshold. for (; Param != ParamEnd; ++Param) { QualType T = (*Param)->getType(); if (T->isDependentType() || !T.isPODType(Context)) continue; unsigned Size = Context.getTypeSizeInChars(T).getQuantity(); if (Size > LangOpts.NumLargeByValueCopy) Diag((*Param)->getLocation(), diag::warn_parameter_size) << (*Param)->getDeclName() << Size; } } ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, VarDecl::StorageClass StorageClass) { // In ARC, infer a lifetime qualifier for appropriate parameter types. if (getLangOpts().ObjCAutoRefCount && T.getObjCLifetime() == Qualifiers::OCL_None && T->isObjCLifetimeType()) { Qualifiers::ObjCLifetime lifetime; // Special cases for arrays: // - if it's const, use __unsafe_unretained // - otherwise, it's an error if (T->isArrayType()) { if (!T.isConstQualified()) { DelayedDiagnostics.add( sema::DelayedDiagnostic::makeForbiddenType( NameLoc, diag::err_arc_array_param_no_ownership, T, false)); } lifetime = Qualifiers::OCL_ExplicitNone; } else { lifetime = T->getObjCARCImplicitLifetime(); } T = Context.getLifetimeQualifiedType(T, lifetime); } ParmVarDecl *New = ParmVarDecl::Create(Context, DC, StartLoc, NameLoc, Name, Context.getAdjustedParameterType(T), TSInfo, StorageClass, 0); // Parameters can not be abstract class types. // For record types, this is done by the AbstractClassUsageDiagnoser once // the class has been completely parsed. if (!CurContext->isRecord() && RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl, AbstractParamType)) New->setInvalidDecl(); // Parameter declarators cannot be interface types. All ObjC objects are // passed by reference. if (T->isObjCObjectType()) { SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd(); Diag(NameLoc, diag::err_object_cannot_be_passed_returned_by_value) << 1 << T << FixItHint::CreateInsertion(TypeEndLoc, "*"); T = Context.getObjCObjectPointerType(T); New->setType(T); } // ISO/IEC TR 18037 S6.7.3: "The type of an object with automatic storage // duration shall not be qualified by an address-space qualifier." // Since all parameters have automatic store duration, they can not have // an address space. if (T.getAddressSpace() != 0) { Diag(NameLoc, diag::err_arg_with_address_space); New->setInvalidDecl(); } return New; } void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls) { DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); // Verify 6.9.1p6: 'every identifier in the identifier list shall be declared' // for a K&R function. if (!FTI.hasPrototype) { for (int i = FTI.NumArgs; i != 0; /* decrement in loop */) { --i; if (FTI.ArgInfo[i].Param == 0) { SmallString<256> Code; llvm::raw_svector_ostream(Code) << " int " << FTI.ArgInfo[i].Ident->getName() << ";\n"; Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared) << FTI.ArgInfo[i].Ident << FixItHint::CreateInsertion(LocAfterDecls, Code.str()); // Implicitly declare the argument as type 'int' for lack of a better // type. AttributeFactory attrs; DeclSpec DS(attrs); const char* PrevSpec; // unused unsigned DiagID; // unused DS.SetTypeSpecType(DeclSpec::TST_int, FTI.ArgInfo[i].IdentLoc, PrevSpec, DiagID); // Use the identifier location for the type source range. DS.SetRangeStart(FTI.ArgInfo[i].IdentLoc); DS.SetRangeEnd(FTI.ArgInfo[i].IdentLoc); Declarator ParamD(DS, Declarator::KNRTypeListContext); ParamD.SetIdentifier(FTI.ArgInfo[i].Ident, FTI.ArgInfo[i].IdentLoc); FTI.ArgInfo[i].Param = ActOnParamDeclarator(S, ParamD); } } } } Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { assert(getCurFunctionDecl() == 0 && "Function parsing confused"); assert(D.isFunctionDeclarator() && "Not a function declarator!"); Scope *ParentScope = FnBodyScope->getParent(); D.setFunctionDefinitionKind(FDK_Definition); Decl *DP = HandleDeclarator(ParentScope, D, MultiTemplateParamsArg()); return ActOnStartOfFunctionDef(FnBodyScope, DP); } static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl*& PossibleZeroParamPrototype) { // Don't warn about invalid declarations. if (FD->isInvalidDecl()) return false; // Or declarations that aren't global. if (!FD->isGlobal()) return false; // Don't warn about C++ member functions. if (isa<CXXMethodDecl>(FD)) return false; // Don't warn about 'main'. if (FD->isMain()) return false; // Don't warn about inline functions. if (FD->isInlined()) return false; // Don't warn about function templates. if (FD->getDescribedFunctionTemplate()) return false; // Don't warn about function template specializations. if (FD->isFunctionTemplateSpecialization()) return false; // Don't warn for OpenCL kernels. if (FD->hasAttr<OpenCLKernelAttr>()) return false; bool MissingPrototype = true; for (const FunctionDecl *Prev = FD->getPreviousDecl(); Prev; Prev = Prev->getPreviousDecl()) { // Ignore any declarations that occur in function or method // scope, because they aren't visible from the header. if (Prev->getDeclContext()->isFunctionOrMethod()) continue; MissingPrototype = !Prev->getType()->isFunctionProtoType(); if (FD->getNumParams() == 0) PossibleZeroParamPrototype = Prev; break; } return MissingPrototype; } void Sema::CheckForFunctionRedefinition(FunctionDecl *FD) { // Don't complain if we're in GNU89 mode and the previous definition // was an extern inline function. const FunctionDecl *Definition; if (FD->isDefined(Definition) && !canRedefineFunction(Definition, getLangOpts())) { if (getLangOpts().GNUMode && Definition->isInlineSpecified() && Definition->getStorageClass() == SC_Extern) Diag(FD->getLocation(), diag::err_redefinition_extern_inline) << FD->getDeclName() << getLangOpts().CPlusPlus; else Diag(FD->getLocation(), diag::err_redefinition) << FD->getDeclName(); Diag(Definition->getLocation(), diag::note_previous_definition); FD->setInvalidDecl(); } } Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // Clear the last template instantiation error context. LastTemplateInstantiationErrorContext = ActiveTemplateInstantiation(); if (!D) return D; FunctionDecl *FD = 0; if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D)) FD = FunTmpl->getTemplatedDecl(); else FD = cast<FunctionDecl>(D); // Enter a new function scope PushFunctionScope(); // See if this is a redefinition. if (!FD->isLateTemplateParsed()) CheckForFunctionRedefinition(FD); // Builtin functions cannot be defined. if (unsigned BuiltinID = FD->getBuiltinID()) { if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) { Diag(FD->getLocation(), diag::err_builtin_definition) << FD; FD->setInvalidDecl(); } } // The return type of a function definition must be complete // (C99 6.9.1p3, C++ [dcl.fct]p6). QualType ResultType = FD->getResultType(); if (!ResultType->isDependentType() && !ResultType->isVoidType() && !FD->isInvalidDecl() && RequireCompleteType(FD->getLocation(), ResultType, diag::err_func_def_incomplete_result)) FD->setInvalidDecl(); // GNU warning -Wmissing-prototypes: // Warn if a global function is defined without a previous // prototype declaration. This warning is issued even if the // definition itself provides a prototype. The aim is to detect // global functions that fail to be declared in header files. const FunctionDecl *PossibleZeroParamPrototype = 0; if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) { Diag(FD->getLocation(), diag::warn_missing_prototype) << FD; if (PossibleZeroParamPrototype) { // We found a declaration that is not a prototype, // but that could be a zero-parameter prototype TypeSourceInfo* TI = PossibleZeroParamPrototype->getTypeSourceInfo(); TypeLoc TL = TI->getTypeLoc(); if (FunctionNoProtoTypeLoc FTL = TL.getAs<FunctionNoProtoTypeLoc>()) Diag(PossibleZeroParamPrototype->getLocation(), diag::note_declaration_not_a_prototype) << PossibleZeroParamPrototype << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void"); } } if (FnBodyScope) PushDeclContext(FnBodyScope, FD); // Check the validity of our function parameters CheckParmsForFunctionDef(FD->param_begin(), FD->param_end(), /*CheckParameterNames=*/true); // Introduce our parameters into the function scope for (unsigned p = 0, NumParams = FD->getNumParams(); p < NumParams; ++p) { ParmVarDecl *Param = FD->getParamDecl(p); Param->setOwningFunction(FD); // If this has an identifier, add it to the scope stack. if (Param->getIdentifier() && FnBodyScope) { CheckShadow(FnBodyScope, Param); PushOnScopeChains(Param, FnBodyScope); } } // If we had any tags defined in the function prototype, // introduce them into the function scope. if (FnBodyScope) { for (llvm::ArrayRef<NamedDecl*>::iterator I = FD->getDeclsInPrototypeScope().begin(), E = FD->getDeclsInPrototypeScope().end(); I != E; ++I) { NamedDecl *D = *I; // Some of these decls (like enums) may have been pinned to the translation unit // for lack of a real context earlier. If so, remove from the translation unit // and reattach to the current context. if (D->getLexicalDeclContext() == Context.getTranslationUnitDecl()) { // Is the decl actually in the context? for (DeclContext::decl_iterator DI = Context.getTranslationUnitDecl()->decls_begin(), DE = Context.getTranslationUnitDecl()->decls_end(); DI != DE; ++DI) { if (*DI == D) { Context.getTranslationUnitDecl()->removeDecl(D); break; } } // Either way, reassign the lexical decl context to our FunctionDecl. D->setLexicalDeclContext(CurContext); } // If the decl has a non-null name, make accessible in the current scope. if (!D->getName().empty()) PushOnScopeChains(D, FnBodyScope, /*AddToContext=*/false); // Similarly, dive into enums and fish their constants out, making them // accessible in this scope. if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) { for (EnumDecl::enumerator_iterator EI = ED->enumerator_begin(), EE = ED->enumerator_end(); EI != EE; ++EI) PushOnScopeChains(*EI, FnBodyScope, /*AddToContext=*/false); } } } // Ensure that the function's exception specification is instantiated. if (const FunctionProtoType *FPT = FD->getType()->getAs<FunctionProtoType>()) ResolveExceptionSpec(D->getLocation(), FPT); // Checking attributes of current function definition // dllimport attribute. DLLImportAttr *DA = FD->getAttr<DLLImportAttr>(); if (DA && (!FD->getAttr<DLLExportAttr>())) { // dllimport attribute cannot be directly applied to definition. // Microsoft accepts dllimport for functions defined within class scope. if (!DA->isInherited() && !(LangOpts.MicrosoftExt && FD->getLexicalDeclContext()->isRecord())) { Diag(FD->getLocation(), diag::err_attribute_can_be_applied_only_to_symbol_declaration) << "dllimport"; FD->setInvalidDecl(); return D; } // Visual C++ appears to not think this is an issue, so only issue // a warning when Microsoft extensions are disabled. if (!LangOpts.MicrosoftExt) { // If a symbol previously declared dllimport is later defined, the // attribute is ignored in subsequent references, and a warning is // emitted. Diag(FD->getLocation(), diag::warn_redeclaration_without_attribute_prev_attribute_ignored) << FD->getName() << "dllimport"; } } // We want to attach documentation to original Decl (which might be // a function template). ActOnDocumentableDecl(D); return D; } /// \brief Given the set of return statements within a function body, /// compute the variables that are subject to the named return value /// optimization. /// /// Each of the variables that is subject to the named return value /// optimization will be marked as NRVO variables in the AST, and any /// return statement that has a marked NRVO variable as its NRVO candidate can /// use the named return value optimization. /// /// This function applies a very simplistic algorithm for NRVO: if every return /// statement in the function has the same NRVO candidate, that candidate is /// the NRVO variable. /// /// FIXME: Employ a smarter algorithm that accounts for multiple return /// statements and the lifetimes of the NRVO candidates. We should be able to /// find a maximal set of NRVO variables. void Sema::computeNRVO(Stmt *Body, FunctionScopeInfo *Scope) { ReturnStmt **Returns = Scope->Returns.data(); const VarDecl *NRVOCandidate = 0; for (unsigned I = 0, E = Scope->Returns.size(); I != E; ++I) { if (!Returns[I]->getNRVOCandidate()) return; if (!NRVOCandidate) NRVOCandidate = Returns[I]->getNRVOCandidate(); else if (NRVOCandidate != Returns[I]->getNRVOCandidate()) return; } if (NRVOCandidate) const_cast<VarDecl*>(NRVOCandidate)->setNRVOVariable(true); } bool Sema::canSkipFunctionBody(Decl *D) { if (!Consumer.shouldSkipFunctionBody(D)) return false; if (isa<ObjCMethodDecl>(D)) return true; FunctionDecl *FD = 0; if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D)) FD = FTD->getTemplatedDecl(); else FD = cast<FunctionDecl>(D); // We cannot skip the body of a function (or function template) which is // constexpr, since we may need to evaluate its body in order to parse the // rest of the file. return !FD->isConstexpr(); } Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) { if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl)) FD->setHasSkippedBody(); else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl)) MD->setHasSkippedBody(); return ActOnFinishFunctionBody(Decl, 0); } Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) { return ActOnFinishFunctionBody(D, BodyArg, false); } Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, bool IsInstantiation) { FunctionDecl *FD = 0; FunctionTemplateDecl *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(dcl); if (FunTmpl) FD = FunTmpl->getTemplatedDecl(); else FD = dyn_cast_or_null<FunctionDecl>(dcl); sema::AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy(); sema::AnalysisBasedWarnings::Policy *ActivePolicy = 0; if (FD) { FD->setBody(Body); if (getLangOpts().CPlusPlus1y && !FD->isInvalidDecl() && !FD->isDependentContext()) { if (FD->getResultType()->isUndeducedType()) { // If the function has a deduced result type but contains no 'return' // statements, the result type as written must be exactly 'auto', and // the deduced result type is 'void'. if (!FD->getResultType()->getAs<AutoType>()) { Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) << FD->getResultType(); FD->setInvalidDecl(); } Context.adjustDeducedFunctionResultType(FD, Context.VoidTy); } } // The only way to be included in UndefinedButUsed is if there is an // ODR use before the definition. Avoid the expensive map lookup if this // is the first declaration. if (FD->getPreviousDecl() != 0 && FD->getPreviousDecl()->isUsed()) { if (FD->getLinkage() != ExternalLinkage) UndefinedButUsed.erase(FD); else if (FD->isInlined() && (LangOpts.CPlusPlus || !LangOpts.GNUInline) && (!FD->getPreviousDecl()->hasAttr<GNUInlineAttr>())) UndefinedButUsed.erase(FD); } if(numElementWise) { FD->setElementWise(true); --numElementWise; } else FD->setElementWise(false); // If the function implicitly returns zero (like 'main') or is naked, // don't complain about missing return statements. if (FD->hasImplicitReturnZero() || FD->hasAttr<NakedAttr>()) WP.disableCheckFallThrough(); // MSVC permits the use of pure specifier (=0) on function definition, // defined at class scope, warn about this non standard construct. if (getLangOpts().MicrosoftExt && FD->isPure()) Diag(FD->getLocation(), diag::warn_pure_function_definition); if (!FD->isInvalidDecl()) { DiagnoseUnusedParameters(FD->param_begin(), FD->param_end()); DiagnoseSizeOfParametersAndReturnValue(FD->param_begin(), FD->param_end(), FD->getResultType(), FD); // If this is a constructor, we need a vtable. if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(FD)) MarkVTableUsed(FD->getLocation(), Constructor->getParent()); // Try to apply the named return value optimization. We have to check // if we can do this here because lambdas keep return statements around // to deduce an implicit return type. if (getLangOpts().CPlusPlus && FD->getResultType()->isRecordType() && !FD->isDependentContext()) computeNRVO(Body, getCurFunction()); } assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) && "Function parsing confused"); } else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) { assert(MD == getCurMethodDecl() && "Method parsing confused"); MD->setBody(Body); if (!MD->isInvalidDecl()) { DiagnoseUnusedParameters(MD->param_begin(), MD->param_end()); DiagnoseSizeOfParametersAndReturnValue(MD->param_begin(), MD->param_end(), MD->getResultType(), MD); if (Body) computeNRVO(Body, getCurFunction()); } if (getCurFunction()->ObjCShouldCallSuper) { Diag(MD->getLocEnd(), diag::warn_objc_missing_super_call) << MD->getSelector().getAsString(); getCurFunction()->ObjCShouldCallSuper = false; } } else { return 0; } assert(!getCurFunction()->ObjCShouldCallSuper && "This should only be set for ObjC methods, which should have been " "handled in the block above."); // Verify and clean out per-function state. if (Body) { // C++ constructors that have function-try-blocks can't have return // statements in the handlers of that block. (C++ [except.handle]p14) // Verify this. if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body)) DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body)); // Verify that gotos and switch cases don't jump into scopes illegally. if (getCurFunction()->NeedsScopeChecking() && !dcl->isInvalidDecl() && !hasAnyUnrecoverableErrorsInThisFunction() && !PP.isCodeCompletionEnabled()) DiagnoseInvalidJumps(Body); if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl)) { if (!Destructor->getParent()->isDependentType()) CheckDestructor(Destructor); MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(), Destructor->getParent()); } // If any errors have occurred, clear out any temporaries that may have // been leftover. This ensures that these temporaries won't be picked up for // deletion in some later function. if (PP.getDiagnostics().hasErrorOccurred() || PP.getDiagnostics().getSuppressAllDiagnostics()) { DiscardCleanupsInEvaluationContext(); } if (!PP.getDiagnostics().hasUncompilableErrorOccurred() && !isa<FunctionTemplateDecl>(dcl)) { // Since the body is valid, issue any analysis-based warnings that are // enabled. ActivePolicy = &WP; } if (!IsInstantiation && FD && FD->isConstexpr() && !FD->isInvalidDecl() && (!CheckConstexprFunctionDecl(FD) || !CheckConstexprFunctionBody(FD, Body))) FD->setInvalidDecl(); assert(ExprCleanupObjects.empty() && "Leftover temporaries in function"); assert(!ExprNeedsCleanups && "Unaccounted cleanups in function"); assert(MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"); } if (!IsInstantiation) PopDeclContext(); PopFunctionScopeInfo(ActivePolicy, dcl); // If any errors have occurred, clear out any temporaries that may have // been leftover. This ensures that these temporaries won't be picked up for // deletion in some later function. if (getDiagnostics().hasErrorOccurred()) { DiscardCleanupsInEvaluationContext(); } return dcl; } /// When we finish delayed parsing of an attribute, we must attach it to the /// relevant Decl. void Sema::ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs) { // Always attach attributes to the underlying decl. if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D)) D = TD->getTemplatedDecl(); ProcessDeclAttributeList(S, D, Attrs.getList()); if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D)) if (Method->isStatic()) checkThisInStaticMemberFunctionAttributes(Method); } /// ImplicitlyDefineFunction - An undeclared identifier was used in a function /// call, forming a call to an implicitly defined function (per C99 6.5.1p2). NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S) { // Before we produce a declaration for an implicitly defined // function, see whether there was a locally-scoped declaration of // this name as a function or variable. If so, use that // (non-visible) declaration, and complain about it. llvm::DenseMap<DeclarationName, NamedDecl *>::iterator Pos = findLocallyScopedExternCDecl(&II); if (Pos != LocallyScopedExternCDecls.end()) { Diag(Loc, diag::warn_use_out_of_scope_declaration) << Pos->second; Diag(Pos->second->getLocation(), diag::note_previous_declaration); return Pos->second; } // Extension in C99. Legal in C90, but warn about it. unsigned diag_id; if (II.getName().startswith("__builtin_")) diag_id = diag::warn_builtin_unknown; else if (getLangOpts().C99) diag_id = diag::ext_implicit_function_decl; else diag_id = diag::warn_implicit_function_decl; Diag(Loc, diag_id) << &II; // Because typo correction is expensive, only do it if the implicit // function declaration is going to be treated as an error. if (Diags.getDiagnosticLevel(diag_id, Loc) >= DiagnosticsEngine::Error) { TypoCorrection Corrected; DeclFilterCCC<FunctionDecl> Validator; if (S && (Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc), LookupOrdinaryName, S, 0, Validator))) { std::string CorrectedStr = Corrected.getAsString(getLangOpts()); std::string CorrectedQuotedStr = Corrected.getQuoted(getLangOpts()); FunctionDecl *Func = Corrected.getCorrectionDeclAs<FunctionDecl>(); Diag(Loc, diag::note_function_suggestion) << CorrectedQuotedStr << FixItHint::CreateReplacement(Loc, CorrectedStr); if (Func->getLocation().isValid() && !II.getName().startswith("__builtin_")) Diag(Func->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr; } } // Set a Declarator for the implicit definition: int foo(); const char *Dummy; AttributeFactory attrFactory; DeclSpec DS(attrFactory); unsigned DiagID; bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy, DiagID); (void)Error; // Silence warning. assert(!Error && "Error setting up implicit decl!"); SourceLocation NoLoc; Declarator D(DS, Declarator::BlockContext); D.AddTypeInfo(DeclaratorChunk::getFunction(/*HasProto=*/false, /*IsAmbiguous=*/false, /*RParenLoc=*/NoLoc, /*ArgInfo=*/0, /*NumArgs=*/0, /*EllipsisLoc=*/NoLoc, /*RParenLoc=*/NoLoc, /*TypeQuals=*/0, /*RefQualifierIsLvalueRef=*/true, /*RefQualifierLoc=*/NoLoc, /*ConstQualifierLoc=*/NoLoc, /*VolatileQualifierLoc=*/NoLoc, /*MutableLoc=*/NoLoc, EST_None, /*ESpecLoc=*/NoLoc, /*Exceptions=*/0, /*ExceptionRanges=*/0, /*NumExceptions=*/0, /*NoexceptExpr=*/0, Loc, Loc, D), DS.getAttributes(), SourceLocation()); D.SetIdentifier(&II, Loc); // Insert this function into translation-unit scope. DeclContext *PrevDC = CurContext; CurContext = Context.getTranslationUnitDecl(); FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(TUScope, D)); FD->setImplicit(); CurContext = PrevDC; AddKnownFunctionAttributes(FD); return FD; } /// \brief Adds any function attributes that we know a priori based on /// the declaration of this function. /// /// These attributes can apply both to implicitly-declared builtins /// (like __builtin___printf_chk) or to library-declared functions /// like NSLog or printf. /// /// We need to check for duplicate attributes both here and where user-written /// attributes are applied to declarations. void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (FD->isInvalidDecl()) return; // If this is a built-in function, map its builtin attributes to // actual attributes. if (unsigned BuiltinID = FD->getBuiltinID()) { // Handle printf-formatting attributes. unsigned FormatIdx; bool HasVAListArg; if (Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) { if (!FD->getAttr<FormatAttr>()) { const char *fmt = "printf"; unsigned int NumParams = FD->getNumParams(); if (FormatIdx < NumParams && // NumParams may be 0 (e.g. vfprintf) FD->getParamDecl(FormatIdx)->getType()->isObjCObjectPointerType()) fmt = "NSString"; FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, fmt, FormatIdx+1, HasVAListArg ? 0 : FormatIdx+2)); } } if (Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx, HasVAListArg)) { if (!FD->getAttr<FormatAttr>()) FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, "scanf", FormatIdx+1, HasVAListArg ? 0 : FormatIdx+2)); } // Mark const if we don't care about errno and that is the only // thing preventing the function from being const. This allows // IRgen to use LLVM intrinsics for such functions. if (!getLangOpts().MathErrno && Context.BuiltinInfo.isConstWithoutErrno(BuiltinID)) { if (!FD->getAttr<ConstAttr>()) FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); } if (Context.BuiltinInfo.isReturnsTwice(BuiltinID) && !FD->getAttr<ReturnsTwiceAttr>()) FD->addAttr(::new (Context) ReturnsTwiceAttr(FD->getLocation(), Context)); if (Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->getAttr<NoThrowAttr>()) FD->addAttr(::new (Context) NoThrowAttr(FD->getLocation(), Context)); if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->getAttr<ConstAttr>()) FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); } IdentifierInfo *Name = FD->getIdentifier(); if (!Name) return; if ((!getLangOpts().CPlusPlus && FD->getDeclContext()->isTranslationUnit()) || (isa<LinkageSpecDecl>(FD->getDeclContext()) && cast<LinkageSpecDecl>(FD->getDeclContext())->getLanguage() == LinkageSpecDecl::lang_c)) { // Okay: this could be a libc/libm/Objective-C function we know // about. } else return; if (Name->isStr("asprintf") || Name->isStr("vasprintf")) { // FIXME: asprintf and vasprintf aren't C99 functions. Should they be // target-specific builtins, perhaps? if (!FD->getAttr<FormatAttr>()) FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, "printf", 2, Name->isStr("vasprintf") ? 0 : 3)); } if (Name->isStr("__CFStringMakeConstantString")) { // We already have a __builtin___CFStringMakeConstantString, // but builds that use -fno-constant-cfstrings don't go through that. if (!FD->getAttr<FormatArgAttr>()) FD->addAttr(::new (Context) FormatArgAttr(FD->getLocation(), Context, 1)); } } TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo) { assert(D.getIdentifier() && "Wrong callback for declspec without declarator"); assert(!T.isNull() && "GetTypeForDeclarator() returned null type"); if (!TInfo) { assert(D.isInvalidType() && "no declarator info for valid type"); TInfo = Context.getTrivialTypeSourceInfo(T); } // Scope manipulation handled by caller. TypedefDecl *NewTD = TypedefDecl::Create(Context, CurContext, D.getLocStart(), D.getIdentifierLoc(), D.getIdentifier(), TInfo); // Bail out immediately if we have an invalid declaration. if (D.isInvalidType()) { NewTD->setInvalidDecl(); return NewTD; } if (D.getDeclSpec().isModulePrivateSpecified()) { if (CurContext->isFunctionOrMethod()) Diag(NewTD->getLocation(), diag::err_module_private_local) << 2 << NewTD->getDeclName() << SourceRange(D.getDeclSpec().getModulePrivateSpecLoc()) << FixItHint::CreateRemoval(D.getDeclSpec().getModulePrivateSpecLoc()); else NewTD->setModulePrivate(); } // C++ [dcl.typedef]p8: // If the typedef declaration defines an unnamed class (or // enum), the first typedef-name declared by the declaration // to be that class type (or enum type) is used to denote the // class type (or enum type) for linkage purposes only. // We need to check whether the type was declared in the declaration. switch (D.getDeclSpec().getTypeSpecType()) { case TST_enum: case TST_struct: case TST_interface: case TST_union: case TST_class: { TagDecl *tagFromDeclSpec = cast<TagDecl>(D.getDeclSpec().getRepAsDecl()); // Do nothing if the tag is not anonymous or already has an // associated typedef (from an earlier typedef in this decl group). if (tagFromDeclSpec->getIdentifier()) break; if (tagFromDeclSpec->getTypedefNameForAnonDecl()) break; // A well-formed anonymous tag must always be a TUK_Definition. assert(tagFromDeclSpec->isThisDeclarationADefinition()); // The type must match the tag exactly; no qualifiers allowed. if (!Context.hasSameType(T, Context.getTagDeclType(tagFromDeclSpec))) break; // Otherwise, set this is the anon-decl typedef for the tag. tagFromDeclSpec->setTypedefNameForAnonDecl(NewTD); break; } default: break; } return NewTD; } /// \brief Check that this is a valid underlying type for an enum declaration. bool Sema::CheckEnumUnderlyingType(TypeSourceInfo *TI) { SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc(); QualType T = TI->getType(); if (T->isDependentType()) return false; if (const BuiltinType *BT = T->getAs<BuiltinType>()) if (BT->isInteger()) return false; Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T; return true; } /// Check whether this is a valid redeclaration of a previous enumeration. /// \return true if the redeclaration was invalid. bool Sema::CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, const EnumDecl *Prev) { bool IsFixed = !EnumUnderlyingTy.isNull(); if (IsScoped != Prev->isScoped()) { Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch) << Prev->isScoped(); Diag(Prev->getLocation(), diag::note_previous_use); return true; } if (IsFixed && Prev->isFixed()) { if (!EnumUnderlyingTy->isDependentType() && !Prev->getIntegerType()->isDependentType() && !Context.hasSameUnqualifiedType(EnumUnderlyingTy, Prev->getIntegerType())) { Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch) << EnumUnderlyingTy << Prev->getIntegerType(); Diag(Prev->getLocation(), diag::note_previous_use); return true; } } else if (IsFixed != Prev->isFixed()) { Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch) << Prev->isFixed(); Diag(Prev->getLocation(), diag::note_previous_use); return true; } return false; } /// \brief Get diagnostic %select index for tag kind for /// redeclaration diagnostic message. /// WARNING: Indexes apply to particular diagnostics only! /// /// \returns diagnostic %select index. static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag) { switch (Tag) { case TTK_Struct: return 0; case TTK_Interface: return 1; case TTK_Class: return 2; default: llvm_unreachable("Invalid tag kind for redecl diagnostic!"); } } /// \brief Determine if tag kind is a class-key compatible with /// class for redeclaration (class, struct, or __interface). /// /// \returns true iff the tag kind is compatible. static bool isClassCompatTagKind(TagTypeKind Tag) { return Tag == TTK_Struct || Tag == TTK_Class || Tag == TTK_Interface; } /// \brief Determine whether a tag with a given kind is acceptable /// as a redeclaration of the given tag declaration. /// /// \returns true if the new tag kind is acceptable, false otherwise. bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo &Name) { // C++ [dcl.type.elab]p3: // The class-key or enum keyword present in the // elaborated-type-specifier shall agree in kind with the // declaration to which the name in the elaborated-type-specifier // refers. This rule also applies to the form of // elaborated-type-specifier that declares a class-name or // friend class since it can be construed as referring to the // definition of the class. Thus, in any // elaborated-type-specifier, the enum keyword shall be used to // refer to an enumeration (7.2), the union class-key shall be // used to refer to a union (clause 9), and either the class or // struct class-key shall be used to refer to a class (clause 9) // declared using the class or struct class-key. TagTypeKind OldTag = Previous->getTagKind(); if (!isDefinition || !isClassCompatTagKind(NewTag)) if (OldTag == NewTag) return true; if (isClassCompatTagKind(OldTag) && isClassCompatTagKind(NewTag)) { // Warn about the struct/class tag mismatch. bool isTemplate = false; if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous)) isTemplate = Record->getDescribedClassTemplate(); if (!ActiveTemplateInstantiations.empty()) { // In a template instantiation, do not offer fix-its for tag mismatches // since they usually mess up the template instead of fixing the problem. Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch) << getRedeclDiagFromTagKind(NewTag) << isTemplate << &Name << getRedeclDiagFromTagKind(OldTag); return true; } if (isDefinition) { // On definitions, check previous tags and issue a fix-it for each // one that doesn't match the current tag. if (Previous->getDefinition()) { // Don't suggest fix-its for redefinitions. return true; } bool previousMismatch = false; for (TagDecl::redecl_iterator I(Previous->redecls_begin()), E(Previous->redecls_end()); I != E; ++I) { if (I->getTagKind() != NewTag) { if (!previousMismatch) { previousMismatch = true; Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch) << getRedeclDiagFromTagKind(NewTag) << isTemplate << &Name << getRedeclDiagFromTagKind(I->getTagKind()); } Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion) << getRedeclDiagFromTagKind(NewTag) << FixItHint::CreateReplacement(I->getInnerLocStart(), TypeWithKeyword::getTagTypeKindName(NewTag)); } } return true; } // Check for a previous definition. If current tag and definition // are same type, do nothing. If no definition, but disagree with // with previous tag type, give a warning, but no fix-it. const TagDecl *Redecl = Previous->getDefinition() ? Previous->getDefinition() : Previous; if (Redecl->getTagKind() == NewTag) { return true; } Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch) << getRedeclDiagFromTagKind(NewTag) << isTemplate << &Name << getRedeclDiagFromTagKind(OldTag); Diag(Redecl->getLocation(), diag::note_previous_use); // If there is a previous defintion, suggest a fix-it. if (Previous->getDefinition()) { Diag(NewTagLoc, diag::note_struct_class_suggestion) << getRedeclDiagFromTagKind(Redecl->getTagKind()) << FixItHint::CreateReplacement(SourceRange(NewTagLoc), TypeWithKeyword::getTagTypeKindName(Redecl->getTagKind())); } return true; } return false; } /// ActOnTag - This is invoked when we see 'struct foo' or 'struct {'. In the /// former case, Name will be non-null. In the later case, Name will be null. /// TagSpec indicates what kind of tag this is. TUK indicates whether this is a /// reference/declaration/definition of a tag. Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType) { // If this is not a definition, it must have a name. IdentifierInfo *OrigName = Name; assert((Name != 0 || TUK == TUK_Definition) && "Nameless record must be a definition!"); assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference); OwnedDecl = false; TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec); bool ScopedEnum = ScopedEnumKWLoc.isValid(); // FIXME: Check explicit specializations more carefully. bool isExplicitSpecialization = false; bool Invalid = false; // We only need to do this matching if we have template parameters // or a scope specifier, which also conveniently avoids this work // for non-C++ cases. if (TemplateParameterLists.size() > 0 || (SS.isNotEmpty() && TUK != TUK_Reference)) { if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier(KWLoc, NameLoc, SS, TemplateParameterLists.data(), TemplateParameterLists.size(), TUK == TUK_Friend, isExplicitSpecialization, Invalid)) { if (Kind == TTK_Enum) { Diag(KWLoc, diag::err_enum_template); return 0; } if (TemplateParams->size() > 0) { // This is a declaration or definition of a class template (which may // be a member of another template). if (Invalid) return 0; OwnedDecl = false; DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attr, TemplateParams, AS, ModulePrivateLoc, TemplateParameterLists.size()-1, TemplateParameterLists.data()); return Result.get(); } else { // The "template<>" header is extraneous. Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams) << TypeWithKeyword::getTagTypeKindName(Kind) << Name; isExplicitSpecialization = true; } } } // Figure out the underlying type if this a enum declaration. We need to do // this early, because it's needed to detect if this is an incompatible // redeclaration. llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying; if (Kind == TTK_Enum) { if (UnderlyingType.isInvalid() || (!UnderlyingType.get() && ScopedEnum)) // No underlying type explicitly specified, or we failed to parse the // type, default to int. EnumUnderlying = Context.IntTy.getTypePtr(); else if (UnderlyingType.get()) { // C++0x 7.2p2: The type-specifier-seq of an enum-base shall name an // integral type; any cv-qualification is ignored. TypeSourceInfo *TI = 0; GetTypeFromParser(UnderlyingType.get(), &TI); EnumUnderlying = TI; if (CheckEnumUnderlyingType(TI)) // Recover by falling back to int. EnumUnderlying = Context.IntTy.getTypePtr(); if (DiagnoseUnexpandedParameterPack(TI->getTypeLoc().getBeginLoc(), TI, UPPC_FixedUnderlyingType)) EnumUnderlying = Context.IntTy.getTypePtr(); } else if (getLangOpts().MicrosoftMode) // Microsoft enums are always of int type. EnumUnderlying = Context.IntTy.getTypePtr(); } DeclContext *SearchDC = CurContext; DeclContext *DC = CurContext; bool isStdBadAlloc = false; RedeclarationKind Redecl = ForRedeclaration; if (TUK == TUK_Friend || TUK == TUK_Reference) Redecl = NotForRedeclaration; LookupResult Previous(*this, Name, NameLoc, LookupTagName, Redecl); if (Name && SS.isNotEmpty()) { // We have a nested-name tag ('struct foo::bar'). // Check for invalid 'foo::'. if (SS.isInvalid()) { Name = 0; goto CreateNewDecl; } // If this is a friend or a reference to a class in a dependent // context, don't try to make a decl for it. if (TUK == TUK_Friend || TUK == TUK_Reference) { DC = computeDeclContext(SS, false); if (!DC) { IsDependent = true; return 0; } } else { DC = computeDeclContext(SS, true); if (!DC) { Diag(SS.getRange().getBegin(), diag::err_dependent_nested_name_spec) << SS.getRange(); return 0; } } if (RequireCompleteDeclContext(SS, DC)) return 0; SearchDC = DC; // Look-up name inside 'foo::'. LookupQualifiedName(Previous, DC); if (Previous.isAmbiguous()) return 0; if (Previous.empty()) { // Name lookup did not find anything. However, if the // nested-name-specifier refers to the current instantiation, // and that current instantiation has any dependent base // classes, we might find something at instantiation time: treat // this as a dependent elaborated-type-specifier. // But this only makes any sense for reference-like lookups. if (Previous.wasNotFoundInCurrentInstantiation() && (TUK == TUK_Reference || TUK == TUK_Friend)) { IsDependent = true; return 0; } // A tag 'foo::bar' must already exist. Diag(NameLoc, diag::err_not_tag_in_scope) << Kind << Name << DC << SS.getRange(); Name = 0; Invalid = true; goto CreateNewDecl; } } else if (Name) { // If this is a named struct, check to see if there was a previous forward // declaration or definition. // FIXME: We're looking into outer scopes here, even when we // shouldn't be. Doing so can result in ambiguities that we // shouldn't be diagnosing. LookupName(Previous, S); // When declaring or defining a tag, ignore ambiguities introduced // by types using'ed into this scope. if (Previous.isAmbiguous() && (TUK == TUK_Definition || TUK == TUK_Declaration)) { LookupResult::Filter F = Previous.makeFilter(); while (F.hasNext()) { NamedDecl *ND = F.next(); if (ND->getDeclContext()->getRedeclContext() != SearchDC) F.erase(); } F.done(); } // C++11 [namespace.memdef]p3: // If the name in a friend declaration is neither qualified nor // a template-id and the declaration is a function or an // elaborated-type-specifier, the lookup to determine whether // the entity has been previously declared shall not consider // any scopes outside the innermost enclosing namespace. // // Does it matter that this should be by scope instead of by // semantic context? if (!Previous.empty() && TUK == TUK_Friend) { DeclContext *EnclosingNS = SearchDC->getEnclosingNamespaceContext(); LookupResult::Filter F = Previous.makeFilter(); while (F.hasNext()) { NamedDecl *ND = F.next(); DeclContext *DC = ND->getDeclContext()->getRedeclContext(); if (DC->isFileContext() && !EnclosingNS->Encloses(ND->getDeclContext())) F.erase(); } F.done(); } // Note: there used to be some attempt at recovery here. if (Previous.isAmbiguous()) return 0; if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) { // FIXME: This makes sure that we ignore the contexts associated // with C structs, unions, and enums when looking for a matching // tag declaration or definition. See the similar lookup tweak // in Sema::LookupName; is there a better way to deal with this? while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC)) SearchDC = SearchDC->getParent(); } } else if (S->isFunctionPrototypeScope()) { // If this is an enum declaration in function prototype scope, set its // initial context to the translation unit. // FIXME: [citation needed] SearchDC = Context.getTranslationUnitDecl(); } if (Previous.isSingleResult() && Previous.getFoundDecl()->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(NameLoc, Previous.getFoundDecl()); // Just pretend that we didn't see the previous declaration. Previous.clear(); } if (getLangOpts().CPlusPlus && Name && DC && StdNamespace && DC->Equals(getStdNamespace()) && Name->isStr("bad_alloc")) { // This is a declaration of or a reference to "std::bad_alloc". isStdBadAlloc = true; if (Previous.empty() && StdBadAlloc) { // std::bad_alloc has been implicitly declared (but made invisible to // name lookup). Fill in this implicit declaration as the previous // declaration, so that the declarations get chained appropriately. Previous.addDecl(getStdBadAlloc()); } } // If we didn't find a previous declaration, and this is a reference // (or friend reference), move to the correct scope. In C++, we // also need to do a redeclaration lookup there, just in case // there's a shadow friend decl. if (Name && Previous.empty() && (TUK == TUK_Reference || TUK == TUK_Friend)) { if (Invalid) goto CreateNewDecl; assert(SS.isEmpty()); if (TUK == TUK_Reference) { // C++ [basic.scope.pdecl]p5: // -- for an elaborated-type-specifier of the form // // class-key identifier // // if the elaborated-type-specifier is used in the // decl-specifier-seq or parameter-declaration-clause of a // function defined in namespace scope, the identifier is // declared as a class-name in the namespace that contains // the declaration; otherwise, except as a friend // declaration, the identifier is declared in the smallest // non-class, non-function-prototype scope that contains the // declaration. // // C99 6.7.2.3p8 has a similar (but not identical!) provision for // C structs and unions. // // It is an error in C++ to declare (rather than define) an enum // type, including via an elaborated type specifier. We'll // diagnose that later; for now, declare the enum in the same // scope as we would have picked for any other tag type. // // GNU C also supports this behavior as part of its incomplete // enum types extension, while GNU C++ does not. // // Find the context where we'll be declaring the tag. // FIXME: We would like to maintain the current DeclContext as the // lexical context, while (!SearchDC->isFileContext() && !SearchDC->isFunctionOrMethod()) SearchDC = SearchDC->getParent(); // Find the scope where we'll be declaring the tag. while (S->isClassScope() || (getLangOpts().CPlusPlus && S->isFunctionPrototypeScope()) || ((S->getFlags() & Scope::DeclScope) == 0) || (S->getEntity() && ((DeclContext *)S->getEntity())->isTransparentContext())) S = S->getParent(); } else { assert(TUK == TUK_Friend); // C++ [namespace.memdef]p3: // If a friend declaration in a non-local class first declares a // class or function, the friend class or function is a member of // the innermost enclosing namespace. SearchDC = SearchDC->getEnclosingNamespaceContext(); } // In C++, we need to do a redeclaration lookup to properly // diagnose some problems. if (getLangOpts().CPlusPlus) { Previous.setRedeclarationKind(ForRedeclaration); LookupQualifiedName(Previous, SearchDC); } } if (!Previous.empty()) { NamedDecl *PrevDecl = (*Previous.begin())->getUnderlyingDecl(); // It's okay to have a tag decl in the same scope as a typedef // which hides a tag decl in the same scope. Finding this // insanity with a redeclaration lookup can only actually happen // in C++. // // This is also okay for elaborated-type-specifiers, which is // technically forbidden by the current standard but which is // okay according to the likely resolution of an open issue; // see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#407 if (getLangOpts().CPlusPlus) { if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(PrevDecl)) { if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) { TagDecl *Tag = TT->getDecl(); if (Tag->getDeclName() == Name && Tag->getDeclContext()->getRedeclContext() ->Equals(TD->getDeclContext()->getRedeclContext())) { PrevDecl = Tag; Previous.clear(); Previous.addDecl(Tag); Previous.resolveKind(); } } } } if (TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) { // If this is a use of a previous tag, or if the tag is already declared // in the same scope (so that the definition/declaration completes or // rementions the tag), reuse the decl. if (TUK == TUK_Reference || TUK == TUK_Friend || isDeclInScope(PrevDecl, SearchDC, S, isExplicitSpecialization)) { // Make sure that this wasn't declared as an enum and now used as a // struct or something similar. if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind, TUK == TUK_Definition, KWLoc, *Name)) { bool SafeToContinue = (PrevTagDecl->getTagKind() != TTK_Enum && Kind != TTK_Enum); if (SafeToContinue) Diag(KWLoc, diag::err_use_with_wrong_tag) << Name << FixItHint::CreateReplacement(SourceRange(KWLoc), PrevTagDecl->getKindName()); else Diag(KWLoc, diag::err_use_with_wrong_tag) << Name; Diag(PrevTagDecl->getLocation(), diag::note_previous_use); if (SafeToContinue) Kind = PrevTagDecl->getTagKind(); else { // Recover by making this an anonymous redefinition. Name = 0; Previous.clear(); Invalid = true; } } if (Kind == TTK_Enum && PrevTagDecl->getTagKind() == TTK_Enum) { const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl); // If this is an elaborated-type-specifier for a scoped enumeration, // the 'class' keyword is not necessary and not permitted. if (TUK == TUK_Reference || TUK == TUK_Friend) { if (ScopedEnum) Diag(ScopedEnumKWLoc, diag::err_enum_class_reference) << PrevEnum->isScoped() << FixItHint::CreateRemoval(ScopedEnumKWLoc); return PrevTagDecl; } QualType EnumUnderlyingTy; if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast<TypeSourceInfo*>()) EnumUnderlyingTy = TI->getType(); else if (const Type *T = EnumUnderlying.dyn_cast<const Type*>()) EnumUnderlyingTy = QualType(T, 0); // All conflicts with previous declarations are recovered by // returning the previous declaration, unless this is a definition, // in which case we want the caller to bail out. if (CheckEnumRedeclaration(NameLoc.isValid() ? NameLoc : KWLoc, ScopedEnum, EnumUnderlyingTy, PrevEnum)) return TUK == TUK_Declaration ? PrevTagDecl : 0; } if (!Invalid) { // If this is a use, just return the declaration we found. // FIXME: In the future, return a variant or some other clue // for the consumer of this Decl to know it doesn't own it. // For our current ASTs this shouldn't be a problem, but will // need to be changed with DeclGroups. if ((TUK == TUK_Reference && (!PrevTagDecl->getFriendObjectKind() || getLangOpts().MicrosoftExt)) || TUK == TUK_Friend) return PrevTagDecl; // Diagnose attempts to redefine a tag. if (TUK == TUK_Definition) { if (TagDecl *Def = PrevTagDecl->getDefinition()) { // If we're defining a specialization and the previous definition // is from an implicit instantiation, don't emit an error // here; we'll catch this in the general case below. bool IsExplicitSpecializationAfterInstantiation = false; if (isExplicitSpecialization) { if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Def)) IsExplicitSpecializationAfterInstantiation = RD->getTemplateSpecializationKind() != TSK_ExplicitSpecialization; else if (EnumDecl *ED = dyn_cast<EnumDecl>(Def)) IsExplicitSpecializationAfterInstantiation = ED->getTemplateSpecializationKind() != TSK_ExplicitSpecialization; } if (!IsExplicitSpecializationAfterInstantiation) { // A redeclaration in function prototype scope in C isn't // visible elsewhere, so merely issue a warning. if (!getLangOpts().CPlusPlus && S->containedInPrototypeScope()) Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name; else Diag(NameLoc, diag::err_redefinition) << Name; Diag(Def->getLocation(), diag::note_previous_definition); // If this is a redefinition, recover by making this // struct be anonymous, which will make any later // references get the previous definition. Name = 0; Previous.clear(); Invalid = true; } } else { // If the type is currently being defined, complain // about a nested redefinition. const TagType *Tag = cast<TagType>(Context.getTagDeclType(PrevTagDecl)); if (Tag->isBeingDefined()) { Diag(NameLoc, diag::err_nested_redefinition) << Name; Diag(PrevTagDecl->getLocation(), diag::note_previous_definition); Name = 0; Previous.clear(); Invalid = true; } } // Okay, this is definition of a previously declared or referenced // tag PrevDecl. We're going to create a new Decl for it. } } // If we get here we have (another) forward declaration or we // have a definition. Just create a new decl. } else { // If we get here, this is a definition of a new tag type in a nested // scope, e.g. "struct foo; void bar() { struct foo; }", just create a // new decl/type. We set PrevDecl to NULL so that the entities // have distinct types. Previous.clear(); } // If we get here, we're going to create a new Decl. If PrevDecl // is non-NULL, it's a definition of the tag declared by // PrevDecl. If it's NULL, we have a new definition. // Otherwise, PrevDecl is not a tag, but was found with tag // lookup. This is only actually possible in C++, where a few // things like templates still live in the tag namespace. } else { // Use a better diagnostic if an elaborated-type-specifier // found the wrong kind of type on the first // (non-redeclaration) lookup. if ((TUK == TUK_Reference || TUK == TUK_Friend) && !Previous.isForRedeclaration()) { unsigned Kind = 0; if (isa<TypedefDecl>(PrevDecl)) Kind = 1; else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2; else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3; Diag(NameLoc, diag::err_tag_reference_non_tag) << Kind; Diag(PrevDecl->getLocation(), diag::note_declared_at); Invalid = true; // Otherwise, only diagnose if the declaration is in scope. } else if (!isDeclInScope(PrevDecl, SearchDC, S, isExplicitSpecialization)) { // do nothing // Diagnose implicit declarations introduced by elaborated types. } else if (TUK == TUK_Reference || TUK == TUK_Friend) { unsigned Kind = 0; if (isa<TypedefDecl>(PrevDecl)) Kind = 1; else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2; else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3; Diag(NameLoc, diag::err_tag_reference_conflict) << Kind; Diag(PrevDecl->getLocation(), diag::note_previous_decl) << PrevDecl; Invalid = true; // Otherwise it's a declaration. Call out a particularly common // case here. } else if (TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) { unsigned Kind = 0; if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1; Diag(NameLoc, diag::err_tag_definition_of_typedef) << Name << Kind << TND->getUnderlyingType(); Diag(PrevDecl->getLocation(), diag::note_previous_decl) << PrevDecl; Invalid = true; // Otherwise, diagnose. } else { // The tag name clashes with something else in the target scope, // issue an error and recover by making this tag be anonymous. Diag(NameLoc, diag::err_redefinition_different_kind) << Name; Diag(PrevDecl->getLocation(), diag::note_previous_definition); Name = 0; Invalid = true; } // The existing declaration isn't relevant to us; we're in a // new scope, so clear out the previous declaration. Previous.clear(); } } CreateNewDecl: TagDecl *PrevDecl = 0; if (Previous.isSingleResult()) PrevDecl = cast<TagDecl>(Previous.getFoundDecl()); // If there is an identifier, use the location of the identifier as the // location of the decl, otherwise use the location of the struct/union // keyword. SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc; // Otherwise, create a new declaration. If there is a previous // declaration of the same entity, the two will be linked via // PrevDecl. TagDecl *New; bool IsForwardReference = false; if (Kind == TTK_Enum) { // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.: // enum X { A, B, C } D; D should chain to X. New = EnumDecl::Create(Context, SearchDC, KWLoc, Loc, Name, cast_or_null<EnumDecl>(PrevDecl), ScopedEnum, ScopedEnumUsesClassTag, !EnumUnderlying.isNull()); // If this is an undefined enum, warn. if (TUK != TUK_Definition && !Invalid) { TagDecl *Def; if ((getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) && cast<EnumDecl>(New)->isFixed()) { // C++0x: 7.2p2: opaque-enum-declaration. // Conflicts are diagnosed above. Do nothing. } else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->getDefinition())) { Diag(Loc, diag::ext_forward_ref_enum_def) << New; Diag(Def->getLocation(), diag::note_previous_definition); } else { unsigned DiagID = diag::ext_forward_ref_enum; if (getLangOpts().MicrosoftMode) DiagID = diag::ext_ms_forward_ref_enum; else if (getLangOpts().CPlusPlus) DiagID = diag::err_forward_ref_enum; Diag(Loc, DiagID); // If this is a forward-declared reference to an enumeration, make a // note of it; we won't actually be introducing the declaration into // the declaration context. if (TUK == TUK_Reference) IsForwardReference = true; } } if (EnumUnderlying) { EnumDecl *ED = cast<EnumDecl>(New); if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast<TypeSourceInfo*>()) ED->setIntegerTypeSourceInfo(TI); else ED->setIntegerType(QualType(EnumUnderlying.get<const Type*>(), 0)); ED->setPromotionType(ED->getIntegerType()); } } else { // struct/union/class // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.: // struct X { int A; } D; D should chain to X. if (getLangOpts().CPlusPlus) { // FIXME: Look for a way to use RecordDecl for simple structs. New = CXXRecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name, cast_or_null<CXXRecordDecl>(PrevDecl)); if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit())) StdBadAlloc = cast<CXXRecordDecl>(New); } else New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name, cast_or_null<RecordDecl>(PrevDecl)); } // Maybe add qualifier info. if (SS.isNotEmpty()) { if (SS.isSet()) { // If this is either a declaration or a definition, check the // nested-name-specifier against the current context. We don't do this // for explicit specializations, because they have similar checking // (with more specific diagnostics) in the call to // CheckMemberSpecialization, below. if (!isExplicitSpecialization && (TUK == TUK_Definition || TUK == TUK_Declaration) && diagnoseQualifiedDeclaration(SS, DC, OrigName, NameLoc)) Invalid = true; New->setQualifierInfo(SS.getWithLocInContext(Context)); if (TemplateParameterLists.size() > 0) { New->setTemplateParameterListsInfo(Context, TemplateParameterLists.size(), TemplateParameterLists.data()); } } else Invalid = true; } if (RecordDecl *RD = dyn_cast<RecordDecl>(New)) { // Add alignment attributes if necessary; these attributes are checked when // the ASTContext lays out the structure. // // It is important for implementing the correct semantics that this // happen here (in act on tag decl). The #pragma pack stack is // maintained as a result of parser callbacks which can occur at // many points during the parsing of a struct declaration (because // the #pragma tokens are effectively skipped over during the // parsing of the struct). if (TUK == TUK_Definition) { AddAlignmentAttributesForRecord(RD); AddMsStructLayoutForRecord(RD); } } if (ModulePrivateLoc.isValid()) { if (isExplicitSpecialization) Diag(New->getLocation(), diag::err_module_private_specialization) << 2 << FixItHint::CreateRemoval(ModulePrivateLoc); // __module_private__ does not apply to local classes. However, we only // diagnose this as an error when the declaration specifiers are // freestanding. Here, we just ignore the __module_private__. else if (!SearchDC->isFunctionOrMethod()) New->setModulePrivate(); } // If this is a specialization of a member class (of a class template), // check the specialization. if (isExplicitSpecialization && CheckMemberSpecialization(New, Previous)) Invalid = true; if (Invalid) New->setInvalidDecl(); if (Attr) ProcessDeclAttributeList(S, New, Attr); // If we're declaring or defining a tag in function prototype scope // in C, note that this type can only be used within the function. if (Name && S->isFunctionPrototypeScope() && !getLangOpts().CPlusPlus) Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New); // Set the lexical context. If the tag has a C++ scope specifier, the // lexical context will be different from the semantic context. New->setLexicalDeclContext(CurContext); // Mark this as a friend decl if applicable. // In Microsoft mode, a friend declaration also acts as a forward // declaration so we always pass true to setObjectOfFriendDecl to make // the tag name visible. if (TUK == TUK_Friend) New->setObjectOfFriendDecl(/* PreviouslyDeclared = */ !Previous.empty() || getLangOpts().MicrosoftExt); // Set the access specifier. if (!Invalid && SearchDC->isRecord()) SetMemberAccessSpecifier(New, PrevDecl, AS); if (TUK == TUK_Definition) New->startDefinition(); // If this has an identifier, add it to the scope stack. if (TUK == TUK_Friend) { // We might be replacing an existing declaration in the lookup tables; // if so, borrow its access specifier. if (PrevDecl) New->setAccess(PrevDecl->getAccess()); DeclContext *DC = New->getDeclContext()->getRedeclContext(); DC->makeDeclVisibleInContext(New); if (Name) // can be null along some error paths if (Scope *EnclosingScope = getScopeForDeclContext(S, DC)) PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false); } else if (Name) { S = getNonFieldDeclScope(S); PushOnScopeChains(New, S, !IsForwardReference); if (IsForwardReference) SearchDC->makeDeclVisibleInContext(New); } else { CurContext->addDecl(New); } // If this is the C FILE type, notify the AST context. if (IdentifierInfo *II = New->getIdentifier()) if (!New->isInvalidDecl() && New->getDeclContext()->getRedeclContext()->isTranslationUnit() && II->isStr("FILE")) Context.setFILEDecl(New); // If we were in function prototype scope (and not in C++ mode), add this // tag to the list of decls to inject into the function definition scope. if (S->isFunctionPrototypeScope() && !getLangOpts().CPlusPlus && InFunctionDeclarator && Name) DeclsInPrototypeScope.push_back(New); if (PrevDecl) mergeDeclAttributes(New, PrevDecl); // If there's a #pragma GCC visibility in scope, set the visibility of this // record. AddPushedVisibilityAttribute(New); OwnedDecl = true; // In C++, don't return an invalid declaration. We can't recover well from // the cases where we make the type anonymous. return (Invalid && getLangOpts().CPlusPlus) ? 0 : New; } void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) { AdjustDeclIfTemplate(TagD); TagDecl *Tag = cast<TagDecl>(TagD); // Enter the tag context. PushDeclContext(S, Tag); ActOnDocumentableDecl(TagD); // If there's a #pragma GCC visibility in scope, set the visibility of this // record. AddPushedVisibilityAttribute(Tag); } Decl *Sema::ActOnObjCContainerStartDefinition(Decl *IDecl) { assert(isa<ObjCContainerDecl>(IDecl) && "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl"); DeclContext *OCD = cast<DeclContext>(IDecl); assert(getContainingDC(OCD) == CurContext && "The next DeclContext should be lexically contained in the current one."); CurContext = OCD; return IDecl; } void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD, SourceLocation FinalLoc, SourceLocation LBraceLoc) { AdjustDeclIfTemplate(TagD); CXXRecordDecl *Record = cast<CXXRecordDecl>(TagD); FieldCollector->StartClass(); if (!Record->getIdentifier()) return; if (FinalLoc.isValid()) Record->addAttr(new (Context) FinalAttr(FinalLoc, Context)); // C++ [class]p2: // [...] The class-name is also inserted into the scope of the // class itself; this is known as the injected-class-name. For // purposes of access checking, the injected-class-name is treated // as if it were a public member name. CXXRecordDecl *InjectedClassName = CXXRecordDecl::Create(Context, Record->getTagKind(), CurContext, Record->getLocStart(), Record->getLocation(), Record->getIdentifier(), /*PrevDecl=*/0, /*DelayTypeCreation=*/true); Context.getTypeDeclType(InjectedClassName, Record); InjectedClassName->setImplicit(); InjectedClassName->setAccess(AS_public); if (ClassTemplateDecl *Template = Record->getDescribedClassTemplate()) InjectedClassName->setDescribedClassTemplate(Template); PushOnScopeChains(InjectedClassName, S); assert(InjectedClassName->isInjectedClassName() && "Broken injected-class-name"); } void Sema::ActOnTagFinishDefinition(Scope *S, Decl *TagD, SourceLocation RBraceLoc) { AdjustDeclIfTemplate(TagD); TagDecl *Tag = cast<TagDecl>(TagD); Tag->setRBraceLoc(RBraceLoc); // Make sure we "complete" the definition even it is invalid. if (Tag->isBeingDefined()) { assert(Tag->isInvalidDecl() && "We should already have completed it"); if (RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) RD->completeDefinition(); } if (isa<CXXRecordDecl>(Tag)) FieldCollector->FinishClass(); // Exit this scope of this tag's definition. PopDeclContext(); if (getCurLexicalContext()->isObjCContainer() && Tag->getDeclContext()->isFileContext()) Tag->setTopLevelDeclInObjCContainer(); // Notify the consumer that we've defined a tag. Consumer.HandleTagDeclDefinition(Tag); } void Sema::ActOnObjCContainerFinishDefinition() { // Exit this scope of this interface definition. PopDeclContext(); } void Sema::ActOnObjCTemporaryExitContainerContext(DeclContext *DC) { assert(DC == CurContext && "Mismatch of container contexts"); OriginalLexicalContext = DC; ActOnObjCContainerFinishDefinition(); } void Sema::ActOnObjCReenterContainerContext(DeclContext *DC) { ActOnObjCContainerStartDefinition(cast<Decl>(DC)); OriginalLexicalContext = 0; } void Sema::ActOnTagDefinitionError(Scope *S, Decl *TagD) { AdjustDeclIfTemplate(TagD); TagDecl *Tag = cast<TagDecl>(TagD); Tag->setInvalidDecl(); // Make sure we "complete" the definition even it is invalid. if (Tag->isBeingDefined()) { if (RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) RD->completeDefinition(); } // We're undoing ActOnTagStartDefinition here, not // ActOnStartCXXMemberDeclarations, so we don't have to mess with // the FieldCollector. PopDeclContext(); } // Note that FieldName may be null for anonymous bitfields. ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, Expr *BitWidth, bool *ZeroWidth) { // Default to true; that shouldn't confuse checks for emptiness if (ZeroWidth) *ZeroWidth = true; // C99 6.7.2.1p4 - verify the field type. // C++ 9.6p3: A bit-field shall have integral or enumeration type. if (!FieldTy->isDependentType() && !FieldTy->isIntegralOrEnumerationType()) { // Handle incomplete types with specific error. if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete)) return ExprError(); if (FieldName) return Diag(FieldLoc, diag::err_not_integral_type_bitfield) << FieldName << FieldTy << BitWidth->getSourceRange(); return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield) << FieldTy << BitWidth->getSourceRange(); } else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth), UPPC_BitFieldWidth)) return ExprError(); // If the bit-width is type- or value-dependent, don't try to check // it now. if (BitWidth->isValueDependent() || BitWidth->isTypeDependent()) return Owned(BitWidth); llvm::APSInt Value; ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value); if (ICE.isInvalid()) return ICE; BitWidth = ICE.take(); if (Value != 0 && ZeroWidth) *ZeroWidth = false; // Zero-width bitfield is ok for anonymous field. if (Value == 0 && FieldName) return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName; if (Value.isSigned() && Value.isNegative()) { if (FieldName) return Diag(FieldLoc, diag::err_bitfield_has_negative_width) << FieldName << Value.toString(10); return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width) << Value.toString(10); } if (!FieldTy->isDependentType()) { uint64_t TypeSize = Context.getTypeSize(FieldTy); if (Value.getZExtValue() > TypeSize) { if (!getLangOpts().CPlusPlus) { if (FieldName) return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_size) << FieldName << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_size) << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; } if (FieldName) Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_size) << FieldName << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; else Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_size) << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; } } return Owned(BitWidth); } /// ActOnField - Each field of a C struct/union is passed into this in order /// to create a FieldDecl object for it. Decl *Sema::ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth) { FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD), DeclStart, D, static_cast<Expr*>(BitfieldWidth), /*InitStyle=*/ICIS_NoInit, AS_public); return Res; } /// HandleField - Analyze a field of a C struct or a C++ data member. /// FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, SourceLocation DeclStart, Declarator &D, Expr *BitWidth, InClassInitStyle InitStyle, AccessSpecifier AS) { IdentifierInfo *II = D.getIdentifier(); SourceLocation Loc = DeclStart; if (II) Loc = D.getIdentifierLoc(); TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType T = TInfo->getType(); if (getLangOpts().CPlusPlus) { CheckExtraCXXDefaultArguments(D); if (DiagnoseUnexpandedParameterPack(D.getIdentifierLoc(), TInfo, UPPC_DataMemberType)) { D.setInvalidType(); T = Context.IntTy; TInfo = Context.getTrivialTypeSourceInfo(T, Loc); } } // TR 18037 does not allow fields to be declared with address spaces. if (T.getQualifiers().hasAddressSpace()) { Diag(Loc, diag::err_field_with_address_space); D.setInvalidType(); } // OpenCL 1.2 spec, s6.9 r: // The event type cannot be used to declare a structure or union field. if (LangOpts.OpenCL && T->isEventT()) { Diag(Loc, diag::err_event_t_struct_field); D.setInvalidType(); } DiagnoseFunctionSpecifiers(D.getDeclSpec()); if (DeclSpec::TSCS TSCS = D.getDeclSpec().getThreadStorageClassSpec()) Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_invalid_thread) << DeclSpec::getSpecifierName(TSCS); // Check to see if this name was declared as a member previously NamedDecl *PrevDecl = 0; LookupResult Previous(*this, II, Loc, LookupMemberName, ForRedeclaration); LookupName(Previous, S); switch (Previous.getResultKind()) { case LookupResult::Found: case LookupResult::FoundUnresolvedValue: PrevDecl = Previous.getAsSingle<NamedDecl>(); break; case LookupResult::FoundOverloaded: PrevDecl = Previous.getRepresentativeDecl(); break; case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: case LookupResult::Ambiguous: break; } Previous.suppressDiagnostics(); if (PrevDecl && PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. PrevDecl = 0; } if (PrevDecl && !isDeclInScope(PrevDecl, Record, S)) PrevDecl = 0; bool Mutable = (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable); SourceLocation TSSL = D.getLocStart(); FieldDecl *NewFD = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle, TSSL, AS, PrevDecl, &D); if (NewFD->isInvalidDecl()) Record->setInvalidDecl(); if (D.getDeclSpec().isModulePrivateSpecified()) NewFD->setModulePrivate(); if (NewFD->isInvalidDecl() && PrevDecl) { // Don't introduce NewFD into scope; there's already something // with the same name in the same scope. } else if (II) { PushOnScopeChains(NewFD, S); } else Record->addDecl(NewFD); return NewFD; } /// \brief Build a new FieldDecl and check its well-formedness. /// /// This routine builds a new FieldDecl given the fields name, type, /// record, etc. \p PrevDecl should refer to any previous declaration /// with the same name and in the same scope as the field to be /// created. /// /// \returns a new FieldDecl. /// /// \todo The Declarator argument is a hack. It will be removed once FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D) { IdentifierInfo *II = Name.getAsIdentifierInfo(); bool InvalidDecl = false; if (D) InvalidDecl = D->isInvalidType(); // If we receive a broken type, recover by assuming 'int' and // marking this declaration as invalid. if (T.isNull()) { InvalidDecl = true; T = Context.IntTy; } QualType EltTy = Context.getBaseElementType(T); if (!EltTy->isDependentType()) { if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) { // Fields of incomplete type force their record to be invalid. Record->setInvalidDecl(); InvalidDecl = true; } else { NamedDecl *Def; EltTy->isIncompleteType(&Def); if (Def && Def->isInvalidDecl()) { Record->setInvalidDecl(); InvalidDecl = true; } } } // OpenCL v1.2 s6.9.c: bitfields are not supported. if (BitWidth && getLangOpts().OpenCL) { Diag(Loc, diag::err_opencl_bitfields); InvalidDecl = true; } // C99 6.7.2.1p8: A member of a structure or union may have any type other // than a variably modified type. if (!InvalidDecl && T->isVariablyModifiedType()) { bool SizeIsNegative; llvm::APSInt Oversized; TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, SizeIsNegative, Oversized); if (FixedTInfo) { Diag(Loc, diag::warn_illegal_constant_array_size); TInfo = FixedTInfo; T = FixedTInfo->getType(); } else { if (SizeIsNegative) Diag(Loc, diag::err_typecheck_negative_array_size); else if (Oversized.getBoolValue()) Diag(Loc, diag::err_array_too_large) << Oversized.toString(10); else Diag(Loc, diag::err_typecheck_field_variable_size); InvalidDecl = true; } } // Fields can not have abstract class types if (!InvalidDecl && RequireNonAbstractType(Loc, T, diag::err_abstract_type_in_decl, AbstractFieldType)) InvalidDecl = true; bool ZeroWidth = false; // If this is declared as a bit-field, check the bit-field. if (!InvalidDecl && BitWidth) { BitWidth = VerifyBitField(Loc, II, T, BitWidth, &ZeroWidth).take(); if (!BitWidth) { InvalidDecl = true; BitWidth = 0; ZeroWidth = false; } } // Check that 'mutable' is consistent with the type of the declaration. if (!InvalidDecl && Mutable) { unsigned DiagID = 0; if (T->isReferenceType()) DiagID = diag::err_mutable_reference; else if (T.isConstQualified()) DiagID = diag::err_mutable_const; if (DiagID) { SourceLocation ErrLoc = Loc; if (D && D->getDeclSpec().getStorageClassSpecLoc().isValid()) ErrLoc = D->getDeclSpec().getStorageClassSpecLoc(); Diag(ErrLoc, DiagID); Mutable = false; InvalidDecl = true; } } FieldDecl *NewFD = FieldDecl::Create(Context, Record, TSSL, Loc, II, T, TInfo, BitWidth, Mutable, InitStyle); if (InvalidDecl) NewFD->setInvalidDecl(); if (PrevDecl && !isa<TagDecl>(PrevDecl)) { Diag(Loc, diag::err_duplicate_member) << II; Diag(PrevDecl->getLocation(), diag::note_previous_declaration); NewFD->setInvalidDecl(); } if (!InvalidDecl && getLangOpts().CPlusPlus) { if (Record->isUnion()) { if (const RecordType *RT = EltTy->getAs<RecordType>()) { CXXRecordDecl* RDecl = cast<CXXRecordDecl>(RT->getDecl()); if (RDecl->getDefinition()) { // C++ [class.union]p1: An object of a class with a non-trivial // constructor, a non-trivial copy constructor, a non-trivial // destructor, or a non-trivial copy assignment operator // cannot be a member of a union, nor can an array of such // objects. if (CheckNontrivialField(NewFD)) NewFD->setInvalidDecl(); } } // C++ [class.union]p1: If a union contains a member of reference type, // the program is ill-formed. if (EltTy->isReferenceType()) { Diag(NewFD->getLocation(), diag::err_union_member_of_reference_type) << NewFD->getDeclName() << EltTy; NewFD->setInvalidDecl(); } } } // FIXME: We need to pass in the attributes given an AST // representation, not a parser representation. if (D) { // FIXME: The current scope is almost... but not entirely... correct here. ProcessDeclAttributes(getCurScope(), NewFD, *D); if (NewFD->hasAttrs()) CheckAlignasUnderalignment(NewFD); } // In auto-retain/release, infer strong retension for fields of // retainable type. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD)) NewFD->setInvalidDecl(); if (T.isObjCGCWeak()) Diag(Loc, diag::warn_attribute_weak_on_field); NewFD->setAccess(AS); return NewFD; } bool Sema::CheckNontrivialField(FieldDecl *FD) { assert(FD); assert(getLangOpts().CPlusPlus && "valid check only for C++"); if (FD->isInvalidDecl()) return true; QualType EltTy = Context.getBaseElementType(FD->getType()); if (const RecordType *RT = EltTy->getAs<RecordType>()) { CXXRecordDecl *RDecl = cast<CXXRecordDecl>(RT->getDecl()); if (RDecl->getDefinition()) { // We check for copy constructors before constructors // because otherwise we'll never get complaints about // copy constructors. CXXSpecialMember member = CXXInvalid; // We're required to check for any non-trivial constructors. Since the // implicit default constructor is suppressed if there are any // user-declared constructors, we just need to check that there is a // trivial default constructor and a trivial copy constructor. (We don't // worry about move constructors here, since this is a C++98 check.) if (RDecl->hasNonTrivialCopyConstructor()) member = CXXCopyConstructor; else if (!RDecl->hasTrivialDefaultConstructor()) member = CXXDefaultConstructor; else if (RDecl->hasNonTrivialCopyAssignment()) member = CXXCopyAssignment; else if (RDecl->hasNonTrivialDestructor()) member = CXXDestructor; if (member != CXXInvalid) { if (!getLangOpts().CPlusPlus11 && getLangOpts().ObjCAutoRefCount && RDecl->hasObjectMember()) { // Objective-C++ ARC: it is an error to have a non-trivial field of // a union. However, system headers in Objective-C programs // occasionally have Objective-C lifetime objects within unions, // and rather than cause the program to fail, we make those // members unavailable. SourceLocation Loc = FD->getLocation(); if (getSourceManager().isInSystemHeader(Loc)) { if (!FD->hasAttr<UnavailableAttr>()) FD->addAttr(new (Context) UnavailableAttr(Loc, Context, "this system field has retaining ownership")); return false; } } Diag(FD->getLocation(), getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member : diag::err_illegal_union_or_anon_struct_member) << (int)FD->getParent()->isUnion() << FD->getDeclName() << member; DiagnoseNontrivial(RDecl, member); return !getLangOpts().CPlusPlus11; } } } return false; } /// TranslateIvarVisibility - Translate visibility from a token ID to an /// AST enum value. static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility) { switch (ivarVisibility) { default: llvm_unreachable("Unknown visitibility kind"); case tok::objc_private: return ObjCIvarDecl::Private; case tok::objc_public: return ObjCIvarDecl::Public; case tok::objc_protected: return ObjCIvarDecl::Protected; case tok::objc_package: return ObjCIvarDecl::Package; } } /// ActOnIvar - Each ivar field of an objective-c class is passed into this /// in order to create an IvarDecl object for it. Decl *Sema::ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind Visibility) { IdentifierInfo *II = D.getIdentifier(); Expr *BitWidth = (Expr*)BitfieldWidth; SourceLocation Loc = DeclStart; if (II) Loc = D.getIdentifierLoc(); // FIXME: Unnamed fields can be handled in various different ways, for // example, unnamed unions inject all members into the struct namespace! TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType T = TInfo->getType(); if (BitWidth) { // 6.7.2.1p3, 6.7.2.1p4 BitWidth = VerifyBitField(Loc, II, T, BitWidth).take(); if (!BitWidth) D.setInvalidType(); } else { // Not a bitfield. // validate II. } if (T->isReferenceType()) { Diag(Loc, diag::err_ivar_reference_type); D.setInvalidType(); } // C99 6.7.2.1p8: A member of a structure or union may have any type other // than a variably modified type. else if (T->isVariablyModifiedType()) { Diag(Loc, diag::err_typecheck_ivar_variable_size); D.setInvalidType(); } // Get the visibility (access control) for this ivar. ObjCIvarDecl::AccessControl ac = Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility) : ObjCIvarDecl::None; // Must set ivar's DeclContext to its enclosing interface. ObjCContainerDecl *EnclosingDecl = cast<ObjCContainerDecl>(CurContext); if (!EnclosingDecl || EnclosingDecl->isInvalidDecl()) return 0; ObjCContainerDecl *EnclosingContext; if (ObjCImplementationDecl *IMPDecl = dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { if (LangOpts.ObjCRuntime.isFragile()) { // Case of ivar declared in an implementation. Context is that of its class. EnclosingContext = IMPDecl->getClassInterface(); assert(EnclosingContext && "Implementation has no class interface!"); } else EnclosingContext = EnclosingDecl; } else { if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) { if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) { Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension(); return 0; } } EnclosingContext = EnclosingDecl; } // Construct the decl. ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, EnclosingContext, DeclStart, Loc, II, T, TInfo, ac, (Expr *)BitfieldWidth); if (II) { NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName, ForRedeclaration); if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S) && !isa<TagDecl>(PrevDecl)) { Diag(Loc, diag::err_duplicate_member) << II; Diag(PrevDecl->getLocation(), diag::note_previous_declaration); NewID->setInvalidDecl(); } } // Process attributes attached to the ivar. ProcessDeclAttributes(S, NewID, D); if (D.isInvalidType()) NewID->setInvalidDecl(); // In ARC, infer 'retaining' for ivars of retainable type. if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID)) NewID->setInvalidDecl(); if (D.getDeclSpec().isModulePrivateSpecified()) NewID->setModulePrivate(); if (II) { // FIXME: When interfaces are DeclContexts, we'll need to add // these to the interface. S->AddDecl(NewID); IdResolver.AddDecl(NewID); } if (LangOpts.ObjCRuntime.isNonFragile() && !NewID->isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl)) Diag(Loc, diag::warn_ivars_in_interface); return NewID; } /// ActOnLastBitfield - This routine handles synthesized bitfields rules for /// class and class extensions. For every class \@interface and class /// extension \@interface, if the last ivar is a bitfield of any type, /// then add an implicit `char :0` ivar to the end of that interface. void Sema::ActOnLastBitfield(SourceLocation DeclLoc, SmallVectorImpl<Decl *> &AllIvarDecls) { if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty()) return; Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1]; ObjCIvarDecl *Ivar = cast<ObjCIvarDecl>(ivarDecl); if (!Ivar->isBitField() || Ivar->getBitWidthValue(Context) == 0) return; ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(CurContext); if (!ID) { if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CurContext)) { if (!CD->IsClassExtension()) return; } // No need to add this to end of @implementation. else return; } // All conditions are met. Add a new bitfield to the tail end of ivars. llvm::APInt Zero(Context.getTypeSize(Context.IntTy), 0); Expr * BW = IntegerLiteral::Create(Context, Zero, Context.IntTy, DeclLoc); Ivar = ObjCIvarDecl::Create(Context, cast<ObjCContainerDecl>(CurContext), DeclLoc, DeclLoc, 0, Context.CharTy, Context.getTrivialTypeSourceInfo(Context.CharTy, DeclLoc), ObjCIvarDecl::Private, BW, true); AllIvarDecls.push_back(Ivar); } void Sema::ActOnFields(Scope* S, SourceLocation RecLoc, Decl *EnclosingDecl, llvm::ArrayRef<Decl *> Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *Attr) { assert(EnclosingDecl && "missing record or interface decl"); // If this is an Objective-C @implementation or category and we have // new fields here we should reset the layout of the interface since // it will now change. if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) { ObjCContainerDecl *DC = cast<ObjCContainerDecl>(EnclosingDecl); switch (DC->getKind()) { default: break; case Decl::ObjCCategory: Context.ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface()); break; case Decl::ObjCImplementation: Context. ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface()); break; } } RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); // Start counting up the number of named members; make sure to include // members of anonymous structs and unions in the total. unsigned NumNamedMembers = 0; if (Record) { for (RecordDecl::decl_iterator i = Record->decls_begin(), e = Record->decls_end(); i != e; i++) { if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(*i)) if (IFD->getDeclName()) ++NumNamedMembers; } } // Verify that all the fields are okay. SmallVector<FieldDecl*, 32> RecFields; bool ARCErrReported = false; for (llvm::ArrayRef<Decl *>::iterator i = Fields.begin(), end = Fields.end(); i != end; ++i) { FieldDecl *FD = cast<FieldDecl>(*i); // Get the type for the field. const Type *FDTy = FD->getType().getTypePtr(); if (!FD->isAnonymousStructOrUnion()) { // Remember all fields written by the user. RecFields.push_back(FD); } // If the field is already invalid for some reason, don't emit more // diagnostics about it. if (FD->isInvalidDecl()) { EnclosingDecl->setInvalidDecl(); continue; } // C99 6.7.2.1p2: // A structure or union shall not contain a member with // incomplete or function type (hence, a structure shall not // contain an instance of itself, but may contain a pointer to // an instance of itself), except that the last member of a // structure with more than one named member may have incomplete // array type; such a structure (and any union containing, // possibly recursively, a member that is such a structure) // shall not be a member of a structure or an element of an // array. if (FDTy->isFunctionType()) { // Field declared as a function. Diag(FD->getLocation(), diag::err_field_declared_as_function) << FD->getDeclName(); FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; } else if (FDTy->isIncompleteArrayType() && Record && ((i + 1 == Fields.end() && !Record->isUnion()) || ((getLangOpts().MicrosoftExt || getLangOpts().CPlusPlus) && (i + 1 == Fields.end() || Record->isUnion())))) { // Flexible array member. // Microsoft and g++ is more permissive regarding flexible array. // It will accept flexible array in union and also // as the sole element of a struct/class. if (getLangOpts().MicrosoftExt) { if (Record->isUnion()) Diag(FD->getLocation(), diag::ext_flexible_array_union_ms) << FD->getDeclName(); else if (Fields.size() == 1) Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_ms) << FD->getDeclName() << Record->getTagKind(); } else if (getLangOpts().CPlusPlus) { if (Record->isUnion()) Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu) << FD->getDeclName(); else if (Fields.size() == 1) Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_gnu) << FD->getDeclName() << Record->getTagKind(); } else if (!getLangOpts().C99) { if (Record->isUnion()) Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu) << FD->getDeclName(); else Diag(FD->getLocation(), diag::ext_c99_flexible_array_member) << FD->getDeclName() << Record->getTagKind(); } else if (NumNamedMembers < 1) { Diag(FD->getLocation(), diag::err_flexible_array_empty_struct) << FD->getDeclName(); FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; } if (!FD->getType()->isDependentType() && !Context.getBaseElementType(FD->getType()).isPODType(Context)) { Diag(FD->getLocation(), diag::err_flexible_array_has_nonpod_type) << FD->getDeclName() << FD->getType(); FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; } // Okay, we have a legal flexible array member at the end of the struct. if (Record) Record->setHasFlexibleArrayMember(true); } else if (!FDTy->isDependentType() && RequireCompleteType(FD->getLocation(), FD->getType(), diag::err_field_incomplete)) { // Incomplete type FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; } else if (const RecordType *FDTTy = FDTy->getAs<RecordType>()) { if (FDTTy->getDecl()->hasFlexibleArrayMember()) { // If this is a member of a union, then entire union becomes "flexible". if (Record && Record->isUnion()) { Record->setHasFlexibleArrayMember(true); } else { // If this is a struct/class and this is not the last element, reject // it. Note that GCC supports variable sized arrays in the middle of // structures. if (i + 1 != Fields.end()) Diag(FD->getLocation(), diag::ext_variable_sized_type_in_struct) << FD->getDeclName() << FD->getType(); else { // We support flexible arrays at the end of structs in // other structs as an extension. Diag(FD->getLocation(), diag::ext_flexible_array_in_struct) << FD->getDeclName(); if (Record) Record->setHasFlexibleArrayMember(true); } } } if (isa<ObjCContainerDecl>(EnclosingDecl) && RequireNonAbstractType(FD->getLocation(), FD->getType(), diag::err_abstract_type_in_decl, AbstractIvarType)) { // Ivars can not have abstract class types FD->setInvalidDecl(); } if (Record && FDTTy->getDecl()->hasObjectMember()) Record->setHasObjectMember(true); if (Record && FDTTy->getDecl()->hasVolatileMember()) Record->setHasVolatileMember(true); } else if (FDTy->isObjCObjectType()) { /// A field cannot be an Objective-c object Diag(FD->getLocation(), diag::err_statically_allocated_object) << FixItHint::CreateInsertion(FD->getLocation(), "*"); QualType T = Context.getObjCObjectPointerType(FD->getType()); FD->setType(T); } else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported && (!getLangOpts().CPlusPlus || Record->isUnion())) { // It's an error in ARC if a field has lifetime. // We don't want to report this in a system header, though, // so we just make the field unavailable. // FIXME: that's really not sufficient; we need to make the type // itself invalid to, say, initialize or copy. QualType T = FD->getType(); Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime(); if (lifetime && lifetime != Qualifiers::OCL_ExplicitNone) { SourceLocation loc = FD->getLocation(); if (getSourceManager().isInSystemHeader(loc)) { if (!FD->hasAttr<UnavailableAttr>()) { FD->addAttr(new (Context) UnavailableAttr(loc, Context, "this system field has retaining ownership")); } } else { Diag(FD->getLocation(), diag::err_arc_objc_object_in_tag) << T->isBlockPointerType() << Record->getTagKind(); } ARCErrReported = true; } } else if (getLangOpts().ObjC1 && getLangOpts().getGC() != LangOptions::NonGC && Record && !Record->hasObjectMember()) { if (FD->getType()->isObjCObjectPointerType() || FD->getType().isObjCGCStrong()) Record->setHasObjectMember(true); else if (Context.getAsArrayType(FD->getType())) { QualType BaseType = Context.getBaseElementType(FD->getType()); if (BaseType->isRecordType() && BaseType->getAs<RecordType>()->getDecl()->hasObjectMember()) Record->setHasObjectMember(true); else if (BaseType->isObjCObjectPointerType() || BaseType.isObjCGCStrong()) Record->setHasObjectMember(true); } } if (Record && FD->getType().isVolatileQualified()) Record->setHasVolatileMember(true); // Keep track of the number of named members. if (FD->getIdentifier()) ++NumNamedMembers; } // Okay, we successfully defined 'Record'. if (Record) { bool Completed = false; if (CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) { if (!CXXRecord->isInvalidDecl()) { // Set access bits correctly on the directly-declared conversions. for (CXXRecordDecl::conversion_iterator I = CXXRecord->conversion_begin(), E = CXXRecord->conversion_end(); I != E; ++I) I.setAccess((*I)->getAccess()); if (!CXXRecord->isDependentType()) { // Adjust user-defined destructor exception spec. if (getLangOpts().CPlusPlus11 && CXXRecord->hasUserDeclaredDestructor()) AdjustDestructorExceptionSpec(CXXRecord,CXXRecord->getDestructor()); // Add any implicitly-declared members to this class. AddImplicitlyDeclaredMembersToClass(CXXRecord); // If we have virtual base classes, we may end up finding multiple // final overriders for a given virtual function. Check for this // problem now. if (CXXRecord->getNumVBases()) { CXXFinalOverriderMap FinalOverriders; CXXRecord->getFinalOverriders(FinalOverriders); for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(), MEnd = FinalOverriders.end(); M != MEnd; ++M) { for (OverridingMethods::iterator SO = M->second.begin(), SOEnd = M->second.end(); SO != SOEnd; ++SO) { assert(SO->second.size() > 0 && "Virtual function without overridding functions?"); if (SO->second.size() == 1) continue; // C++ [class.virtual]p2: // In a derived class, if a virtual member function of a base // class subobject has more than one final overrider the // program is ill-formed. Diag(Record->getLocation(), diag::err_multiple_final_overriders) << (const NamedDecl *)M->first << Record; Diag(M->first->getLocation(), diag::note_overridden_virtual_function); for (OverridingMethods::overriding_iterator OM = SO->second.begin(), OMEnd = SO->second.end(); OM != OMEnd; ++OM) Diag(OM->Method->getLocation(), diag::note_final_overrider) << (const NamedDecl *)M->first << OM->Method->getParent(); Record->setInvalidDecl(); } } CXXRecord->completeDefinition(&FinalOverriders); Completed = true; } } } } if (!Completed) Record->completeDefinition(); if (Record->hasAttrs()) CheckAlignasUnderalignment(Record); } else { ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(RecFields.data()); if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl)) { ID->setEndOfDefinitionLoc(RBrac); // Add ivar's to class's DeclContext. for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { ClsFields[i]->setLexicalDeclContext(ID); ID->addDecl(ClsFields[i]); } // Must enforce the rule that ivars in the base classes may not be // duplicates. if (ID->getSuperClass()) DiagnoseDuplicateIvars(ID, ID->getSuperClass()); } else if (ObjCImplementationDecl *IMPDecl = dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl"); for (unsigned I = 0, N = RecFields.size(); I != N; ++I) // Ivar declared in @implementation never belongs to the implementation. // Only it is in implementation's lexical context. ClsFields[I]->setLexicalDeclContext(IMPDecl); CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac); IMPDecl->setIvarLBraceLoc(LBrac); IMPDecl->setIvarRBraceLoc(RBrac); } else if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) { // case of ivars in class extension; all other cases have been // reported as errors elsewhere. // FIXME. Class extension does not have a LocEnd field. // CDecl->setLocEnd(RBrac); // Add ivar's to class extension's DeclContext. // Diagnose redeclaration of private ivars. ObjCInterfaceDecl *IDecl = CDecl->getClassInterface(); for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { if (IDecl) { if (const ObjCIvarDecl *ClsIvar = IDecl->getIvarDecl(ClsFields[i]->getIdentifier())) { Diag(ClsFields[i]->getLocation(), diag::err_duplicate_ivar_declaration); Diag(ClsIvar->getLocation(), diag::note_previous_definition); continue; } for (ObjCInterfaceDecl::known_extensions_iterator Ext = IDecl->known_extensions_begin(), ExtEnd = IDecl->known_extensions_end(); Ext != ExtEnd; ++Ext) { if (const ObjCIvarDecl *ClsExtIvar = Ext->getIvarDecl(ClsFields[i]->getIdentifier())) { Diag(ClsFields[i]->getLocation(), diag::err_duplicate_ivar_declaration); Diag(ClsExtIvar->getLocation(), diag::note_previous_definition); continue; } } } ClsFields[i]->setLexicalDeclContext(CDecl); CDecl->addDecl(ClsFields[i]); } CDecl->setIvarLBraceLoc(LBrac); CDecl->setIvarRBraceLoc(RBrac); } } if (Attr) ProcessDeclAttributeList(S, Record, Attr); } /// \brief Determine whether the given integral value is representable within /// the given type T. static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T) { assert(T->isIntegralType(Context) && "Integral type required!"); unsigned BitWidth = Context.getIntWidth(T); if (Value.isUnsigned() || Value.isNonNegative()) { if (T->isSignedIntegerOrEnumerationType()) --BitWidth; return Value.getActiveBits() <= BitWidth; } return Value.getMinSignedBits() <= BitWidth; } // \brief Given an integral type, return the next larger integral type // (or a NULL type of no such type exists). static QualType getNextLargerIntegralType(ASTContext &Context, QualType T) { // FIXME: Int128/UInt128 support, which also needs to be introduced into // enum checking below. assert(T->isIntegralType(Context) && "Integral type required!"); const unsigned NumTypes = 4; QualType SignedIntegralTypes[NumTypes] = { Context.ShortTy, Context.IntTy, Context.LongTy, Context.LongLongTy }; QualType UnsignedIntegralTypes[NumTypes] = { Context.UnsignedShortTy, Context.UnsignedIntTy, Context.UnsignedLongTy, Context.UnsignedLongLongTy }; unsigned BitWidth = Context.getTypeSize(T); QualType *Types = T->isSignedIntegerOrEnumerationType()? SignedIntegralTypes : UnsignedIntegralTypes; for (unsigned I = 0; I != NumTypes; ++I) if (Context.getTypeSize(Types[I]) > BitWidth) return Types[I]; return QualType(); } EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *Val) { unsigned IntWidth = Context.getTargetInfo().getIntWidth(); llvm::APSInt EnumVal(IntWidth); QualType EltTy; if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue)) Val = 0; if (Val) Val = DefaultLvalueConversion(Val).take(); if (Val) { if (Enum->isDependentType() || Val->isTypeDependent()) EltTy = Context.DependentTy; else { SourceLocation ExpLoc; if (getLangOpts().CPlusPlus11 && Enum->isFixed() && !getLangOpts().MicrosoftMode) { // C++11 [dcl.enum]p5: If the underlying type is fixed, [...] the // constant-expression in the enumerator-definition shall be a converted // constant expression of the underlying type. EltTy = Enum->getIntegerType(); ExprResult Converted = CheckConvertedConstantExpression(Val, EltTy, EnumVal, CCEK_Enumerator); if (Converted.isInvalid()) Val = 0; else Val = Converted.take(); } else if (!Val->isValueDependent() && !(Val = VerifyIntegerConstantExpression(Val, &EnumVal).take())) { // C99 6.7.2.2p2: Make sure we have an integer constant expression. } else { if (Enum->isFixed()) { EltTy = Enum->getIntegerType(); // In Obj-C and Microsoft mode, require the enumeration value to be // representable in the underlying type of the enumeration. In C++11, // we perform a non-narrowing conversion as part of converted constant // expression checking. if (!isRepresentableIntegerValue(Context, EnumVal, EltTy)) { if (getLangOpts().MicrosoftMode) { Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy; Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).take(); } else Diag(IdLoc, diag::err_enumerator_too_large) << EltTy; } else Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).take(); } else if (getLangOpts().CPlusPlus) { // C++11 [dcl.enum]p5: // If the underlying type is not fixed, the type of each enumerator // is the type of its initializing value: // - If an initializer is specified for an enumerator, the // initializing value has the same type as the expression. EltTy = Val->getType(); } else { // C99 6.7.2.2p2: // The expression that defines the value of an enumeration constant // shall be an integer constant expression that has a value // representable as an int. // Complain if the value is not representable in an int. if (!isRepresentableIntegerValue(Context, EnumVal, Context.IntTy)) Diag(IdLoc, diag::ext_enum_value_not_int) << EnumVal.toString(10) << Val->getSourceRange() << (EnumVal.isUnsigned() || EnumVal.isNonNegative()); else if (!Context.hasSameType(Val->getType(), Context.IntTy)) { // Force the type of the expression to 'int'. Val = ImpCastExprToType(Val, Context.IntTy, CK_IntegralCast).take(); } EltTy = Val->getType(); } } } } if (!Val) { if (Enum->isDependentType()) EltTy = Context.DependentTy; else if (!LastEnumConst) { // C++0x [dcl.enum]p5: // If the underlying type is not fixed, the type of each enumerator // is the type of its initializing value: // - If no initializer is specified for the first enumerator, the // initializing value has an unspecified integral type. // // GCC uses 'int' for its unspecified integral type, as does // C99 6.7.2.2p3. if (Enum->isFixed()) { EltTy = Enum->getIntegerType(); } else { EltTy = Context.IntTy; } } else { // Assign the last value + 1. EnumVal = LastEnumConst->getInitVal(); ++EnumVal; EltTy = LastEnumConst->getType(); // Check for overflow on increment. if (EnumVal < LastEnumConst->getInitVal()) { // C++0x [dcl.enum]p5: // If the underlying type is not fixed, the type of each enumerator // is the type of its initializing value: // // - Otherwise the type of the initializing value is the same as // the type of the initializing value of the preceding enumerator // unless the incremented value is not representable in that type, // in which case the type is an unspecified integral type // sufficient to contain the incremented value. If no such type // exists, the program is ill-formed. QualType T = getNextLargerIntegralType(Context, EltTy); if (T.isNull() || Enum->isFixed()) { // There is no integral type larger enough to represent this // value. Complain, then allow the value to wrap around. EnumVal = LastEnumConst->getInitVal(); EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2); ++EnumVal; if (Enum->isFixed()) // When the underlying type is fixed, this is ill-formed. Diag(IdLoc, diag::err_enumerator_wrapped) << EnumVal.toString(10) << EltTy; else Diag(IdLoc, diag::warn_enumerator_too_large) << EnumVal.toString(10); } else { EltTy = T; } // Retrieve the last enumerator's value, extent that type to the // type that is supposed to be large enough to represent the incremented // value, then increment. EnumVal = LastEnumConst->getInitVal(); EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType()); EnumVal = EnumVal.zextOrTrunc(Context.getIntWidth(EltTy)); ++EnumVal; // If we're not in C++, diagnose the overflow of enumerator values, // which in C99 means that the enumerator value is not representable in // an int (C99 6.7.2.2p2). However, we support GCC's extension that // permits enumerator values that are representable in some larger // integral type. if (!getLangOpts().CPlusPlus && !T.isNull()) Diag(IdLoc, diag::warn_enum_value_overflow); } else if (!getLangOpts().CPlusPlus && !isRepresentableIntegerValue(Context, EnumVal, EltTy)) { // Enforce C99 6.7.2.2p2 even when we compute the next value. Diag(IdLoc, diag::ext_enum_value_not_int) << EnumVal.toString(10) << 1; } } } if (!EltTy->isDependentType()) { // Make the enumerator value match the signedness and size of the // enumerator's type. EnumVal = EnumVal.extOrTrunc(Context.getIntWidth(EltTy)); EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType()); } return EnumConstantDecl::Create(Context, Enum, IdLoc, Id, EltTy, Val, EnumVal); } Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, AttributeList *Attr, SourceLocation EqualLoc, Expr *Val) { EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl); EnumConstantDecl *LastEnumConst = cast_or_null<EnumConstantDecl>(lastEnumConst); // The scope passed in may not be a decl scope. Zip up the scope tree until // we find one that is. S = getNonFieldDeclScope(S); // Verify that there isn't already something declared with this name in this // scope. NamedDecl *PrevDecl = LookupSingleName(S, Id, IdLoc, LookupOrdinaryName, ForRedeclaration); if (PrevDecl && PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(IdLoc, PrevDecl); // Just pretend that we didn't see the previous declaration. PrevDecl = 0; } if (PrevDecl) { // When in C++, we may get a TagDecl with the same name; in this case the // enum constant will 'hide' the tag. assert((getLangOpts().CPlusPlus || !isa<TagDecl>(PrevDecl)) && "Received TagDecl when not in C++!"); if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) { if (isa<EnumConstantDecl>(PrevDecl)) Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id; else Diag(IdLoc, diag::err_redefinition) << Id; Diag(PrevDecl->getLocation(), diag::note_previous_definition); return 0; } } // C++ [class.mem]p15: // If T is the name of a class, then each of the following shall have a name // different from T: // - every enumerator of every member of class T that is an unscoped // enumerated type if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>( TheEnumDecl->getDeclContext()->getRedeclContext())) if (!TheEnumDecl->isScoped() && Record->getIdentifier() && Record->getIdentifier() == Id) Diag(IdLoc, diag::err_member_name_of_class) << Id; EnumConstantDecl *New = CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val); if (New) { // Process attributes. if (Attr) ProcessDeclAttributeList(S, New, Attr); // Register this decl in the current scope stack. New->setAccess(TheEnumDecl->getAccess()); PushOnScopeChains(New, S); } ActOnDocumentableDecl(New); return New; } // Returns true when the enum initial expression does not trigger the // duplicate enum warning. A few common cases are exempted as follows: // Element2 = Element1 // Element2 = Element1 + 1 // Element2 = Element1 - 1 // Where Element2 and Element1 are from the same enum. static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum) { Expr *InitExpr = ECD->getInitExpr(); if (!InitExpr) return true; InitExpr = InitExpr->IgnoreImpCasts(); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(InitExpr)) { if (!BO->isAdditiveOp()) return true; IntegerLiteral *IL = dyn_cast<IntegerLiteral>(BO->getRHS()); if (!IL) return true; if (IL->getValue() != 1) return true; InitExpr = BO->getLHS(); } // This checks if the elements are from the same enum. DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr); if (!DRE) return true; EnumConstantDecl *EnumConstant = dyn_cast<EnumConstantDecl>(DRE->getDecl()); if (!EnumConstant) return true; if (cast<EnumDecl>(TagDecl::castFromDeclContext(ECD->getDeclContext())) != Enum) return true; return false; } struct DupKey { int64_t val; bool isTombstoneOrEmptyKey; DupKey(int64_t val, bool isTombstoneOrEmptyKey) : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {} }; static DupKey GetDupKey(const llvm::APSInt& Val) { return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(), false); } struct DenseMapInfoDupKey { static DupKey getEmptyKey() { return DupKey(0, true); } static DupKey getTombstoneKey() { return DupKey(1, true); } static unsigned getHashValue(const DupKey Key) { return (unsigned)(Key.val * 37); } static bool isEqual(const DupKey& LHS, const DupKey& RHS) { return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey && LHS.val == RHS.val; } }; // Emits a warning when an element is implicitly set a value that // a previous element has already been set to. static void CheckForDuplicateEnumValues(Sema &S, ArrayRef<Decl *> Elements, EnumDecl *Enum, QualType EnumType) { if (S.Diags.getDiagnosticLevel(diag::warn_duplicate_enum_values, Enum->getLocation()) == DiagnosticsEngine::Ignored) return; // Avoid anonymous enums if (!Enum->getIdentifier()) return; // Only check for small enums. if (Enum->getNumPositiveBits() > 63 || Enum->getNumNegativeBits() > 64) return; typedef SmallVector<EnumConstantDecl *, 3> ECDVector; typedef SmallVector<ECDVector *, 3> DuplicatesVector; typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector; typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey> ValueToVectorMap; DuplicatesVector DupVector; ValueToVectorMap EnumMap; // Populate the EnumMap with all values represented by enum constants without // an initialier. for (unsigned i = 0, e = Elements.size(); i != e; ++i) { EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); // Null EnumConstantDecl means a previous diagnostic has been emitted for // this constant. Skip this enum since it may be ill-formed. if (!ECD) { return; } if (ECD->getInitExpr()) continue; DupKey Key = GetDupKey(ECD->getInitVal()); DeclOrVector &Entry = EnumMap[Key]; // First time encountering this value. if (Entry.isNull()) Entry = ECD; } // Create vectors for any values that has duplicates. for (unsigned i = 0, e = Elements.size(); i != e; ++i) { EnumConstantDecl *ECD = cast<EnumConstantDecl>(Elements[i]); if (!ValidDuplicateEnum(ECD, Enum)) continue; DupKey Key = GetDupKey(ECD->getInitVal()); DeclOrVector& Entry = EnumMap[Key]; if (Entry.isNull()) continue; if (EnumConstantDecl *D = Entry.dyn_cast<EnumConstantDecl*>()) { // Ensure constants are different. if (D == ECD) continue; // Create new vector and push values onto it. ECDVector *Vec = new ECDVector(); Vec->push_back(D); Vec->push_back(ECD); // Update entry to point to the duplicates vector. Entry = Vec; // Store the vector somewhere we can consult later for quick emission of // diagnostics. DupVector.push_back(Vec); continue; } ECDVector *Vec = Entry.get<ECDVector*>(); // Make sure constants are not added more than once. if (*Vec->begin() == ECD) continue; Vec->push_back(ECD); } // Emit diagnostics. for (DuplicatesVector::iterator DupVectorIter = DupVector.begin(), DupVectorEnd = DupVector.end(); DupVectorIter != DupVectorEnd; ++DupVectorIter) { ECDVector *Vec = *DupVectorIter; assert(Vec->size() > 1 && "ECDVector should have at least 2 elements."); // Emit warning for one enum constant. ECDVector::iterator I = Vec->begin(); S.Diag((*I)->getLocation(), diag::warn_duplicate_enum_values) << (*I)->getName() << (*I)->getInitVal().toString(10) << (*I)->getSourceRange(); ++I; // Emit one note for each of the remaining enum constants with // the same value. for (ECDVector::iterator E = Vec->end(); I != E; ++I) S.Diag((*I)->getLocation(), diag::note_duplicate_element) << (*I)->getName() << (*I)->getInitVal().toString(10) << (*I)->getSourceRange(); delete Vec; } } void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDeclX, ArrayRef<Decl *> Elements, Scope *S, AttributeList *Attr) { EnumDecl *Enum = cast<EnumDecl>(EnumDeclX); QualType EnumType = Context.getTypeDeclType(Enum); if (Attr) ProcessDeclAttributeList(S, Enum, Attr); if (Enum->isDependentType()) { for (unsigned i = 0, e = Elements.size(); i != e; ++i) { EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); if (!ECD) continue; ECD->setType(EnumType); } Enum->completeDefinition(Context.DependentTy, Context.DependentTy, 0, 0); return; } // TODO: If the result value doesn't fit in an int, it must be a long or long // long value. ISO C does not support this, but GCC does as an extension, // emit a warning. unsigned IntWidth = Context.getTargetInfo().getIntWidth(); unsigned CharWidth = Context.getTargetInfo().getCharWidth(); unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); // Verify that all the values are okay, compute the size of the values, and // reverse the list. unsigned NumNegativeBits = 0; unsigned NumPositiveBits = 0; // Keep track of whether all elements have type int. bool AllElementsInt = true; for (unsigned i = 0, e = Elements.size(); i != e; ++i) { EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); if (!ECD) continue; // Already issued a diagnostic. const llvm::APSInt &InitVal = ECD->getInitVal(); // Keep track of the size of positive and negative values. if (InitVal.isUnsigned() || InitVal.isNonNegative()) NumPositiveBits = std::max(NumPositiveBits, (unsigned)InitVal.getActiveBits()); else NumNegativeBits = std::max(NumNegativeBits, (unsigned)InitVal.getMinSignedBits()); // Keep track of whether every enum element has type int (very commmon). if (AllElementsInt) AllElementsInt = ECD->getType() == Context.IntTy; } // Figure out the type that should be used for this enum. QualType BestType; unsigned BestWidth; // C++0x N3000 [conv.prom]p3: // An rvalue of an unscoped enumeration type whose underlying // type is not fixed can be converted to an rvalue of the first // of the following types that can represent all the values of // the enumeration: int, unsigned int, long int, unsigned long // int, long long int, or unsigned long long int. // C99 6.4.4.3p2: // An identifier declared as an enumeration constant has type int. // The C99 rule is modified by a gcc extension QualType BestPromotionType; bool Packed = Enum->getAttr<PackedAttr>() ? true : false; // -fshort-enums is the equivalent to specifying the packed attribute on all // enum definitions. if (LangOpts.ShortEnums) Packed = true; if (Enum->isFixed()) { BestType = Enum->getIntegerType(); if (BestType->isPromotableIntegerType()) BestPromotionType = Context.getPromotedIntegerType(BestType); else BestPromotionType = BestType; // We don't need to set BestWidth, because BestType is going to be the type // of the enumerators, but we do anyway because otherwise some compilers // warn that it might be used uninitialized. BestWidth = CharWidth; } else if (NumNegativeBits) { // If there is a negative value, figure out the smallest integer type (of // int/long/longlong) that fits. // If it's packed, check also if it fits a char or a short. if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) { BestType = Context.SignedCharTy; BestWidth = CharWidth; } else if (Packed && NumNegativeBits <= ShortWidth && NumPositiveBits < ShortWidth) { BestType = Context.ShortTy; BestWidth = ShortWidth; } else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) { BestType = Context.IntTy; BestWidth = IntWidth; } else { BestWidth = Context.getTargetInfo().getLongWidth(); if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) { BestType = Context.LongTy; } else { BestWidth = Context.getTargetInfo().getLongLongWidth(); if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth) Diag(Enum->getLocation(), diag::warn_enum_too_large); BestType = Context.LongLongTy; } } BestPromotionType = (BestWidth <= IntWidth ? Context.IntTy : BestType); } else { // If there is no negative value, figure out the smallest type that fits // all of the enumerator values. // If it's packed, check also if it fits a char or a short. if (Packed && NumPositiveBits <= CharWidth) { BestType = Context.UnsignedCharTy; BestPromotionType = Context.IntTy; BestWidth = CharWidth; } else if (Packed && NumPositiveBits <= ShortWidth) { BestType = Context.UnsignedShortTy; BestPromotionType = Context.IntTy; BestWidth = ShortWidth; } else if (NumPositiveBits <= IntWidth) { BestType = Context.UnsignedIntTy; BestWidth = IntWidth; BestPromotionType = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) ? Context.UnsignedIntTy : Context.IntTy; } else if (NumPositiveBits <= (BestWidth = Context.getTargetInfo().getLongWidth())) { BestType = Context.UnsignedLongTy; BestPromotionType = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) ? Context.UnsignedLongTy : Context.LongTy; } else { BestWidth = Context.getTargetInfo().getLongLongWidth(); assert(NumPositiveBits <= BestWidth && "How could an initializer get larger than ULL?"); BestType = Context.UnsignedLongLongTy; BestPromotionType = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) ? Context.UnsignedLongLongTy : Context.LongLongTy; } } // Loop over all of the enumerator constants, changing their types to match // the type of the enum if needed. for (unsigned i = 0, e = Elements.size(); i != e; ++i) { EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); if (!ECD) continue; // Already issued a diagnostic. // Standard C says the enumerators have int type, but we allow, as an // extension, the enumerators to be larger than int size. If each // enumerator value fits in an int, type it as an int, otherwise type it the // same as the enumerator decl itself. This means that in "enum { X = 1U }" // that X has type 'int', not 'unsigned'. // Determine whether the value fits into an int. llvm::APSInt InitVal = ECD->getInitVal(); // If it fits into an integer type, force it. Otherwise force it to match // the enum decl type. QualType NewTy; unsigned NewWidth; bool NewSign; if (!getLangOpts().CPlusPlus && !Enum->isFixed() && isRepresentableIntegerValue(Context, InitVal, Context.IntTy)) { NewTy = Context.IntTy; NewWidth = IntWidth; NewSign = true; } else if (ECD->getType() == BestType) { // Already the right type! if (getLangOpts().CPlusPlus) // C++ [dcl.enum]p4: Following the closing brace of an // enum-specifier, each enumerator has the type of its // enumeration. ECD->setType(EnumType); continue; } else { NewTy = BestType; NewWidth = BestWidth; NewSign = BestType->isSignedIntegerOrEnumerationType(); } // Adjust the APSInt value. InitVal = InitVal.extOrTrunc(NewWidth); InitVal.setIsSigned(NewSign); ECD->setInitVal(InitVal); // Adjust the Expr initializer and type. if (ECD->getInitExpr() && !Context.hasSameType(NewTy, ECD->getInitExpr()->getType())) ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy, CK_IntegralCast, ECD->getInitExpr(), /*base paths*/ 0, VK_RValue)); if (getLangOpts().CPlusPlus) // C++ [dcl.enum]p4: Following the closing brace of an // enum-specifier, each enumerator has the type of its // enumeration. ECD->setType(EnumType); else ECD->setType(NewTy); } Enum->completeDefinition(BestType, BestPromotionType, NumPositiveBits, NumNegativeBits); // If we're declaring a function, ensure this decl isn't forgotten about - // it needs to go into the function scope. if (InFunctionDeclarator) DeclsInPrototypeScope.push_back(Enum); CheckForDuplicateEnumValues(*this, Elements, Enum, EnumType); // Now that the enum type is defined, ensure it's not been underaligned. if (Enum->hasAttrs()) CheckAlignasUnderalignment(Enum); } Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr, SourceLocation StartLoc, SourceLocation EndLoc) { StringLiteral *AsmString = cast<StringLiteral>(expr); FileScopeAsmDecl *New = FileScopeAsmDecl::Create(Context, CurContext, AsmString, StartLoc, EndLoc); CurContext->addDecl(New); return New; } DeclResult Sema::ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path) { Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible, /*IsIncludeDirective=*/false); if (!Mod) return true; SmallVector<SourceLocation, 2> IdentifierLocs; Module *ModCheck = Mod; for (unsigned I = 0, N = Path.size(); I != N; ++I) { // If we've run out of module parents, just drop the remaining identifiers. // We need the length to be consistent. if (!ModCheck) break; ModCheck = ModCheck->Parent; IdentifierLocs.push_back(Path[I].second); } ImportDecl *Import = ImportDecl::Create(Context, Context.getTranslationUnitDecl(), AtLoc.isValid()? AtLoc : ImportLoc, Mod, IdentifierLocs); Context.getTranslationUnitDecl()->addDecl(Import); return Import; } void Sema::createImplicitModuleImport(SourceLocation Loc, Module *Mod) { // Create the implicit import declaration. TranslationUnitDecl *TU = getASTContext().getTranslationUnitDecl(); ImportDecl *ImportD = ImportDecl::CreateImplicit(getASTContext(), TU, Loc, Mod, Loc); TU->addDecl(ImportD); Consumer.HandleImplicitImportDecl(ImportD); // Make the module visible. PP.getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, Loc, /*Complain=*/false); } void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name, IdentifierInfo* AliasName, SourceLocation PragmaLoc, SourceLocation NameLoc, SourceLocation AliasNameLoc) { Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName); AsmLabelAttr *Attr = ::new (Context) AsmLabelAttr(AliasNameLoc, Context, AliasName->getName()); if (PrevDecl) PrevDecl->addAttr(Attr); else (void)ExtnameUndeclaredIdentifiers.insert( std::pair<IdentifierInfo*,AsmLabelAttr*>(Name, Attr)); } void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, SourceLocation PragmaLoc, SourceLocation NameLoc) { Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName); if (PrevDecl) { PrevDecl->addAttr(::new (Context) WeakAttr(PragmaLoc, Context)); } else { (void)WeakUndeclaredIdentifiers.insert( std::pair<IdentifierInfo*,WeakInfo> (Name, WeakInfo((IdentifierInfo*)0, NameLoc))); } } void Sema::ActOnPragmaWeakAlias(IdentifierInfo* Name, IdentifierInfo* AliasName, SourceLocation PragmaLoc, SourceLocation NameLoc, SourceLocation AliasNameLoc) { Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc, LookupOrdinaryName); WeakInfo W = WeakInfo(Name, NameLoc); if (PrevDecl) { if (!PrevDecl->hasAttr<AliasAttr>()) if (NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl)) DeclApplyPragmaWeak(TUScope, ND, W); } else { (void)WeakUndeclaredIdentifiers.insert( std::pair<IdentifierInfo*,WeakInfo>(AliasName, W)); } } Decl *Sema::getObjCDeclContext() const { return (dyn_cast_or_null<ObjCContainerDecl>(CurContext)); } AvailabilityResult Sema::getCurContextAvailability() const { const Decl *D = cast<Decl>(getCurObjCLexicalContext()); return D->getAvailability(); }
[ "zenghongbin16@mails.ucas.ac.cn" ]
zenghongbin16@mails.ucas.ac.cn
8bbd1b97c9286e76c2ee2e30bab1d5efe3c4fd4a
a7d417b677c62920cc408ee6b07e8a9106b30d2f
/lab2/lab2/readfromfile.cpp
234a4117da2a6f474ea87c239817459ce9d1df35
[]
no_license
KITKATJN/LAB2MOCOS
9dafe557326d381a6a4ae94f5745034c39de4b2d
94ab261792bd3b14a2783081325a21848fe15996
refs/heads/main
2023-04-05T09:57:31.887241
2021-04-11T14:59:45
2021-04-11T14:59:45
356,677,286
0
0
null
null
null
null
UTF-8
C++
false
false
643
cpp
#include "Header.h" std::vector < std::complex < double>> ReadSignal(std::string path) { std::ifstream file; file.open(path); std::size_t count = 0; double x; while (file >> x) count++; std::cout << "count = " << count << std::endl; std::vector < std::complex < double>> signal(count / 2); double tmp; file.close(); file.open(path); for (size_t i = 0; i < count; i++) { file >> tmp; if (i % 2 == 0) { signal[i / 2].real(tmp); } else { signal[i / 2].imag(tmp); } //std::cout << "signal = " << signal[i / 2] << " i = " << i << std::endl; } file.close(); return signal; }
[ "noreply@github.com" ]
KITKATJN.noreply@github.com
8b39ec91989d277cda0767101743597b7b23dac1
c40a70b70835a0a8b8672f3d2c10c82fe13d55ff
/switch.cpp
a459913b2f25c14707e1761cc9033e1bcaded569
[]
no_license
RodArg/OOPDemo
4561df368f5753990cb94a87882fe0f502503b2d
55351defeeff0f8fe660ba38d21d363cc38f873a
refs/heads/master
2020-03-22T05:59:06.663981
2018-08-01T22:51:18
2018-08-01T22:51:18
139,604,312
0
0
null
null
null
null
UTF-8
C++
false
false
321
cpp
#include "std_lib_facilities.h" int main(){ int num; cout << "What's your favorite number 1-10?"; cin >> num; switch(num){ case 0: case 2: case 4: case 6: case 8: case 10: cout << "Nice and even"; break; case 1: case 3: case 5: case 9: cout << "That's odd"; break; case 7: cout << "Lucky!"; break; } }
[ "rodrigo.arg01@gmail.com" ]
rodrigo.arg01@gmail.com
e609cef92d881e1f9ac4548a74bf2e91b485e1a4
49c55e28d66238a6b6cc6ad26b3ea4ff7db6f6df
/src/src/FlowSinkProcessor.h
6708d7529964210ad504bb8bffe56bdd21de9ee2
[]
no_license
akosiorek/optical_flow
3380825e55d15a4d7f57e8717c7fa9be4d5c3e10
d48918f56e864d7d1f087216e0e0e7435a19069a
refs/heads/master
2021-01-02T22:57:14.563839
2015-07-03T11:23:04
2015-07-03T11:23:04
33,973,413
1
3
null
2015-05-19T17:46:10
2015-04-15T04:37:34
C++
UTF-8
C++
false
false
1,423
h
#ifndef FLOW_SINK_PROCESSOR_H #define FLOW_SINK_PROCESSOR_H #include <vector> #include "common.h" #include "DataFlowPolicy.h" #include "FlowSlice.h" #include "IFlowSinkTask.h" template<template <class> class InputBufferT> class FlowSinkProcessor : public BufferedInputPolicy<FlowSlice::Ptr, InputBufferT> { public: using InputBuffer = typename BufferedInputPolicy<FlowSlice::Ptr, InputBufferT>::InputBuffer; FlowSinkProcessor() : processThread_(nullptr), running_(false) {} ~FlowSinkProcessor() { stop(); } bool start() { LOG_FUN_START; processThread_ = std::make_unique<std::thread>(&FlowSinkProcessor::processFlowSlices, this); if(processThread_ != nullptr) return running_ = true, running_; else return false; LOG_FUN_END; } void stop() { if(running_==true) { running_ = false; processThread_->join(); processThread_.reset(); } } void addTask(std::unique_ptr<IFlowSinkTask> task) { taskQueue_.emplace_back(std::move(task)); } private: void processFlowSlices() { while(running_ == true) { if(this->hasInput()) { auto input = this->inputBuffer_->front(); this->inputBuffer_->pop(); for(std::size_t i = 0; i<taskQueue_.size(); ++i) { taskQueue_[i]->process(input); } } } } std::vector<std::unique_ptr<IFlowSinkTask> > taskQueue_; std::unique_ptr<std::thread> processThread_; std::atomic_bool running_; }; #endif
[ "dawidh.adrian@googlemail.com" ]
dawidh.adrian@googlemail.com
c6adcc10b4743ccfbef86b75d557eea81d2318f3
4fc802a5e091f42d463917e07dd6e104604cecf6
/Tarea2_Ej7/src/Headers/InputManager.h
e0a58c5b871e60323490cc0973d0b613c3aa642c
[]
no_license
FernandaRTenorio/DIMyR_FerRomeroT
c0ca9692960454bc8ac90f99975bfef6f71211d4
3ca115f6aa7b22a3e6f1230b8833749ae6239521
refs/heads/master
2020-12-07T03:49:04.678662
2016-12-13T17:22:46
2016-12-13T17:22:46
66,040,302
0
0
null
null
null
null
UTF-8
C++
false
false
1,634
h
#ifndef _InputManager_H #define _InputManager_H #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtx/transform2.hpp> #include <glm/gtx/quaternion.hpp> #include <glm/gtc/type_ptr.hpp> // Standar GLFW for the management of inputs codes keyboards enum InputCodes { kEscape = 27, Space = 32, Left = 37, Up = 38, Right = 39, Down = 40, a = 97, A = 65, b = 98, B = 66, c = 99, C = 67, d = 100, D = 68, e = 101, E = 69, f = 102, F = 70, g = 103, G = 71, h = 104, H = 72, i = 105, I = 73, j = 106, J = 74, k = 107, K = 75, l = 108, L = 76, m = 109, M = 77, n = 110, N = 78, o = 111, O = 79, p = 112, P = 80, q = 113, Q = 81, r = 114, R = 82, s = 115, S = 83, t = 116, T = 84, u = 117, U = 85, v = 118, V = 86, w = 119, W = 87, x = 120, X = 88, y = 121, Y = 89, z = 122, Z = 90, }; enum MouseCodes { button_left = 1, button_right = 2, button_middle = 3, }; class InputManager { public: static bool rotar; InputManager() : exitApp(false) { } void keyPressed(InputCodes code, float deltaTime); void mouseMoved(float mouseX, float mouseY); void mouseClicked(MouseCodes code); void mouseScroll(float yoffset); glm::mat4 getTransform(); bool isExitApp() { return exitApp; } glm::ivec2 getLastMousePos() { return lastMousePos; } void setLastMousePos(glm::ivec2 lastMousePos) { this->lastMousePos = lastMousePos; } /* glm::mat4 getTransform(){ //transform = glm::rotate(transform, glm::radians(30.0f), glm::vec3(0.0f, 1.0f, 0.0f)); return transform; }*/ protected: bool exitApp; glm::ivec2 lastMousePos; }; #endif
[ "fernandiux_mo@hotmail.com" ]
fernandiux_mo@hotmail.com
110620a945036f77fd104ba8a5a318c38c1eed69
b375b5f1ab13f8c9d8b3003435a4980d6c5a1215
/GameServer/GameMsg.h
9d82d8c58c64858cd65b54e5b9e4c0dc65de213d
[]
no_license
2316707511/GameProject
08291b43e90c1463ac5e14cd2f52da26645fa838
533d96d1acc91f6cedaf3f7bf7803599edff815b
refs/heads/master
2020-11-27T07:49:17.420504
2019-12-24T09:27:32
2019-12-24T09:27:32
229,360,156
0
0
null
null
null
null
GB18030
C++
false
false
1,377
h
#pragma once #include "zinx.h" #include "msg.pb.h" #include <list> using namespace std; class GameSingleTLV :public UserData { public: //根据游戏的协议需求,定义的消息ID 枚举 enum GameMsgType { GAME_MSG_LOGON_SYNCPID = 1, //同步玩家id和名字 GAME_MSG_TALK_CONTENT = 2, //聊天信息 GAME_MSG_NEW_POSTION = 3, //同步玩家位置 GAME_MSG_SKILL_TRIGGER = 4, //技能触发 GAME_MSG_SKILL_CONTACT = 5, //技能命中 GAME_MSG_CHANGE_WORLD = 6, //场景切换 GAME_MSG_BROADCAST = 200, //普通广播消息 GAME_MSG_LOGOFF_SYNCPID = 201, //玩家离线消息 GAME_MSG_SUR_PLAYER = 202, //同步周边玩家消息 GAME_MSG_SKILL_BROAD = 204, //技能触发广播 GAME_MSG_SKILL_CONTACT_BROAD = 205, //技能命中广播 GAME_MSG_CHANGE_WORLD_RESPONSE = 206, //切换场景广播 } m_MsgType; //存储单个protobuf的消息对象 google::protobuf::Message *m_poGameMsg = NULL; public: GameSingleTLV(GameMsgType _Type, google::protobuf::Message * _poGameMsg); GameSingleTLV(GameMsgType _Type, std::string _szInputData); ~GameSingleTLV(); std::string Serialize(); }; class GameMsg : public UserData { public: GameMsg(); virtual ~GameMsg(); public: list<GameSingleTLV*> m_MsgList; };
[ "2316707511@qq.com" ]
2316707511@qq.com
7afa1c2512c09b448ca65af6197a4c3814d94142
4392a99245845c9f047e84b1cd4e53ac72983391
/HDOJ/1097.cpp
26dcbc0b34015a6c8b87cf7e82d6e1be4018bd43
[]
no_license
netcan/Netcan_ICPC
54aa26e111aa989fb9802d93b679acdfe4293198
73cde45b23301870bdb2f3eeead3ce46dd229e92
refs/heads/master
2021-01-20T07:18:35.117023
2016-09-07T02:08:13
2016-09-07T02:08:13
39,720,148
4
2
null
null
null
null
UTF-8
C++
false
false
1,434
cpp
////////////////////System Comment//////////////////// ////Welcome to Hangzhou Dianzi University Online Judge ////http://acm.hdu.edu.cn ////////////////////////////////////////////////////// ////Username: netcan ////Nickname: Netcan ////Run ID: ////Submit time: 2015-05-08 16:38:52 ////Compiler: GUN C++ ////////////////////////////////////////////////////// ////Problem ID: 1097 ////Problem Title: ////Run result: Accept ////Run time:0MS ////Run memory:1596KB //////////////////System Comment End////////////////// /************************************************************************* > File Name: 1097.cpp > Author: Netcan > Blog: http://www.netcan.xyz > Mail: 1469709759@qq.com > Created Time: Fri 08 May 2015 16:07:26 CST ************************************************************************/ #include <iostream> #include <vector> #include <string> #include <queue> #include <algorithm> #include <cmath> #include <ctime> #include <cstdio> #include <sstream> #include <deque> #include <functional> #include <iterator> #include <list> #include <map> #include <memory> #include <stack> #include <set> #include <numeric> #include <utility> #include <cstring> using namespace std; int main() { int a, b,c; while(cin >> a >> b) { c = a %= 10; b %= 4; if(b == 0) { b = 4; } while(--b) c = c*a%10; cout << c << endl; } return 0; }
[ "1469709759@qq.com" ]
1469709759@qq.com
5c5f18bb483024a56a579b764f85298b3e5518d1
5aa4d76fef6247d93b6500f73512cdc98143b25d
/Soket/CHAT/SampleServer/Sample.h
5fbe0abbd51a1a50268cc41199a0f6189e2e5a2f
[]
no_license
leader1118/KHJ-Project
a854bc392991e24774ab0feca0bb49eb8593ef15
0eb0144bbd2b4d40156402a5994c8f782b558f6c
refs/heads/master
2020-04-05T20:44:07.339776
2019-02-01T10:11:45
2019-02-01T10:11:45
157,193,296
0
1
null
null
null
null
UTF-8
C++
false
false
370
h
#pragma once #include "TCore.h" #include "TUdpSocket.h" class Sample: public TCore { public: TUdpSocket m_Udp; public: bool Init(); bool Release(); bool PreRender() { return true; } bool PostRender() { return true; } LRESULT MsgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); public: Sample(void); ~Sample(void); };
[ "hyunjin9173@gmail.com" ]
hyunjin9173@gmail.com
7cd2f4bd102ca4415e512e65725a3323b62d2db5
790714546b4638d8d69995d9158a313c795dbffd
/inet_insertions/MobileNode.cc
cc9a10de99439d460bc93599f8394d93472ea8a2
[]
no_license
brunoolivieri/omnetpp-mobility-drones
13f76fdac4d5bda1668017a52436a26850320182
f20f72fed2d8273ed29d302759898b2bc4542444
refs/heads/master
2023-03-05T06:57:29.253913
2021-02-18T10:17:41
2021-02-18T10:17:41
313,561,272
2
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,988
cc
#include "MobileNode.h" #include "stdlib.h" #include <time.h> #include "inet/inet_insertions/MobileNode.h" //namespace inet { //Register_Class(MobileNode); Define_Module(MobileNode); void MobileNode::initialize(){ // TO-DO: these ID shaw be UUID as in network internalMobNodeId = this->getId() - par("simulationIndexOfFirstNode").intValue() + 1; par("internalMobNodeId").setIntValue(internalMobNodeId); //this->myType = static_cast<mobileNodeType>(par("nodeType").intValue()); std::cout << "UAV initialization of internalMobNodeId: " << internalMobNodeId << " Class " << this->getClassName() << "." << endl; for (int n= 0; n< par("wayPointSetSize").intValue(); n++){ if (n == 0 ){ waypoints[n].x = 0; waypoints[n].y = 0; } else { if (n % 2 == 0){ waypoints[n].x = n * 100 + internalMobNodeId * 200; waypoints[n].y = n * 100 + internalMobNodeId * 200; } else { if (n % 3 == 0) { waypoints[n].x = 2 * 100 + internalMobNodeId * 200; waypoints[n].y = 0 * 100 + internalMobNodeId * 200; } else { waypoints[n].x = 0 * 100 + internalMobNodeId * 200; waypoints[n].y = 2 * 100 + internalMobNodeId * 200; } } } waypoints[n].z = 10;// + internalMobNodeId; } par("nextX_0").setDoubleValue(0); par("nextY_0").setDoubleValue(0); par("nextZ_0").setDoubleValue(10); par("nextX_1").setDoubleValue(0 * 100 + internalMobNodeId*100); par("nextY_1").setDoubleValue(2 * 100 + internalMobNodeId*100); par("nextZ_1").setDoubleValue(10);// + internalMobNodeId); par("nextX_2").setDoubleValue(2 * 100 + internalMobNodeId*100); par("nextY_2").setDoubleValue(2 * 100 + internalMobNodeId*100); par("nextZ_2").setDoubleValue(10);// + internalMobNodeId); par("nextX_3").setDoubleValue(2 * 100 + internalMobNodeId*100); par("nextY_3").setDoubleValue(0 * 100 + internalMobNodeId*100); par("nextZ_3").setDoubleValue(10);// + internalMobNodeId); } int MobileNode::processMessage(inet::Packet *msg) { // O getname é o payload std::cout << "UAV-" << internalMobNodeId << " received: " << msg->getName() << endl; return 1; } string MobileNode::generateNextPacketToSend(){ std::ostringstream payload; payload << "Hi from " << "UAV-" << internalMobNodeId << "{" << ++sentMsgs << "}" << endl; return payload.str().c_str(); }; int MobileNode::refreshNextWayPoint() { //int um = 1; //std::cout << "\n\nrefreshNextWayPoint() = " << par("internalMobNodeId").intValue() << endl; return internalMobNodeId; } void MobileNode::handleMessage(cMessage *msg) { std::cout << " MobileNode::handleMessage: " << msg << endl; } //} //namespace
[ "bruno@olivieri.com.br" ]
bruno@olivieri.com.br
d32f30ac9fc860f5eb376c64d9d8ba960f1b7dd3
aec87add1dcaa69f84b9408bc6a9bf85363563f2
/tests/interface/TWNEOTests.cpp
8565c0813ffcedbbc6e79ae99e5509c4be57213c
[ "MIT" ]
permissive
maxUo/wallet-core
bd2396a8cf5a2907958359fcde24cdd09bddc4c8
13fc3733327749c5ecefa821da657290211df869
refs/heads/master
2020-12-30T02:40:08.927517
2020-02-06T13:36:32
2020-02-06T13:36:32
238,834,431
0
1
MIT
2020-02-07T03:17:45
2020-02-07T03:17:44
null
UTF-8
C++
false
false
1,354
cpp
// Copyright © 2017-2020 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. #include <TrustWalletCore/TWNEOSigner.h> #include <TrustWalletCore/TWCoinType.h> #include <TrustWalletCore/TWHash.h> #include <TrustWalletCore/TWHDWallet.h> #include <TrustWalletCore/TWHRP.h> #include "HexCoding.h" #include "TWTestUtilities.h" #include <gtest/gtest.h> using namespace TW; #include <iostream> TEST(NEO, ExtendedKeys) { auto wallet = WRAP(TWHDWallet, TWHDWalletCreateWithMnemonic( STRING("client recycle grass verb guitar battle abstract table they swamp accuse athlete recall ski light").get(), STRING("NEO").get() )); auto xpub = WRAPS(TWHDWalletGetExtendedPublicKey(wallet.get(), TWPurposeBIP44, TWCoinTypeNEO, TWHDVersionXPUB)); auto xprv = WRAPS(TWHDWalletGetExtendedPrivateKey(wallet.get(), TWPurposeBIP44, TWCoinTypeNEO, TWHDVersionXPRV)); assertStringsEqual(xpub, "xpub6CEwQUwgAnJmxNkb7CxuJGZN8FQNnqkKWeFjHqBEsD6PN267g3yNejdZyNEALzM7CxbQbtBzmndRjhvKyQDZoP8JrBLBQ8DJbhS1ge9Ln6F"); assertStringsEqual(xprv, "xprv9yFazyQnLQkUjtg81BRtw8cdaDZtPP2U9RL8VSmdJsZQVDky8Wf86wK687witsCZhYZCaRALSbGRVbLBuzDzbp6dpJFqnjnvNbiNV4JgrNY"); }
[ "noreply@github.com" ]
maxUo.noreply@github.com
ce3fb3184c9a7d1b79e8a3da026f5f0c0e324051
2a1cadc7c37e34e449f9a9ce159c29f425a8c82f
/mediatek/platform/mt6577/hardware/audio/aud_drv/AudioAnalogAfe.h
ec76406c612a86646a52a36f27c7bde35695a772
[]
no_license
abgoyal-archive/OT_5035E
31e74ab4fed05b8988acdc68c5a3af6b6381f43f
56d0850adfc5501ebb4a3b020bd1b985d5e9dcdc
refs/heads/master
2022-04-16T15:09:24.021237
2015-02-07T00:22:16
2015-02-07T00:22:16
30,439,232
0
2
null
2020-03-08T21:16:36
2015-02-07T00:20:49
C
UTF-8
C++
false
false
7,459
h
#ifndef ANDROID_AUDIO_ANALOGAFE_H #define ANDROID_AUDIO_ANALOGAFE_H #include <stdint.h> #include <sys/types.h> #include "AudioYusuDef.h" #ifndef ABB_MDSYS_BASE #define ABB_MDSYS_BASE (0xFD114000) #endif #define MIX_ABB_REGION (0x9B4) #define MIX_PMU_REGION (0x724) #define MASK_ALL (0xFFFFFFFF) typedef enum { AnalogAFE_MUTE_L = 0, AnalogAFE_MUTE_R = 1, AnalogAFE_MUTE_ALL = 2, AnalogAFE_MUTE_NONE = 3 } AnalogAFE_MUTE; typedef enum { AUDIO_PATH, VOICE_PATH, FM_PATH_MONO, FM_PATH_STEREO, FM_MONO_AUDIO, FM_STEREO_AUDIO, NONE_PATH }AnalogAFE_Mux; // AP_MDSYS #define WR_PATH0 (ABB_MDSYS_BASE+0x0100) #define WR_PATH1 (ABB_MDSYS_BASE+0x0104) #define WR_PATH2 (ABB_MDSYS_BASE+0x0108) #define ABIST_MON_CON0 (ABB_MDSYS_BASE+0x0220) #define ABIST_MON_CON1 (ABB_MDSYS_BASE+0x0224) #define ABIST_MON_CON2 (ABB_MDSYS_BASE+0x0228) #define ABIST_MON_CON3 (ABB_MDSYS_BASE+0x022C) #define ABIST_MON_CON4 (ABB_MDSYS_BASE+0x0230) #define ABIST_MON_CON5 (ABB_MDSYS_BASE+0x0234) #define ABIST_MON_CON6 (ABB_MDSYS_BASE+0x0238) #define ABIST_MON_CON7 (ABB_MDSYS_BASE+0x023C) #define ABIST_MON_CON8 (ABB_MDSYS_BASE+0x0240) #define AUDIO_CON0 (ABB_MDSYS_BASE+0x0300) #define AUDIO_CON1 (ABB_MDSYS_BASE+0x0304) #define AUDIO_CON2 (ABB_MDSYS_BASE+0x0308) #define AUDIO_CON3 (ABB_MDSYS_BASE+0x030C) #define AUDIO_CON4 (ABB_MDSYS_BASE+0x0310) #define AUDIO_CON5 (ABB_MDSYS_BASE+0x0314) #define AUDIO_CON6 (ABB_MDSYS_BASE+0x0318) #define AUDIO_CON7 (ABB_MDSYS_BASE+0x031C) #define AUDIO_CON8 (ABB_MDSYS_BASE+0x0320) #define AUDIO_CON9 (ABB_MDSYS_BASE+0x0324) #define AUDIO_CON10 (ABB_MDSYS_BASE+0x0328) #define AUDIO_CON11 (ABB_MDSYS_BASE+0x032C) #define AUDIO_CON12 (ABB_MDSYS_BASE+0x0330) #define AUDIO_CON13 (ABB_MDSYS_BASE+0x0334) #define AUDIO_CON14 (ABB_MDSYS_BASE+0x0338) #define AUDIO_CON15 (ABB_MDSYS_BASE+0x033C) #define AUDIO_CON16 (ABB_MDSYS_BASE+0x0340) #define AUDIO_CON17 (ABB_MDSYS_BASE+0x0344) #define AUDIO_CON20 (ABB_MDSYS_BASE+0x0380) #define AUDIO_CON21 (ABB_MDSYS_BASE+0x0384) #define AUDIO_CON22 (ABB_MDSYS_BASE+0x0388) #define AUDIO_CON23 (ABB_MDSYS_BASE+0x038C) #define AUDIO_CON24 (ABB_MDSYS_BASE+0x0390) #define AUDIO_CON25 (ABB_MDSYS_BASE+0x0394) #define AUDIO_CON26 (ABB_MDSYS_BASE+0x0398) #define AUDIO_CON27 (ABB_MDSYS_BASE+0x039C) #define AUDIO_CON28 (ABB_MDSYS_BASE+0x03A0) #define AUDIO_CON29 (ABB_MDSYS_BASE+0x03A4) #define AUDIO_CON30 (ABB_MDSYS_BASE+0x03A8) #define AUDIO_CON31 (ABB_MDSYS_BASE+0x03AC) #define AUDIO_CON32 (ABB_MDSYS_BASE+0x03B0) #define AUDIO_CON33 (ABB_MDSYS_BASE+0x03B4) #define AUDIO_CON34 (ABB_MDSYS_BASE+0x03B8) #define AUDIO_CON35 (ABB_MDSYS_BASE+0x03BC) #define AUDIO_NCP0 (ABB_MDSYS_BASE+0x0400) #define AUDIO_NCP1 (ABB_MDSYS_BASE+0x0404) #define AUDIO_LDO0 (ABB_MDSYS_BASE+0x0440) #define AUDIO_LDO1 (ABB_MDSYS_BASE+0x0444) #define AUDIO_LDO2 (ABB_MDSYS_BASE+0x0448) #define AUDIO_LDO3 (ABB_MDSYS_BASE+0x044C) #define AUDIO_GLB0 (ABB_MDSYS_BASE+0x0480) #define AUDIO_GLB1 (ABB_MDSYS_BASE+0x0484) #define AUDIO_GLB2 (ABB_MDSYS_BASE+0x0488) #define AUDIO_REG0 (ABB_MDSYS_BASE+0x04C0) #define AUDIO_REG1 (ABB_MDSYS_BASE+0x04C4) #define BBRX_CON0 (ABB_MDSYS_BASE+0x0A00) #define BBRX_CON1 (ABB_MDSYS_BASE+0x0A04) #define BBRX_CON2 (ABB_MDSYS_BASE+0x0A08) #define BBRX_CON3 (ABB_MDSYS_BASE+0x0A0C) #define BBRX_CON4 (ABB_MDSYS_BASE+0x0A10) #define BBRX_CON5 (ABB_MDSYS_BASE+0x0A14) #define BBRX_CON6 (ABB_MDSYS_BASE+0x0A18) #define BBRX_CON7 (ABB_MDSYS_BASE+0x0A1C) #define BBRX_CON8 (ABB_MDSYS_BASE+0x0A20) #define BBRX_CON9 (ABB_MDSYS_BASE+0x0A24) #define BBRX_CON10 (ABB_MDSYS_BASE+0x0A28) #define BBRX_CON11 (ABB_MDSYS_BASE+0x0A2C) #define BBRX_CON12 (ABB_MDSYS_BASE+0x0A30) #define BBRX_CON13 (ABB_MDSYS_BASE+0x0A34) #define BBRX_CON14 (ABB_MDSYS_BASE+0x0A38) #define BBRX_CON15 (ABB_MDSYS_BASE+0x0A3C) #define BBRX_CON16 (ABB_MDSYS_BASE+0x0A40) #define BBRX_CON17 (ABB_MDSYS_BASE+0x0A44) #define BBTX_CON0 (ABB_MDSYS_BASE+0x0A80) #define BBTX_CON1 (ABB_MDSYS_BASE+0x0A84) #define BBTX_CON2 (ABB_MDSYS_BASE+0x0A88) #define BBTX_CON3 (ABB_MDSYS_BASE+0x0A8C) #define BBTX_CON4 (ABB_MDSYS_BASE+0x0A90) #define BBTX_CON5 (ABB_MDSYS_BASE+0x0A94) #define BBTX_CON6 (ABB_MDSYS_BASE+0x0A98) #define BBTX_CON7 (ABB_MDSYS_BASE+0x0A9C) #define BBTX_CON9 (ABB_MDSYS_BASE+0x0AA4) #define BBTX_CON10 (ABB_MDSYS_BASE+0x0AA8) #define BBTX_CON11 (ABB_MDSYS_BASE+0x0AAC) #define BBTX_CON12 (ABB_MDSYS_BASE+0x0AB0) #define BBTX_CON13 (ABB_MDSYS_BASE+0x0AB4) #define BBTX_CON14 (ABB_MDSYS_BASE+0x0AB8) #define BBTX_CON15 (ABB_MDSYS_BASE+0x0ABC) #define BBTX_CON16 (ABB_MDSYS_BASE+0x0AC0) #define APC_CON0 (ABB_MDSYS_BASE+0x0C00) #define APC_CON1 (ABB_MDSYS_BASE+0x0C04) #define VBIAS_CON0 (ABB_MDSYS_BASE+0x0C40) #define VBIAS_CON1 (ABB_MDSYS_BASE+0x0C44) #define AFC_CON0 (ABB_MDSYS_BASE+0x0CC0) #define AFC_CON1 (ABB_MDSYS_BASE+0x0CC4) #define AFC_CON2 (ABB_MDSYS_BASE+0x0CC8) #define BBTX_CON17 (ABB_MDSYS_BASE+0x0F00) #define BBTX_CON18 (ABB_MDSYS_BASE+0x0F04) namespace android { class AudioYusuHardware; class AudioAnalog { public: AudioAnalog(AudioYusuHardware *hw); ~AudioAnalog(); void SetAnaReg(uint32 offset,uint32 value, uint32 mask); void GetAnaReg(uint32 offset,uint32 *value); void AnalogAFE_Open(AnalogAFE_Mux mux); void AnalogAFE_Close(AnalogAFE_Mux mux); void AnalogAFE_ChangeMux(AnalogAFE_Mux mux); void AnalogAFE_Depop(AnalogAFE_Mux mux, bool Enable); void AnalogAFE_Set_Mute(AnalogAFE_MUTE MuteType); void AnalogAFE_EnableHeadset(bool Enable); bool AnalogAFE_Init(uint32 Fd); bool AnalogAFE_Deinit(void); void EnableHeadset(bool Enable); void AnalogAFE_Set_DL_AUDHPL_PGA_Gain(int gain_value); void AnalogAFE_Set_DL_AUDHPR_PGA_Gain(int gain_value); void AnalogAFE_Recover(void); void AnalogAFE_Set_LineIn_Gain(int gain_value); void AnalogAFE_Request_ANA_CLK(void); void AnalogAFE_Release_ANA_CLK(void); //#ifdef AUDIO_HQA_SUPPORT void HQA_AFE_Set_DL_AUDHS_PGA_Gain(int gain_value); void HQA_AFE_Set_DL_AUDHPL_PGA_Gain(int gain_value); void HQA_AFE_Set_DL_AUDHPR_PGA_Gain(int gain_value); void HQA_AFE_Set_AUD_LineIn_Gain(int gain_value); void Afe_Set_AUD_Level_Shift_Buf_L_Gain(int gain_value); void Afe_Set_AUD_Level_Shift_Buf_R_Gain(int gain_value); void HQA_AFE_Set_AUD_UL_ANA_PreAMP_L_Gain(int gain_value); void HQA_AFE_Set_AUD_UL_ANA_PreAMP_R_Gain(int gain_value); void HQA_Analog_AFE_Select_Audio_Voice_Buffer(int gain_value); // 1:Audio Buffer, 2:Voice Buffer void HQA_Audio_LineIn_Record(int bEnable); void HQA_Audio_LineIn_Play(int bEnable); //#endif private: AudioYusuHardware *mAudioHardware; int mFd; pthread_mutex_t depopMutex; //used for depop flow //#ifdef AUDIO_HQA_SUPPORT int m_audio_voice_DAC_sel; //#endif }; }; // namespace android #endif
[ "abgoyal@gmail.com" ]
abgoyal@gmail.com
a88d48a7ad9cea117a5ee4fe23980e4a8937a6b5
2ef8f10d0d6ff404c87c9f290833131464b42167
/2/2_You_jump_I_jump_3/2_You_jump_I_jump_3.cpp
9ad411f6a3511469a306dbb6b9f63fe895fc2694
[]
no_license
EventideX/Class
ccfb7b9c41e183207f8d3ffe05d98e03ef9f39b4
18b70997bdf47aeb603093afe4458fde7bcfeb3a
refs/heads/master
2021-01-17T21:54:14.084637
2017-03-12T14:44:37
2017-03-12T14:44:37
84,183,464
0
0
null
null
null
null
UTF-8
C++
false
false
340
cpp
#include<iostream> using namespace std; int main() { int i, j, k, n, m, s, t, a[10001] = { 0 }, x, y; cin >> n >> x >> y; t = 0; i = 1; j = 1; k = 0; while (t == 0) { i += x; j += y; if (i > n) i = i - n; if (j > n) j = j - n; a[i]++; a[j]++; k++; if ((a[i] > 1) || (a[j] > 1)) t = 1; } cout << k; return 0; }
[ "844058637@qq.com" ]
844058637@qq.com
20d6d432049f37e9c4a5f704e7b8652da6d1416a
a69574670179ba33bc67d9de6004c27fbefc6638
/topcoder/TCO11 Wildcard/250.cpp
4254fed5ea838f464b9723783e5e58f1372e7abf
[]
no_license
ashpsycho/CP
d60516ad6aad6a5045053344acb99210d954c53f
1ae2d9825363c4d25ed2c865b04223a48d6b1f6a
refs/heads/master
2021-01-18T23:37:19.382933
2018-06-05T11:02:39
2018-06-05T11:02:39
48,465,588
0
0
null
null
null
null
UTF-8
C++
false
false
854
cpp
#include <bits/stdc++.h> using namespace std; class EventOrder{ public: int getCount(int longE,int inst){ long long i,j,k=0,mod=1000000009L, dp[2][3004]; for(i=0;i<2;i++) for(j=0;j<3002;j++)dp[i][j]=0; dp[0][0]=1; for(i=0;i<longE;i++){ for(j=0;j<3002;j++){ dp[1][j]=(dp[1][j]+((j*(j-1))/2)*dp[0][j])%mod; dp[1][j+1]=(dp[1][j+1]+j*(j+1)*dp[0][j])%mod; dp[1][j+2]=(dp[1][j+2]+(((j+2)*(j+1))/2)*dp[0][j])%mod; } for(j=0;j<3002;j++){ dp[0][j]=dp[1][j]; dp[1][j]=0; } } for(i=0;i<inst;i++){ for(j=0;j<3002;j++){ dp[1][j]=(dp[1][j]+j*dp[0][j])%mod; dp[1][j+1]=(dp[1][j+1]+(j+1)*dp[0][j])%mod; } for(j=0;j<3002;j++){ dp[0][j]=dp[1][j]; dp[1][j]=0; } } for(i=0;i<=(2*(longE+inst));i++)cout<<dp[0][i]<<" "; cout<<"\n"; for(i=k=0;i<3002;i++)k=(k+dp[0][i])%mod; return k; } };
[ "lavania_a@worksap.co.jp" ]
lavania_a@worksap.co.jp
a661c438c4f7c5f3978590045c9d6c1d3945f128
aafccc71b3ba659a9b6a606d805d9889c9fabc09
/codechef/jan2014long/error.cpp
485709f1c2995802b1555a4383db24418c90d228
[]
no_license
abhashksingh/practice-programs
6bf37670e8f385a2bb274bb14ffb9052944a9ab5
02602f61ad4812726dedb6c760c81dc647244b8c
refs/heads/master
2021-01-25T05:23:09.630415
2014-08-24T17:07:10
2014-08-24T17:07:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
409
cpp
#include <iostream> #include <string> #include <algorithm> #include <stdio.h> using namespace std; int main() { string inp,c1="010",c2="101"; long long t; size_t r1,r2; scanf("%lld",&t); cin.ignore(); while(t--) { getline(cin,inp); r1 = inp.find(c1); r2 = inp.find(c2); if((r1!=string::npos)&&(r2!=string::npos)) { printf("%s","Good\n"); } else { printf("%s","Bad\n"); } } }
[ "superabhash@gmail.com" ]
superabhash@gmail.com
2dd31397f0bab427098a38f6f253bec0f72eec04
71e7675390503901564239473b56ad26bdfa13db
/src/zoidfs/ftb/FTBClient.cpp
05e489198abd0c5ccd1d656abec6c4a9c8e7706e
[]
no_license
radix-io-archived/iofsl
1b5263f066da8ca50c7935009c142314410325d8
35f2973e8648ac66297df551516c06691383997a
refs/heads/main
2023-06-30T13:59:18.734208
2013-09-11T15:24:26
2013-09-11T15:24:26
388,571,488
0
0
null
null
null
null
UTF-8
C++
false
false
3,020
cpp
#include "FTBClient.hh" #include "ServerSelector.hh" #include "iofwdutil/IOFWDLog.hh" #include "common/ftb/ftb.pb.h" #include <arpa/inet.h> #include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/format.hpp> #include <ftb.h> using boost::format; namespace zoidfs { //=========================================================================== FTBClient::FTBClient (ServerSelector & sel) : sel_ (sel), log_ (iofwdutil::IOFWDLog::getSource ("ftbclient")) { FTB_client_t clientinfo; strcpy (clientinfo.event_space, "IOFSL.IOFSL.IOFSL"); strcpy (clientinfo.client_name, "iofslclient"); strcpy (clientinfo.client_jobid, "blabla"); strcpy (clientinfo.client_subscription_style, "FTB_SUBSCRIPTION_POLLING"); clientinfo.client_polling_queue_len=0; checkFTB (FTB_Connect (&clientinfo, &handle_)); checkFTB (FTB_Subscribe (&sub_, handle_, "", 0, 0)); ZLOG_INFO(log_, "FTBClient initialized..."); } void FTBClient::poll () { FTB_receive_event_t event; const int ret = FTB_Poll_event (sub_, &event); if (ret != FTB_SUCCESS) { if (ret != FTB_GOT_NO_EVENT) checkFTB (ret); return; } ZLOG_INFO (log_, format("Received event: %s %s") % event.event_space % event.event_name); parseData (&event.event_payload[0], sizeof(event.event_payload)); } void FTBClient::parseData (const void * p, size_t size) { ftb::LoadUpdate info; const char * ptr = static_cast<const char*>(p); size_t used = 0; uint32_t len = ntohl (*(const uint32_t*) ptr); ptr += sizeof (uint32_t); used += sizeof (uint32_t); if (used + len >= size) return; if (!info.ParseFromArray (ptr, len)) { ZLOG_ERROR (log_, format("Could not decode FTB event!")); return; } ZLOG_ERROR(log_, format("Event: %s %f") % info.id().location () % info.load()); boost::uuids::uuid u = boost::uuids::nil_uuid (); const std::string & uuid = info.id().uuid(); // invalid uuid if (uuid.size() != 16) return; std::copy (uuid.begin(), uuid.end (), u.begin()); // Ignore invalid uuids if (u.is_nil()) return; sel_.updateServerInfo (u, info.id().location ().c_str(), info.load ()); } FTBClient::~FTBClient () { checkFTB (FTB_Disconnect (handle_)); } int FTBClient::checkFTB (int ret) const { if (ret == FTB_SUCCESS) return ret; ZLOG_ERROR (log_, format("FTB returned error: %i") % ret); return ret; } //=========================================================================== }
[ "dkimpe@mcs.anl.gov" ]
dkimpe@mcs.anl.gov
5ca97377bae739c51c0e5c7ba86db2577212ff4d
17e7f2f8b786ee8361b9b755740e816411751b76
/NexusNative/nnetwork/ntcp_server.h
daaca79435c4943d98aca7a70fa4ecd1c113c2a1
[]
no_license
windless1015/My3DEngine2008
880945bd9d9f5e9a2ed30fe869ee53ec5b4fe2da
6fffdd1b158ba9c63ffd564788fddd5706e08ac0
refs/heads/master
2022-11-13T17:41:46.620000
2020-07-02T13:31:19
2020-07-02T13:31:19
null
0
0
null
null
null
null
GB18030
C++
false
false
5,139
h
/** * nexus network - ntcp_server * * Copyright (C) 2010 NexusDev * * Author: D. Zhao * Date: Feb, 2010 */ #ifndef _NNETWORK_NTCP_SERVER_H_ #define _NNETWORK_NTCP_SERVER_H_ #include "ncommon.h" #include "nnetwork_def.h" #include "ntcp_session.h" #include <boost/thread/thread.hpp> namespace nexus { /** * ntcp_server广域网服务器端通信底层 */ class nNET_API ntcp_server : private nnoncopyable { private: friend class ntcp_session; public: ntcp_server(); virtual ~ntcp_server(); /** * 启动服务器监听指定端口的任意地址 */ bool startup(const ntcp_server_config& param); /** * 关闭服务器,该函数所在执行线程不被强制关闭,建议在主线程中关闭 */ void shutdown(); /** * 向指定连接发送数据,内部采用引用计数的方式访问数据 * 如果同一nmessage被send多次要先置所有的引用次数再调用send, server内部会释放nmessage内存数据 * @param session_id 连接id * @param msg_ptr 共享消息的地址 * @param size 发送数据的实际长度 */ NINLINE bool send(uint32 session_id, nmessage* msg_ptr, uint32 size) { if ((session_id & 0X0000FFFF) >= m_ntcp_server_param.max_session) { msg_ptr->dec_reference(); return false; } return m_sessions_ptr[session_id & 0X0000FFFF].send(session_id, msg_ptr, size); } /** * 关闭指定连接 * @param session_id 连接id */ NINLINE void close(uint32 session_id) { if ((session_id & 0X0000FFFF) >= m_ntcp_server_param.max_session) { return; } return m_sessions_ptr[session_id & 0X0000FFFF].close(session_id); } /** * 新连接建立回调函数, 注意线程安全 * note: 函数不要处理过多的逻辑,封装一个消息投递到统一的逻辑消息队列 * @param session_id 连接id * @param address 连接ip地址 * @param port 连接端口 */ virtual void on_connect(uint32 session_id, uint32 address, uint32 port) {} /** * 消息接收回调函数, 注意线程安全 * note: recv nmessage 的引用计数都为0,调用回调后网络底层不在引用该内存 * 函数不要处理过多的逻辑,转发消息或将消息投递到统一的逻辑消息队列 * @param session_id 连接id * @param msg_ptr 消息地址 * @param port 消息的实际长度 */ virtual void on_datarecv(uint32 session_id, nmessage* msg_ptr, uint32 size) {} /** * 连接关闭回调函数, 注意线程安全 * note: 函数不要处理过多的逻辑,封装一个消息投递到统一的逻辑线程队列 * @param session_id 连接id */ virtual void on_disconnect(uint32 session_id) {} private: // 释放该类申请的内存资源 void _free_memory(); // iocp工作线程负责处理完成包 void _worker_thread(int32 thread_index); // 异步accpet请求 void _async_accept(); // 异步accpet请求响应回调 void _handle_accept(ntcp_session* session_ptr, DWORD last_error, nsafe_mem_pool* pool_ptr); // 向完成端口投递一个close回调请求 NINLINE void _post_close_call_back(uint32 session_id) { if (0XFFFFFFFF == session_id) { return; } ::PostQueuedCompletionStatus(m_completion_port, 0, (ULONG_PTR)session_id, 0); } NINLINE void _handle_close(uint32 session_id) { if ((session_id & 0X0000FFFF) >= m_ntcp_server_param.max_session) { return; } // 回调上层关闭函数 on_disconnect(session_id); // 将session归还个连接管理池 _return_session(&(m_sessions_ptr[session_id & 0X0000FFFF])); _async_accept(); } // 取得一个可用的会话 NINLINE ntcp_session* _get_available_session() { nguard<nfast_mutex> guard(m_mutex); if (TSVRS_OPEN != m_status || m_available_sessions.empty()) { return NULL; } ntcp_session* temp_ptr = m_available_sessions.front(); m_available_sessions.pop_front(); temp_ptr->_pre_accept(); return temp_ptr; } // 归还一个关闭的会话 NINLINE void _return_session(ntcp_session* session_ptr) { nguard<nfast_mutex> guard(m_mutex); if (!session_ptr) { return; } m_available_sessions.push_back(session_ptr); } private: SOCKET m_sock_listen; // 监听socket HANDLE m_completion_port; // 服务器完成端口 LPFN_ACCEPTEX m_fn_acceptex; LPFN_GETACCEPTEXSOCKADDRS m_fn_get_acceptex_sock_addr; volatile LONG m_acceptexs; // 放出的AcceptEx数量 nfast_mutex m_mutex; // 保护连接池线程安全及server状态改变 ntcp_session* m_sessions_ptr; std::list<ntcp_session*> m_available_sessions; boost::thread_group m_threads; // 线程池 ntcp_server_config m_ntcp_server_param; LONG m_max_acceptex; nsafe_mem_pool* m_pools_ptr; // 内存池 TCPServerStatus m_status; }; } // namespace nexus #endif _NNETWORK_NTCP_SERVER_H_
[ "neil3d@126.com" ]
neil3d@126.com
17d3a7a1f3fb2fd05fda153f59ca72c40b7636ca
6fad097d94153a3bb5d504908721064b40f38bd0
/eh-sim/src/simulate.hpp
8a50133955b7dafd422586c3345301ae2a8d4654
[ "MIT" ]
permissive
charleyXuTO/thumbulator
8aecbe605bdbe42932aefcf5a5d0e5109e6d12fd
487dfac96d88948ea2a316244ca7b952e5dce5c6
refs/heads/master
2020-05-23T18:01:27.330962
2018-07-06T18:24:14
2018-07-06T18:24:14
186,878,961
0
0
null
2019-05-15T18:05:15
2019-05-15T18:05:14
null
UTF-8
C++
false
false
705
hpp
#ifndef EH_SIM_SIMULATE_HPP #define EH_SIM_SIMULATE_HPP #include <chrono> #include <cstdint> namespace ehsim { class eh_scheme; struct stats_bundle; class voltage_trace; /** * Simulate an energy harvesting device. * * @param binary_file The path to the application binary file. * @param power The power supply over time. * @param scheme The energy harvesting scheme to use. * @param always_harvest true to harvest always, false to harvest during off periods only. * * @return The statistics tracked during the simulation. */ stats_bundle simulate(char const *binary_file, ehsim::voltage_trace const &power, eh_scheme *scheme, bool always_harvest); } #endif //EH_SIM_SIMULATE_HPP
[ "mario.badr@outlook.com" ]
mario.badr@outlook.com
0ff5fe476bd1749edd16259586c393bd797a89db
198f1f5606add5d11ecc7f264e11e83e05de92e7
/Classes/not used/SensoryMemory.cpp
826cc558e5e1eda0cb40819fcccbb46b2454788f
[]
no_license
jsenter/MOBAclient
407c6a44441976adbd0d040cb6ac8548fb254a6d
490924a9bbfccd9fe54f9b1916fd70be32b18326
refs/heads/master
2021-01-15T21:30:31.820134
2016-11-26T05:12:38
2016-11-26T05:12:38
null
0
0
null
null
null
null
UHC
C++
false
false
11,259
cpp
#include "SensoryMemory.h" #include "GameWorld.h" #include "AbstCharacter.h" #include "Timer/CrudeTimer.h" #include "SteeringBehavior.h" USING_NS_CC; std::stringstream & operator<<(std::stringstream &ss, const MemoryRecord& m) { ss << m.attackable << std::endl << m.within_view << std::endl << m.time_became_visible << std::endl << m.time_last_sensed << std::endl << m.time_last_visible << std::endl << m.recent_damage << std::endl << m.last_sensed_position.x << ", " << m.last_sensed_position.y << std::endl; return ss; } //------------------------------- ctor ---------------------------------------- //----------------------------------------------------------------------------- SensoryMemory::SensoryMemory( AbstCharacter* const owner, double memory_span) : _owner(owner), _memory_span(memory_span) { //--------------------------"Rendering Setting-------------------------------// _memory_label = Label::createWithTTF( "", Prm.FontFolderName + "/" + "arial" + ".ttf", 11); float min_x = owner->getNowSprite()->getBoundingBox().getMinX(); float min_y = owner->getNowSprite()->getBoundingBox().getMinY(); float max_x = owner->getNowSprite()->getBoundingBox().getMaxX(); float max_y = owner->getNowSprite()->getBoundingBox().getMaxY(); _memory_label->setVerticalAlignment(cocos2d::TextVAlignment::TOP); _memory_label->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); _memory_label->setAnchorPoint(Vec2(1, 1)); RenderUtil::labelSetting( owner->getNowSprite(), _memory_label, Vec2(0, max_y - min_y)); _memory_label->setVisible(Prm.RenderMemoryLabel); } SensoryMemory::~SensoryMemory() { _memory_label->removeFromParent(); } //--------------------- makeNewRecordIfNotAlreadyPresent ---------------------- void SensoryMemory::makeNewRecordIfNotAlreadyPresent(AbstCharacter* const opponent) { //else check to see if this Opponent already exists in the memory. If it doesn't, //create a new record if (_memory_map.find(opponent) == _memory_map.end()) { _memory_map[opponent] = MemoryRecord(); } } //------------------------ removeBotFromMemory -------------------------------- // // this removes a bot's record from memory //----------------------------------------------------------------------------- void SensoryMemory::removeBotFromMemory(AbstCharacter* const bot) { MemoryMap::iterator record = _memory_map.find(bot); if (record != _memory_map.end()) { _memory_map.erase(record); } } //----------------------- updateWithSoundSource ------------------------------- // // this updates the record for an individual opponent. Note, there is no need to // test if the opponent is within the FOV because that test will be done when the // updateVision method is called //----------------------------------------------------------------------------- void SensoryMemory::updateWithSoundSource(AbstCharacter* const noise_maker) { //make sure the bot being examined is not this bot if (_owner != noise_maker) { //if the bot is already part of the memory then update its data, else //create a new memory record and add it to the memory makeNewRecordIfNotAlreadyPresent(noise_maker); MemoryRecord& info = _memory_map[noise_maker]; //test if there is LOS between bots if (_owner->getWorld()->isLOSOkay(_owner->getPos(), noise_maker->getPos())) { info.attackable = true; //record the position of the bot info.last_sensed_position = noise_maker->getPos(); } else { info.attackable = false; } //record the time it was sensed info.time_last_sensed = (double)Clock.getCurrentTime(); } } //----------------------- updateWithDamageSource ------------------------------- // // this updates the record for an individual opponent. Note, there is no need to // test if the opponent is within the FOV because that test will be done when the // updateVision method is called // 때린사람 위치 기억. //----------------------------------------------------------------------------- void SensoryMemory::updateWithDamageSource(AbstCharacter* const shooter, int damage) { if (shooter == nullptr) return; //make sure the bot being examined is not this bot if (_owner != shooter) // probably not possible { //if the bot is already part of the memory then update its data, else //create a new memory record and add it to the memory makeNewRecordIfNotAlreadyPresent(shooter); MemoryRecord& info = _memory_map[shooter]; info.recent_damage += damage; //test if there is LOS between bots if (_owner->getWorld()->isLOSOkay(_owner->getPos(), shooter->getPos())) { //record the position of the bot info.last_sensed_position = shooter->getPos(); } else { info.attackable = false; } //record the time it was sensed info.time_last_sensed = (double)Clock.getCurrentTime(); } } //----------------------------- updateVision ---------------------------------- // // this method iterates through all the bots in the game world to test if // they are in the field of view. Each bot's memory record is updated // accordingly //----------------------------------------------------------------------------- void SensoryMemory::updateVision() { _owner->getWorld()->getGameMap()->getAgentCellSpace()-> calculateNeighborsForSmall( _owner->getPos(), &geometry::Circle( _owner->getPos(), _owner->getSteering()->getViewDistance())); for (auto iter = _owner->getWorld()->getGameMap()->getAgentCellSpace()->begin(); !_owner->getWorld()->getGameMap()->getAgentCellSpace()->end(); iter = _owner->getWorld()->getGameMap()->getAgentCellSpace()->next()) { if (_owner != iter) { //make sure it is part of the memory map makeNewRecordIfNotAlreadyPresent(iter); //get a reference to this bot's data MemoryRecord& info = _memory_map[iter]; if (util::inRange( _owner->getPos(), iter->getPos(), _owner->getSteering()->getViewDistance())) { info.time_last_sensed = Clock.getCurrentTime(); info.last_sensed_position = iter->getPos(); info.time_last_visible = Clock.getCurrentTime(); float tolerance = 20.0f; if (util::inRange( iter->getPos(), _owner->getPos(), _owner->getBRadius() + iter->getBRadius() + tolerance)) { info.attackable = true; } else info.attackable = false; if (info.within_view == false) { info.within_view = true; info.time_became_visible = info.time_last_sensed; } } else { info.attackable = false; info.within_view = false; } } } } void SensoryMemory::render() { if (!Prm.RenderMemoryLabel) return; std::stringstream ss; ss << "Memory\n"; for (auto it = std::begin(_memory_map); it != std::end(_memory_map); it++) { ss << "Id : " << it->first->getId() << std::endl; ss << it->second << std::endl; } _memory_label->setString(ss.str()); } //------------------------ getListOfRecentlySensedOpponents ------------------- // // returns a list of the bots that have been sensed recently //----------------------------------------------------------------------------- std::list<AbstCharacter*> SensoryMemory::getListOfRecentlySensedOpponents()const { //this will store all the opponents the bot can remember std::list<AbstCharacter*> opponents; double current_time = Clock.getCurrentTime(); MemoryMap::const_iterator rec = _memory_map.begin(); for (rec; rec != _memory_map.end(); ++rec) { //if this bot has been updated in the memory recently, add to list if ((current_time - rec->second.time_last_sensed) <= _memory_span) { opponents.push_back(rec->first); } } return opponents; } //----------------------------- isOpponentAttackable -------------------------------- // // returns true if the bot given as a parameter can be shot (ie. its not // obscured by walls) //----------------------------------------------------------------------------- bool SensoryMemory::isOpponentAttackable(AbstCharacter* const opponent)const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end()) { return it->second.attackable; } return false; } //----------------------------- isOpponentWithinFOV -------------------------------- // // returns true if the bot given as a parameter is within FOV //----------------------------------------------------------------------------- bool SensoryMemory::isOpponentWithinFOV(AbstCharacter* const opponent) const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end()) { return it->second.within_view; } return false; } //---------------------------- getLastRecordedPositionOfOpponent ------------------- // // returns the last recorded position of the bot //----------------------------------------------------------------------------- Vec2 SensoryMemory::getLastRecordedPositionOfOpponent(AbstCharacter* const opponent) const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end()) { return it->second.last_sensed_position; } throw std::runtime_error("< SensoryMemory::getLastRecordedPositionOfOpponent>: Attempting to get position of unrecorded bot"); } //----------------------------- getTimeOpponentHasBeenVisible ---------------------- // // returns the amount of time the given bot has been visible //----------------------------------------------------------------------------- double SensoryMemory::getTimeOpponentHasBeenVisible(AbstCharacter* const opponent) const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end() && it->second.within_view) { return Clock.getCurrentTime() - it->second.time_became_visible; } return 0; } int SensoryMemory::getDamage(AbstCharacter* const opponent)const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end()) { return it->second.recent_damage; } return 0; } //-------------------- getTimeOpponentHasBeenOutOfView ------------------------ // // returns the amount of time the given opponent has remained out of view // returns a high value if opponent has never been seen or not present //----------------------------------------------------------------------------- double SensoryMemory::getTimeOpponentHasBeenOutOfView(AbstCharacter* const opponent)const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end()) { return Clock.getCurrentTime() - it->second.time_last_visible; } return std::numeric_limits<double>::max(); } //------------------------ getTimeSinceLastSensed ---------------------- // // returns the amount of time the given bot has been visible //----------------------------------------------------------------------------- double SensoryMemory::getTimeSinceLastSensed(AbstCharacter* const opponent)const { MemoryMap::const_iterator it = _memory_map.find(opponent); if (it != _memory_map.end() && it->second.within_view) { return Clock.getCurrentTime() - it->second.time_last_sensed; } return 0; } bool SensoryMemory::isUnderAttack() const { MemoryMap::const_iterator rec = _memory_map.begin(); for (rec; rec != _memory_map.end(); ++rec) { //if this bot has hit us, return true if ((*rec).second.recent_damage > 0) return true; } return false; }
[ "insooneelife@naver.com" ]
insooneelife@naver.com
1d519b46b14d062a7550bd6c0286c51969077f1c
ef836b7ae3cc245f466c55cb1e351d5bda4220c7
/qtTeamTalk/filesview.cpp
ea306bfec638f81baf4434677d780f311b3f5b19
[]
no_license
DevBDK/TeamTalk5
1e26cc2bcba87fd1079e070079cf82f4d78e5a4c
14d4cf040a49521cc44c94df85fe4cfef91e7729
refs/heads/master
2021-01-12T00:11:10.644407
2017-02-20T08:09:32
2017-02-20T08:09:32
78,031,402
0
0
null
2017-01-11T21:14:24
2017-01-04T16:11:58
C++
UTF-8
C++
false
false
2,630
cpp
/* * Copyright (c) 2005-2016, BearWare.dk * * Contact Information: * * Bjoern D. Rasmussen * Kirketoften 5 * DK-8260 Viby J * Denmark * Email: contact@bearware.dk * Phone: +45 20 20 54 59 * Web: http://www.bearware.dk * * This source code is part of the TeamTalk 5 SDK owned by * BearWare.dk. All copyright statements may not be removed * or altered from any source distribution. If you use this * software in a product, an acknowledgment in the product * documentation is required. * */ #include "filesview.h" #include <QDragEnterEvent> #include <QUrl> #include <QFileInfo> #include <QMimeData> #include "common.h" #include "filesmodel.h" extern TTInstance* ttInst; FilesView::FilesView(QWidget* parent) : QTreeView(parent) { setAcceptDrops(true); } QList<int> FilesView::selectedFiles(QStringList* fileNames/* = NULL*/) { QItemSelectionModel* sel = selectionModel(); QModelIndexList indexes = sel->selectedRows();//selectedIndexes (); QList<int> files; for(int i=0;i<indexes.size();i++) { files.push_back(indexes[i].internalId()); if(fileNames) fileNames->push_back(indexes[i].data(COLUMN_INDEX_NAME).toString()); } return files; } void FilesView::dragEnterEvent(QDragEnterEvent *event) { if((TT_GetFlags(ttInst) & CLIENT_AUTHORIZED) == 0) return; foreach(QUrl url, event->mimeData()->urls()) if (!url.isEmpty()) { event->acceptProposedAction(); return; } } void FilesView::dragMoveEvent(QDragMoveEvent * event) { if((TT_GetFlags(ttInst) & CLIENT_AUTHORIZED) == 0) return; foreach(QUrl url, event->mimeData()->urls()) if (!url.isEmpty()) { event->acceptProposedAction(); return; } } void FilesView::dropEvent(QDropEvent *event) { QStringList files; foreach(QUrl url, event->mimeData()->urls()) files.push_back(url.toLocalFile()); emit(uploadFiles(files)); } void FilesView::mousePressEvent(QMouseEvent* event ) { QTreeView::mousePressEvent(event); //QDrag* drag = new QDrag(this); //QMimeData* mimedata = new QMimeData();; ////QList<QUrl> urls; ////urls.push_back(QUrl("foo.txt")); ////mimedata->setUrls(urls); ////drag->setMimeData(mimedata); //int ret = drag->exec(Qt::CopyAction); //mimedata = drag->mimeData(); //ret = ret; } void FilesView::slotNewSelection(const QItemSelection & selected) { emit(filesSelected(selected.size()>0)); }
[ "contact@bearware.dk" ]
contact@bearware.dk
02567772f8c35d2caa6f13bdcd89c0fe104024da
74fafa521fc4ebe7fb7d47b7ca9df76ae8028143
/CBProjects/game1/blackbox.cpp
968a13808fbf66bbf619e3630c8fec9209d34b1d
[]
no_license
JKick101/sometrash
e1be4da20d5c3b2150871eb970c168583ea12590
9f9d8c18c5fdcd7e969085b6fbe28ad8447ac830
refs/heads/master
2021-07-20T01:17:49.976513
2017-10-29T00:02:26
2017-10-29T00:02:26
108,422,662
0
0
null
null
null
null
UTF-8
C++
false
false
12,064
cpp
// BLACKBOX.CPP - Game Engine // INCLUDES /////////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN // make sure all macros are included #include <windows.h> // include important windows stuff #include <windowsx.h> #include <mmsystem.h> #include <iostream> // include important C/C++ stuff #include <conio.h> #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <string.h> #include <stdarg.h> #include <stdio.h> #include <math.h> #include <io.h> #include <fcntl.h> #include <ddraw.h> // directX includes #include "blackbox.h" // game library includes #pragma comment (lib,"d3d9.lib") #pragma comment (lib,"d3dx9.lib") //DDraw #pragma comment (lib,"DDraw.lib") // DEFINES //////////////////////////////////////////////////// // TYPES ////////////////////////////////////////////////////// // PROTOTYPES ///////////////////////////////////////////////// // EXTERNALS ////////////////////////////////////////////////// extern HWND main_window_handle; // save the window handle extern HINSTANCE main_instance; // save the instance // GLOBALS //////////////////////////////////////////////////// LPDIRECTDRAW7 lpdd = NULL; // dd object LPDIRECTDRAWSURFACE7 lpddsprimary = NULL; // dd primary surface LPDIRECTDRAWSURFACE7 lpddsback = NULL; // dd back surface LPDIRECTDRAWPALETTE lpddpal = NULL; // a pointer to the created dd palette LPDIRECTDRAWCLIPPER lpddclipper = NULL; // dd clipper PALETTEENTRY palette[256]; // color palette PALETTEENTRY save_palette[256]; // used to save palettes DDSURFACEDESC2 ddsd; // a direct draw surface description struct DDBLTFX ddbltfx; // used to fill DDSCAPS2 ddscaps; // a direct draw surface capabilities struct HRESULT ddrval; // result back from dd calls DWORD start_clock_count = 0; // used for timing // these defined the general clipping rectangle int min_clip_x = 0, // clipping rectangle max_clip_x = SCREEN_WIDTH-1, min_clip_y = 0, max_clip_y = SCREEN_HEIGHT-1; // these are overwritten globally by DD_Init() int screen_width = SCREEN_WIDTH, // width of screen screen_height = SCREEN_HEIGHT, // height of screen screen_bpp = SCREEN_BPP; // bits per pixel // FUNCTIONS ////////////////////////////////////////////////// int DD_Init(int width, int height, int bpp) { // this function initializes directdraw int index; // looping variable // create object and test for error if (DirectDrawCreateEx(NULL, reinterpret_cast<void **>(&lpdd), IID_IDirectDraw7, NULL)!=DD_OK) return(0); // set cooperation level to windowed mode normal if (lpdd->SetCooperativeLevel(main_window_handle, DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)!=DD_OK) return(0); // set the display mode if (lpdd->SetDisplayMode(width,height,bpp,0,0)!=DD_OK) return(0); // set globals screen_height = height; screen_width = width; screen_bpp = bpp; // Create the primary surface memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; // we need to let dd know that we want a complex // flippable surface structure, set flags for that ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; // set the backbuffer count to 1 ddsd.dwBackBufferCount = 1; // create the primary surface lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL); // query for the backbuffer i.e the secondary surface ddscaps.dwCaps = DDSCAPS_BACKBUFFER; lpddsprimary->GetAttachedSurface(&ddscaps,&lpddsback); // create and attach palette // create palette data // clear all entries defensive programming memset(palette,0,256*sizeof(PALETTEENTRY)); // create a R,G,B,GR gradient palette for (index=0; index < 256; index++) { // set each entry if (index < 64) palette[index].peRed = index*4; else // shades of green if (index >= 64 && index < 128) palette[index].peGreen = (index-64)*4; else // shades of blue if (index >= 128 && index < 192) palette[index].peBlue = (index-128)*4; else // shades of grey if (index >= 192 && index < 256) palette[index].peRed = palette[index].peGreen = palette[index].peBlue = (index-192)*4; // set flags palette[index].peFlags = PC_NOCOLLAPSE; } // end for index // now create the palette object if (lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_INITIALIZE | DDPCAPS_ALLOW256, palette,&lpddpal,NULL)!=DD_OK) return(0); // attach the palette to the primary if (lpddsprimary->SetPalette(lpddpal)!=DD_OK) return(0); // clear out both primary and secondary surfaces DD_Fill_Surface(lpddsprimary,0); DD_Fill_Surface(lpddsback,0); // attach a clipper to the screen RECT screen_rect = {0,0,screen_width,screen_height}; lpddclipper = DD_Attach_Clipper(lpddsback,1,&screen_rect); // return success return(1); } // end DD_Init /////////////////////////////////////////////////////////////// int DD_Shutdown(void) { // this function release all the resources directdraw // allocated, mainly to com objects // release the clipper first if (lpddclipper) lpddclipper->Release(); // release the palette if (lpddpal) lpddpal->Release(); // release the secondary surface if (lpddsback) lpddsback->Release(); // release the primary surface if (lpddsprimary) lpddsprimary->Release(); // finally, the main dd object if (lpdd) lpdd->Release(); // return success return(1); } // end DD_Shutdown /////////////////////////////////////////////////////////////// LPDIRECTDRAWCLIPPER DD_Attach_Clipper(LPDIRECTDRAWSURFACE7 lpdds, int num_rects, LPRECT clip_list) { // this function creates a clipper from the sent clip list and attaches // it to the sent surface int index; // looping var LPDIRECTDRAWCLIPPER lpddclipper; // pointer to the newly created dd clipper LPRGNDATA region_data; // pointer to the region data that contains // the header and clip list // first create the direct draw clipper if ((lpdd->CreateClipper(0,&lpddclipper,NULL))!=DD_OK) return(NULL); // now create the clip list from the sent data // first allocate memory for region data region_data = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+num_rects*sizeof(RECT)); // now copy the rects into region data memcpy(region_data->Buffer, clip_list, sizeof(RECT)*num_rects); // set up fields of header region_data->rdh.dwSize = sizeof(RGNDATAHEADER); region_data->rdh.iType = RDH_RECTANGLES; region_data->rdh.nCount = num_rects; region_data->rdh.nRgnSize = num_rects*sizeof(RECT); region_data->rdh.rcBound.left = 64000; region_data->rdh.rcBound.top = 64000; region_data->rdh.rcBound.right = -64000; region_data->rdh.rcBound.bottom = -64000; // find bounds of all clipping regions for (index=0; index<num_rects; index++) { // test if the next rectangle unioned with the current bound is larger if (clip_list[index].left < region_data->rdh.rcBound.left) region_data->rdh.rcBound.left = clip_list[index].left; if (clip_list[index].right > region_data->rdh.rcBound.right) region_data->rdh.rcBound.right = clip_list[index].right; if (clip_list[index].top < region_data->rdh.rcBound.top) region_data->rdh.rcBound.top = clip_list[index].top; if (clip_list[index].bottom > region_data->rdh.rcBound.bottom) region_data->rdh.rcBound.bottom = clip_list[index].bottom; } // end for index // now we have computed the bounding rectangle region and set up the data // now let's set the clipping list if ((lpddclipper->SetClipList(region_data, 0))!=DD_OK) { // release memory and return error free(region_data); return(NULL); } // end if // now attach the clipper to the surface if ((lpdds->SetClipper(lpddclipper))!=DD_OK) { // release memory and return error free(region_data); return(NULL); } // end if // all is well, so release memory and send back the pointer to the new clipper free(region_data); return(lpddclipper); } // end DD_Attach_Clipper /////////////////////////////////////////////////////////////// int DD_Flip(void) { // this function flip the primary surface with the secondary surface // flip pages while(lpddsprimary->Flip(NULL, DDFLIP_WAIT)!=DD_OK); // flip the surface // return success return(1); } // end DD_Flip /////////////////////////////////////////////////////////////// DWORD Start_Clock(void) { // this function starts the clock, that is, saves the current // count, use in conjunction with Wait_Clock() return(start_clock_count = Get_Clock()); } // end Start_Clock /////////////////////////////////////////////////////////////// DWORD Get_Clock(void) { // this function returns the current tick count // return time return(GetTickCount()); } // end Get_Clock /////////////////////////////////////////////////////////////// DWORD Wait_Clock(DWORD count) { // this function is used to wait for a specific number of clicks // since the call to Start_Clock while((Get_Clock() - start_clock_count) < count); return(Get_Clock()); } // end Wait_Clock /////////////////////////////////////////////////////////////// int DD_Fill_Surface(LPDIRECTDRAWSURFACE7 lpdds,int color) { DDBLTFX ddbltfx; // this contains the DDBLTFX structure // clear out the structure and set the size field DD_INIT_STRUCT(ddbltfx); // set the dwfillcolor field to the desired color ddbltfx.dwFillColor = color; // ready to blt to surface lpdds->Blt(NULL, // ptr to dest rectangle NULL, // ptr to source surface, NA NULL, // ptr to source rectangle, NA DDBLT_COLORFILL | DDBLT_WAIT | DDBLT_ASYNC, // fill and wait &ddbltfx); // ptr to DDBLTFX structure // return success return(1); } // end DD_Fill_Surface /////////////////////////////////////////////////////////////// int Draw_Rectangle(int x1, int y1, int x2, int y2, int color, LPDIRECTDRAWSURFACE7 lpdds) { // this function uses directdraw to draw a filled rectangle DDBLTFX ddbltfx; // this contains the DDBLTFX structure RECT fill_area; // this contains the destination rectangle // clear out the structure and set the size field DD_INIT_STRUCT(ddbltfx); // set the dwfillcolor field to the desired color ddbltfx.dwFillColor = color; // fill in the destination rectangle data (your data) fill_area.top = y1; fill_area.left = x1; fill_area.bottom = y2+1; fill_area.right = x2+1; // ready to blt to surface, in this case blt to primary dwadlpdds->Blt(&fill_area, // ptr to dest rectangle NULL, // ptr to source surface, NA NULL, // ptr to source rectangle, NA DDBLT_COLORFILL | DDBLT_WAIT | DDBLT_ASYNC, // fill and wait &ddbltfx); // ptr to DDBLTFX structure // return success return(1); } // end Draw_Rectangle /////////////////////////////////////////////////////////////// int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE7 lpdds) { // this function draws the sent text on the sent surface // using color index as the color in the palette HDC xdc; // the working dc // get the dc from surface if (lpdds->GetDC(&xdc)!=DD_OK) return(0); // set the colors for the text up SetTextColor(xdc,RGB(palette[color].peRed,palette[color].peGreen,palette[color].peBlue) ); // set background mode to transparent so black isn't copied SetBkMode(xdc, TRANSPARENT); // draw the text a TextOut(xdc,x,y,text,strlen(text)); // release the dc lpdds->ReleaseDC(xdc); // return success return(1); } // end Draw_Text_GDI ///////////////////////////////////////////////////////////////
[ "ilyababichev101@gmal.com" ]
ilyababichev101@gmal.com
08ca013dcd33e3ce9e2beefb4e4786cb72a53c5f
625d129f66712f0d5c5e19c8f80d510f58dd3727
/data structures/binary search.cpp
c0ea6c3f9d8dd197de8cce3908e1ebce267cce51
[]
no_license
valeriaconde/school
61621a9262078fcd71832ebe880eff80e3ae8b4f
210d96a4e86f45e14a6e6297bc186327f72f90de
refs/heads/main
2023-08-16T17:00:51.026552
2021-09-21T16:25:24
2021-09-21T16:25:24
401,173,524
0
0
null
null
null
null
UTF-8
C++
false
false
3,932
cpp
// Actividad 1.3 // Entregado 11/09/2020 // Equipo #21 // Juan Pablo Salazar A01740200 // Valeria Conde A01281637 // Melissa Vélez Martínez A00827220 #include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> using namespace std; // Struct Datos para guardar objetos de cada dato en el archivo struct Datos{ // O(1) Datos(int fecha, string mes, int dia, string hora, string ip, string rFalla){ this->fecha = fecha; this->hora = hora; this->dia = dia; this->mes = mes; this->ip = ip; this->rFalla = rFalla; } int fecha,dia; string mes, hora, ip,rFalla; }; // funcion para convertir el mes al formato numerico // O(1) int monthInNum(string mes){ if(mes == "Jan") return 1; if(mes == "Feb") return 2; if(mes == "Mar") return 3; if(mes == "Apr") return 4; if(mes == "May") return 5; if(mes == "Jun") return 6; if(mes == "Jul") return 7; if(mes == "Aug") return 8; if(mes == "Sep") return 9; if(mes == "Oct") return 10; if(mes == "Nov") return 11; if(mes == "Dec") return 12; return 0; } // Busca partiendo el area de busqueda a la mitad cada iteracion // O(logn) int binSearch(vector<Datos> vDatos, int ind, int mode) { if(mode == 2) ind++; int left = 0, right = vDatos.size()-1, mid; while(left<right){ mid = (left + right) /2; if (vDatos[mid].fecha >= ind){ right = mid; } else { left = mid+1; } } if(mode==2) return left-1; return left; } // Ordena la bitacora y deja buscar en ella int main() { //abre el archivo ifstream arch; arch.open("bitacora.txt"); int dia, fecha, min, max; string rFalla, ip, mes, hora; bool rep = true, save; vector<Datos> vDatos; char v; // Lee el archivo y crea un vector con objetos de tipo Datos while(!arch.eof()){ arch>> mes>> dia>>hora>> ip; getline(arch,rFalla); fecha = monthInNum(mes)*100 + dia; Datos dato(fecha, mes, dia, hora, ip, rFalla); vDatos.push_back(dato); } cout<< vDatos.size()<< " datos size "<< endl; // ordena datos por fecha //O(nlogn) sort(vDatos.begin(), vDatos.end(), [](const Datos& lhs, const Datos& rhs) { return lhs.fecha < rhs.fecha; }); // repite mientras el usuario decida seguir buscando while(rep){ // pide al usuario fechas minima y maxima cout << "BUSQUEDA DE INFORMACION POR FECHA\nFecha de inicio (Mes y dia): "; cin >> mes >> dia; min = monthInNum(mes)*100 + dia; cout << "Fecha de fin (Mes y dia): "; cin >> mes >> dia; max = monthInNum(mes)*100 + dia; min = binSearch(vDatos,min,0); max = binSearch(vDatos,max,2); // despliega los registros entre esas fechas for(int i = min; i<= max; i++){ cout<< vDatos[i].mes << " "<< vDatos[i].dia<< " "<< vDatos[i].hora << " "<< vDatos[i].ip<< vDatos[i].rFalla<<endl; } // genera un archivo con los registros solicitados cout<< "Desea guardar la busqueda? (escriba S para si y N para no)"<<endl; cin>>v; if(v == 'S'){ cout<< "Escriba el nombre del archivo que desea: "; cin >> ip; // reusamos variable ip para guardar espacio ip.append(".txt"); ofstream out(ip); for (int i = min; i<= max; i++) { // escribe los datos al archivo out<< vDatos[i].mes << " "<< vDatos[i].dia<< " "<< vDatos[i].hora << " "<< vDatos[i].ip<< vDatos[i].rFalla<<endl; } out.close(); } cout<< "Desea volver a buscar? (escriba S para si y N para no)" << endl; cin >> v; rep = (v == 'S' ? 1:0); } cout<< "Escriba el nombre del archivo en el que desea la lista ordenada: "; cin >> ip; ip.append(".txt"); ofstream out(ip); for (int i = 0; i<= vDatos.size()-1; i++) { // escribe los datos al archivo out<< vDatos[i].mes << " "<< vDatos[i].dia<< " "<< vDatos[i].hora << " "<< vDatos[i].ip<< vDatos[i].rFalla<<endl; } }
[ "valeriaconde.96@gmail.com" ]
valeriaconde.96@gmail.com
987fbefbf5d3a33536c65566ad89fff725a9c714
9ca5e88f35f1b9ca6e966498d49e853f20e7201e
/src/qt/sendcoinsdialog.cpp
998df42b3fb1c254ebe6aabdb81a4d92a11afffe
[ "MIT" ]
permissive
myworldgithub/Horgerchain
dce64c51325de4efd6eb45dd7f31183b53bfe2c4
8d9c9bdf0c598b1457e75e90635afa97cb533ac6
refs/heads/master
2020-03-07T20:12:47.284188
2018-04-02T02:25:29
2018-04-02T02:25:29
127,691,667
0
0
null
null
null
null
UTF-8
C++
false
false
18,653
cpp
#include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" // Coin Control #include "init.h" #include "addresstablemodel.h" #include "coincontrol.h" #include "coincontroldialog.h" #include "walletmodel.h" #include "bitcoinunits.h" #include "addressbookpage.h" #include "optionsmodel.h" #include "sendcoinsentry.h" #include "guiutil.h" #include "askpassphrasedialog.h" #include "base58.h" #include "wallet.h" #include <QMessageBox> #include <QLocale> #include <QTextDocument> #include <QScrollBar> // Coin Control #include <QClipboard> SendCoinsDialog::SendCoinsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SendCoinsDialog), model(0) { ui->setupUi(this); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->addButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon()); #endif #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a Horgerchain address")); #endif addEntry(); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // Coin Control ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont()); connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority())); connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); ui->labelCoinControlPriority->addAction(clipboardPriorityAction); ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); fNewRecipientAllowed = true; } void SendCoinsDialog::setModel(WalletModel *model) { this->model = model; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setModel(model); } } if(model && model->getOptionsModel()) { setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64))); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); // Coin Control connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels())); ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); } } SendCoinsDialog::~SendCoinsDialog() { delete ui; } void SendCoinsDialog::on_sendButton_clicked() { WalletModel::EncryptionStatus status = model->getEncryptionStatus(); if(status != WalletModel::Unencrypted) { model->setWalletLocked(true); AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this); emit sendCoinsClicked("UnLock Wallet"); dlg.setModel(model); if(dlg.exec() != QDialog::Accepted) { return; } } fWalletUnlockMintOnly = true; emit sendCoinsClicked("Lock Wallet"); QList<SendCoinsRecipient> recipients; bool valid = true; if(!model) return; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); } fNewRecipientAllowed = false; QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } // WalletModel::SendCoinsReturn sendstatus = model->sendCoins(recipients); // Coin Control WalletModel::SendCoinsReturn sendstatus; if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) sendstatus = model->sendCoins(recipients); else sendstatus = model->sendCoins(recipients, CoinControlDialog::coinControl); switch(sendstatus.status) { case WalletModel::InvalidAddress: QMessageBox::warning(this, tr("Send Coins"), tr("The recipient address is not valid, please recheck."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::InvalidAmount: QMessageBox::warning(this, tr("Send Coins"), tr("The amount to pay must be larger than 0."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The amount exceeds your balance."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountWithFeeExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The total exceeds your balance when the %1 transaction fee is included."). arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendstatus.fee)), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::DuplicateAddress: QMessageBox::warning(this, tr("Send Coins"), tr("Duplicate address found, can only send to each address once per send operation."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCreationFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: Transaction creation failed."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCommitFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::Aborted: // User aborted, nothing to do break; case WalletModel::OK: accept(); // Coin Control CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); break; } fNewRecipientAllowed = true; } void SendCoinsDialog::clear() { // Remove entries until only one left while(ui->entries->count()) { delete ui->entries->takeAt(0)->widget(); } addEntry(); updateRemoveEnabled(); ui->sendButton->setDefault(true); } void SendCoinsDialog::reject() { clear(); } void SendCoinsDialog::accept() { clear(); } SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(this); entry->setModel(model); ui->entries->addWidget(entry); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); // Coin Control connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); updateRemoveEnabled(); // Focus the field, so that entry can start immediately entry->clear(); entry->setFocus(); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); QCoreApplication::instance()->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); return entry; } void SendCoinsDialog::updateRemoveEnabled() { // Remove buttons are enabled as soon as there is more than one send-entry bool enabled = (ui->entries->count() > 1); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setRemoveEnabled(enabled); } } setupTabChain(0); // Coin Control coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { delete entry; updateRemoveEnabled(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { prev = entry->setupTabChain(prev); } } QWidget::setTabOrder(prev, ui->addButton); QWidget::setTabOrder(ui->addButton, ui->sendButton); return ui->sendButton; } void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) { if(!fNewRecipientAllowed) return; SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setValue(rv); } bool SendCoinsDialog::handleURI(const QString &uri) { SendCoinsRecipient rv; // URI has to be valid if (GUIUtil::parseBitcoinURI(uri, &rv)) { CBitcoinAddress address(rv.address.toStdString()); if (!address.IsValid()) return false; pasteEntry(rv); return true; } return false; } void SendCoinsDialog::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance) { Q_UNUSED(stake); Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); if(!model || !model->getOptionsModel()) return; int unit = model->getOptionsModel()->getDisplayUnit(); ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); } void SendCoinsDialog::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update labelBalance with the current balance and the current unit ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance())); } } // Coin Control: copy label "Quantity" to clipboard void SendCoinsDialog::coinControlClipboardQuantity() { QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text()); } // Coin Control: copy label "Amount" to clipboard void SendCoinsDialog::coinControlClipboardAmount() { QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); } // Coin Control: copy label "Fee" to clipboard void SendCoinsDialog::coinControlClipboardFee() { QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" "))); } // Coin Control: copy label "After fee" to clipboard void SendCoinsDialog::coinControlClipboardAfterFee() { QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" "))); } // Coin Control: copy label "Bytes" to clipboard void SendCoinsDialog::coinControlClipboardBytes() { QApplication::clipboard()->setText(ui->labelCoinControlBytes->text()); } // Coin Control: copy label "Priority" to clipboard void SendCoinsDialog::coinControlClipboardPriority() { QApplication::clipboard()->setText(ui->labelCoinControlPriority->text()); } // Coin Control: copy label "Low output" to clipboard void SendCoinsDialog::coinControlClipboardLowOutput() { QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text()); } // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" "))); } // Coin Control: settings menu - coin control enabled/disabled by user void SendCoinsDialog::coinControlFeatureChanged(bool checked) { ui->frameCoinControl->setVisible(checked); if (!checked && model) // coin control features disabled CoinControlDialog::coinControl->SetNull(); } // Coin Control: button inputs -> show actual coin control dialog void SendCoinsDialog::coinControlButtonClicked() { CoinControlDialog dlg; dlg.setModel(model); dlg.exec(); coinControlUpdateLabels(); } // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { if (model) { if (state == Qt::Checked) CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get(); else CoinControlDialog::coinControl->destChange = CNoDestination(); } ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed void SendCoinsDialog::coinControlChangeEdited(const QString & text) { if (model) { CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get(); // label for the change address ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); if (text.isEmpty()) ui->labelCoinControlChangeLabel->setText(""); else if (!CBitcoinAddress(text.toStdString()).IsValid()) { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid Horgerchain address")); } else { QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); if (!associatedLabel.isEmpty()) ui->labelCoinControlChangeLabel->setText(associatedLabel); else { CPubKey pubkey; CKeyID keyid; CBitcoinAddress(text.toStdString()).GetKeyID(keyid); if (model->getPubKey(keyid, pubkey)) ui->labelCoinControlChangeLabel->setText(tr("(no label)")); else { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address")); } } } } } // Coin Control: update labels void SendCoinsDialog::coinControlUpdateLabels() { if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) return; // set pay amounts CoinControlDialog::payAmounts.clear(); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) CoinControlDialog::payAmounts.append(entry->getValue().amount); } if (CoinControlDialog::coinControl->HasSelected()) { // actual coin control calculation CoinControlDialog::updateLabels(model, this); // show coin control stats ui->labelCoinControlAutomaticallySelected->hide(); ui->widgetCoinControl->show(); } else { // hide coin control stats ui->labelCoinControlAutomaticallySelected->show(); ui->widgetCoinControl->hide(); ui->labelCoinControlInsuffFunds->hide(); } }
[ "eqrtty@163.com" ]
eqrtty@163.com
4e316c6d4f80923a702381d18c87d703a722590c
711619c0fef88df3c62bb78a8a847ce8e439de01
/exercise-01.cpp
3a448465a399ba9908bab46357430fd9483c7e97
[]
no_license
shenaach/strukdat-03
0ace5a3b8873dd0435af7eff5ece0a3bc0e6301d
165d935c3c7ae671f75a7fe9baea0a91c7f567ac
refs/heads/master
2020-04-28T14:45:39.947048
2019-03-13T04:44:06
2019-03-13T04:44:06
175,347,879
0
0
null
null
null
null
UTF-8
C++
false
false
970
cpp
/* Nama program : Exercise 01 Nama : Sharashena Chairani NPM : 140810180022 Tanggal buat : 13 Maret 2019 Deskripsi : Segiempat *************************************************/ #include <iostream> #include <cmath> #include <math.h> using namespace std; typedef struct{ float panjang; float lebar; } segiempat; void input(segiempat *s){ cout << "Panjang : "; cin >> s->panjang; cout << "Lebar : "; cin >> s->lebar; } float keliling(segiempat s){ return(2*(s.panjang+s.lebar)); } float luas(segiempat s){ return(s.panjang*s.lebar); } float diagonal(segiempat s){ return(sqrt(s.panjang*s.panjang+s.lebar*s.lebar)); } void print(segiempat s){ cout << "Keliling\t: " <<keliling(s)<<endl; cout << "Luas\t\t: " <<luas(s)<<endl; cout << "Diagonal\t: "<<diagonal(s)<<endl; } int main() { segiempat* sg; sg = new segiempat; input(sg); print(*sg); return 0; }
[ "shenachairani@gmail.com" ]
shenachairani@gmail.com
46f4a7be8fb79d2b1b373e5144651978aa0b3e17
032de413fe4b756456bed9aefcf81f38ac38a3ed
/binary_tree_level_order_zigzag.cpp
2e497e951ab1568998e4657b389901dabcd20bcd
[]
no_license
elden2010/leetcode
1eede355bd466114e005a6cb4e6e758cf2dceca6
d6963e82826721901cdcf51ba4fbef4732c102ee
refs/heads/master
2020-05-27T20:12:53.861858
2013-11-02T04:13:06
2013-11-02T04:13:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,287
cpp
class Solution { public: vector<vector<int> > zigzagLevelOrder(TreeNode *root) { vector<vector<int> > ret; vector<vector<TreeNode*> > allLvl; // store all TreeNodes in levels if(root) { // initial set up vector<TreeNode*> newLvl; newLvl.push_back(root); allLvl.push_back(newLvl); // iteration through levels do { newLvl.clear(); vector<TreeNode*> &oldLvl = allLvl.back(); // for(vector<TreeNode*>::iterator it=oldLvl.begin();it!=oldLvl.end();++it) { TreeNode* tnode = (*it); if(tnode->left) newLvl.push_back(tnode->left); if(tnode->right) newLvl.push_back(tnode->right); } if(!newLvl.empty()) allLvl.push_back(newLvl); } while (!newLvl.empty()); // store val bool left2right=true; for(vector<vector<TreeNode*> >::iterator it1 = allLvl.begin();it1!=allLvl.end();++it1) { vector<TreeNode*> tNodes = *it1; vector<int> tVals; if(left2right) for(vector<TreeNode*>::iterator it2 = tNodes.begin();it2!=tNodes.end();++it2) tVals.push_back((*it2)->val); else for(vector<TreeNode*>::reverse_iterator it2 = tNodes.rbegin();it2!=tNodes.rend();++it2) tVals.push_back((*it2)->val); left2right = !left2right; ret.push_back(tVals); } } return ret; } };
[ "elden.yu@gmail.com" ]
elden.yu@gmail.com
1798865c1c8ae846de77c0a49f5faf77f3e31b2f
74ef3dca3c51cc006cb4a6e001d677177fde415b
/Projecte/Graph.cpp
e6bb52056cbd6d1476c50214d5885b18b60a1fe0
[]
no_license
Elektroexe/ProjecteLP
32b58508db63b0d0863c5975f692163edf3d8bed
e0eb6ede9c5c4dc2bdbb2111d3e990aeab4ef221
refs/heads/master
2020-04-18T08:21:01.920629
2019-01-24T16:32:26
2019-01-24T16:32:26
167,393,337
1
0
null
null
null
null
UTF-8
C++
false
false
161
cpp
#include "Graph.h" void Graph::calculaComunitats(list<Tree<double>*>& listDendrogram) { Comunitat c(&m_mAdjacencia); c.calculaComunitats(listDendrogram); }
[ "gerson.e.ramirez@gmail.com" ]
gerson.e.ramirez@gmail.com
175c3f8eac990435d1c3261d83d13126b08bf815
6a6a952f5e73520a26823cb0ffa984fff594afdc
/ortools/gscip/gscip_event_handler.h
cc3c3bb3305bde3ba2f85f9f7a656351a55fd43a
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "LicenseRef-scancode-unknown-license-reference" ]
permissive
hmaytac/or-tools
010c9aeffab5da24a87520423e0558369e5d3de1
21b3cc679628a4d9c81f33da77012339aabc6c72
refs/heads/master
2023-07-17T14:26:42.542840
2021-09-03T13:28:10
2021-09-03T13:29:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,678
h
// Copyright 2010-2021 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Provides a safe C++ interface for SCIP event handlers, which are described at // https://www.scipopt.org/doc-7.0.1/html/EVENT.php. #ifndef OR_TOOLS_GSCIP_GSCIP_EVENT_HANDLER_H_ #define OR_TOOLS_GSCIP_GSCIP_EVENT_HANDLER_H_ #include <string> #include <vector> #include "ortools/gscip/gscip.h" #include "scip/type_event.h" namespace operations_research { struct GScipEventHandlerDescription { // For the first two members below, the SCIP constraint handler // property name is provided. See // https://www.scipopt.org/doc-7.0.1/html/EVENT.php#EVENTHDLR_PROPERTIES for // details. // See CONSHDLR_NAME in SCIP documentation above. std::string name; // See CONSHDLR_DESC in SCIP documentation above. std::string description; }; // Passed by value. This is a lightweight interface to the callback context and // the underlying problem. It's preferred for callbacks to use the context // object to query information rather than using the raw SCIP pointer, because // the context object can be set up to do this in a safe way. class GScipEventHandlerContext { public: GScipEventHandlerContext(GScip* gscip, SCIP_EVENTTYPE event_type) : gscip_(gscip), event_type_(event_type) {} GScip* gscip() const { return gscip_; } // This is always an atomic event type, not a mask (i.e., one of the events // defined as a bitwise OR). SCIP_EVENTTYPE event_type() const { return event_type_; } // TODO(user,user): Support additional properties that might need to be // queried within an event handler. private: GScip* const gscip_; const SCIP_EVENTTYPE event_type_; }; // Inherit from this to implement the callback and override Init() to call // CatchEvent() for the events you want to listen to. // // Usage: // // class MyHandler : public GScipEventHandler { // public: // MyHandler() // : GScipEventHandler({ // .name = "my handler", .description = "something"}) {} // // SCIP_RETCODE Init(GScip* const gscip) override { // SCIP_CALL(CatchEvent(SCIP_EVENTTYPE_SOLFOUND)); // return SCIP_OKAY; // } // // SCIP_RETCODE Execute(const GScipEventHandlerContext context) override { // ... // return SCIP_OKAY; // } // }; // // std::unique_ptr<GScip> gscip = ...; // // MyHandler handler; // handler.Register(gscip.get()); // class GScipEventHandler { public: explicit GScipEventHandler(const GScipEventHandlerDescription& description) : description_(description) {} virtual ~GScipEventHandler() = default; // Registers this event handler to the given GScip. // // This function CHECKs that this handler has not been previously registered. // // The given GScip won't own this handler but will keep a pointer to it that // will be used during the solve. void Register(GScip* gscip); // Initialization of the event handler. Called after the problem was // transformed. // // The implementation should use the CatchEvent() method to register to global // events. // // Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly // propagate errors. virtual SCIP_RETCODE Init(GScip* gscip) { return SCIP_OKAY; } // Called when a caught event is emitted. // // Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly // propagate errors. virtual SCIP_RETCODE Execute(GScipEventHandlerContext context) { return SCIP_OKAY; } // Deinitialization of the event handler. // // Called before the transformed problem is freed and after all the events // specified in CatchEvent() have been dropped (thus there is no need to // implement this function to drop these events since this would have already // been done). // // Return SCIP_OKAY, or use SCIP_CALL macro to wraps SCIP calls to properly // propagate errors. virtual SCIP_RETCODE Exit(GScip* gscip) { return SCIP_OKAY; } protected: // Catches a global event (i.e. not a variable or row depedent one) based on // the input event_type mask. // // This method must only be called after the problem is transformed; typically // it is called in the Init() virtual method. // // Caught events will be automatically dropped when the handler will be called // on EXIT (before calling the corresponding Exit() member function). // // See scip/type_event.h for the list of possible events. This function // corresponds to SCIPcatchEvent(). // // TODO(user,user): Support Var and Row events. // // TODO(user,user): Support registering events in the EVENTINITSOL // callback, which would cause them to be trapped only after presolve. SCIP_RETCODE CatchEvent(SCIP_EVENTTYPE event_type); private: struct CaughtEvent { CaughtEvent(const SCIP_EVENTTYPE event_type, const int filter_pos) : event_type(event_type), filter_pos(filter_pos) {} // The event_type mask for this catch. SCIP_EVENTTYPE event_type; // The key used by SCIP to identify this catch with SCIPdropEvent(). Using // this key prevents SCIP from having to do a look up to find the catch and // helps when there are duplicates. // // It is the index of the data associated to the catch in the array SCIP // uses as storage (this index is stable, even after other catch added // previously are removed, since SCIP maintains a free-list of removed items // instead of renumbering all elements). int filter_pos; }; // Calls SCIPdropEvent() for all events in caught_events_ and clear this // collection. // // This is not a member function since it needs to be visible to the SCIP Exit // callback function. friend SCIP_RETCODE DropAllEvents(GScipEventHandler& handler); const GScipEventHandlerDescription description_; // Pointer to GScip set by Register(); GScip* gscip_ = nullptr; // Pointer to the event handler registered on SCIP. SCIP_EVENTHDLR* event_handler_ = nullptr; // Caught events via CatchEvent(). std::vector<CaughtEvent> caught_events_; }; } // namespace operations_research #endif // OR_TOOLS_GSCIP_GSCIP_EVENT_HANDLER_H_
[ "lperron@google.com" ]
lperron@google.com
89d749cfd6d0f8ebba7d4257244c4abf74fec665
c963958323984427bf29e17ba544d78a9b1739fd
/CTEHL2MPFireBullets.h
0141204ef46891cb95937f55d76a780f32f1245b
[]
no_license
hentaidad/gmod-sdk
ada3beae43af4b6da401155f783b3132860b027b
8c451b5c57a1ced3da4a686ffb2cd83e42adcc3f
refs/heads/master
2020-03-19T05:25:36.394975
2018-06-03T18:35:43
2018-06-03T18:35:43
135,929,392
0
0
null
null
null
null
UTF-8
C++
false
false
662
h
//*********************************************** // SDK Generated by ValveGen (written by Chod) // File: CTEHL2MPFireBullets.h //*********************************************** #pragma once #pragma pack(push,1) class CTEHL2MPFireBullets { public: unsigned char _0x0[0x10]; int m_iPlayer; // 0x10 vector3 m_vecOrigin; // 0x14 vector3 m_vecDir; // 0x20 int m_iAmmoID; // 0x2c int m_iWeaponIndex; // 0x30 int m_iSeed; // 0x34 float m_flSpread; // 0x38 int m_iShots; // 0x3c int m_bDoImpacts; // 0x40 int m_bDoTracers; // 0x41 char* m_TracerType; // 0x42 }; #pragma pack(pop)
[ "noreply@github.com" ]
hentaidad.noreply@github.com
f3a1c60284c3fd6371d93ef48508e215b800fcf2
ca87b6d95b8951346226cbccc78fa6b971fa906c
/delivery/include/Account.h
c2993ad7e7b0bf5a98ae819036786ea1cfac7906
[]
no_license
ngreen3/Deep-Learning
05de586c66050accd107aa6d69959ceebc8f2db8
c6ec177f5e6bbb9fd6abb0c3f14249806f873262
refs/heads/master
2020-03-12T13:30:15.371389
2018-05-01T06:54:07
2018-05-01T06:54:07
130,643,736
1
0
null
null
null
null
UTF-8
C++
false
false
1,191
h
#ifndef _ACCOUNT_H_ #define _ACCOUNT_H_ #include "OpenPosition.h" #include "enumErrorOutputs.h" #include <iostream> #include <vector> #include <cmath> using namespace std; class Account { private: // Current cash level double cash = 0; // List of all open positions held by the account vector<OpenPosition> openPositions; public: // ---- Constructors ---- // New Account Account() { } // Account with cash Account(double cashAmt) : cash(cashAmt) { } // Account with cash and stocks Account(int cashAmt, vector<OpenPosition> positions) : cash(cashAmt), openPositions(positions) { } //---- Getters ---- // Get the current cash level double getCash(); // Get the list of open positions vector<OpenPosition> getOpenPositions(); // ---- Setters ---- // Change the cash level by given amount void addCash(double value); // Add an open position to the list void addOpenPosition(OpenPosition position); // Remove an open position from the list int removeOpenPosition(OpenPosition position, int count = 1); int updatePositionType(OpenPosition position, int type, double price); }; #endif
[ "naomi.green@mines.sdsmt.edu" ]
naomi.green@mines.sdsmt.edu
766f52f3eef84ffe1bad92eb6e18e7f881262be0
5f4e7f89ac9f8934beb9fd9a5d8aff232fb9e105
/babies/ame_folder/ame/ame.ino
3caf4b081aac56a7a08d1551f19eba8a78020d93
[]
no_license
AmedeoSpagnolo/lullababy
2ca2b5845dae2fa565ab06ec6973ac6f71832616
665f75ffe914dc84b013f2453466d9e06277cf26
refs/heads/master
2020-07-28T17:33:44.820281
2019-10-07T06:29:57
2019-10-07T06:29:57
209,480,024
0
0
null
null
null
null
UTF-8
C++
false
false
1,088
ino
#include <SD.h> #include <SPI.h> #include <arduino.h> #include <MusicPlayer.h> long x = 0; long y = 0; long z = 0; long prev = 0; bool shake = false; void setup(void) { Serial.begin(9600); player.begin(); player.setPlayMode(PM_REPEAT_ONE); player.playOne("cry.mp3"); } void loop(){ player.play(); player.setVolume(0x00); int i; long x,y,z; //read value 50 times and output the average x=y=z=0; for (i=0 ; i < 50 ; i++) { x = x + analogRead(3) ; // X軸 y = y + analogRead(4) ; // Y軸 z = z + analogRead(5) ; // Z軸 } x = x / 50 ; y = y / 50 ; z = z / 50 ; shake = (x + y + z - prev) > 10; int rotateX = (x-277)/2.48 - 90; //formula to determine angle Serial.print("X:") ; Serial.print(rotateX) ; int rotateY = (y-277)/2.48 - 90; Serial.print(" Y:") ; Serial.print(rotateY) ; int rotateZ = (z-277)/2.48 - 90; Serial.print(" Z:") ; Serial.print(rotateZ) ; Serial.print(" Shakes:"); Serial.println(shake); prev = x + y + z; if (shake > 0){ player.setVolume(0xfe); delay(10000); } delay(250); }
[ "amedeo.spagnolo@gmail.com" ]
amedeo.spagnolo@gmail.com
93bf6b5eb1594887f85085b89e60dd13813ff4b4
5ccabccc3c54423c73072f9d9dfc522f70a689fd
/AudioPlayer.h
45f2e19ad9db9efb8631db30dcfcc9171c3c6fdc
[]
no_license
RyanSwann1/CPP-SFML-Platformer
60a4374ba49ce73bbb5d31da5a0e6ca31275651e
c483801d4c7b498e6d33ad799e680e5537641a8d
refs/heads/master
2021-01-11T08:52:39.117354
2016-10-31T23:28:57
2016-10-31T23:28:57
72,383,614
0
0
null
null
null
null
UTF-8
C++
false
false
1,096
h
#pragma once #include <string> #include <unordered_map> #include <vector> #include <SFML\Audio.hpp> struct AudioClip { AudioClip(const std::string& audioClipName, sf::Sound* audioClip) : m_name(audioClipName), m_audioClip(audioClip) {} std::string m_name; sf::Sound* m_audioClip; }; using AudioClips = std::vector<AudioClip>; //using AudioClips = std::vector<std::pair<std::string, sf::Sound*>>; struct SharedContext; class AudioPlayer { public: AudioPlayer(SharedContext* sharedContext); ~AudioPlayer(); void registerOwner(const std::string& ownerID); void registerAudioClip(const std::string& audioOwner, const std::string& ClipName); void play(const std::string& audioClipName); void stop(const std::string& audioClipName); private: std::unordered_map<std::string, AudioClips> m_owners; //String is owner - IE'Player' SharedContext* m_sharedContext; std::string m_currentOwner; AudioClips* m_currentAudioClips; sf::Sound* findAudioClip(const std::string& audioClipName); void loadInAudioClips(const std::string& fileName); };
[ "noreply@github.com" ]
RyanSwann1.noreply@github.com
d8bbbd8725a5bb1c971ca4fe8429f6014ee2ebe8
3ea68b2659229e3258592bf7ee035bfb9a51aaab
/kmint_handout/kmintapp/src/pathfinding/dijkstra.h
665175c441039d4d662db93c1841291622a5175f
[]
no_license
JorisWillig/KIProject
43a5df2fc9acb4943ef85d61138296fe61d8974b
64bd8a3a5210ee1193e8691013bf6ff535a586dd
refs/heads/master
2020-04-04T19:07:09.768329
2018-11-20T12:07:21
2018-11-20T12:07:21
156,192,626
0
0
null
null
null
null
UTF-8
C++
false
false
1,103
h
#pragma once #include "pathfinder.h" #include <map> #include <queue> #include <vector> namespace pathfinding { class Dijkstra : public IPathfinder { public: Path findPath(map::map_graph& graph, const map::map_node* start, const map::map_node* target) override; private: struct Comparator { Comparator(const Dijkstra& d) : dijkstra(d) { } bool operator()(const map::map_node* lhs, const map::map_node* rhs) { return dijkstra.getWeight(*lhs) > dijkstra.getWeight(*rhs); } const Dijkstra& dijkstra; }; void buildPath(Path& path); bool hasCalculatedWeight(const map::map_node& node) const; float getWeight(const map::map_node& node) const; const map::map_node& getOtherNode(const map::map_edge& edge, const map::map_node& currentNode) const; std::map<const map::map_node*, float> m_weights; std::priority_queue<const map::map_node*, std::vector<const map::map_node*>, Comparator> m_nodeQueue{ Comparator(*this) }; map::map_graph* m_graph; }; } // namespace pathfinding
[ "fabio.waljaard@gmail.com" ]
fabio.waljaard@gmail.com
a801c81a2ad918f700887d6ca2fc84f27df864e6
b3e525a3c48800303019adac8f9079109c88004e
/dol/iris/test/offload/crypto_sha_testvec.hpp
27ded2dd2024e89b9b9e325ae63e2254c6e3f346
[]
no_license
PsymonLi/sw
d272aee23bf66ebb1143785d6cb5e6fa3927f784
3890a88283a4a4b4f7488f0f79698445c814ee81
refs/heads/master
2022-12-16T21:04:26.379534
2020-08-27T07:57:22
2020-08-28T01:15:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,404
hpp
#ifndef _CRYPTO_SHA_TESTVEC_HPP_ #define _CRYPTO_SHA_TESTVEC_HPP_ #include <stdint.h> #include <string> #include <memory> #include <math.h> #include <unistd.h> #include <assert.h> #include <openssl/ssl.h> #include "logger.hpp" #include "offload_base_params.hpp" #include "testvec_parser.hpp" #include "crypto_sha.hpp" using namespace tests; namespace crypto_sha { /* * Default CAVP Montecarlo iterations */ #define SHA_MONTECARLO_ITERS_MAX 100000 #define SHA_MONTECARLO_RESULT_EPOCH 1000 #define SHA_MONTECARLO_RESULT_LIVENESS 10 /* * Default CAVP message size in multiples of seed size */ #define SHA_MONTECARLO_SEED_MULT_SHA3 1 #define SHA_MONTECARLO_SEED_MULT_SHA1 3 #define SHA_MONTECARLO_SEED_MULT_MAX SHA_MONTECARLO_SEED_MULT_SHA1 class sha_test_repr_t; class sha_msg_repr_t; class sha_testvec_t; /* * Emulate named parameters support for sha_testvec_t constructor */ class sha_testvec_params_t { public: sha_testvec_params_t() : crypto_symm_type_(crypto_symm::CRYPTO_SYMM_TYPE_SHA), msg_desc_mem_type_(DP_MEM_TYPE_HBM), msg_digest_mem_type_(DP_MEM_TYPE_HBM), status_mem_type_(DP_MEM_TYPE_HBM), doorbell_mem_type_(DP_MEM_TYPE_HBM), montecarlo_iters_max_(SHA_MONTECARLO_ITERS_MAX), montecarlo_result_epoch_(SHA_MONTECARLO_RESULT_EPOCH) { } sha_testvec_params_t& crypto_symm_type(crypto_symm::crypto_symm_type_t crypto_symm_type) { crypto_symm_type_ = crypto_symm_type; return *this; } sha_testvec_params_t& msg_desc_mem_type(dp_mem_type_t msg_desc_mem_type) { msg_desc_mem_type_ = msg_desc_mem_type; return *this; } sha_testvec_params_t& msg_digest_mem_type(dp_mem_type_t msg_digest_mem_type) { msg_digest_mem_type_ = msg_digest_mem_type; return *this; } sha_testvec_params_t& status_mem_type(dp_mem_type_t status_mem_type) { status_mem_type_ = status_mem_type; return *this; } sha_testvec_params_t& doorbell_mem_type(dp_mem_type_t doorbell_mem_type) { doorbell_mem_type_ = doorbell_mem_type; return *this; } sha_testvec_params_t& montecarlo_iters_max(uint32_t montecarlo_iters_max) { montecarlo_iters_max_ = montecarlo_iters_max; return *this; } sha_testvec_params_t& montecarlo_result_epoch(uint32_t montecarlo_result_epoch) { montecarlo_result_epoch_ = montecarlo_result_epoch; return *this; } sha_testvec_params_t& base_params(offload_base_params_t& base_params) { base_params_ = base_params; return *this; } crypto_symm::crypto_symm_type_t crypto_symm_type(void) { return crypto_symm_type_; } dp_mem_type_t msg_desc_mem_type(void) { return msg_desc_mem_type_; } dp_mem_type_t msg_digest_mem_type(void) { return msg_digest_mem_type_; } dp_mem_type_t status_mem_type(void) { return status_mem_type_; } dp_mem_type_t doorbell_mem_type(void) { return doorbell_mem_type_; } uint32_t montecarlo_iters_max(void) { return montecarlo_iters_max_; } uint32_t montecarlo_result_epoch(void) { return montecarlo_result_epoch_; } offload_base_params_t& base_params(void) { return base_params_; } private: crypto_symm::crypto_symm_type_t crypto_symm_type_; dp_mem_type_t msg_desc_mem_type_; dp_mem_type_t msg_digest_mem_type_; dp_mem_type_t status_mem_type_; dp_mem_type_t doorbell_mem_type_; uint32_t montecarlo_iters_max_; uint32_t montecarlo_result_epoch_; offload_base_params_t base_params_; }; /* * Emulate named parameters support for sha_testvec_t pre_push */ class sha_testvec_pre_push_params_t { public: sha_testvec_pre_push_params_t() {} sha_testvec_pre_push_params_t& scripts_dir(const string& scripts_dir) { scripts_dir_.assign(scripts_dir); return *this; } sha_testvec_pre_push_params_t& testvec_fname(const string& testvec_fname) { testvec_fname_.assign(testvec_fname); return *this; } sha_testvec_pre_push_params_t& rsp_fname_suffix(const string& rsp_fname_suffix) { rsp_fname_suffix_.assign(rsp_fname_suffix); return *this; } string& scripts_dir(void) { return scripts_dir_; } string& testvec_fname(void) { return testvec_fname_; } string& rsp_fname_suffix(void) { return rsp_fname_suffix_; } private: string scripts_dir_; string testvec_fname_; string rsp_fname_suffix_; }; /* * Emulate named parameters support for sha_testvec_t push */ class sha_testvec_push_params_t { public: sha_testvec_push_params_t() : sha_ring_(nullptr), push_type_(ACC_RING_PUSH_HW_DIRECT), seq_qid_(0) { } sha_testvec_push_params_t& sha_ring(acc_ring_t *sha_ring) { sha_ring_ = sha_ring; return *this; } sha_testvec_push_params_t& push_type(acc_ring_push_t push_type) { push_type_ = push_type; return *this; } sha_testvec_push_params_t& seq_qid(uint32_t seq_qid) { seq_qid_ = seq_qid; return *this; } acc_ring_t *sha_ring(void) { return sha_ring_; } acc_ring_push_t push_type(void) { return push_type_; } uint32_t seq_qid(void) { return seq_qid_; } private: acc_ring_t *sha_ring_; acc_ring_push_t push_type_; uint32_t seq_qid_; }; /* * Crypto SHA Montecarlo result */ class sha_montecarlo_result_t { public: sha_montecarlo_result_t() : repr_nbytes(0) { } ~sha_montecarlo_result_t() { for (size_t idx = 0; idx < count(); idx++) { delete [] result_vec.at(idx); } } bool push_back(dp_mem_t *src_result) { uint32_t src_nbytes = src_result->content_size_get(); uint8_t *result; if (src_nbytes && ((repr_nbytes == 0) || (repr_nbytes == src_nbytes))) { repr_nbytes = src_nbytes; result = new (std::nothrow) uint8_t[src_nbytes]; if (result) { memcpy(result, src_result->read(), src_nbytes); result_vec.push_back(result); return true; } } return false; } uint32_t count(void) { return result_vec.size(); } const uint8_t *result(uint32_t idx) { return idx < count() ? result_vec.at(idx) : nullptr; } bool result_to_dp_mem(uint32_t idx, dp_mem_t *dst) { if (idx < count()) { memcpy(dst->read(), result(idx), min(dst->line_size_get(), size())); dst->write_thru(); return true; } return false; } uint32_t size(void) { return repr_nbytes; } private: vector<uint8_t *> result_vec; uint32_t repr_nbytes; }; /* * Crypto SHA test vector */ class sha_testvec_t { public: sha_testvec_t(sha_testvec_params_t& params); ~sha_testvec_t(); friend class sha_test_repr_t; friend class sha_msg_repr_t; bool pre_push(sha_testvec_pre_push_params_t& pre_params); bool push(sha_testvec_push_params_t& push_params); bool post_push(void); bool completion_check(void); bool full_verify(void); void rsp_file_output(void); private: bool is_montecarlo(sha_msg_repr_t *msg_repr); bool montecarlo_msg_set(sha_msg_repr_t *msg_repr, dp_mem_t *seed0, dp_mem_t *seed1, dp_mem_t *seed2); void montecarlo_execute(sha_msg_repr_t *msg_repr); sha_testvec_params_t testvec_params; sha_testvec_pre_push_params_t pre_params; sha_testvec_push_params_t push_params; testvec_parser_t *testvec_parser; testvec_output_t *rsp_output; vector<shared_ptr<sha_test_repr_t>> test_repr_vec; uint32_t num_test_failures; bool hw_started; bool test_success; }; /* * Crypto SHA test representative */ class sha_test_repr_t { public: sha_test_repr_t(sha_testvec_t& sha_testvec) : sha_testvec(sha_testvec), sha_nbytes(0), failed_parse_token(PARSE_TOKEN_ID_VOID) { } ~sha_test_repr_t() { if (sha_testvec.testvec_params.base_params().destructor_free_buffers()) { if (sha_testvec.test_success || !sha_testvec.hw_started) { } } } friend class sha_testvec_t; friend class sha_msg_repr_t; private: sha_testvec_t& sha_testvec; string sha_algo; u_long sha_nbytes; parser_token_id_t failed_parse_token; vector<shared_ptr<sha_msg_repr_t>> msg_repr_vec; }; /* * Crypto SHA message representative */ class sha_msg_repr_t { public: sha_msg_repr_t(sha_testvec_t& sha_testvec, u_long sha_nbytes) : sha_testvec(sha_testvec), sha_nbytes(sha_nbytes), msg_nbits(0), msg(nullptr), crypto_sha(nullptr), failed_parse_token(PARSE_TOKEN_ID_VOID), failure_expected(false), push_failure(false), compl_failure(false), verify_failure(false) { assert(sha_nbytes); seed = new dp_mem_t(1, sha_nbytes, DP_MEM_ALIGN_SPEC, sha_testvec.testvec_params.msg_digest_mem_type(), CRYPTO_SYMM_MSG_INPUT_ALIGNMENT, DP_MEM_ALLOC_NO_FILL); seed->content_size_set(0); md_expected = new dp_mem_t(1, sha_nbytes, DP_MEM_ALIGN_SPEC, sha_testvec.testvec_params.msg_digest_mem_type(), CRYPTO_SYMM_HASH_OUTPUT_ALIGNMENT, DP_MEM_ALLOC_NO_FILL); md_expected->content_size_set(0); md_actual = new dp_mem_t(1, sha_nbytes, DP_MEM_ALIGN_SPEC, sha_testvec.testvec_params.msg_digest_mem_type(), CRYPTO_SYMM_HASH_OUTPUT_ALIGNMENT, DP_MEM_ALLOC_FILL_ZERO); md_actual->content_size_set(0); /* * Contiguous messages, each of seed size, for Montecarlo test */ msg_mct_vec = new dp_mem_t(1, sha_nbytes * SHA_MONTECARLO_SEED_MULT_MAX, DP_MEM_ALIGN_SPEC, sha_testvec.testvec_params.msg_digest_mem_type(), CRYPTO_SYMM_MSG_INPUT_ALIGNMENT, DP_MEM_ALLOC_NO_FILL); msg_mct0 = msg_mct_vec->fragment_find(sha_nbytes * 0, sha_nbytes); msg_mct1 = msg_mct_vec->fragment_find(sha_nbytes * 1, sha_nbytes); msg_mct2 = msg_mct_vec->fragment_find(sha_nbytes * 2, sha_nbytes); msg_mct_vec->content_size_set(0); } bool msg_alloc(void) { uint32_t alloc_nbytes; /* * Ensure we allocate at least 1 byte */ alloc_nbytes = msg_nbits ? (msg_nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE : 1; msg = new dp_mem_t(1, alloc_nbytes, DP_MEM_ALIGN_SPEC, sha_testvec.testvec_params.msg_digest_mem_type(), CRYPTO_SYMM_MSG_INPUT_ALIGNMENT, DP_MEM_ALLOC_FILL_ZERO); msg->content_size_set(0); return true; } ~sha_msg_repr_t() { if (sha_testvec.testvec_params.base_params().destructor_free_buffers()) { if (sha_testvec.test_success || !sha_testvec.hw_started) { if (crypto_sha) delete crypto_sha; if (seed) delete seed; if (msg_mct_vec) delete msg_mct_vec; if (msg) delete msg; if (md_actual) delete md_actual; if (md_expected) delete md_expected; } } } friend class sha_testvec_t; private: sha_testvec_t& sha_testvec; u_long sha_nbytes; u_long msg_nbits; dp_mem_t *seed; dp_mem_t *msg; dp_mem_t *msg_mct_vec; dp_mem_t *msg_mct0; // fragments of msg_mct_vec dp_mem_t *msg_mct1; // " " dp_mem_t *msg_mct2; // " " dp_mem_t *md_expected; dp_mem_t *md_actual; sha_t *crypto_sha; sha_montecarlo_result_t montecarlo_expected; sha_montecarlo_result_t montecarlo_actual; parser_token_id_t failed_parse_token; uint32_t failure_expected: 1, push_failure : 1, compl_failure : 1, verify_failure : 1; }; } // namespace crypto_sha #endif // _CRYPTO_SHA_TESTVEC_HPP_
[ "32073521+raghavaks@users.noreply.github.com" ]
32073521+raghavaks@users.noreply.github.com
460920ed9d8984a9e02467ed8f52bcb29eeda912
4d3a7ac0d0dd35d8cd4a8cdebdf28e405df7b508
/단어변환.cpp
9f5f7e1b9b0a52c6c76835dcea3963fe9f3d516f
[]
no_license
HannSoo/algoPrac
c98bd50672dd2eb4e3f913f01320b6b2b757a0ec
a974cfad3ed510e32466e99abfd209f0d491e0ac
refs/heads/master
2020-03-27T11:10:46.066957
2019-11-21T07:51:22
2019-11-21T07:51:22
146,470,270
1
0
null
null
null
null
UTF-8
C++
false
false
1,557
cpp
#include <iostream> #include <vector> #include <string> #include <queue> using namespace std; vector<string> words; bool isAdj(string a, string b); int targetLvl; vector<string> bfs(string start,string target){ int size = words.size(); vector<bool> discovered(size, false); queue<string> q; queue<int> lvl; vector<string> order; cout << "The order is empty" << order.empty() << endl; q.push(start); lvl.push(0); while(!q.empty()){ string here = q.front(); int thisLvl = lvl.front(); cout << "bfs visits " << here << "on level" << thisLvl << endl; if(here == target){ targetLvl = thisLvl; break; } q.pop(); lvl.pop(); order.push_back(here); for(int i = 0; i< size; i++){ if(isAdj(words[i],here)) if(!discovered[i]){ q.push(words[i]); lvl.push(thisLvl + 1); discovered[i] = true; } } } return order; } bool isAdj(string a, string b){ int status = 0; int size =a.size(); if(size!= b.size()) return false; for(int i = 0 ; i < size; i++){ if(a[i] != b[i]) status += 1; if(status > 1) break; } return (status == 1)? true : false; } int solution(string begin, string target, vector<string> words) { vector<string> answer; answer = bfs(begin,target); for(auto stage : answer){ cout << stage << ' '; } cout << endl; return targetLvl; } int main(){ cout << solution("hit","cog",{"hot","dot","dog", "lot", "log", "cog"}) << endl; return 0; }
[ "ggt1324@gmail.com" ]
ggt1324@gmail.com
fcbb1f63755d255fc0157d51f0bde275f18aa806
ebd4e46c40aade4df0bf9a61026a37ca19ef9641
/Rat_In_The_Maze.cpp
f2494c15013102d1d15afc72df874d4ecbd9db7f
[]
no_license
vrragul1405043/Recursion-Backtracking
048db2d52aa89064c50c521256220443f1fe0d3d
b59919457fd51b40b84597b097705ecaacfb4597
refs/heads/master
2023-06-24T01:04:14.813635
2021-07-28T13:34:00
2021-07-28T13:34:00
388,720,765
0
0
null
null
null
null
UTF-8
C++
false
false
1,013
cpp
class Solution{ void solve(int i, int j, vector<vector<int>> &a, int n, vector<string> &ans, string move, vector<vector<int>> &vis, int di[], int dj[]) { if(i==n-1 && j==n-1) { ans.push_back(move); return; } string dir = "DLRU"; for(int ind = 0; ind<4;ind++) { int nexti = i + di[ind]; int nextj = j + dj[ind]; if(nexti >= 0 && nextj >= 0 && nexti < n && nextj < n && !vis[nexti][nextj] && a[nexti][nextj] == 1) { vis[i][j] = 1; solve(nexti, nextj, a, n, ans, move + dir[ind], vis, di, dj); vis[i][j] = 0; } } } public: vector<string> findPath(vector<vector<int>> &m, int n) { vector<string> ans; vector<vector<int>> vis(n, vector<int> (n, 0)); int di[] = {+1, 0, 0, -1}; int dj[] = {0, -1, 1, 0}; if(m[0][0] == 1) solve(0,0,m,n, ans, "", vis, di, dj); return ans; } };
[ "ragul.ravishankar@gmail.com" ]
ragul.ravishankar@gmail.com
ee7d7bcb7818032f16127ca2fcf09db41a21cb26
c048e266bcfd87389e0082f80290614f090915cc
/main.cpp
a42fd03680b8f154152adbda95e1ecc6cc6e88ce
[]
no_license
BarNeeY95/Timp_l6
1cfb172acdf08eba9cc5d8bd71cd46d8911a79e0
48c988eddcf56fb331a277308d5349191d065775
refs/heads/master
2021-01-02T22:17:27.469452
2015-06-03T06:30:19
2015-06-03T06:30:19
36,784,440
0
0
null
null
null
null
UTF-8
C++
false
false
3,980
cpp
// // main.cpp // // // // /** \include <iostream> \include <string> */ #include <iostream> #include <string> ///- Используем пространство стандартных имен using namespace std; /** \tparam T {Шаблонный тип, отвечающий за подаваемые в метода класса типы int и string} */ template <typename T> /** \class List \brief Класс "Список", реализованный с помощью линейного односвязного списка */ class List { ///- Указатель на следующий элемент List* pNext; ///- Значение элемента шаблонного типа T value; public: ///- Конструктор с параметром List(T value) { this->value = value; } ///- Метод добавления элемента в список void add(List* p, List* &pF) { p->pNext = pF; pF = p; } ///- Метод вывода списка на экран void printAll(List *pF) { List* p = pF; int i = 0; while (p != NULL) { cout << "Element #" << ++i << ": "; cout << p->value << endl; p = p->pNext; } } }; /**\return {0} - выход из функции */ /// Функция main() − точка входа в программу int main() { ///> Алгоритм функции ///- Инициализация переменных int N, n; char type; ///- Вводим количество тестов cout << "Enter the number of tests: N = "; cin >> N; ///- Реализация N-го количества тестов for (int i = 1; i <= N; ++i) { ///- Вводим количество элементов списка cout << endl << "Enter the number of list elements: n = "; cin >> n; ///- Вводим тип элементов списка cout << "Enter the type of list elements ('i' - integer, 's' - string): "; cin >> type; ///- В зависимости от типа выбираем определенную ветвь case. В случае ошибки выбираем ветвь default switch (type) { case 's': { List<string>* pF = NULL; ///- Вводим элементы for (int k = 1; k <= n; ++k) { string str = ""; cout << "Element #" << k << ": "; cin >> str; List<string>* list = new List<string>(str); pF->add(list, pF); } ///- Вызываем метод вывода элементов списка cout << endl << "Test #" << i << endl; pF->printAll(pF); delete pF; break; } case 'i': { List<int>* pF = NULL; ///- Вводим элементы for (int k = 1; k <= n; ++k) { int num; cout << "Element #" << k << ": "; cin >> num; List<int>* list = new List<int>(num); pF->add(list, pF); } ///- Вызываем метод вывода элементов списка cout << endl << "Test #" << i << endl; pF->printAll(pF); delete pF; break; } ///- В случае неверно введенного типа выводим сообщение об ошибке на экран default: cout << "Undefined type" << endl; break; } } cout << endl; ///- Пауза в работе программы system("pause"); return 0; }
[ "krid3d@yandex.ru" ]
krid3d@yandex.ru
b40ee980ed793757704bbf7b6023ec8bc319e551
f23fea7b41150cc5037ddf86cd7a83a4a225b68b
/SDK/BP_Prompt_EmissaryEntitlementPurchased_parameters.h
3e0175c75caa029292b86e4d97c9d226f2b374b4
[]
no_license
zH4x/SoT-SDK-2.2.0.1
36e1cf7f23ece6e6b45e5885f01ec7e9cd50625e
f2464e2e733637b9fa0075cde6adb5ed2be8cdbd
refs/heads/main
2023-06-06T04:21:06.057614
2021-06-27T22:12:34
2021-06-27T22:12:34
380,845,087
0
0
null
null
null
null
UTF-8
C++
false
false
2,118
h
#pragma once // Name: SoT, Version: 2.2.0b /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.OnEmissaryEntitlementPurchasedFunc struct UBP_Prompt_EmissaryEntitlementPurchased_C_OnEmissaryEntitlementPurchasedFunc_Params { struct FEmissaryEntitlementPurchasedEvent NewParam; // (Parm) }; // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.EmissaryEntitlementPurchased struct UBP_Prompt_EmissaryEntitlementPurchased_C_EmissaryEntitlementPurchased_Params { struct FEmissaryEntitlementPurchasedEvent NewParam; // (Parm) }; // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.Evaluate struct UBP_Prompt_EmissaryEntitlementPurchased_C_Evaluate_Params { }; // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.RegisterOtherEvents_Implementable struct UBP_Prompt_EmissaryEntitlementPurchased_C_RegisterOtherEvents_Implementable_Params { }; // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.UnregisterOtherEvents_Implementable struct UBP_Prompt_EmissaryEntitlementPurchased_C_UnregisterOtherEvents_Implementable_Params { }; // Function BP_Prompt_EmissaryEntitlementPurchased.BP_Prompt_EmissaryEntitlementPurchased_C.ExecuteUbergraph_BP_Prompt_EmissaryEntitlementPurchased struct UBP_Prompt_EmissaryEntitlementPurchased_C_ExecuteUbergraph_BP_Prompt_EmissaryEntitlementPurchased_Params { int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData, NoDestructor) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "Massimo.linker@gmail.com" ]
Massimo.linker@gmail.com
235e8c20127d3f7115df32ebba148f613b0dadc9
bdf9b430d9e6302b58cbdd2c2f438f3500ce62e1
/Old Topcoder SRM codes/Maxu.cpp
5d961a22a514bca2d2656de3b10517538ba499dd
[]
no_license
rituraj0/Topcoder
b0e7e5d738dfd6f2b3bee4116ccf4fbb8048fe9c
3b0eca3a6168b2c67b4b209e111f75e82df268ba
refs/heads/master
2021-01-25T05:16:18.768469
2014-12-14T13:47:39
2014-12-14T13:47:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
271
cpp
#include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; using namespace std; int main() { int a=10,b=5; int c; // c=a >? b ; return abs(a-b) >? abs(a+b); cout<<c<<endl; return 0; }
[ "rituraj.tc@gmail.com" ]
rituraj.tc@gmail.com
d91505c886d2dca96da1a32f076fa38f80216f87
f028d17056e8955accc84b5fa087ada9ba5a8241
/lesson7/InClass/Human.cpp
dfc0defa11826924b13ad2b75f9be9fb42e0ac30
[]
no_license
ck1001099-Teaching/cpp_course_2020fall
a20afd39bf0ece657f902ce52e40cfdab47c4bf1
91b80a47738cac07cb9efe1cb396acd03c241291
refs/heads/master
2023-01-25T02:53:52.633725
2020-12-08T03:43:21
2020-12-08T03:43:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,100
cpp
#include <iostream> #include <string> using namespace std; class Dog{ public: private: }; class Human{ public: string name; string bloodType; string birth; void SetLINEID(string ID){ LINE_ID = ID; } string GetLINEID(string name){ if (name == "小華"){ return LINE_ID; } else { cout << "不告訴你!" << endl; return ""; } } private: string LINE_ID; }; int main(){ //宣告「Human 類別」的物件,物件名稱為 h1 Human h1; h1.name = "小王"; h1.bloodType = "O"; h1.birth = "1996/02/02"; Human h2; h2.name = "小華"; h2.bloodType = "AB"; h2.birth = "1996/02/14"; cout << h1.name << " " << h1.bloodType << " " << h1.birth << endl; cout << h2.name << " " << h2.bloodType << " " << h2.birth << endl; h1.SetLINEID("myntu"); // h1.LINE_ID = "myntu"; 因為 LINE_ID 在 private member 裡,所以這行會 compile 不過 cout << "小華跟小王拿 LINE ID ,小王的 LINE ID: " << h1.GetLINEID("小華") << endl; cout << "小明跟小王拿 LINE ID ,小王的 LINE ID: " << h1.GetLINEID("小明") << endl; return 0; }
[ "ck1001099@gmail.com" ]
ck1001099@gmail.com
89b73796aac1fa0c577dc559cccee8775b395f2d
493ac26ce835200f4844e78d8319156eae5b21f4
/flow_simulation/ideal_flow/processor1/0.12/U
c7f2a5cafa267a45e7d7709053f9129bf51bf282
[]
no_license
mohan-padmanabha/worm_project
46f65090b06a2659a49b77cbde3844410c978954
7a39f9384034e381d5f71191122457a740de3ff0
refs/heads/master
2022-12-14T14:41:21.237400
2020-08-21T13:33:10
2020-08-21T13:33:10
289,277,792
0
0
null
null
null
null
UTF-8
C++
false
false
48,861
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0.12"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 1466 ( (-2.51867 -0.286169 -2.03466e-16) (1.88336 0.0383447 1.50308e-18) (-0.520923 -0.101222 7.28e-16) (-0.00297946 2.49041 -7.49919e-17) (-0.131464 -0.0892668 -7.70994e-16) (-0.441039 -0.0626501 -1.12617e-15) (-1.89014 -0.270844 1.99418e-16) (0.00916501 -0.161927 2.1385e-16) (8.62199 0.155304 -1.2946e-18) (-0.235505 -0.0234529 2.35533e-16) (-0.336875 0.0329484 -3.51669e-16) (-0.238759 -0.0499512 0) (10.3001 0.0544746 0) (-0.0207417 -0.139328 -2.0738e-16) (-0.329649 -0.156989 0) (-0.307947 -0.10383 2.83013e-16) (-0.156141 -0.139069 -1.39491e-16) (-0.0642985 2.60714 -3.28989e-17) (0.359058 4.52808 -9.5629e-17) (0.00810872 3.27261 2.35564e-16) (0.0628057 3.75304 1.05078e-16) (0.249628 -0.283592 8.46728e-18) (-0.150198 4.77661 -6.53154e-17) (0.0460904 3.19729 -2.53887e-17) (9.88434 0.0901969 5.65413e-17) (1.33285 0.249834 -2.61668e-16) (-0.616277 -1.10726 -1.60552e-16) (-0.127539 3.72931 0) (-0.612666 0.0364433 0) (5.19532 1.79339 4.98625e-17) (-0.716028 -0.208896 2.4088e-16) (1.53 -0.193293 1.62e-16) (-0.28064 -0.0546587 2.63919e-16) (0.0561035 3.05606 2.583e-16) (2.55441 0.0442143 9.0013e-17) (-0.434132 0.435709 3.00301e-16) (0.117064 3.04655 0) (-0.0844359 -0.103971 -3.56663e-16) (0.10105 0.00906178 -4.03843e-16) (-0.43357 0.0450624 -4.42706e-16) (-1.63043 -0.0118811 -1.50723e-16) (-0.127435 -0.13922 -4.45171e-16) (0.482935 -0.146813 2.18408e-16) (-1.23916 -0.234095 1.39911e-18) (-0.225101 -0.0599211 -4.8835e-18) (-1.62861 -0.0770922 0) (0.134995 -0.263288 1.14298e-17) (0.0666834 -0.0226288 0) (-0.195783 -0.0517405 1.44698e-16) (-0.122092 -0.0413693 0) (-0.728255 -0.0909816 -1.04671e-16) (1.5483 0.0296691 -4.38338e-16) (-0.306843 0.041243 7.12843e-16) (-0.0566858 -0.00481787 7.29143e-16) (-0.29882 -0.0592969 -1.2163e-16) (7.34528 -0.100769 9.74681e-17) (-1.75686 0.0632438 -2.20197e-17) (-0.27571 -0.121891 0) (-0.270046 0.0110202 1.27157e-17) (-0.160656 0.0333627 0) (0.736334 0.928478 1.96534e-20) (-1.60742 -0.19166 -1.18025e-16) (-0.256211 -0.259093 2.19854e-16) (2.01572 0.0380616 1.73853e-16) (-0.199308 7.74472 -1.4527e-16) (0.432977 -0.230044 3.1058e-16) (-0.598344 3.11812 0) (0.118621 2.40241 4.46136e-17) (6.76718 -0.161705 2.41261e-17) (-0.841073 0.0371801 -2.00367e-16) (0.812182 1.82687 1.19155e-15) (-0.215388 4.02104 0) (0.0504082 2.49818 0) (9.42416 -0.00643424 -1.18838e-16) (0.4862 0.768454 3.00818e-16) (3.80867 0.0606709 -1.08759e-16) (-1.51992 -0.168059 1.03252e-16) (-0.126827 -0.150747 -1.26461e-16) (-0.456258 0.00686139 0) (4.11569 0.418979 0) (-0.0490642 -0.073362 -2.01963e-16) (-0.530407 -0.120316 -3.76439e-16) (-0.74243 0.00403958 -3.259e-16) (0.566847 4.15779 2.59216e-16) (-0.0205521 2.7574 1.81401e-16) (0.18555 3.54297 6.70061e-17) (0.0254989 3.09137 0) (3.0557 -0.101671 1.53631e-18) (-0.0458866 -0.0608817 4.65564e-16) (-0.641087 0.228202 -3.07748e-16) (1.48239 0.280068 -9.4561e-17) (-0.460441 -0.667628 -3.26476e-16) (-0.000935509 1.58098 -7.77538e-17) (-2.04578 0.981546 -2.00031e-16) (0.0151926 -0.380127 0) (-0.385671 -0.015847 -4.4119e-16) (1.66739 0.0450193 3.71325e-16) (-0.125864 -0.0720582 -1.20176e-17) (7.59417 -0.171878 2.46151e-16) (-0.233851 -0.0481641 1.09955e-16) (-0.521981 -0.0894136 5.60983e-16) (-0.858063 0.0265533 0) (0.120502 -0.0207743 4.65149e-16) (-0.0672802 -0.0573799 3.81853e-16) (1.09385 0.0668021 -1.55827e-16) (0.197877 -0.113566 9.47134e-17) (-0.278585 -0.00046218 -2.66599e-17) (0.00754695 -0.0162886 0) (-0.316934 0.128024 2.82549e-16) (-1.99304 -0.103803 7.63862e-17) (0.923636 0.717858 -3.03012e-16) (2.80135 0.00777863 3.53147e-17) (-2.34475 -0.439933 -3.56668e-17) (0.23605 -0.161763 -5.35031e-17) (-0.231201 -0.0370912 0) (1.61975 0.343967 8.82302e-17) (-0.169774 -0.333394 2.32829e-16) (-0.378811 0.156402 0) (-1.87695 -0.144181 1.47977e-16) (-0.739003 -0.469757 -7.17607e-16) (-0.171075 3.46727 -5.54157e-17) (-1.41018 -0.46848 2.89627e-16) (-0.0238641 -0.0184943 -1.40493e-15) (-0.849885 -0.2283 0) (-0.100181 -0.0870062 -9.24121e-16) (-0.825338 0.246358 -9.29741e-22) (6.24999 0.272707 4.29866e-17) (-0.363238 4.37987 -7.33754e-17) (0.06765 3.26139 3.87414e-17) (2.73044 0.37874 1.5183e-16) (-0.0927503 -0.0648904 3.12389e-17) (-0.574094 -0.24802 0) (-0.267519 4.7914 4.55372e-17) (0.0431109 3.20848 5.42309e-17) (1.75434 0.103368 -1.48723e-17) (-1.74714 -0.00893924 0) (-0.860718 -0.192113 0) (-0.223461 -0.0396377 -1.21802e-17) (-1.86981 -0.0363709 -9.78368e-17) (-0.659689 -0.214328 2.48374e-16) (-0.198753 -0.0015269 0) (-0.0437972 3.77597 -1.02469e-16) (0.0176999 3.20068 -4.56328e-17) (-0.0497883 4.70886 -2.56502e-18) (1.78882 -1.49623 -2.56368e-16) (0.227146 3.67805 1.5589e-16) (1.45475 -0.259458 -2.79183e-16) (2.17262 -0.323902 -3.92834e-16) (3.23768 0.713155 -6.07712e-17) (-0.884657 -0.344173 1.12149e-15) (1.57657 0.259303 1.77251e-16) (2.04822 0.00729129 5.84426e-19) (6.59379 0.106185 -3.12459e-19) (-0.0852951 -0.492649 0) (3.23845 0.459801 0) (0.124262 -0.232891 3.56509e-16) (-0.175052 3.49077 -2.44326e-17) (0.0186199 3.01681 -2.64686e-16) (1.52446 -0.386372 1.03336e-15) (4.75991 4.18257 6.22144e-17) (1.36922 -0.308949 1.22592e-16) (5.60691 0.717491 0) (0.18341 2.37825 9.22664e-17) (-0.191832 3.3562 2.11805e-19) (1.36404 2.81891 0) (1.65864 -0.774118 1.69168e-16) (0.0589653 3.15866 0) (-0.395907 4.51033 2.05091e-16) (-0.245011 3.43213 -4.8074e-17) (-0.337274 7.32822 5.79225e-17) (-0.158279 3.6461 3.16941e-16) (0.696365 -0.243124 -1.16585e-16) (-0.059802 -0.07917 6.42851e-17) (6.81934 -0.0528425 -1.3661e-17) (2.08468 0.00168155 -2.72054e-16) (8.50955 -0.0755775 -2.35948e-16) (4.93704 2.33186 1.72166e-16) (4.64699 1.29921 -6.86481e-17) (1.06112 0.563596 -4.15879e-16) (0.520417 2.39354 -2.43028e-16) (10.0213 -0.0883803 2.8025e-16) (2.00307 0.0933232 -3.28703e-17) (-0.157248 3.08282 -2.58025e-16) (0.172255 -0.0877367 3.48952e-16) (2.87208 -0.154993 -3.74943e-17) (0.0796062 3.48269 -5.12491e-18) (-0.0498703 2.72916 -1.80059e-16) (1.24831 4.47912 -1.50753e-16) (6.30745 -0.253754 6.11311e-17) (-0.726058 -0.296252 4.83073e-16) (-0.0467497 3.76232 -2.19571e-16) (0.577677 1.19487 -8.69756e-19) (0.169755 0.817494 1.06731e-17) (0.0966995 3.74828 3.80142e-16) (5.1002 3.50954 -3.61472e-17) (1.23602 0.595383 0) (-0.63084 -0.0661911 4.2026e-18) (0.787335 -0.110278 -5.09606e-16) (0.669568 3.03851 -2.98156e-16) (0.314489 3.53317 -7.70142e-16) (-0.0884212 0.548988 0) (2.93369 0.530046 0) (5.85481 1.57762 -3.00895e-19) (-2.3633 4.3356 0) (1.10237 1.43381 2.32868e-16) (0.901614 2.59279 -1.95921e-16) (0.153977 3.67094 -1.85031e-16) (6.30804 2.93979 0) (1.65436 -0.354009 1.20796e-16) (0.0389038 3.25497 2.01952e-20) (0.152051 4.72194 9.06953e-17) (0.016607 2.73021 -1.66639e-16) (-0.186643 3.68759 0) (-0.187639 3.68541 2.53618e-16) (0.094611 3.72205 -6.38052e-17) (-0.102798 3.25891 8.49395e-20) (0.039149 3.47734 4.54112e-18) (-0.124597 2.67712 -1.59427e-16) (2.08043 3.8997 1.5741e-16) (0.0621318 3.22772 3.83439e-16) (-0.414812 4.56015 -1.6491e-16) (1.69843 0.251997 -1.24871e-16) (-0.155261 3.2493 -3.8754e-16) (1.12548 0.798992 2.87795e-16) (-0.22002 3.32893 1.46877e-16) (1.80579 3.4508 -1.76877e-16) (-0.200494 -0.250744 6.7595e-16) (0.174655 -0.0328418 -3.29105e-16) (1.30487 0.424223 -3.02139e-16) (1.7643 0.188908 3.17884e-20) (0.48603 1.62743 -6.06964e-16) (2.76119 -0.195061 2.21357e-16) (0.0680828 3.55638 1.6081e-16) (-1.18934 7.50077 1.48523e-16) (-0.769467 -0.252476 5.89235e-17) (1.2975 1.97273 -8.17189e-16) (0.0333217 3.16953 6.68463e-17) (-0.242103 4.61882 1.94226e-17) (2.4678 0.0343384 2.13299e-16) (-0.106425 3.63351 3.93466e-17) (-0.198388 1.18257 0) (4.31999 0.296052 4.38637e-17) (5.55044 2.44737 8.90976e-17) (0.357706 3.06896 3.44946e-16) (1.82769 0.00146119 0) (5.87515 0.552775 0) (1.66533 -0.0757248 0) (9.81322 0.0036694 0) (3.64944 0.602996 -1.16029e-16) (5.36862 2.92934 -8.22062e-17) (0.0165125 3.65896 -9.11464e-17) (-0.706332 7.57879 -2.17646e-16) (5.97597 3.55403 4.06683e-18) (-2.41553 -1.20041 -1.0151e-16) (0.825151 -0.365507 2.97817e-16) (2.00454 -0.320556 -2.51129e-16) (-0.162302 3.41079 0) (7.90554 3.70182 -1.8134e-16) (0.040127 2.00108 -1.0085e-16) (-0.00873654 2.15184 1.37368e-16) (-0.327228 0.797437 0) (-0.29287 4.71014 -3.01937e-17) (0.0384949 3.18469 -7.3366e-17) (1.77631 0.110321 3.18272e-20) (3.88582 4.66529 9.52311e-18) (-0.034358 -0.0416738 -3.75184e-16) (1.70624 0.131799 2.82862e-16) (3.30753 0.597983 -1.06102e-16) (0.138354 3.63422 -3.20785e-17) (8.74656 3.2236 -8.31889e-17) (0.384741 2.50481 -1.6668e-16) (-0.0225047 2.05965 0) (-0.0718445 0.419607 6.99578e-18) (1.7041 -0.275833 -1.52114e-16) (1.68628 0.200287 -3.63108e-16) (0.976475 1.04355 5.55224e-16) (1.47015 0.408585 -2.58627e-16) (1.76765 7.12669 -1.27301e-16) (-0.250701 3.38851 -2.15213e-16) (3.47287 0.768413 1.60685e-16) (1.83444 -0.0626891 2.21882e-16) (-0.847021 1.72443 2.39174e-17) (2.44156 5.86149 0) (4.81635 -0.0229813 -3.93311e-17) (1.12173 0.954409 4.66361e-16) (-0.0921102 -0.233853 -2.07907e-16) (3.92043 1.00983 0) (3.73685 0.997093 -3.17045e-16) (-0.371116 -0.020103 0) (7.10235 3.47232 -2.95352e-16) (7.68943 0.395581 1.34694e-16) (-2.41339 -0.155786 -1.27959e-18) (10.1886 0.0369775 -2.843e-16) (-0.326772 0.00298594 0) (2.59324 6.84677 1.1391e-16) (1.27983 3.06028 -3.49584e-16) (-0.0996362 1.82637 1.87589e-16) (-0.109746 -0.0978484 5.67091e-17) (3.91908 0.985847 7.50144e-17) (1.80819 0.0657594 -2.61922e-16) (0.0241775 -0.115751 0) (-0.251958 -0.133267 2.66716e-16) (0.187592 0.0623853 0) (10.0429 -0.0574715 -1.79104e-16) (0.0493458 3.15395 0) (0.102358 1.13235 1.40443e-16) (-1.52416 2.57304 1.29673e-16) (-0.2586 -0.120673 -3.18319e-17) (1.15918 6.61286 -3.35883e-17) (-0.710406 4.20084 1.11499e-16) (7.22655 1.1681 1.50979e-16) (-0.534832 4.22478 0) (0.066439 3.16269 -9.2913e-20) (2.51219 0.422079 -1.75335e-16) (3.73391 1.55314 -2.15982e-16) (4.423 2.31639 -3.2688e-16) (1.50068 1.83588 0) (4.02279 3.15968 2.35889e-16) (-0.288273 -0.147088 0) (-0.279991 -0.276175 3.95552e-16) (0.372328 1.31413 0) (-0.0636273 1.99731 -1.93914e-16) (0.0656887 2.05928 -8.72924e-17) (1.81102 -0.0188145 3.21541e-16) (0.0776209 2.996 -4.17853e-17) (6.07321 4.72378 -9.99329e-17) (-0.0476561 -0.156099 -1.11849e-16) (3.17111 3.49499 -2.61891e-16) (1.80566 -0.101238 -2.71533e-16) (1.96961 0.394398 2.20636e-16) (-0.194944 3.81321 1.2837e-16) (6.65574 4.09537 5.83394e-16) (-0.383776 -0.203482 -5.35093e-16) (1.73311 7.32441 2.69411e-17) (2.73174 4.17939 -1.41838e-16) (6.82307 1.65431 5.99992e-17) (2.24794 1.67788 -4.24987e-16) (2.41252 -0.122597 3.66856e-16) (-1.33697 2.53248 -2.18849e-16) (-1.2511 -0.0396376 -2.15213e-16) (-0.0684091 0.0509408 8.88776e-19) (6.4628 2.47928 7.09455e-17) (-0.215487 -0.0955536 5.89461e-17) (1.72366 3.74531 -3.43457e-17) (-0.744191 7.06369 -7.23792e-17) (0.314015 0.0662388 -1.00154e-16) (4.88815 -0.130529 -1.75267e-17) (2.01039 5.2981 -9.25702e-17) (5.67532 -0.272395 2.30853e-17) (2.81948 2.94768 1.64945e-16) (5.25031 4.91645 -2.71896e-18) (8.08787 2.56777 -4.60874e-17) (-0.73889 4.11808 -1.12042e-16) (1.79492 1.86164 1.1145e-17) (1.94394 0.567621 0) (1.92065 3.94305 1.82334e-16) (-0.244422 1.19001 -3.8295e-16) (3.37339 0.445077 5.77252e-18) (9.47229 2.15828 0) (1.55959 6.06381 2.92654e-17) (1.4573 -0.0170007 0) (1.61079 6.04419 9.01466e-17) (1.00017 7.42843 9.74401e-17) (-1.69186 4.03942 0) (-0.318745 -0.110753 -3.74953e-16) (-0.504283 3.06703 -5.83598e-20) (7.10873 2.27377 5.50211e-17) (7.45458 1.80113 4.68435e-17) (-1.4946 -1.72522 1.5569e-16) (1.14799 7.53301 4.31724e-18) (0.807275 6.97482 0) (0.800902 6.49187 8.48179e-17) (0.644625 4.33 -2.84746e-17) (0.897301 7.38311 -3.91187e-18) (-0.267612 -0.200643 8.14003e-16) (-0.00514083 2.96276 7.23089e-17) (-0.383271 -0.0126018 -4.1424e-17) (0.490295 5.36908 7.0594e-17) (-1.99227 0.743248 5.92462e-16) (3.40676 5.83188 -8.64526e-17) (-0.896517 3.16877 1.25883e-16) (-0.719648 2.94578 -4.17817e-16) (-0.712074 3.14787 -2.63311e-16) (-0.545045 3.10008 3.91388e-16) (-0.394684 2.88008 0) (-0.550553 2.91807 2.13728e-16) (-0.228645 -0.118052 -2.8801e-17) (-0.227028 -0.15736 -3.12422e-16) (-0.239964 -0.148201 2.21532e-16) (-0.223584 -0.170215 -5.54583e-17) (-0.00786018 1.85556 2.35531e-17) (0.109806 2.55647 6.89146e-17) (-1.55432 3.63154 -6.72582e-17) (0.022472 2.55223 -8.06086e-17) (-1.79357 3.16723 1.69294e-19) (-1.43698 2.1053 1.34702e-16) (-0.221536 -0.276732 -6.8238e-17) (0.402272 5.89705 -3.18213e-17) (-1.92635 3.1009 6.85718e-17) (-0.723576 1.84509 0) (-0.249242 -0.260835 -2.32937e-16) (-0.0431004 -0.216621 2.78277e-16) (-0.438372 4.67927 0) (-0.292719 -0.419368 3.3275e-16) (-0.838642 6.12677 -2.65267e-17) (0.0517021 -0.234369 -7.65003e-19) (-0.189586 3.96657 -4.79993e-16) (-0.605107 0.0906931 -1.27934e-16) (-0.621603 -0.565678 0) (-0.0814252 -0.377864 1.8785e-16) (-0.295961 -0.492056 -1.60115e-16) (-0.240537 3.05779 -2.10868e-16) (-0.155743 1.27866 3.30268e-16) (-0.0161407 -0.174875 9.91001e-16) (0.557333 0.00782536 -1.70454e-16) (-0.13943 -0.388466 0) (-0.349074 -0.33961 0) (-0.108623 0.0966528 1.6815e-16) (-0.239742 -0.314663 0) (-1.88568 -0.276038 0) (0.0385712 -0.766172 -2.4567e-16) (0.104254 -0.340904 6.00985e-16) (-1.84624 -0.275161 0) (-0.156289 1.91975 1.39087e-16) (-1.77043 -0.267659 1.39401e-16) (-0.108305 -0.680133 -3.45067e-19) (-0.216656 -1.51072 5.40845e-16) (0.953774 3.0921 2.13644e-17) (-1.76062 -0.278279 -7.47524e-16) (-0.378441 -0.825455 4.37735e-16) (-0.180982 -0.164295 0) (-1.85869 2.52043 -6.3166e-19) (-0.276247 -0.22735 5.64592e-16) (-1.08344 3.78428 3.45552e-17) (1.96384 -0.0175081 -5.66333e-16) (-0.682033 0.662243 -4.16706e-16) (-0.365374 -0.24999 9.09444e-17) (-1.24289 -0.64524 -7.23481e-17) (0.0583883 -0.121633 4.70514e-16) (-0.195268 -0.14023 -4.99735e-16) (-0.47615 -0.25746 5.24549e-17) (-0.0412943 1.27503 -1.06648e-16) (-0.236841 -0.107053 3.73745e-16) (-0.498873 -0.121928 0) (1.88306 -0.0164695 -3.19286e-16) (-1.8403 -0.475169 1.7239e-16) (7.42118 0.129761 7.10211e-17) (1.88685 0.0108884 0) (-1.89409 -0.374899 -1.10796e-16) (-0.213844 -0.107179 2.40191e-16) (1.89025 0.0878304 -7.38534e-19) (-2.03311 0.0891947 -1.40708e-16) (-0.438649 0.406518 -5.37855e-17) (9.52276 0.268725 2.9108e-17) (-0.0444701 2.22605 -2.7023e-18) (-0.0620616 1.33171 6.48536e-18) (-0.210865 -0.365648 0) (-0.597902 0.26581 0) (-0.15944 1.00869 0) (1.84403 0.0503277 2.836e-16) (-0.214981 -0.10994 -6.17252e-16) (-0.102514 1.79274 -2.89277e-17) (-0.442137 -0.114776 -2.9075e-16) (-0.197465 0.932679 7.8747e-16) (-0.384225 -0.185695 2.79074e-16) (-1.80053 0.170533 -1.59515e-16) (-0.363092 2.73185 -1.57572e-16) (-0.192369 1.65529 -4.28041e-17) (-0.756028 1.63126 -7.52041e-17) (-0.532494 2.7454 7.96397e-17) (-0.371863 1.54267 1.68787e-16) (-0.18017 0.0112807 3.37955e-19) (-0.272289 -0.25861 -7.85104e-16) (0.17509 -0.0819509 8.76225e-20) (1.78542 0.123423 1.64516e-16) (-1.65044 0.569036 6.99036e-19) (-0.0391775 0.0994702 -3.35463e-16) (-2.51509 5.05329 0) (-2.35905 6.63326 0) (-3.05025 5.28917 -5.74353e-18) (0.659029 7.66219 -8.96484e-17) (-0.0888299 1.64072 3.2953e-16) (0.10409 2.96887 -2.51821e-16) (-2.4685 6.26011 7.31191e-17) (-2.74752 6.08411 -2.41481e-17) (5.34997 4.11782 -1.97324e-16) (-1.69554 1.22659 -1.74738e-16) (0.0202403 0.158229 3.07263e-16) (0.0270454 7.08847 -7.14023e-17) (0.365119 7.70413 8.81803e-17) (-2.44345 6.23064 9.59822e-17) (-0.130092 3.66138 6.77156e-17) (-0.215602 -0.183505 -2.75048e-16) (-0.215241 2.73076 1.59444e-16) (-2.71208 4.54095 0) (0.0795043 2.76596 3.96831e-17) (0.0750137 2.92578 0) (-0.254231 2.84978 9.1921e-18) (3.63084 2.34551 0) (-1.27729 3.66929 8.43287e-17) (-0.383151 3.04203 0) (-0.359332 3.24494 0) (-0.416443 0.507844 2.99211e-20) (-0.549036 0.208066 3.36772e-16) (0.109864 0.227505 -3.4091e-16) (-1.6164 4.32222 0) (0.756683 6.27889 0) (1.82686 0.178366 2.43263e-16) (-1.72477 1.46007 1.22791e-16) (0.10983 2.88584 0) (2.17562 -0.184175 3.10868e-16) (-2.83744 5.77532 -1.22225e-17) (-2.02215 4.17769 5.135e-17) (-0.250286 1.58314 -1.35977e-16) (0.131976 2.95376 -1.46386e-16) (-1.45401 3.8669 -1.1708e-16) (-0.265288 2.14209 -2.9423e-17) (9.82552 0.105188 -2.6608e-16) (7.59141 -0.290078 7.13824e-18) (-0.0856357 -0.243277 9.73293e-16) (-0.260867 2.96827 -8.15385e-18) (-0.917813 1.96607 2.80732e-16) (-2.08064 6.1561 6.31162e-18) (3.78405 4.26553 0) (-2.74145 5.40515 0) (-0.509511 2.50802 4.61173e-17) (-0.694425 2.12739 0) (-0.91115 -0.822057 -4.43706e-16) (-0.321455 2.51474 -6.46417e-17) (-2.42762 5.84989 -9.95558e-17) (-2.21402 -0.103418 1.58341e-16) (-0.688096 3.04095 -4.22973e-17) (1.32155 4.15329 -1.88726e-16) (-0.00188535 2.75131 0) (-0.0390055 2.8412 0) (-0.463461 2.11485 -5.44398e-17) (3.50091 6.51674 0) (0.962948 5.65206 0) (-0.13886 2.19587 0) (0.0572664 2.5843 -2.66446e-16) (4.73645 4.78953 8.2543e-17) (-0.46187 0.404946 -3.25843e-16) (0.0551881 0.341481 -3.23161e-16) (-1.78707 3.73931 1.72884e-16) (-0.176525 2.53446 8.4094e-17) (2.43646 6.94331 -3.7175e-17) (-0.0683003 2.54863 2.56147e-18) (4.44909 6.03249 -4.24699e-17) (-1.69815 5.94187 -5.32154e-17) (1.7701 0.265831 1.32072e-16) (-0.554837 -2.07634 2.24765e-16) (-1.66142 2.14369 8.57793e-17) (0.110152 0.495425 -6.42779e-17) (-0.135836 2.83653 -1.44835e-17) (-0.425635 2.11436 5.19864e-17) (0.18324 2.96602 2.49369e-16) (0.168708 2.91912 -8.70589e-20) (-1.34344 3.53473 3.17037e-17) (1.78165 0.125236 1.20015e-16) (5.335 5.39417 -1.81856e-16) (-2.2694 5.46004 1.32859e-17) (1.33009 2.24475 1.62667e-16) (1.81482 0.019367 2.86376e-16) (2.54282 4.37725 2.98717e-17) (8.11995 -0.284277 -2.4021e-16) (-1.82054 3.45579 6.27876e-17) (-0.0974454 2.73969 9.90056e-18) (-1.98638 5.77401 -1.31431e-17) (1.2763 4.78714 6.05928e-17) (-0.0495599 3.05798 1.59765e-16) (0.0883705 3.08604 3.68298e-17) (-1.81196 5.42164 0) (2.7216 0.259596 0) (4.1928 1.57722 4.91567e-16) (-3.14793 4.07469 -4.74787e-18) (-0.798077 4.14073 8.25719e-17) (7.84305 3.41672 -3.7629e-17) (-0.0632404 2.97439 3.94309e-17) (0.0426383 2.85858 -1.93106e-17) (-2.44266 -1.65806 3.64053e-16) (-3.12722 5.08238 -4.15188e-17) (-0.00811097 3.03272 -7.4321e-17) (0.0113833 2.90363 1.49037e-16) (-1.91762 4.52409 -1.59381e-16) (-1.08608 3.39159 2.35019e-16) (-2.99129 4.80732 4.81388e-17) (-0.375315 3.58504 7.80877e-20) (9.46785 1.26219 9.33205e-18) (0.151694 2.79385 -2.4207e-16) (-1.60927 3.40937 -1.05982e-16) (0.0465711 3.12364 -1.52474e-16) (3.20544 6.39392 0) (2.89003 -0.998458 0) (-0.065309 2.8982 -1.55649e-16) (0.0872723 3.69724 9.9664e-20) (-0.0399837 3.27558 5.0856e-17) (0.638921 4.62507 8.58138e-17) (-1.17839 5.42771 7.06879e-18) (-3.27032 4.24399 1.5587e-18) (-1.40581 5.89063 2.02483e-17) (2.39339 2.73701 0) (7.19493 4.34226 -6.6025e-18) (7.12047 4.23218 -7.934e-17) (1.51652 7.05207 3.6972e-18) (-0.0834126 3.29954 -8.75355e-17) (2.17764 -0.888227 -1.99172e-16) (2.07562 -0.163026 -2.23909e-16) (0.143325 -0.0859733 -1.57561e-16) (-0.203823 -0.22121 -1.28289e-16) (-0.517794 3.32038 0) (-2.81335 3.87649 5.55009e-18) (-0.268566 1.36447 0) (3.99229 5.65274 0) (4.5153 5.74599 4.21694e-17) (0.0234978 2.02312 0) (4.72246 3.29399 1.16574e-16) (4.65292 1.64151 -1.29038e-16) (3.24783 5.10424 5.51905e-17) (7.4533 0.588262 0) (-0.607837 3.7819 -1.14312e-17) (2.04838 6.57401 1.34691e-17) (-0.13967 -0.17545 4.39032e-16) (2.11135 -0.292413 -1.50009e-16) (5.61837 5.42614 2.38775e-16) (5.5134 -0.0177774 -5.03589e-18) (-0.152993 2.9162 1.60884e-16) (0.0777167 1.71519 1.83738e-16) (2.5657 -0.264999 1.11212e-16) (1.86037 1.18745 -1.67407e-16) (0.0574857 2.97335 0) (-2.74165 5.35022 -3.33756e-17) (7.28918 2.8686 1.03439e-16) (7.55547 0.951776 -9.73461e-17) (6.38139 4.76552 6.34949e-17) (-0.128774 3.0131 -8.51441e-17) (8.93044 2.39042 5.18087e-17) (-0.900246 4.44523 -8.28919e-20) (-1.23938 5.58162 -2.8828e-17) (3.45802 0.931129 3.91469e-16) (0.190009 2.46851 7.27622e-17) (-1.54913 5.60561 5.7464e-17) (-0.730541 4.0791 3.69418e-17) (-0.770979 4.49539 8.27512e-18) (1.42149 0.578065 2.30934e-16) (-0.326768 3.49624 -1.36998e-16) (6.51273 4.93683 -1.02021e-16) (2.13231 0.256459 1.00059e-16) (-1.54393 4.64658 0) (-0.929082 5.067 3.7578e-18) (2.64369 5.90975 -2.81821e-17) (-0.199539 3.08482 -8.37575e-17) (9.32 -0.167156 3.33781e-16) (2.05176 0.571484 -2.75752e-19) (-0.194655 -0.109896 3.17242e-16) (-0.132542 5.60889 1.29783e-16) (-0.476303 3.57139 2.48198e-16) (-1.5144 2.3252 1.46391e-16) (-0.075086 1.84598 2.08721e-16) (1.79298 -0.210262 3.40405e-16) (9.93186 0.772487 5.74716e-17) (-2.05248 6.55767 -7.08419e-17) (3.02192 -0.16313 4.58189e-18) (-1.27522 0.259947 4.4602e-16) (7.74632 3.71717 0) (-1.9328 6.06846 0) (2.0566 0.288535 1.42198e-16) (-0.6821 0.672449 7.79416e-19) (3.07515 0.533874 0) (-0.591338 0.282617 0) (-1.6807 1.78694 0) (-0.260427 -0.107193 -5.72454e-17) (2.23095 -0.224421 5.00279e-17) (-0.855648 0.275023 0) (0.129476 -0.0663185 1.0742e-15) (0.115751 -0.257019 -1.09829e-15) (0.026223 -0.155879 1.87481e-16) (-0.263625 -0.162234 -3.40657e-16) (0.612034 0.215808 2.68372e-17) (-2.00283 -0.13261 1.27868e-16) (7.99539 2.41309 2.47607e-16) (0.104345 2.61574 8.50942e-18) (-0.234641 -0.111471 -2.71067e-17) (1.55502 0.126787 8.2684e-16) (-0.645152 1.34915 0) (0.120243 0.261777 -3.60224e-16) (0.905159 -0.162162 2.71002e-16) (1.1061 0.30591 0) (-0.624966 0.0731498 2.0872e-16) (-3.10709 4.42612 6.5023e-18) (-0.598825 0.136719 0) (0.653273 4.58184 7.99349e-17) (8.33065 1.75751 -3.51197e-17) (8.14893 3.11847 -1.70524e-16) (-0.15463 5.6867 -1.54556e-16) (0.504014 0.312371 3.19712e-16) (-0.499842 0.0405587 -7.38999e-16) (-0.523009 6.28869 -9.29886e-17) (0.250362 -1.32006 -1.05469e-16) (1.28417 0.2442 -4.64494e-18) (-2.22362 4.76019 8.12847e-17) (-0.250212 3.69486 2.22291e-16) (0.869126 0.318848 0) (-0.673564 0.0999372 1.89415e-16) (1.80599 -0.0468806 0) (-0.689825 3.37314 0) (-1.09558 3.60611 1.4223e-16) (2.76747 0.0384116 -1.61119e-16) (-1.39318 1.42315 8.65578e-17) (-0.324417 0.00103603 3.71263e-16) (-0.879118 3.3996 -1.23516e-16) (-2.44925 3.81618 0) (-0.262648 3.75907 1.26423e-19) (-2.69527 0.0913995 3.11988e-16) (-0.59644 3.53362 3.74349e-17) (-1.4017 5.29341 6.47255e-17) (0.0022884 2.823 2.34562e-16) (3.94936 1.63221 -4.50944e-17) (-1.23204 4.03018 1.12669e-19) (1.3306 1.75953 -1.48054e-16) (3.00254 0.655423 -9.92516e-17) (4.4384 0.0206605 5.79078e-17) (-0.390952 -0.245397 -3.27923e-16) (-0.636283 1.99302 0) (0.0653344 1.38046 0) (-0.0183682 1.84606 0) (-0.0458436 3.21993 4.53523e-16) (0.158836 2.49086 -4.35449e-17) (-0.708209 2.49562 0) (-1.30596 2.85578 0) (0.457177 0.0685149 5.89058e-17) (0.783482 -0.243337 9.30922e-17) (0.00354129 1.22252 2.90311e-16) (1.68305 -1.54232 3.53006e-16) (-0.14283 -0.232675 0) (-0.564876 0.995123 -5.58755e-17) (1.77696 2.21627 7.61032e-16) (-0.0950932 2.61999 7.50732e-21) (-1.12003 5.23087 0) (-0.335639 -0.0145369 -3.00768e-16) (-1.76132 6.28052 4.44698e-17) (0.0814315 3.00743 1.3483e-16) (-0.114226 -0.217874 1.49491e-16) (-0.257232 3.2259 0) (-0.604102 -0.0830798 1.92574e-16) (-0.00187781 -0.97225 6.64971e-16) (-1.74211 -0.371495 3.09085e-16) (1.47393 0.0728872 0) (0.118072 0.626991 2.78887e-17) (-2.08688 3.80217 -1.06974e-16) (6.01349 0.403751 -9.28353e-18) (0.13092 2.5454 -2.52006e-17) (-2.71332 -2.53772 -3.45991e-16) (1.54875 0.181042 1.66266e-19) (-0.105934 0.107149 1.79686e-16) (-0.524026 1.08495 4.39038e-16) (-0.314911 0.982869 -1.35121e-16) (0.327045 3.56545 1.95114e-16) (0.205626 2.51195 0) (8.7495 0.142444 -1.03444e-16) (0.13322 3.82694 -8.4693e-17) (-0.00558949 2.74767 8.92647e-17) (-2.15828 0.840846 1.6531e-16) (1.35069 0.798184 6.32073e-19) (3.22062 1.17229 -4.61966e-17) (-1.60708 7.28888 -4.20556e-17) (5.81212 2.04872 0) (-0.166046 3.56383 -3.25023e-17) (0.544856 0.850525 0) (-0.609928 0.166778 0) (-0.0657129 3.37194 2.6881e-16) (2.35342 -0.19243 -8.0502e-17) (-2.55214 2.84592 1.31713e-18) (-0.0159713 -0.0834755 3.13966e-16) (-1.49864 -0.457921 1.87624e-16) (-0.110438 -0.839763 8.97893e-19) (-0.243434 3.07902 -4.57464e-16) (2.93336 1.89254 3.23776e-17) (-0.199782 0.199374 3.86325e-16) (-0.711644 2.74991 -3.55633e-19) (-0.0183302 3.4373 2.0631e-16) (0.035952 2.22122 0) (-1.79579 2.77846 3.4172e-17) (-0.090374 3.73968 4.24936e-17) (-2.45201 -0.983407 -1.69859e-17) (0.763059 3.07239 -6.45397e-17) (-0.00583862 -0.214335 -2.96203e-16) (-0.216189 -0.234906 4.17361e-16) (0.133949 2.99586 0) (-1.11539 3.8458 7.8365e-17) (0.164744 7.49496 -1.41242e-16) (-0.901287 2.9478 1.31447e-16) (-1.19138 5.46516 -2.56161e-16) (-0.278563 3.04607 0) (-2.13999 1.87069 -4.33981e-16) (2.13823 -0.0332714 -1.24201e-17) (8.58351 0.732535 -5.20641e-17) (-1.1209 4.82418 1.31585e-16) (-0.0177122 -0.811754 1.47206e-17) (-0.423447 -0.321304 -3.07105e-16) (0.0314802 1.11192 -6.73649e-17) (-1.68969 2.50143 -2.43232e-16) (-0.132186 -1.00718 -1.85456e-16) (0.0109676 3.10162 1.56133e-16) (-0.284692 -0.147751 -3.64708e-16) (5.2468 2.79704 1.80664e-16) (0.0263529 -0.0976374 -4.76534e-16) (0.0768853 0.366026 1.8846e-16) (8.60038 -0.187813 6.55151e-17) (0.0315863 -0.475198 7.74023e-19) (0.126984 2.54757 1.48089e-16) (-0.0828912 2.78763 7.65658e-17) (-1.49879 6.1532 -6.47015e-17) (-0.360158 4.22523 4.38874e-18) (0.0522618 3.2989 1.53417e-16) (1.24578 1.084 -3.55985e-20) (-0.327605 -0.121199 2.8186e-16) (0.374169 0.0189099 -8.55918e-17) (-0.145498 3.58385 0) (1.73735 0.178038 -1.69747e-16) (-1.04684 4.89894 -7.7837e-17) (0.998102 -0.258084 -1.03052e-16) (-1.37734 4.24562 1.27123e-19) (-0.634193 0.0329733 -3.38048e-16) (3.93889 0.935111 -8.73157e-17) (0.0829443 -0.394549 2.29769e-16) (-1.67452 -0.370755 1.83912e-16) (-0.30201 2.11264 0) (9.23922 0.720137 0) (8.33955 0.272673 3.87664e-17) (-0.297548 3.99291 0) (3.90494 0.539183 0) (1.55635 1.0757 -2.1574e-16) (-2.34565 3.31558 0) (-0.191409 -0.265312 1.65557e-16) (-1.80267 -0.146527 2.0635e-16) (-0.273998 -0.43852 -2.84863e-19) (-0.597604 -0.462362 -1.12946e-16) (-0.443852 0.168686 -3.82946e-16) (-2.1978 2.46383 5.01479e-20) (-2.06838 2.91779 0) (-2.06524 3.45422 -6.07459e-17) (-0.788734 4.04011 1.35007e-16) (-2.03874 5.12108 2.7943e-17) (-2.37144 -0.348378 -4.3626e-19) (0.672403 -2.0465 0) (0.430068 5.68081 3.38831e-18) (1.42278 0.0407231 -1.3688e-16) (0.0303157 3.08572 2.84413e-16) (2.16941 -0.0625558 0) (0.379284 -0.300279 -6.51115e-16) (-1.50652 -2.3206 1.85047e-16) (4.76937 -0.208854 3.54307e-17) (-0.197529 2.39559 -9.94311e-17) (0.263813 2.63722 0) (-1.46932 3.12651 1.34047e-16) (2.44889 -0.236081 6.13307e-16) (2.8675 0.0962011 -8.4407e-19) (2.12181 0.273473 6.00143e-16) (0.0992696 -0.284885 9.32513e-17) (-0.57559 3.24753 -1.91661e-16) (-0.643196 7.47186 -2.16305e-16) (0.0284532 3.03479 -5.39233e-16) (9.65689 -0.167454 1.85434e-19) (-1.1066 2.64944 -5.28699e-16) (0.92255 0.422764 -1.42466e-17) (-1.72258 -2.32545 1.3783e-16) (-0.409176 2.17558 1.02665e-16) (0.173302 1.59767 -3.52281e-16) (2.32415 -0.0363099 2.80343e-16) (0.205852 2.84644 8.04973e-17) (-1.44223 3.34667 -8.45323e-17) (1.26525 0.145435 5.04701e-16) (1.92763 -1.43845 -1.00842e-16) (1.58928 -0.399371 -6.09411e-17) (-2.07989 6.88533 -8.64061e-17) (-0.906148 2.40461 -7.32623e-19) (-1.78527 4.83975 0) (0.0825807 2.40229 0) (0.066152 2.31957 0) (0.08212 2.44419 -6.23891e-17) (-0.063295 2.18979 4.02147e-17) (0.0402092 2.1997 0) (-0.0928669 2.39644 0) (-0.0095639 2.13063 0) (0.0819389 3.20516 -1.30835e-16) (-0.0814848 4.47475 0) (-0.0131371 4.46258 0) (0.0974694 3.07944 1.32016e-16) (0.0498435 3.24146 0) (0.0139074 3.25098 -6.18883e-17) (0.109265 2.92687 3.15577e-17) (-0.158741 4.32464 0) (0.0517308 4.27831 -1.10826e-16) (0.113714 2.57838 -5.77956e-17) (0.115751 2.75382 3.52116e-17) (0.108871 3.94188 1.20517e-16) (0.151287 3.489 3.49111e-17) (0.253024 2.77413 1.66372e-17) (0.192222 3.10234 -1.9543e-17) (-0.0111487 3.24726 6.43056e-17) (-0.0254543 3.25063 0) (-0.0366493 3.24732 0) (0.067226 2.4927 6.22979e-17) (2.90682 -0.0833366 4.10088e-17) (10.1395 0.096291 -1.83979e-18) (0.640838 0.0806506 -3.00072e-16) (1.99614 -0.745427 -8.32328e-17) (-3.17784 3.04612 -1.24679e-16) (-0.818519 -0.18932 -2.16846e-16) (-1.45735 1.98147 2.69933e-16) (0.0057178 -0.095649 3.18228e-16) (-0.26265 -0.118745 0) (-0.888252 4.35654 -2.24159e-16) (-0.0690397 3.68472 -9.1107e-17) (-0.102009 3.31618 -8.25843e-17) (-0.457841 -0.257247 -5.38816e-16) (1.47039 0.123785 0) (9.04264 1.55822 -9.11345e-18) (-0.28877 -0.115934 -1.95914e-16) (-1.15936 2.21073 1.52375e-16) (2.58904 -1.43594 8.98644e-17) (1.98476 -0.116043 8.84102e-16) (-0.547508 1.72905 2.04669e-16) (1.95663 -0.00729756 0) (-0.00813003 6.85856 3.63502e-16) (-1.61703 5.11792 0) (0.675779 -0.628163 0) (-0.0581015 3.21532 0) (-1.24713 -0.287345 8.67505e-17) (-0.0690145 0.00449731 2.306e-16) (8.8263 0.766849 -2.24877e-16) (0.119932 -0.0613451 -2.23103e-16) (9.9507 0.031581 -6.20434e-17) (-0.272688 0.969686 0) (-0.0615755 -0.286681 0) (3.15658 -1.48004 -9.01448e-17) (0.0465794 3.09866 3.41793e-16) (-0.420319 0.327784 0) (-0.0666599 -0.916142 -3.65224e-16) (-1.77034 -0.306233 0) (-0.2641 -0.0748878 0) (1.75772 -0.142993 3.19154e-17) (2.44926 0.427764 8.89976e-19) (0.0236368 3.26248 -7.63647e-17) (-1.69747 -0.247678 -3.89409e-16) (-0.384421 -0.445081 3.28556e-16) (2.47763 0.0505668 -1.6857e-16) (-0.119476 2.84915 0) (5.48755 -0.175686 2.82619e-17) (8.7377 1.18625 0) (1.47539 1.4751 -4.20635e-16) (0.105047 -0.555646 -3.42782e-16) (4.05937 0.782638 -2.7901e-16) (0.0180573 -1.42959 -2.244e-16) (0.690914 -0.0615563 -2.56091e-16) (0.220396 2.02261 -4.62462e-16) (0.766379 0.409379 -1.49292e-17) (-0.173648 -0.122446 8.41118e-17) (-0.109627 -0.516618 -2.30342e-17) (1.58072 1.95804 1.91364e-17) (-1.43119 4.8965 1.28359e-16) (3.24602 2.69348 2.8157e-16) (-0.0830674 2.92069 3.32123e-17) (1.31414 0.0233295 1.29942e-18) (0.0155118 2.53832 6.84118e-20) (-0.542128 3.25924 -6.74007e-19) (0.0587588 -0.0930967 3.13259e-16) (-0.200987 -0.0870359 3.71853e-16) (-0.898527 2.71995 1.47731e-16) (2.29098 -1.53596 -3.87303e-16) (-0.48918 -0.224071 3.24666e-16) (-0.206044 2.70801 5.01385e-16) (0.303345 -0.384527 0) (-0.249867 2.87997 -2.86357e-16) (1.99807 0.143306 -5.49742e-16) (1.78436 0.0885448 -3.8124e-17) (1.59228 0.518076 -6.14426e-16) (0.0421248 2.79442 1.12455e-16) (0.207851 -0.364519 -1.63649e-16) (1.79601 0.0183122 -6.01259e-16) (-2.69459 -0.153821 1.24293e-16) (0.0362765 2.78151 7.10937e-17) (-0.411331 3.69266 -2.58413e-16) (-0.0975594 3.11263 -4.41486e-17) (8.19418 -0.133289 -3.28987e-17) (-0.078008 3.07475 3.09735e-17) (-0.611814 3.92291 5.17057e-17) (2.02471 0.0528735 1.27376e-16) (-0.594132 2.53803 2.87908e-16) (0.0361208 1.93242 -2.98152e-16) (1.68399 0.130156 3.13682e-16) (0.0885465 -0.0885738 3.50864e-17) (-0.20402 -0.147107 0) (0.42388 6.67438 -1.15048e-16) (-0.419776 3.83165 -8.26936e-17) (-0.317657 3.15166 1.60828e-16) (4.41958 1.04252 -3.98373e-16) (1.02196 -1.24716 2.64432e-16) (-0.373805 -0.11053 2.47677e-19) (-0.731243 -0.25364 -6.7898e-17) (-1.09468 3.15795 -6.9416e-19) (-2.39212 3.18253 4.90313e-17) (0.577404 2.86335 1.5865e-16) (8.73747 -0.0534755 -9.22024e-18) (0.278576 1.62036 -1.50908e-16) (-1.75125 -0.248454 4.30423e-16) (-0.440528 -0.629404 1.7996e-16) (0.119927 -0.0465086 3.535e-16) (-0.0567882 -0.155405 8.08448e-17) (9.60676 0.0512271 -1.18058e-16) (-0.050485 0.685486 3.31097e-16) (-0.353521 0.753587 6.76645e-16) (-0.412517 -0.0349375 5.05378e-16) (0.703036 0.0864639 2.23497e-16) (-0.580562 0.560288 -9.35147e-20) (0.0664798 0.243589 -4.17096e-16) (0.996868 -1.16833 -1.69719e-16) (1.95283 -0.264896 9.23793e-17) (1.79069 -0.167474 -4.58776e-16) (-1.05195 4.68356 -2.10764e-16) (0.00859234 2.46188 3.70325e-17) (2.1863 -1.02908 4.0257e-16) (0.0807825 -0.237834 -4.81753e-16) (0.122958 1.03969 0) (0.0713502 3.24078 -1.7062e-16) (-0.146296 3.16081 -3.37927e-17) (0.0272572 2.7718 2.7615e-17) (-0.00697508 4.76068 -4.53649e-17) (0.0483004 3.22286 -9.9701e-17) (-0.0305504 -0.167624 2.71969e-16) (-1.55751 -0.341879 -4.08175e-17) (0.124611 3.72366 1.71839e-16) (1.7699 0.43809 0) (0.664507 -0.138574 -1.90169e-17) (-3.29011 3.17677 2.69292e-17) (2.58984 -1.4443 0) (2.8036 0.386252 -4.14532e-16) (0.70384 0.626274 0) (-1.43349 3.19641 1.52865e-19) (10.2096 -0.0266558 1.25242e-16) (1.83341 0.677043 3.37817e-16) (0.930474 0.0359544 -6.9178e-17) (-0.753227 -0.375569 0) (-0.181123 -0.0495322 1.15951e-15) (1.16247 0.0110937 -1.68581e-17) (-0.26486 -0.313295 7.3545e-16) (0.370722 0.991357 -3.68861e-19) (1.17526 0.0425097 0) (0.241288 -0.0933422 2.90527e-16) (-1.24649 4.73779 -1.21086e-16) (-1.4571 -0.0918641 5.00012e-16) (-0.0358093 0.0456734 1.15515e-15) (1.75535 0.00752952 1.57488e-16) (0.0180746 3.06308 -4.16268e-19) (0.953045 -0.0223863 -3.12303e-17) (-1.79754 1.25453 -2.65476e-16) (2.41307 -0.164956 0) (0.937348 3.20142 0) (1.82386 -0.296021 -2.56228e-16) (2.1705 0.181361 4.88286e-16) (-2.83471 0.898991 -1.61652e-16) (9.61095 1.56852 0) (1.41614 0.180023 1.12996e-18) (1.01156 0.0124049 1.50501e-16) (0.815604 0.207981 -8.17483e-17) (-0.00263099 3.42113 3.51025e-16) (0.18553 1.94561 3.18903e-16) (-1.59991 -0.338689 -7.30069e-16) (0.0257491 0.0169838 9.73093e-16) (0.056931 0.0592075 3.62574e-17) (-2.65485 4.60889 -1.17292e-16) (-1.09507 2.9198 2.44054e-16) (1.25024 0.0385914 1.9857e-17) (-2.71047 1.50533 1.85384e-16) (1.40002 -0.0624152 3.06527e-16) (-2.17741 -0.236386 -9.73362e-17) (9.74385 1.5401 0) (1.45427 -0.0418031 -5.84302e-16) (1.30843 -0.0770711 0) (-1.65563 0.899737 -1.00734e-18) (-0.0644609 0.154205 -3.06626e-16) (10.3993 0.241246 0) (-0.0730947 2.84479 -1.28593e-16) (1.38398 -0.0244405 -2.29642e-17) (1.43093 -0.0257959 3.43299e-16) (1.4032 -0.00550183 0) (1.39876 -0.0247717 -2.32719e-17) (0.838939 0.0214885 -7.48213e-18) (0.781827 0.0168246 7.68166e-18) (0.64702 -0.117977 0) (0.872795 -0.115582 0) (1.05259 -0.103686 0) (1.19463 -0.0899964 -1.95219e-17) (0.741464 -0.000352874 7.45414e-17) (-0.326365 4.29961 7.96712e-17) (2.77883 -1.65693 8.03334e-17) (2.68502 0.026563 -3.12164e-16) (1.85081 -0.162962 2.06963e-16) (-0.17808 1.69412 -1.2161e-16) (-1.10895 4.49963 0) (1.93118 0.0631019 -2.27552e-16) (-0.153747 3.36031 2.8166e-17) (0.0398082 2.66976 -8.65829e-17) (-1.28917 3.13698 -2.58955e-16) (-1.71501 -0.287079 1.61238e-16) (-0.173774 -0.478966 -2.18179e-16) (-0.575401 -0.293695 0) (0.00182721 3.76997 2.55525e-16) (5.18357 0.827752 0) (-1.30153 5.03518 -8.54583e-17) (-1.27878 3.35455 -3.10677e-16) (-0.108519 -0.0308766 0) (-0.0988077 3.73798 1.02149e-16) (2.15817 -0.176814 2.15624e-16) (2.62161 0.563574 1.18758e-16) (0.0191763 1.07121 -2.32034e-16) (2.26361 0.0441861 -1.80913e-16) (2.54423 0.0584444 4.48215e-17) (0.0626734 3.72465 0) (-0.722794 -0.21838 -2.74377e-17) (1.05633 4.18544 -2.66475e-16) (0.799045 1.32564 -1.07188e-18) (-0.19656 2.57912 -2.00223e-17) (0.0424622 2.51716 3.5782e-17) (-0.211746 3.6753 0) (9.75227 0.383381 3.33208e-17) (-0.11391 -0.354156 -1.41657e-16) (1.79246 -0.162429 -6.88963e-17) (2.60512 0.290656 0) (-0.0590661 -0.474754 1.26772e-16) (4.27587 -0.247823 -1.94377e-16) (3.0163 -0.0496895 -6.29417e-18) (-0.230527 -0.0733343 -4.30725e-16) (-2.49255 -0.380348 1.9371e-16) (0.280891 1.98821 -5.96462e-17) (-1.50627 2.80919 0) (2.3048 0.427081 -1.13439e-16) (-2.09676 -1.23162 -6.98138e-16) (0.0356785 3.05447 -8.34336e-17) (-0.177099 -0.131339 -6.72835e-16) (-0.194992 3.41128 -1.51193e-16) (-0.22144 -0.435195 -6.22918e-16) (0.0906826 -0.0574233 0) (-0.148763 -0.09701 -3.91838e-17) (2.58872 2.65333 -1.70154e-16) (-1.10612 6.7605 4.55459e-17) (-0.289656 -0.588354 3.27416e-16) (-0.0117715 1.77294 0) (-1.73239 2.53451 3.33297e-17) (0.362042 7.06767 2.20675e-16) (-0.156647 3.18321 -1.28173e-16) (0.716852 0.0202325 -5.95498e-17) (0.699221 0.0213443 6.4942e-17) (0.0414093 3.16254 -4.10626e-17) (0.749504 -0.325215 -2.96132e-16) (-0.795175 -0.144153 -4.39097e-19) (2.46841 0.4048 -2.22303e-16) (0.309249 -0.354572 -1.02782e-19) (2.39255 1.31042 -4.08574e-19) (-0.109467 3.5268 2.93275e-16) (8.00821 -0.0420108 2.86464e-16) (0.517439 2.25944 7.41457e-17) (-0.169888 3.47686 0) (0.0406776 2.57387 -3.34768e-17) (-0.354309 1.87957 0) (-0.967105 6.51015 2.27867e-16) (6.62386 1.717 -1.17542e-16) (-0.19598 -2.17666 -5.50189e-18) (-1.13514 7.31296 1.55215e-16) (-0.104851 -0.289961 1.26417e-16) (-1.62566 -0.236857 2.44114e-17) (-1.63685 3.15478 2.15831e-20) (0.205005 2.57857 7.53941e-17) (-0.952095 -0.218958 -9.79139e-16) (-0.220847 0.026619 1.07122e-15) (1.41908 -1.93224 3.8522e-16) (4.6567 0.0913359 -3.58682e-17) (-0.596163 3.22433 -1.32506e-16) (-1.25462 -1.21037 2.98473e-16) (-0.152623 -0.904685 -5.77774e-20) (-1.6212 6.89374 -1.58264e-16) (6.04297 0.0529178 0) (2.17241 0.578553 -3.39662e-16) (-0.145744 3.37989 -8.19423e-17) (-0.644663 0.0171659 4.62376e-16) (-0.165241 2.13518 -5.29078e-19) (-0.0202186 3.39247 -3.65598e-16) (-1.83281 2.52201 0) (-0.0236677 1.3459 0) (-2.04523 1.64024 -2.20104e-17) (-1.22515 -1.11318 5.26008e-17) (-0.484075 0.0196741 -1.20558e-17) (0.492072 -2.05913 -1.46704e-16) (1.57133 0.752168 9.05476e-19) (-1.7655 -0.377587 -1.60466e-16) (-0.154226 -0.0951477 -8.01698e-17) (-1.0752 5.79939 -1.30572e-17) (7.96004 -0.200607 -2.15585e-17) (0.786587 0.120862 -8.88179e-19) (1.15734 0.391004 4.35704e-16) (5.22022 1.4265 1.45905e-16) (0.908861 -0.373608 -2.16325e-16) (-0.475744 -0.395493 4.30942e-16) (6.5116 1.25032 -8.48288e-17) (6.38798 2.03536 -5.99144e-19) (1.94252 -0.203836 0) (-0.0966258 2.64996 0) (8.76066 -0.0147906 -1.51617e-16) (-3.04643 2.05667 1.61492e-16) (1.9071 0.145378 -1.08233e-16) (-1.17356 0.729014 -1.97142e-16) (1.0698 0.223837 6.69041e-17) (2.86011 0.890074 -1.04142e-16) (-1.22202 -0.324141 0) (-0.096814 0.0181519 -2.48917e-16) (9.88708 0.291196 -4.01101e-18) (-0.319943 -0.0294612 3.19926e-16) (0.619597 0.0376293 -7.7679e-17) (0.0164923 2.40655 0) (-0.0118706 3.14457 -3.61811e-16) (-0.661459 3.64012 -4.12163e-16) (-0.569209 -0.256591 -2.91614e-16) (-0.599917 4.47361 1.64099e-17) (9.77393 0.618399 -1.49889e-17) (-2.13501 5.03586 0) (-2.93061 -1.25737 1.09241e-16) (0.0735293 -0.1128 -2.62177e-17) (-0.24013 -0.112011 -6.49391e-16) (-0.281927 -0.02354 -1.12102e-15) (1.05456 -1.62999 -3.13428e-16) (-1.65413 4.40151 1.50323e-16) (3.48478 0.734687 5.82109e-16) (-0.40866 1.25632 -1.17634e-16) (-0.0422511 1.95398 -1.06711e-16) (-1.80649 2.31755 -5.5011e-16) (-0.297338 0.539408 1.03938e-16) (-0.913021 -0.578553 1.45602e-16) (-0.941745 0.0502721 2.17348e-16) (0.0565814 -0.0960064 0) (-0.211138 -0.0873896 1.61694e-16) (-0.298438 0.0819706 -1.78583e-16) (0.409735 -1.44248 2.34214e-16) (-2.84458 3.11886 5.34607e-17) (-0.310183 1.98915 5.38904e-16) (0.946127 -0.36101 4.08525e-16) (0.605251 3.35225 0) (0.0490996 -0.12814 -5.53687e-16) (0.1299 -0.0414861 -5.16358e-16) (-0.506353 4.03314 0) (-2.92681 0.366839 3.99249e-17) (9.84681 0.166673 0) (0.0907419 3.09002 -2.24156e-16) (0.0395936 2.91419 -8.51209e-18) (2.90573 1.27578 3.34532e-16) (-0.126673 3.31687 3.50207e-17) (5.43341 -0.101063 -8.48932e-17) (-0.252059 -1.42745 -5.47179e-17) (-0.279416 0.0063407 2.80897e-16) (0.0626756 2.94235 0) (-2.68924 2.41244 -2.49882e-16) (-3.07151 3.19011 2.50416e-17) (1.98292 0.246945 -2.09555e-16) (-0.194795 2.54759 1.60946e-16) (1.53454 1.06968 4.28538e-16) (-0.189193 -0.518595 2.51379e-16) (-1.89747 6.94998 1.54653e-16) (-2.86563 -2.93142 -1.07451e-16) (-0.00708632 2.02166 -9.04403e-17) (-0.176968 1.1151 -1.20803e-16) (0.177553 1.60023 1.76852e-16) (10.137 0.0436589 -5.5923e-17) (2.08929 0.010675 3.74649e-16) (0.366986 -0.461667 4.96249e-19) (0.36781 -0.0843046 1.92262e-16) (-1.30826 4.51646 0) (-1.23424 1.5226 3.66445e-16) (4.46827 0.188674 -4.17015e-19) (-1.14423 4.18762 4.3514e-16) (-1.89069 -0.177493 0) (-0.530976 3.91593 0) (0.089967 3.09205 2.17398e-20) (9.99219 1.09102 -6.41425e-18) (-0.41938 0.72676 1.78502e-16) (2.34248 0.0253693 -3.33322e-16) (0.436993 0.239586 0) (5.46602 0.0315806 -2.79015e-17) (0.178078 -0.426757 -4.56106e-16) (0.113577 2.1435 -9.55646e-18) (-1.76454 2.87799 0) (-0.589098 2.0488 -1.38132e-16) (-0.410796 3.80402 -1.98227e-16) (3.59342 -1.10043 1.33638e-16) (0.463314 6.70586 -2.07179e-16) (-0.322739 1.14351 1.5467e-17) (-1.43353 2.70327 -8.02133e-17) (0.0760906 2.46458 1.01114e-17) (-0.129262 1.38047 2.19506e-16) (-0.355405 1.16993 -4.60043e-16) (0.747419 0.00997651 -7.07001e-17) (0.228924 4.76491 6.23291e-17) (-0.000375888 3.24199 8.90586e-17) (0.139447 3.68839 -9.69046e-17) (-0.221917 -0.13576 0) (-0.430845 0.530004 -1.35534e-16) (-0.219425 -0.172526 2.29123e-16) (9.94674 0.0217375 0) (0.0808047 2.83265 -1.51932e-16) (-0.606584 3.66188 0) (-0.309426 1.67067 6.15531e-17) (-0.165688 -0.26691 1.36838e-16) (-1.72307 1.95849 2.32342e-16) (-0.00703652 0.436644 3.28502e-16) (-1.39461 -0.224753 -5.67789e-17) (-0.0760282 -0.058555 -6.23886e-17) (-1.96111 -0.341884 0) (1.8896 -0.0941223 -3.09783e-16) (-0.868107 3.65052 2.05396e-19) (9.67195 0.915999 2.8499e-18) (0.780398 0.0829123 -4.31632e-16) (-2.08112 0.124927 -7.42589e-18) (-1.7561 -0.273185 0) (3.01744 -0.138983 0) (-0.962638 4.14988 -1.98082e-16) (-0.15023 -1.03634 0) (0.136976 0.0978355 1.43832e-16) (3.27095 -0.194556 1.6774e-17) (0.000211295 0.971462 2.72057e-16) (9.64412 0.0322041 0) (-0.27556 -0.210266 -5.7867e-16) (-0.349883 -0.458569 0) (0.557567 0.453817 3.81063e-17) (-0.250976 2.14169 1.38202e-16) (0.978465 0.100553 0) (-0.890757 3.9067 -1.33626e-16) (0.21634 2.08178 7.19607e-17) (-1.65168 2.86723 -5.91383e-17) (-0.602524 -0.336843 3.37398e-16) (-0.503977 -0.211475 9.22948e-20) (-1.46496 6.98383 -6.58055e-17) (0.0391643 0.138988 0) (1.72204 -0.0352611 -2.97658e-17) (-0.210797 1.6228 3.38132e-16) (1.60333 -0.133961 0) (-1.34399 -1.9966 5.07593e-17) (-0.136637 -0.184562 -1.97519e-16) (-1.28786 3.81978 -1.18663e-16) (2.56858 0.460337 1.95905e-16) (1.77413 0.413235 0) (-3.17149 1.82277 -1.61136e-17) (1.01649 0.232595 -2.01138e-17) (-0.0894734 -0.0259864 0) (1.79681 -0.269809 1.3248e-16) (1.35811 0.336439 -1.42908e-16) (0.00383479 3.33439 -1.44922e-16) (-0.618856 0.0233661 -5.81125e-16) (5.00314 1.12627 -7.52955e-17) (0.673502 -0.367816 -1.46427e-16) (2.24659 0.89675 6.79274e-16) (2.75811 0.194593 3.37382e-18) (2.24361 0.455999 -9.19863e-17) (-0.304086 3.86172 7.17339e-17) (2.05023 0.0679679 1.7655e-16) (-1.34058 5.50993 1.33877e-17) (0.378033 0.551024 -2.34838e-17) (5.76173 1.2278 0) (-1.67725 6.63012 4.76063e-17) (-2.89029 1.70811 3.64003e-18) (0.289674 0.292779 -1.79932e-16) (0.0569108 0.159938 -2.44961e-16) (1.18663 -0.0164839 -2.92111e-17) (0.684538 -0.00758869 2.95467e-16) (-0.232404 2.31423 0) (2.63301 -0.153285 1.25299e-16) (1.86337 1.02888 -1.14525e-15) (-1.35796 6.45312 1.23632e-17) (0.294214 2.13958 0) (1.89374 0.015804 -5.16724e-17) (-0.222512 -2.0834 -3.51504e-17) (1.92091 1.49748 3.12113e-18) (-0.342112 -0.129142 -2.67044e-16) (-0.191747 -0.248793 -8.62699e-20) (-1.77304 -0.316264 -1.13368e-16) (0.488985 -1.53498 -4.19048e-16) (0.0798474 -0.489924 0) (-0.417006 -0.43525 0) (-0.350536 0.871052 0) (-0.0100625 3.79214 0) (-0.562406 -0.263179 -1.92854e-16) (0.59939 3.72185 -1.54238e-16) (0.224058 1.44782 1.56091e-16) (-0.0615326 3.17922 0) (0.541352 4.16412 2.07981e-16) (-0.0257384 3.19274 -1.2693e-16) (0.0335539 3.78479 -2.77038e-17) (0.0123353 3.8003 -6.0509e-17) (2.96831 -0.136281 -7.97241e-17) (0.116988 3.56964 -1.65639e-17) (-0.125645 0.268879 -3.31908e-16) (-1.75585 1.65665 4.65978e-16) (1.73924 0.0289764 -1.88921e-16) (0.0512911 -0.0751431 0) (-0.197625 -0.098704 3.25867e-21) (1.22435 -0.326815 -5.75967e-16) (-1.98011 -2.12493 -2.31795e-16) (2.20606 0.193942 4.9229e-16) (-0.302051 4.50859 8.79869e-17) (0.047754 3.18481 0) (1.07491 3.65614 0) (-0.0831515 3.38639 -1.44186e-16) (0.0282597 3.76924 3.37739e-17) (1.70383 0.0979709 7.30979e-17) (-0.157002 3.72753 3.06675e-18) (0.330457 -0.798679 -9.16596e-17) (-1.99075 -0.418618 -3.82978e-16) (-0.77182 -0.15142 0) (0.0497394 3.74043 -3.76956e-16) (-2.8371 0.167233 9.62963e-20) (-1.76689 -0.172022 -2.4799e-16) (-1.84482 -0.218822 -5.58131e-17) (2.94663 0.016875 0) (2.14921 -0.0107876 -4.30805e-16) (-0.121565 1.98347 -8.79898e-18) (2.23044 -0.0641824 -4.8896e-17) (2.11688 0.197722 -1.12703e-16) (1.73197 0.0502729 -6.07653e-17) (9.3313 0.280213 -6.21683e-17) (4.76129 0.869669 0) (0.018926 3.54114 -9.46053e-17) (-2.93216 -2.40616 -1.17908e-16) (1.78509 0.0581695 -1.63228e-17) (0.684488 -0.119389 6.13781e-16) (-0.252711 -0.339345 1.79134e-16) (1.63455 0.111666 -3.40285e-16) (2.75147 -0.228901 -9.25195e-17) (7.17942 -0.0981454 1.27882e-16) (-1.41194 0.693996 9.9514e-16) (-1.85157 -1.03207 4.54736e-16) (-3.47651 -2.97872 -2.62142e-16) (-0.373215 0.0885436 -1.14773e-15) (-1.90996 0.157835 -4.98415e-16) (-0.0922921 0.203886 -2.99549e-16) (-0.168651 -0.118546 -1.18289e-15) (-0.177068 0.106321 -1.94029e-16) (0.330301 0.290835 -7.84786e-18) (-0.569414 0.0072103 0) (-0.115211 0.36712 0) (0.60698 0.278444 1.47425e-16) (-0.563999 0.466079 1.01812e-16) (0.281113 0.593153 -9.68643e-16) (0.152672 0.0635803 1.21005e-15) (3.67285 0.554018 -5.90958e-17) (0.890621 0.412226 0) (6.0169 0.03231 7.51959e-17) (6.98088 -0.0719857 2.72287e-16) (7.72775 -0.154584 -1.2673e-17) (-1.58296 -0.164042 1.68639e-16) (-1.55754 -0.0207788 2.69429e-17) (-0.282709 -0.00786289 1.54304e-18) (0.616199 -0.147429 0) (-0.392525 -0.0433552 1.41002e-16) (-0.430748 -0.0464728 0) (0.297182 -0.0797717 -1.53199e-17) (-0.569432 -0.0503637 -4.02899e-18) (1.66167 -0.0125797 3.11331e-16) (1.81671 0.0849549 -4.53827e-16) (1.96589 -0.0181094 0) ) ; boundaryField { frontAndBack { type empty; } wallOuter { type noSlip; } inlet { type fixedValue; value nonuniform 0(); } outlet { type zeroGradient; } wallInner { type noSlip; } procBoundary1to0 { type processor; value nonuniform List<vector> 29 ( (-0.862519 -0.54841 -2.30449e-16) (-0.862519 -0.54841 -2.30449e-16) (-2.05783 -0.171469 0) (-1.8837 -0.399858 1.75545e-16) (-0.546891 -1.33419 -1.34568e-16) (-1.03249 -0.485933 -1.48178e-16) (2.55188 0.109444 2.45808e-16) (-1.13934 -0.156987 0) (1.22135 -0.340567 0) (-1.62442 -0.51003 -1.69134e-16) (-1.47119 -0.279777 -3.20267e-16) (-1.03249 -0.485933 -1.48178e-16) (-2.05783 -0.171469 0) (-1.18427 -0.370095 0) (4.6988 0.101494 9.33224e-17) (7.60595 0.312787 0) (-0.546891 -1.33419 -1.34568e-16) (0.178632 -1.29437 0) (-1.8837 -0.399858 1.75545e-16) (-0.680493 -0.677981 3.44338e-18) (9.77553 0.401129 -2.54415e-17) (9.88876 0.26618 -1.16087e-17) (1.12162 -1.09222 -2.12236e-16) (7.94695 0.114902 1.42801e-16) (7.94695 0.114902 1.42801e-16) (1.12162 -1.09222 -2.12236e-16) (10.487 0.186662 -5.00587e-17) (0.745119 0.00674868 0) (10.487 0.186662 -5.00587e-17) ) ; } procBoundary1to2 { type processor; value uniform (0.629111 -0.883754 -2.14897e-16); } procBoundary1to3 { type processor; value nonuniform List<vector> 48 ( (0.156466 3.0633 0) (0.134052 3.15897 1.12261e-19) (0.0916207 3.15626 2.0351e-16) (0.0916207 3.15626 2.0351e-16) (0.104237 2.46778 -1.07576e-16) (0.0199602 2.17711 7.48975e-16) (0.0199602 2.17711 7.48975e-16) (0.169943 0.832734 0) (0.205402 3.01071 0) (-0.0153239 -0.531 0) (-0.085143 -0.320648 -3.48291e-16) (-0.0153239 -0.531 0) (0.0535537 -0.313275 4.2141e-16) (0.19028 -0.399173 3.70912e-16) (0.193802 -0.679097 -2.06133e-16) (0.0535537 -0.313275 4.2141e-16) (0.0789249 -0.152776 4.88575e-20) (0.0789249 -0.152776 4.88575e-20) (0.0597675 -0.11198 0) (0.0597675 -0.11198 0) (0.04408 -0.0714451 2.81224e-17) (0.0205511 0.0112085 2.21666e-16) (0.0320344 -0.125325 -2.31146e-16) (-0.135997 0.569514 1.0776e-15) (-0.135997 0.569514 1.0776e-15) (0.0937874 -0.146837 0) (0.0578889 0.0700134 0) (0.0578889 0.0700134 0) (0.0983066 0.184449 5.20803e-16) (0.104052 0.929651 -3.82415e-16) (0.011846 0.0791939 -1.75046e-16) (0.0983066 0.184449 5.20803e-16) (0.169943 0.832734 0) (0.237607 2.92236 -6.07094e-16) (0.0989823 -0.130816 -2.17483e-16) (0.104052 0.929651 -3.82415e-16) (0.284843 2.15152 -3.25597e-16) (-0.085143 -0.320648 -3.48291e-16) (0.1622 3.02084 0) (0.0231696 3.3392 2.36215e-17) (0.110666 -0.230574 5.23335e-16) (0.293049 2.7547 2.57151e-16) (0.237607 2.92236 -6.07094e-16) (0.0989823 -0.130816 -2.17483e-16) (0.403092 -0.84854 8.27866e-17) (-0.002349 2.73637 1.08863e-20) (0.0854846 3.16113 0) (0.110666 -0.230574 5.23335e-16) ) ; } } // ************************************************************************* //
[ "mohan.2611@gmail.com" ]
mohan.2611@gmail.com
86644dd736a3e80c254d13be8b17623150143310
4d48900772a8c7f6e2b37b17800c6adcecdb6757
/Source/Plugins/NetModeler/stdafx.cpp
0b514b25ef87944ff786638c3c2879cbf17a6276
[]
no_license
boltej/Envision
42831983d5cf04dfc98b5ea95722e29472af3ca6
eb90284c03ac709fd99e226834821b09eb9e50e6
refs/heads/master
2023-08-09T02:24:34.509337
2023-07-19T17:32:49
2023-07-19T17:32:49
179,588,778
5
4
null
2022-11-29T17:19:52
2019-04-04T22:55:26
C++
UTF-8
C++
false
false
200
cpp
// stdafx.cpp : source file that includes just the standard includes // Modeler.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ "john.bolte@oregonstate.edu" ]
john.bolte@oregonstate.edu
d5a212b330e39bb5dcac48401c30d7845e924339
e2052e830c93eb8451ebc533d89929f143465c36
/myfirstopencv/hist.cpp
b08057e3a2453217c09cc27991de37776fd63001
[]
no_license
haocong/opencv-object-recognition
4471993baa1e333141daf6017008d7649fc25be0
f047d42d9b523565f84d4dcd2e9be4cc3e2288a9
refs/heads/master
2021-01-11T10:05:06.196123
2017-01-16T16:42:30
2017-01-16T16:42:30
78,092,265
0
0
null
null
null
null
UTF-8
C++
false
false
3,220
cpp
#include <highgui.h> #include <cv.h> #include <opencv2/legacy/legacy.hpp> using namespace std; IplImage* doScale(IplImage* image_input, double scale) { CvSize size; size.width = (int)image_input->width * scale; size.height = (int)image_input->height * scale; IplImage* image_output = cvCreateImage(size, image_input->depth, image_input->nChannels); cvResize(image_input, image_output, CV_INTER_LINEAR); return image_output; } IplImage* doCanny(IplImage* image_input, double lowThresh, double highThresh, double aperture) { if(image_input->nChannels != 1) return (0); IplImage* image_output = cvCreateImage(cvGetSize(image_input), image_input->depth, image_input->nChannels); cvCanny(image_input,image_output,lowThresh,highThresh,aperture); return image_output; } int hist() { IplImage *src1 = cvLoadImage("/Users/haocong/Desktop/colorFiltered/3.jpg"); IplImage *src2 = cvLoadImage("/Users/haocong/Desktop/colorFiltered/6.jpg"); double scale = 320.0 / src1->width; IplImage *img1 = doScale(src1, scale); IplImage *img2 = doScale(src2, scale); IplImage *img_gray1 = cvCreateImage(cvGetSize(img1),IPL_DEPTH_8U,1); IplImage *img_gray2 = cvCreateImage(cvGetSize(img2),IPL_DEPTH_8U,1); cvCvtColor(img1,img_gray1,CV_BGR2GRAY); cvCvtColor(img2,img_gray2,CV_BGR2GRAY); cvNamedWindow("img1",CV_WINDOW_AUTOSIZE); cvShowImage("img1", img1); cvNamedWindow("img2",CV_WINDOW_AUTOSIZE); cvShowImage("img2", img2); // IplImage *img_canny1 = doCanny(img_gray1, 50, 100, 3); // IplImage *img_canny2 = doCanny(img_gray2, 50, 100, 3); cvNamedWindow("img_gray1",CV_WINDOW_AUTOSIZE); cvShowImage("img_gray1", img_gray1); cvNamedWindow("img_gray2",CV_WINDOW_AUTOSIZE); cvShowImage("img_gray2", img_gray2); int hist_size=256;//直方图的横轴长度 // int hist_height=256;//直方图的纵轴高度 float range[]={0,255}; //灰度级的范围 float* ranges[]={range}; CvHistogram *Histogram1 = cvCreateHist(1,&hist_size,CV_HIST_ARRAY,ranges,1); CvHistogram *Histogram2 = cvCreateHist(1,&hist_size,CV_HIST_ARRAY,ranges,1); cvCalcHist(&img_gray1,Histogram1,0,0);//计算直方图 cvNormalizeHist(Histogram1,1.0);//归一化直方图 cvCalcHist(&img_gray2,Histogram2,0,0);//计算直方图 cvNormalizeHist(Histogram2,1.0);//归一化直方图 printf("CV_COMP_CORREL : %.4f\n",cvCompareHist(Histogram1,Histogram2,CV_COMP_CORREL)); printf("CV_COMP_CHISQR : %.4f\n",cvCompareHist(Histogram1,Histogram2,CV_COMP_CHISQR)); printf("CV_COMP_INTERSECT : %.4f\n",cvCompareHist(Histogram1,Histogram2,CV_COMP_INTERSECT)); printf("CV_COMP_BHATTACHARYYA : %.4f\n",cvCompareHist(Histogram1,Histogram2,CV_COMP_BHATTACHARYYA)); cvWaitKey(0); cvDestroyAllWindows(); cvReleaseImage(&src1); cvReleaseImage(&src2); cvReleaseImage(&img1); cvReleaseImage(&img2); cvReleaseImage(&img_gray1); cvReleaseImage(&img_gray2); return 0; }
[ "haocong.xu@gmail.com" ]
haocong.xu@gmail.com
711f3ecc01b1e77b12b670f1b61e4f4c517f8a7c
d58f5e22717dbac802faca8a1748f9f9a10dbb11
/data-structures/tests/optional.cxx
01b96022dbd09566367e4f3c66a3d832b22c20ed
[ "BSD-3-Clause" ]
permissive
mtezych/cpp
f5705bfd1fc31f8727b17773a732b86269f4830d
ea000b4d86faa112a2bfa3cc2e62638c8e14fd15
refs/heads/master
2023-05-25T16:04:00.964687
2023-05-09T03:44:18
2023-05-09T03:44:18
79,068,122
2
2
null
null
null
null
UTF-8
C++
false
false
4,233
cxx
/* * BSD 3-Clause License * * Copyright (c) 2021, Mateusz Zych * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <cxx/optional.hxx> #include <catch2/catch.hpp> namespace { namespace check { template <typename value_type> auto empty (const cxx::optional<value_type>& optional) -> void { REQUIRE(!optional.has_value()); REQUIRE(!optional); } template <typename value_type> auto owns (const cxx::optional<value_type>& optional, const value_type & value) -> void { REQUIRE(optional.has_value()); REQUIRE(optional); REQUIRE(optional.value() == value); } } namespace test { class object { private: int i; float f; char c; public: explicit constexpr object (int i = 0, float f = 0.0f, char c = '\0') noexcept : i { i }, f { f }, c { c } { } constexpr auto operator == (const object& other) const noexcept -> bool { return (this->i == other.i) && (this->f == other.f) && (this->c == other.c); } constexpr auto method () noexcept -> void { } }; } } TEST_CASE ("[optional] default construct") { const auto optional = cxx::optional<int> { }; check::empty(optional); } TEST_CASE ("[optional] construct from nullopt") { const auto optional = cxx::optional<int> { cxx::nullopt }; check::empty(optional); } TEST_CASE ("[optional] emplace value") { auto optional = cxx::optional<test::object> { }; check::empty(optional); optional.emplace(7, 0.7f, '%'); check::owns(optional, test::object { 7, 0.7f, '%' }); } TEST_CASE ("[optional] assign nullopt") { auto optional = cxx::optional<char> { }; check::empty(optional); optional.emplace('*'); check::owns(optional, '*'); optional = cxx::nullopt; check::empty(optional); } TEST_CASE ("[optional] make_optional() function") { const auto optional = cxx::make_optional<test::object>(11, 1.1f, '&'); check::owns(optional, test::object { 11, 1.1f, '&' }); } TEST_CASE ("[optional] idiomatic usage") { auto optional = cxx::optional<test::object> { }; check::empty(optional); optional.emplace(4, 0.8f, '#'); check::owns(optional, test::object { 4, 0.8f, '#' }); { if (optional) { SUCCEED(); } else { FAIL(); } optional->method(); } optional.reset(); check::empty(optional); }
[ "mte.zych@gmail.com" ]
mte.zych@gmail.com
1523e6658c46df5904c527648ebee6ac1325c5cf
2eb779146daa0ba6b71344ecfeaeaec56200e890
/oneflow/core/vm/object_instruction_type.cpp
7df0ca5ac6c8c9b1afe2fe9964ba767749677239
[ "Apache-2.0" ]
permissive
hxfxjun/oneflow
ee226676cb86f3d36710c79cb66c2b049c46589b
2427c20f05543543026ac9a4020e479b9ec0aeb8
refs/heads/master
2023-08-17T19:30:59.791766
2021-10-09T06:58:33
2021-10-09T06:58:33
414,906,649
0
0
Apache-2.0
2021-10-09T06:15:30
2021-10-08T08:29:45
C++
UTF-8
C++
false
false
11,666
cpp
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "oneflow/core/vm/stream_desc.msg.h" #include "oneflow/core/vm/control_stream_type.h" #include "oneflow/core/vm/instruction_type.h" #include "oneflow/core/vm/instruction.msg.h" #include "oneflow/core/vm/infer_stream_type.h" #include "oneflow/core/vm/string_object.h" #include "oneflow/core/vm/virtual_machine.msg.h" #include "oneflow/core/vm/naive_instruction_status_querier.h" #include "oneflow/core/vm/object_wrapper.h" #include "oneflow/core/common/util.h" #include "oneflow/core/object_msg/flat_msg_view.h" #include "oneflow/core/job/resource.pb.h" #include "oneflow/core/job/parallel_desc.h" #include "oneflow/core/register/register_manager.h" #include "oneflow/core/eager/lazy_ref_blob_object.h" namespace oneflow { namespace vm { namespace { template<typename DoEachT> void ForEachMachineIdAndDeviceIdInRange(const ParallelDesc& parallel_desc, const Range& machine_id_range, const DoEachT& DoEach) { if (machine_id_range.size() < parallel_desc.sorted_machine_ids().size()) { FOR_RANGE(int64_t, machine_id, machine_id_range.begin(), machine_id_range.end()) { if (parallel_desc.HasMachineId(machine_id)) { for (int64_t device_id : parallel_desc.sorted_dev_phy_ids(machine_id)) { DoEach(machine_id, device_id); } } } } else { for (int64_t machine_id : parallel_desc.sorted_machine_ids()) { if (machine_id >= machine_id_range.begin() && machine_id < machine_id_range.end()) { for (int64_t device_id : parallel_desc.sorted_dev_phy_ids(machine_id)) { DoEach(machine_id, device_id); } } } } } } // namespace class NewObjectInstructionType final : public InstructionType { public: NewObjectInstructionType() = default; ~NewObjectInstructionType() override = default; bool ResettingIdToObjectMap() const override { return true; } using stream_type = ControlStreamType; // clang-format off FLAT_MSG_VIEW_BEGIN(NewObjectInstruction); FLAT_MSG_VIEW_DEFINE_REPEATED_PATTERN(int64_t, logical_object_id); FLAT_MSG_VIEW_END(NewObjectInstruction); // clang-format on void Infer(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetTypeId>(vm, instr_msg); } void Compute(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetValueId>(vm, instr_msg); } void Infer(Instruction*) const override { UNIMPLEMENTED(); } void Compute(Instruction*) const override { UNIMPLEMENTED(); } private: template<int64_t (*GetLogicalObjectId)(int64_t)> void Run(VirtualMachine* vm, InstructionMsg* instr_msg) const { FlatMsgView<NewObjectInstruction> view(instr_msg->operand()); const auto& parallel_desc = CHECK_JUST(vm->GetInstructionParallelDesc(*instr_msg)); CHECK(static_cast<bool>(parallel_desc)); FOR_RANGE(int, i, 0, view->logical_object_id_size()) { int64_t logical_object_id = GetLogicalObjectId(view->logical_object_id(i)); auto logical_object = ObjectMsgPtr<LogicalObject>::New(logical_object_id, parallel_desc); CHECK(vm->mut_id2logical_object()->Insert(logical_object.Mutable()).second); auto* global_device_id2mirrored_object = logical_object->mut_global_device_id2mirrored_object(); ForEachMachineIdAndDeviceIdInRange( *parallel_desc, vm->machine_id_range(), [&](int64_t machine_id, int64_t device_id) { int64_t global_device_id = vm->vm_resource_desc().GetGlobalDeviceId(machine_id, device_id); auto mirrored_object = ObjectMsgPtr<MirroredObject>::New(logical_object.Mutable(), global_device_id); CHECK(global_device_id2mirrored_object->Insert(mirrored_object.Mutable()).second); }); } } }; COMMAND(RegisterInstructionType<NewObjectInstructionType>("NewObject")); class BroadcastObjectReferenceInstructionType final : public InstructionType { public: BroadcastObjectReferenceInstructionType() = default; ~BroadcastObjectReferenceInstructionType() override = default; bool ResettingIdToObjectMap() const override { return true; } using stream_type = ControlStreamType; // clang-format off FLAT_MSG_VIEW_BEGIN(BroadcastObjectReferenceInstruction); FLAT_MSG_VIEW_DEFINE_PATTERN(int64_t, new_object); FLAT_MSG_VIEW_DEFINE_PATTERN(int64_t, sole_mirrored_object); FLAT_MSG_VIEW_END(BroadcastObjectReferenceInstruction); // clang-format on void Infer(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetTypeId>(vm, instr_msg); } void Compute(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetValueId>(vm, instr_msg); } void Infer(Instruction*) const override { UNIMPLEMENTED(); } void Compute(Instruction*) const override { UNIMPLEMENTED(); } private: template<int64_t (*GetLogicalObjectId)(int64_t)> void Run(VirtualMachine* vm, InstructionMsg* instr_msg) const { const auto& parallel_desc = CHECK_JUST(vm->GetInstructionParallelDesc(*instr_msg)); FlatMsgView<BroadcastObjectReferenceInstruction> args(instr_msg->operand()); const RwMutexedObject* sole_rw_mutexed_object = nullptr; { int64_t object_id = GetLogicalObjectId(args->sole_mirrored_object()); auto* logical_object = vm->mut_id2logical_object()->FindPtr(object_id); CHECK_NOTNULL(logical_object); auto* map = logical_object->mut_global_device_id2mirrored_object(); sole_rw_mutexed_object = &map->Begin()->rw_mutexed_object(); CHECK_NOTNULL(sole_rw_mutexed_object); } CHECK(static_cast<bool>(parallel_desc)); int64_t new_object = GetLogicalObjectId(args->new_object()); auto logical_object = ObjectMsgPtr<LogicalObject>::New(new_object, parallel_desc); CHECK(vm->mut_id2logical_object()->Insert(logical_object.Mutable()).second); auto* global_device_id2mirrored_object = logical_object->mut_global_device_id2mirrored_object(); ForEachMachineIdAndDeviceIdInRange( *parallel_desc, vm->machine_id_range(), [&](int64_t machine_id, int64_t device_id) { int64_t global_device_id = vm->vm_resource_desc().GetGlobalDeviceId(machine_id, device_id); auto mirrored_object = ObjectMsgPtr<MirroredObject>::New(logical_object.Mutable(), global_device_id); mirrored_object->reset_rw_mutexed_object(*sole_rw_mutexed_object); CHECK(global_device_id2mirrored_object->Insert(mirrored_object.Mutable()).second); }); } }; COMMAND( RegisterInstructionType<BroadcastObjectReferenceInstructionType>("BroadcastObjectReference")); class ReplaceMirroredInstructionType final : public InstructionType { public: ReplaceMirroredInstructionType() = default; ~ReplaceMirroredInstructionType() override = default; bool ResettingIdToObjectMap() const override { return true; } using stream_type = ControlStreamType; // clang-format off FLAT_MSG_VIEW_BEGIN(ReplaceMirroredInstruction); FLAT_MSG_VIEW_DEFINE_REPEATED_PATTERN(int64_t, lhs_object_id); FLAT_MSG_VIEW_DEFINE_PATTERN(OperandSeparator, separator); FLAT_MSG_VIEW_DEFINE_REPEATED_PATTERN(int64_t, rhs_object_id); FLAT_MSG_VIEW_END(ReplaceMirroredInstruction); // clang-format on void Infer(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetTypeId>(vm, instr_msg); } void Compute(VirtualMachine* vm, InstructionMsg* instr_msg) const override { Run<&IdUtil::GetValueId>(vm, instr_msg); } void Infer(Instruction*) const override { UNIMPLEMENTED(); } void Compute(Instruction*) const override { UNIMPLEMENTED(); } private: template<int64_t (*GetLogicalObjectId)(int64_t)> void Run(VirtualMachine* vm, InstructionMsg* instr_msg) const { FlatMsgView<ReplaceMirroredInstruction> args(instr_msg->operand()); auto DoEachRhsObject = [&](MirroredObject* lhs, int64_t global_device_id) { CHECK_EQ(lhs->rw_mutexed_object().access_list().size(), 0); FOR_RANGE(int, i, 0, args->rhs_object_id_size()) { int64_t rhs_object_id = GetLogicalObjectId(args->rhs_object_id(i)); const auto* rhs = vm->GetMirroredObject(rhs_object_id, global_device_id); if (rhs != nullptr) { lhs->reset_rw_mutexed_object(rhs->rw_mutexed_object()); break; } } }; const auto& parallel_desc = CHECK_JUST(vm->GetInstructionParallelDesc(*instr_msg)); CHECK(static_cast<bool>(parallel_desc)); ForEachMachineIdAndDeviceIdInRange( *parallel_desc, vm->machine_id_range(), [&](int64_t machine_id, int64_t device_id) { FOR_RANGE(int, i, 0, args->lhs_object_id_size()) { int64_t global_device_id = vm->vm_resource_desc().GetGlobalDeviceId(machine_id, device_id); int64_t lhs_object_id = GetLogicalObjectId(args->lhs_object_id(i)); auto* lhs = vm->MutMirroredObject(lhs_object_id, global_device_id); if (lhs != nullptr) { DoEachRhsObject(lhs, global_device_id); } } }); } }; COMMAND(RegisterInstructionType<ReplaceMirroredInstructionType>("ReplaceMirrored")); class DeleteObjectInstructionType final : public InstructionType { public: DeleteObjectInstructionType() = default; ~DeleteObjectInstructionType() override = default; using stream_type = ControlStreamType; // clang-format off FLAT_MSG_VIEW_BEGIN(DeleteObjectInstruction); FLAT_MSG_VIEW_DEFINE_REPEATED_PATTERN(DelOperand, object); FLAT_MSG_VIEW_END(DeleteObjectInstruction); // clang-format on void Infer(VirtualMachine* vm, Instruction* instruction) const override { // do nothing, delete objects in Compute method Run<&IdUtil::GetTypeId>(vm, instruction); } void Compute(VirtualMachine* vm, Instruction* instruction) const override { Run<&IdUtil::GetValueId>(vm, instruction); } void Infer(Instruction*) const override { UNIMPLEMENTED(); } void Compute(Instruction*) const override { UNIMPLEMENTED(); } private: template<int64_t (*GetLogicalObjectId)(int64_t)> void Run(VirtualMachine* vm, Instruction* instruction) const { auto* instr_msg = instruction->mut_instr_msg(); const auto* parallel_desc = CHECK_JUST(vm->GetInstructionParallelDesc(*instr_msg)).get(); if (parallel_desc && !parallel_desc->ContainingMachineId(vm->this_machine_id())) { return; } FlatMsgView<DeleteObjectInstruction> view(instr_msg->operand()); FOR_RANGE(int, i, 0, view->object_size()) { CHECK(view->object(i).operand().has_all_mirrored_object()); int64_t logical_object_id = view->object(i).operand().logical_object_id(); logical_object_id = GetLogicalObjectId(logical_object_id); auto* logical_object = vm->mut_id2logical_object()->FindPtr(logical_object_id); CHECK_NOTNULL(logical_object); CHECK(logical_object->is_delete_link_empty()); vm->mut_delete_logical_object_list()->PushBack(logical_object); } } }; COMMAND(RegisterInstructionType<DeleteObjectInstructionType>("DeleteObject")); } // namespace vm } // namespace oneflow
[ "noreply@github.com" ]
hxfxjun.noreply@github.com
d5e03cde8722d69495c85051fc2ebfd4966397e2
bc2ee860790f7ccedb5f68c13d528cf303dc2389
/src/engine/videoimage.cpp
8a2ce1345e9bc9dbbad22dbe56f78cb4b89dc643
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
FreeAllegiance/Allegiance-AZ
d0d3fc4655f94c0a145245c43ff4f3cddaeb9d1a
1d8678ddff9e2efc79ed449de6d47544989bc091
refs/heads/master
2021-06-26T02:54:18.589811
2017-09-10T23:47:19
2017-09-10T23:47:19
40,015,917
1
0
null
null
null
null
UTF-8
C++
false
false
8,576
cpp
#include "pch.h" #include "mmstream.h" #include "amstream.h" #include "ddstream.h" ////////////////////////////////////////////////////////////////////////////// // // VideoImage // ////////////////////////////////////////////////////////////////////////////// class VideoImageImpl : public VideoImage { public: ////////////////////////////////////////////////////////////////////////////// // // Data members // ////////////////////////////////////////////////////////////////////////////// RectValue* GetRect() { return RectValue::Cast(GetChild(0)); } TRef<EventSourceImpl> m_peventSource; TRef<PrivateEngine> m_pengine; TRef<IAMMultiMediaStream> m_pAMStream; TRef<IDirectDrawStreamSample> m_psample; TRef<IDirectDrawSurfaceX> m_pddsSample; TRef<PrivateSurface> m_psurface; ZString m_strFile; bool m_bTriggered; bool m_bFirstFrame; bool m_bStarted; ////////////////////////////////////////////////////////////////////////////// // // Constructor // ////////////////////////////////////////////////////////////////////////////// VideoImageImpl( PrivateEngine* pengine, RectValue* prect, const ZString& str ) : VideoImage(prect), m_pengine(pengine), m_peventSource(new EventSourceImpl()), m_strFile(str), m_bStarted(false), m_bTriggered(false), m_bFirstFrame(true) { // // Create the Active Movie Multi Media Stream // HRESULT hr = CoCreateInstance(CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, IID_IAMMultiMediaStream, (void **)&m_pAMStream); if (FAILED(hr) || m_pAMStream == NULL) { m_pAMStream = NULL; return; } ZSucceeded(m_pAMStream->Initialize(STREAMTYPE_READ, 0, NULL)); // // Add renders for sound and video // DDDevice* pdddevice = m_pengine->GetPrimaryDevice(); ZSucceeded(m_pAMStream->AddMediaStream(pdddevice->GetDD(), &MSPID_PrimaryVideo, 0, NULL)); // // Don't check the return value. If this fails there just won't be audio playback. // m_pAMStream->AddMediaStream(NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL); // // Open the AVI File // WCHAR wPath[MAX_PATH]; MultiByteToWideChar(CP_ACP, 0, m_strFile, -1, wPath, ArrayCount(wPath)); if (FAILED(m_pAMStream->OpenFile(wPath, 0))) { m_pAMStream = NULL; } } bool IsValid() { return m_pAMStream != NULL; } ////////////////////////////////////////////////////////////////////////////// // // Implementation methods // ////////////////////////////////////////////////////////////////////////////// void AllocateSample() { if (m_pAMStream) { // // Create a Direct Draw video steam // TRef<IMediaStream> pPrimaryVidStream; TRef<IDirectDrawMediaStream> pDDStream; TRef<IDirectDrawSurface> pdds; ZSucceeded(m_pAMStream->GetMediaStream(MSPID_PrimaryVideo, &pPrimaryVidStream)); ZSucceeded(pPrimaryVidStream->QueryInterface(IID_IDirectDrawMediaStream, (void **)&pDDStream)); // // Get Information about the stream // DDSDescription ddsdCurrent; DDSDescription ddsdDesired; IDirectDrawPalette* pddpal; DWORD flags; HRESULT hr = pDDStream->GetFormat( (DDSURFACEDESC*)&ddsdCurrent, &pddpal, (DDSURFACEDESC*)&ddsdDesired, &flags ); // // !!! sometime the size will come back zero, in that case just don't display anything // if ( FAILED(hr) || ddsdDesired.XSize() == 0 || ddsdDesired.YSize() == 0 ) { End(); return; } // // Create a surface that the video will be rendered to // CastTo( m_psurface, m_pengine->CreateSurface( ddsdDesired.Size(), SurfaceType2D() ) ); DDSurface* pddsurface; CastTo(pddsurface, m_psurface->GetVideoSurface()); _ASSERT( false ); /* m_pddsSample = pddsurface->GetDDSX(); // // Create a ddsample from the surface // ZSucceeded(pDDStream->CreateSample( pddsurface->GetDDS(), NULL, DDSFF_PROGRESSIVERENDER, &m_psample ));*/ } } void Start() { // // Start playback // m_bStarted = true; ZSucceeded(m_pAMStream->SetState(STREAMSTATE_RUN)); } void End() { if (!m_bTriggered) { m_bTriggered = true; m_peventSource->Trigger(); } } ////////////////////////////////////////////////////////////////////////////// // // DeviceDependant methods // ////////////////////////////////////////////////////////////////////////////// void ClearDevice() { // // no need to free the stream since we always use the primary device // // m_pAMStream = NULL; m_pddsSample = NULL; m_psample = NULL; } ////////////////////////////////////////////////////////////////////////////// // // VideoImage methods // ////////////////////////////////////////////////////////////////////////////// IEventSource* GetEventSource() { return m_peventSource; } ////////////////////////////////////////////////////////////////////////////// // // Image methods // ////////////////////////////////////////////////////////////////////////////// void CalcBounds() { m_bounds.SetRect(GetRect()->GetValue()); } void Render(Context* pcontextArg) { if (m_bFirstFrame) { m_bFirstFrame = false; return; } if (m_psample == NULL) { AllocateSample(); } if (m_psample) { if (!m_bStarted) { Start(); } bool bTrigger = (m_psample->Update(0, NULL, NULL, 0) != S_OK); PrivateContext* pcontext; CastTo(pcontext, pcontextArg); WinRect rect = WinRect::Cast(GetRect()->GetValue()); WinPoint size = m_psurface->GetSize(); if ( size.X() <= rect.XSize() / 2 && size.Y() <= rect.YSize() / 2 ) { // // Double size sample will fit on screen so double it // WinPoint offset = rect.Min() + (rect.Size() - size * 2) / 2; pcontext->GetSurface()->BitBlt( WinRect( offset, offset + size * 2 ), m_psurface ); } else { // // Center the sample // pcontext->GetSurface()->BitBlt( rect.Min() + (rect.Size() - size) / 2, m_psurface ); } if (bTrigger) { End(); } } else { End(); } } ////////////////////////////////////////////////////////////////////////////// // // Value members // ////////////////////////////////////////////////////////////////////////////// ZString GetFunctionName() { return "VideoImage"; } }; ////////////////////////////////////////////////////////////////////////////// // // // ////////////////////////////////////////////////////////////////////////////// TRef<VideoImage> CreateVideoImage( Engine* pengine, RectValue* prect, const ZString& str ) { PrivateEngine* pprivateEngine; CastTo(pprivateEngine, pengine); return new VideoImageImpl(pprivateEngine, prect, str); }
[ "austin.w.harris@gmail.com" ]
austin.w.harris@gmail.com
7138b8028fc6b1f11f2f96accfaec6782f0425ec
3cc724e49843928f6e0886ca99110ce87b806b9c
/capdDynSys/examples/newton/newtonSimple.cpp
fe7bbf22a2486c0d1d82616974a9a6022bbabde4
[]
no_license
dreal-deps/capdDynSys-3.0
ec6245d470c40b74eaafeae14cac28d985eb8c4f
1d02413c10be5354e5c81d2533d0fde89243d455
refs/heads/master
2021-01-10T20:20:12.351964
2014-06-27T21:27:52
2014-06-27T21:27:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,992
cpp
///////////////////////////////////////////////////////////////////////////// /// @file newtonSimple.cpp /// /// This file contains examples how to use Newton and Krawczyk classes /// /// This file differs from newtontst.cpp only in using facade classes /// instead of general templates /// /// @author Tomasz Kapela ///////////////////////////////////////////////////////////////////////////// // Copyright (C) 2000-2005 by the CAPD Group. // // This file constitutes a part of the CAPD library, // distributed under the terms of the GNU General Public License. // Consult http://capd.wsb-nlu.edu.pl/ for details. #include <cmath> #include <stdexcept> #include <fstream> #include <iostream> #include "capd/newton/Newton.h" #include "capd/newton/Krawczyk.h" /* ****************************************************************** * Example 1: Non-rigorous (ordinary) Newton and Krawczyk Method * Each iteration gives new estimate (hopefully better) * for zero of given map (R^n -> R^n) */ //#include "capd/DInterval.h" #include "capd/facade/DVector.h" #include "capd/facade/DMatrix.h" #include "capd/facade/DMap.h" using namespace capd::facade; // For Henon map we iterate nonrigorous Newton Operator. // Iteration is not rigorous because we pass non rigorous map (DMap) void FloatHenonMap() { // Creating Hennon map and setting its parameters std::cout << "\n HENON map: H(x,y) = (1 - a*x*x + y, b*x) where a=1.4, b=0.3 "; DMap henon("var:x,y,a,b;fun:1-a*x*x+y,b*x;"); henon.setParameter("a",1.4); henon.setParameter("b",0.3); // Setting initial conditions DVector x(2); x[0]=-1300; x[1] = 1000; std::cout << "\n\n Non rigorous NEWTON OPERATOR " << "\n Starting point x0 = " << x; // We make 5 iterations of Newton method for zero finding for(int i=1; i<=5; ++i) { x = capd::newton::NewtonOperator(x, x, henon); std::cout << "\n x "<< i << " = " << x; } } /* ****************************************************************** * Example 2: Rigorous Newton and Krawczyk Method * Each iteration gives new set (hopefully smaller) * for zero of given map (R^n -> R^n) */ #include "capd/facade/IVector.h" #include "capd/facade/IMatrix.h" #include "capd/facade/IMap.h" using namespace capd; // For Henon map we iterate Krawczyk and Newton Interval Operators. // In this example Newton Method requires much smaller initial set then Krawczyk to work. void HenonMap() { std::cout << "\n\n HENON map: H(x,y) = (1 - a*x*x + y, b*x) where a=1.4, b=0.3 "; // We define henon map and set its parameters IMap Henon("var:x,y,a,b;fun:1-a*x*x+y,b*x;"); Henon.setParameter("a", DInterval(1.4)); Henon.setParameter("b",DInterval(0.3)); IVector x0(2), K(2), N(2); // We define an initial set for iterations of taking Krawczyk Operator K[0] = DInterval(-100,110); K[1]=DInterval(-100,110); std::cout << "\n\n Interval KRAWCZYK OPERATOR " << "\n for set X = " << K; for(int i=1; i<=5; ++i) { x0=midVector(K); K = capd::newton::KrawczykOperator(x0, K, Henon); std::cout << "\n iteration "<< i << " = " << K; } // We define an initial set for iterations of taking Newton Operator N[0]=DInterval(-.1,.1); N[1] = DInterval(0.9,1.1); std::cout << "\n\n Interval NEWTON OPERATOR " << "\n for set X = " << N; for(int i=1; i<=5; ++i) { x0=midVector(N); N = capd::newton::NewtonOperator(x0, N, Henon); std::cout << "\n iteration "<< i << " = " << N; } } /* ****************************************************************************** * Example 3: Rigorous proof of the existence of zero of * a second iteration of the Henon map * * In this example we also define special class that can be passed as * a parameter to Newton or Krawczyk operator (instaed of Map class). * It is useful e.g. when part of the map definition is * an integration of ODE or map is a composition of several other maps. */ /* Class MapIterator computes n-th iterate * of given map. */ class MapIterator { public: // These internal types need to be defined typedef IVector VectorType; typedef IMatrix MatrixType; typedef IMap MapType; MapIterator(const MapType &f, int iter = 1): map(f) { numberOfIteration = iter; dim = 2; } /* *** Needed Operators and Functions **************/ // Value of a map - used in Newton for computation in a point VectorType operator()(VectorType x) { for(int i=0; i<numberOfIteration; ++i) x = map(x); return x; } // Value and derivative of a map - used in Krawczyk for computation in a point VectorType operator()(VectorType x, MatrixType &dF) { dF = MatrixType::Identity(dim); for(int i=0; i<numberOfIteration; ++i) { dF = map[x]* dF; x = map(x); } return x; } // Derivative of a map - used in both Krawczyk and Newton for computation on a set X MatrixType operator[](VectorType x) { MatrixType dF = MatrixType::Identity(dim); for(int i=0; i<numberOfIteration; ++i) { dF = map[x]* dF; x = map(x); } return dF; } int dimension() const { return dim; } /* *************************** */ private: // members needed only by this particular class int dim; int numberOfIteration; MapType map; }; // Rigorous proof of the existence of zero for second iteration of Henon map // Instead of IMap class we use defined above class MapIterator. void HenonProof() { std::cout << "\n\n SECOND ITERATION OF HENON IMap: \n H(x,y) = (1 - a*x*x + y, b*x) where a=1.4, b=0.3 "; IMap Henon("var:x,y,a,b;fun:1-a*x*x+y,b*x;"); Henon.setParameter("a",DInterval(1.4)); Henon.setParameter("b",DInterval(0.3)); MapIterator IMap(Henon, 2); capd::newton::Krawczyk<MapIterator> henon(IMap); std::cout << "\n\n KRAWCZYK PROOF \n\n "; DVector x(2); // Good quess for zero for second iteration of Henon map x[0] = -10./3; x[1]=131./9; // It is also a center of the set. double size = 1.e-5; // Size of the set in which we will search for a zero try{ capd::newton::KrawczykResult code = henon.proof(x, size); std::cout << resultToText(code) ; std::cout << "\n\n afer " << henon.numberOfIterations << " iteration of Krawczyk method" << "\n set X " << henon.X << "\n Krawczyk operator K " << henon.K << std::endl; } catch(std::exception& e) { std::cout << e.what(); } } // ------------------------------------------------------------------------- int main(int, char *[]) { try { FloatHenonMap(); HenonMap(); HenonProof(); }catch(std::exception& e) { std::cout << e.what() << std::endl; return 1; } return 0; }
[ "soonhok@cs.cmu.edu" ]
soonhok@cs.cmu.edu
68cfd158b94fcc2d1a6e2ebe5b35d2d6ef799df5
f753c6173870b72768fe106715b5cbe8496b9a89
/private/tst/avb_streamhandler/src/IasTestAvbPtpClockDomain.cpp
1670f2f846f8d3fc6774b6286c551282f4d721af
[ "BSL-1.0", "BSD-3-Clause" ]
permissive
intel/AVBStreamHandler
3615b97a799a544b2b3847ad9f5f69902fbcab6e
45558f68e84cc85fa38c8314a513b876090943bd
refs/heads/master
2023-09-02T13:13:49.643816
2022-08-04T22:47:26
2022-08-04T22:47:26
145,041,581
17
24
NOASSERTION
2019-04-11T23:04:57
2018-08-16T21:38:32
C++
UTF-8
C++
false
false
1,513
cpp
/* * Copyright (C) 2018 Intel Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ /** * @file IasTestAvbPtpClockDomain.cpp * @date 2018 */ #include "gtest/gtest.h" #define private public #define protected public #include "avb_streamhandler/IasAvbPtpClockDomain.hpp" #include "avb_streamhandler/IasAvbStreamHandlerEnvironment.hpp" #undef protected #undef private using namespace IasMediaTransportAvb; namespace IasMediaTransportAvb { class IasTestAvbPtpClockDomain : public ::testing::Test { protected: IasTestAvbPtpClockDomain(): mAvbPtpClockDomain(NULL) , mEnvironment(NULL) { DLT_REGISTER_APP("IAAS", "AVB Streamhandler"); } virtual ~IasTestAvbPtpClockDomain() { DLT_UNREGISTER_APP(); } // Sets up the test fixture. virtual void SetUp() { dlt_enable_local_print(); mEnvironment = new IasAvbStreamHandlerEnvironment(DLT_LOG_INFO); ASSERT_TRUE(NULL != mEnvironment); mEnvironment->registerDltContexts(); mAvbPtpClockDomain = new IasAvbPtpClockDomain(); } virtual void TearDown() { delete mAvbPtpClockDomain; mAvbPtpClockDomain = NULL; if (NULL != mEnvironment) { mEnvironment->unregisterDltContexts(); delete mEnvironment; mEnvironment = NULL; } } IasAvbPtpClockDomain* mAvbPtpClockDomain; IasAvbStreamHandlerEnvironment* mEnvironment; }; } // namespace IasMediaTransportAvb TEST_F(IasTestAvbPtpClockDomain, CTor_DTor) { ASSERT_TRUE(NULL != mAvbPtpClockDomain); }
[ "keerock.lee@intel.com" ]
keerock.lee@intel.com
5d59d7b4a790177bac03972b15768bdbfb081aec
32af99b4bfdc6d8bbe8267ce08d661a8af369c12
/FYP_detect/tests/sequence_number/main.cpp
994dd12574e0dd764b7fdd12b43c2c7d5cbf8d4c
[]
no_license
Dthird/FYP
6056ec0b65720b1be3d737985ab6aea1b55de6aa
b73004d8ae4bed877f88c6481697f7e5cce3609b
refs/heads/master
2020-04-01T16:51:51.783879
2015-12-30T07:53:59
2015-12-30T07:53:59
28,626,185
0
0
null
null
null
null
UTF-8
C++
false
false
3,338
cpp
#include <iostream> #include <vector> #include <llvm/IR/Module.h> #include <llvm/Support/SourceMgr.h> #include <llvm/IRReader/IRReader.h> #include <llvm/Support/raw_ostream.h> #include <llvm/IR/LLVMContext.h> #include <llvm/IR/Function.h> #include <llvm/IR/CFG.h> #include <llvm/Analysis/LoopInfo.h> #include <llvm/PassAnalysisSupport.h> #include <llvm/IR/BasicBlock.h> #include <fcntl.h> #include <errno.h> using namespace llvm; unsigned getSequenceNumber(Function &F, BasicBlock *bb){ unsigned SN = 1; for(Function::iterator I = F.begin(), E = F.end() ; I != E ; I++){ if ((BasicBlock *)I == bb){ break; } SN++; } return SN; } /** * Create a std::unique_ptr<llvm::Module> from an IR file (binary or plain-text) */ std::unique_ptr<llvm::Module> loadModuleFromBitcodeFile(const char *filename, llvm::LLVMContext& context){ SMDiagnostic err; /* // Load the input module... std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context); if (!M) { Err.print(argv[0], errs()); return 1; } */ /// If the given file holds a bitcode image, return a Module for it. /// Otherwise, attempt to parse it as LLVM Assembly and return a Module /// for it. ///std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err, /// LLVMContext &Context); std::unique_ptr<llvm::Module> mod(parseIRFile(filename, err, context)); if (!mod){ errs() << err.getMessage(); mod = 0; } return mod; } int main(int argc, char **argv){ LLVMContext &context = getGlobalContext(); std::unique_ptr<Module> mainModule = loadModuleFromBitcodeFile("parser.bc", context); std::cout << "load,successfully\n" ; Module::FunctionListType &fl = mainModule->getFunctionList(); std::cout << "get function list.\n"; Function *f1 = mainModule->getFunction("ComputeSize"); if(f1 != NULL){ std::cout << "ComputeSize get!\n"; } //f1->viewCFG(); std::cout << "\n\n"; int x = 1; for(Function::iterator I = f1->begin(), E = f1->end() ; I != E ; I++){ errs() << I->getName() << ":" << I->size() << "\t" << x << "\t" << getSequenceNumber(*f1, I) << "\n"; x++; } errs() << "\n\n"; /*Module::iterator it; int i=0; for(it = fl.begin(); it != fl.end() ; it++){ //std::cout << i++ << "\n"; //errs() << it->getName() << "\n"; } */ //Function::iterator it_f; // LoopInfoBase<BasicBlock, Loop> LI = BasicBlockPass::getAnalysis<LoopInfo>(); /*template<typename AnalysisType> AnalysisType &Pass::getAnalysis(Function &F) */ //LoopInfo *LI = &getAnalysis<LoopInfo>(f1); //Pass *pass; //LoopInfo *LI = &(pass->getAnalysis<LoopInfo>(*f1)); //LI->runOnFunction(*f1); /*unsigned x = 0, y = 0; for(it_f = f1->begin(); it_f != f1->end() ; it_f++){ errs() << it_f->getName() << "\t\tx:" << ++x << "\t"; for (succ_iterator I = succ_begin(it_f), E = succ_end(it_f); I != E; I++) { y++; } errs() << "y:" << y << "\t"; y = 0; errs() << "z:" << LI->getLoopDepth(it_f) << "\t"; errs() << "w:" << it_f->size() << "\n"; } */ return 0; }
[ "sydongjx@163.com" ]
sydongjx@163.com
b64253ba6408e75dbc7c41b13d09b53b8a946599
6451f4869745d523f220c6b9ce019b5a701c8778
/Solutions/q.cpp
90f77f908e0740ed5cf5c7b470d0051a485df790
[ "MIT" ]
permissive
dariodsa/Information-Theory
de5f2628bd5bd1a732f13ca90c48555bd1a39369
8102af59be9258159d480d3a079cb3d8938154f3
refs/heads/master
2022-11-08T00:50:49.634108
2020-07-13T06:57:17
2020-07-13T06:57:17
111,422,077
0
0
null
null
null
null
UTF-8
C++
false
false
204
cpp
#include <stdio.h> int main(int argc, char *argv[]) { FILE *pfile = fopen(argv[1],"r"); FILE *pfile2 = fopen("out1.txt","w"); char t; while(fscanf(pfile,"%c",&t)) { fprintf(pfile2,"%c,",t); } }
[ "dario.sindicic@gmail.com" ]
dario.sindicic@gmail.com
b8fe7880b433eecaba6b3dde34f9357043cecea7
bd0a5fa497bcd418c71b9d0a4d5329ebc98a0f44
/Graphs/shortest_distance_1or2.cpp
04dc84ad04b0d30221be7c226d45349c2d805cdd
[]
no_license
pruvi007/InterViewBit_Academy
f9ab953919dc4afb4711118640cb72883c3106a8
f1022d6ff8aaf28ffcff688ba69af4aeff136200
refs/heads/master
2021-07-04T10:47:06.639914
2020-10-09T06:45:44
2020-10-09T06:45:44
186,099,196
3
0
null
null
null
null
UTF-8
C++
false
false
1,433
cpp
/* Find shortest distance between source and destination in a graph which has weights 1 or 2. idea: introduce dummy nodes to make distances 1, then apply BFS to get the shortest distance. */ // solution by @pruvi007 #include<bits/stdc++.h> using namespace std; vector< vector<int> > v(100001); int bfs(bool vis[],int source,int dest) { // we will push val,level in the queue queue< pair<int,int> > q; q.push({source,0}); vis[source] = true; while(!q.empty()) { int n = q.size(); for(int i=0;i<n;i++) { pair<int,int> p = q.front(); q.pop(); // cout << p.first << " "; if(p.first == dest) return p.second; for(int j=0;j<v[p.first].size();j++) { if(vis[v[p.first][j]] == false) { vis[v[p.first][j]] = true; q.push({v[p.first][j],p.second+1}); } } } // cout << endl; } return -1; } int main() { int n; cin >> n; int m; cin >> m; int l1 = 99999; while(m--) { int x,y,w; cin >> x >> y >> w; if(w == 2) { int t1 = l1; int t2 = l1+1; l1+=2; v[x].push_back(t1); v[t1].push_back(y); } else { v[x].push_back(y); v[y].push_back(x); } } cout << endl; for(int i=0;i<v.size();i++) { if(v[i].size() > 0) { cout << i << ": "; for(int j=0;j<v[i].size();j++) cout << v[i][j] << " "; cout << endl; } } int s,d; cin >> s >> d; bool vis[100001]; memset(vis,0,sizeof(vis)); cout << bfs(vis,s,d) << endl; }
[ "pruvi007@gmail.com" ]
pruvi007@gmail.com
1c06e05cec436f8d9342ee144445e19c4561ac02
5fd7ba925b2cb277f2e4fe182f28fe4df960b92d
/2468/2468.cpp
a3c97250186e8de6515cc759c75cbb22f7391b39
[]
no_license
htyvv/2021-BaekJun
e8c144561a2a5d80bf881427e76faaae68b4d4cf
f0c58e29ffcfc75e0463227753ffb9e03a813169
refs/heads/main
2023-06-20T18:02:44.026216
2021-08-07T14:32:26
2021-08-07T14:32:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
756
cpp
#include<iostream> using namespace std; int n; int map[100][100]; bool check[100][100]; int dx[] = { 1,0,-1,0 }; int dy[] = { 0,1,0,-1 }; void dfs(int x, int y); int main() { cin >> n; int input; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { cin >> input; map[i][j] = input - n; } } int cnt = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (map[i][j] <= 0 || check[i][j] == true) continue; dfs(j, i); cnt++; } } cout << cnt; } void dfs(int x, int y) { check[y][x] = true; for (int i = 0; i < 4; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (0 >= nx && nx >= n && 0 >= ny && ny >= n) continue; if (map[ny][nx] > 0 && check[ny][nx] == false) { dfs(nx, ny); } } }
[ "htyvv@naver.com" ]
htyvv@naver.com
79e25a1afaca24e7c70fa54497a3e6c8f93a2ccc
8c5ca1bee5f581cebea051f181725698ef3e4e31
/src/libtsduck/dtv/mpe/tsMPEDemux.cpp
eec293ce12b2e87e421cb8f6cb17a33f564a5402
[ "BSD-2-Clause" ]
permissive
vtns/tsduck
1f914c799fcd3e758fbea144cbd7a14f95e17f00
2a7c923ef054d8f42fd4428efe905b033574f78f
refs/heads/master
2023-08-28T08:11:02.430223
2021-10-29T23:28:47
2021-10-29T23:28:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,202
cpp
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsMPEDemux.h" #include "tsMPEPacket.h" #include "tsBinaryTable.h" #include "tsPAT.h" #include "tsDataBroadcastIdDescriptor.h" #include "tsIPMACStreamLocationDescriptor.h" //---------------------------------------------------------------------------- // Constructors and destructors. //---------------------------------------------------------------------------- ts::MPEDemux::MPEDemux(DuckContext& duck, MPEHandlerInterface* mpe_handler, const PIDSet& pid_filter) : SuperClass(duck, pid_filter), _handler(mpe_handler), _psi_demux(duck, this, this), _ts_id(0), _pmts(), _new_pids(), _int_tags() { immediateReset(); } ts::MPEDemux::~MPEDemux() { } //---------------------------------------------------------------------------- // Add / remove MPE PID's (overridden from AbstractDemux). // The added / removed PID's are also added / removed in the section demux. //---------------------------------------------------------------------------- void ts::MPEDemux::addPID(PID pid) { SuperClass::addPID(pid); _psi_demux.addPID(pid); } void ts::MPEDemux::addPIDs(const PIDSet& pids) { SuperClass::addPIDs(pids); _psi_demux.addPIDs(pids); } void ts::MPEDemux::removePID(PID pid) { SuperClass::removePID(pid); _psi_demux.removePID(pid); } //---------------------------------------------------------------------------- // Reset the analysis context (partially built PES packets). //---------------------------------------------------------------------------- void ts::MPEDemux::immediateReset() { SuperClass::immediateReset(); // Reset the PSI demux since the transport may be completely different. _psi_demux.reset(); // Forget everything about the current TS. _ts_id = 0; _pmts.clear(); _new_pids.reset(); _int_tags.clear(); // To get PID's with MPE, we need to analyze the PMT's. // To get the PMT PID's, we need to analyze the PAT. _psi_demux.addPID(PID_PAT); } //---------------------------------------------------------------------------- // Feed the demux with a TS packet. //---------------------------------------------------------------------------- void ts::MPEDemux::feedPacket(const TSPacket& pkt) { // Super class processing first. SuperClass::feedPacket(pkt); // Submit the packet to the PSI handler to detect MPE streams. _psi_demux.feedPacket(pkt); } //---------------------------------------------------------------------------- // Invoked by the PSI demux when a single section is available. // Used to collect DSM-CC sections carrying MPE. //---------------------------------------------------------------------------- void ts::MPEDemux::handleSection(SectionDemux& demux, const Section& section) { // We are notified of absolutely all sections, including PMT, etc. // So, we need to carefully filter the sections. This must be a // DSM-CC Private Data section and it must come from a PID we filter. if (section.tableId() == TID_DSMCC_PD && _pid_filter.test(section.sourcePID())) { // Build the corresponding MPE packet. MPEPacket mpe(section); if (mpe.isValid() && _handler != nullptr) { // Send the MPE packet to the application. beforeCallingHandler(section.sourcePID()); try { _handler->handleMPEPacket(*this, mpe); } catch (...) { afterCallingHandler(false); throw; } afterCallingHandler(true); } } } //---------------------------------------------------------------------------- // Invoked by the PSI demux when a complete table is available. //---------------------------------------------------------------------------- void ts::MPEDemux::handleTable(SectionDemux& demux, const BinaryTable& table) { switch (table.tableId()) { case TID_PAT: { PAT pat(_duck, table); if (pat.isValid() && table.sourcePID() == PID_PAT) { // Remember our transport stream. _ts_id = pat.ts_id; // Add all PMT PID's to PSI demux. for (PAT::ServiceMap::const_iterator it = pat.pmts.begin(); it != pat.pmts.end(); ++it) { _psi_demux.addPID(it->second); } } break; } case TID_PMT: { PMTPtr pmt(new PMT(_duck, table)); if (!pmt.isNull() && pmt->isValid()) { // Keep track of all PMT's in the TS. _pmts[pmt->service_id] = pmt; // Process content of the PMT. processPMT(*pmt); } break; } case TID_INT: { INT imnt(_duck, table); if (imnt.isValid()) { processINT(imnt); } break; } default: { break; } } } //---------------------------------------------------------------------------- // Process a PMT. //---------------------------------------------------------------------------- void ts::MPEDemux::processPMT(const PMT& pmt) { // Loop on all components of the service. for (PMT::StreamMap::const_iterator it = pmt.streams.begin(); it != pmt.streams.end(); ++it) { const PID pid = it->first; const PMT::Stream& stream(it->second); // Loop on all data_broadcast_id_descriptors for the component. for (size_t i = stream.descs.search(DID_DATA_BROADCAST_ID); i < stream.descs.count(); i = stream.descs.search(DID_DATA_BROADCAST_ID, i + 1)) { if (!stream.descs[i].isNull()) { const DataBroadcastIdDescriptor desc(_duck, *stream.descs[i]); if (desc.isValid()) { // Found a valid data_broadcast_id_descriptor. switch (desc.data_broadcast_id) { case DBID_IPMAC_NOTIFICATION: // This component carries INT tables. // We need to collect the INT. _psi_demux.addPID(pid); break; case DBID_MPE: // This component carries MPE sections. processMPEDiscovery(pmt, pid); break; default: break; } } } } // Look for an optional stream_identifier_descriptor for this component. uint8_t ctag = 0; if (stream.getComponentTag(ctag) && _int_tags.count(ServiceTagToInt(pmt.service_id, ctag)) != 0) { // This PID was signalled as MPE in the INT, process it. processMPEDiscovery(pmt, pid); } } } //---------------------------------------------------------------------------- // Process an INT (IP/MAC Notification Table). //---------------------------------------------------------------------------- void ts::MPEDemux::processINT(const INT& imnt) { // Process all descriptor lists in the table. Normally, the IP/MAC stream // location descriptors should be only in the operational descriptor loop // of a device. But we should be prepared to incorrect signalization. processINTDescriptors(imnt.platform_descs); for (INT::DeviceList::const_iterator it = imnt.devices.begin(); it != imnt.devices.end(); ++it) { processINTDescriptors(it->second.target_descs); processINTDescriptors(it->second.operational_descs); } } //---------------------------------------------------------------------------- // Process a descriptor list in the INT. //---------------------------------------------------------------------------- void ts::MPEDemux::processINTDescriptors(const DescriptorList& descs) { // Loop on all IP/MAC stream_location_descriptors. for (size_t i = descs.search(DID_INT_STREAM_LOC); i < descs.count(); i = descs.search(DID_INT_STREAM_LOC, i + 1)) { const IPMACStreamLocationDescriptor desc(_duck, *descs[i]); if (desc.isValid() && desc.transport_stream_id == _ts_id) { // Found an MPE PID in this transport stream. // First, record the MPE service and component. _int_tags.insert(ServiceTagToInt(desc.service_id, desc.component_tag)); // Check if we already found the PMT for this service const PMTMap::const_iterator it(_pmts.find(desc.service_id)); PID pid = PID_NULL; if (it != _pmts.end() && (pid = it->second->componentTagToPID(desc.component_tag)) != PID_NULL) { // Yes, the PMT was already found and it has a component with the specified tag. processMPEDiscovery(*it->second, pid); } } } } //---------------------------------------------------------------------------- // Process the discovery of a new MPE PID. //---------------------------------------------------------------------------- void ts::MPEDemux::processMPEDiscovery(const PMT& pmt, PID pid) { // Don't signal the same PID twice. if (!_new_pids.test(pid) && _handler != nullptr) { // Remember we signalled this PID. _new_pids.set(pid); // Invoke the user-defined handler to signal the new PID. beforeCallingHandler(pid); try { _handler->handleMPENewPID(*this, pmt, pid); } catch (...) { afterCallingHandler(false); throw; } afterCallingHandler(true); } }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
02313b76fe6647698850697869aeeecf4aec2a7e
9f7ae044ec7e6fab9bd27e81b636ea242d3dfa1d
/examples/cpp/open_response/request_open_resp.cpp
8c08dd1a012d46f30778761d61087a7b58d9e0e3
[ "LicenseRef-scancode-us-govt-public-domain" ]
permissive
barbaroony/GMSEC_API
9ced39b6d6847a14db386264be907403acc911da
85f806c2519104f5e527dab52331c974d590145a
refs/heads/master
2022-12-18T20:52:36.877566
2020-09-25T12:27:13
2020-09-25T12:27:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,769
cpp
/* * Copyright 2007-2020 United States Government as represented by the * Administrator of The National Aeronautics and Space Administration. * No copyright is claimed in the United States under Title 17, U.S. Code. * All Rights Reserved. */ /** * @file request_open_resp.cpp * * This file contains an example demonstrating how to issue a request message * and handle a coinciding reply message when using the open-response * configuration option. This example program is intended to be run after * starting up the 'reply_open_resp' example program. * * It is also recommended that you run a subscriber application * (i.e. GMSEC_API/bin/gmsub) with the configuration option 'mw-expose-resp' * set to true in order to see how any subscriber can receive reply messages * while using the open-response functionality. Note that by setting the * configuration option 'GMSEC-REQ-RESP' to 'open-resp' in the requester * automatically turns on the 'mw-expose-resp' option. */ #include <gmsec4_cpp.h> #include <string> #include <sstream> #include <iostream> using namespace gmsec::api; using namespace gmsec::api::mist; const char* OPEN_RESP_REQUEST_SUBJECT = "GMSEC.MISSION.SAT_ID.RESP.REQUEST_OPENRESP"; const char* OPEN_RESP_REPLY_SUBJECT = "GMSEC.MISSION.SAT_ID.RESP.REPLY_OPENRESP"; //o Helper functions void initializeLogging(Config& config); int main(int argc, char* argv[]) { if (argc <= 1) { std::cout << "usage: " << argv[0] << " mw-id=<middleware ID>" << std::endl; return -1; } //o Load the command-line input into a GMSEC Config object // A Config object is basically a key-value pair map which is used to // pass configuration options into objects such as Connections, // ConnectionManagers, Subscribe and Publish function calls, Messages, // etc. Config config(argc, argv); //o Since this example program uses an invalid message, we ensure the // validation check is disabled. config.addValue("gmsec-msg-content-validate-all", "false"); //o Ensure that the open-response is enabled // Note: Other subscribing applications should set the configuration // option 'mw-expose-resp' to 'true' in order to receive exposed replies // By setting the configuration option 'GMSEC-REQ-RESP' to 'open-resp' // here, it automatically enables the 'mw-expose-resp' option. config.addValue("GMSEC-REQ-RESP", "OPEN-RESP"); // If it was not specified in the command-line arguments, set LOGLEVEL // to 'INFO' and LOGFILE to 'stdout' to allow the program report output // on the terminal/command line initializeLogging(config); //o Print the GMSEC API version number using the GMSEC Logging // interface // This is useful for determining which version of the API is // configured within the environment GMSEC_INFO << ConnectionManager::getAPIVersion(); try { //o Create the ConnectionManager ConnectionManager connMgr(config); //o Open the connection to the middleware connMgr.initialize(); //o Output middleware client library version GMSEC_INFO << connMgr.getLibraryVersion(); //o Subscribe to the bus in preparation to receive the // open-response message (Because it will not be routed // to the reqeust() call) std::ostringstream reply_subject; reply_subject << OPEN_RESP_REPLY_SUBJECT << ".*"; connMgr.subscribe(reply_subject.str().c_str()); //o Output information GMSEC_INFO << "Issuing a request using the subject '" << OPEN_RESP_REQUEST_SUBJECT << "'"; //o Create message Message requestMsg(OPEN_RESP_REQUEST_SUBJECT, Message::REQUEST); //o Add fields to message requestMsg.addField("QUESTION", "Is there anyone out there?"); requestMsg.addField("COMPONENT", "request"); //o Display XML representation of request message GMSEC_INFO << "Sending request message:\n" << requestMsg.toXML(); //o Send Request Message // Timeout periods: // -1 - Wait forever // 0 - Return immediately // >0 - Time in milliseconds before timing out Message* replyMsg = connMgr.request(requestMsg, 1000, GMSEC_REQUEST_REPUBLISH_NEVER); // Example error handling for calling request() with a timeout if (replyMsg) { // Display the XML string representation of the reply GMSEC_INFO << "Received replyMsg:\n" << replyMsg->toXML(); //o Destroy the replyMsg message connMgr.release(replyMsg); } //o Disconnect from the middleware and clean up the Connection connMgr.cleanup(); } catch (Exception& e) { GMSEC_ERROR << e.what(); return -1; } return 0; } void initializeLogging(Config& config) { const char* logLevel = config.getValue("LOGLEVEL"); const char* logFile = config.getValue("LOGFILE"); if (!logLevel) { config.addValue("LOGLEVEL", "INFO"); } if (!logFile) { config.addValue("LOGFILE", "STDERR"); } }
[ "david.m.whitney@nasa.gov" ]
david.m.whitney@nasa.gov
6c6bac7a6b0d5570c27f31b042f767e117f5b8dd
f8a7754b0621d1b936a3177d7888d1c7439b18f2
/Source/ActionGame/CharacterInterface.h
3b0b4dd30eebd50031f878118af1274d64b21a6d
[]
no_license
kaznakajima/ActionGameProj
085722fa5a031c0bf7995d4134ac21277716a58a
bb26636ea07a2c6d1c09758a8eff15a13f1106f9
refs/heads/master
2021-06-12T15:11:35.359447
2019-09-09T14:26:55
2019-09-09T14:26:55
185,239,210
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,989
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "UObject/Interface.h" #include "CharacterInterface.generated.h" UINTERFACE() class ACTIONGAME_API UCharacterInterface : public UInterface { GENERATED_UINTERFACE_BODY() }; // キャラクターのステータス USTRUCT(BlueprintType) struct FCharacterStatus { GENERATED_USTRUCT_BODY() // キャラクターID UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterStatus") int ID; // キャラクター名 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterStatus") FText Name; // 最大HP UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterStatus") float MaxHP; // 攻撃力 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterStatus") float Power; // 守備力 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterStatus") float Defence; // 攻撃範囲 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CharacterParam") float AttackRange; }; // キャラクターインターフェース class ACTIONGAME_API ICharacterInterface { GENERATED_IINTERFACE_BODY() public: // コリジョン有効化 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "InterfaceAction") void OnUseCollision(class UPrimitiveComponent* Col); // コリジョン無効化 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "InterfaceAction") void OnUnUseCollision(class UPrimitiveComponent* Col_1, class UPrimitiveComponent* Col_2); // ダメージ処理 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "InterfaceAction") void OnDamage(AActor* actor, float defence); // それぞれのアクションイベント UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Action") void CharacterAction(); // 死亡イベント UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Action") void DeathAction(); };
[ "nkc.kazuya.nakajima@gmail.com" ]
nkc.kazuya.nakajima@gmail.com
530d32029dfd83b2f150a0c9fde952d1c5d0df05
bffb0c3c64029c7fa8521cce1374105803a280e1
/docs/cpp/codes/new_delete.cpp
e8b7f71f5b5d0a409c576a24157bf0b430b2a8a9
[]
no_license
yiouejv/blog
b7d6ea015e13da9f988ac5a62098d24561f43d9b
f5c0a3ce26e961df3fc8879f55b681bb9d8aae51
refs/heads/master
2021-07-06T20:33:39.124373
2021-03-28T08:47:52
2021-03-28T08:47:52
229,209,161
0
1
null
null
null
null
UTF-8
C++
false
false
499
cpp
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { // new 申请内存 int *p1 = new int; // c++ *p1 = 12; // 写 cout << *p1 << endl; // 读 delete p1; // delete + 指针 // 申请并初始化 int *p2 = new int(123); cout << *p2 << endl; delete p2; // 申请数组空间,返回空间的首地址 int *p = new int[5]; p[0] = 0; p[1] = 1; p[2] = 2; p[3] = 3; p[4] = 4; cout << p << endl; delete[] p; // 释放数组要加[] return 0; }
[ "yiouejv@126.com" ]
yiouejv@126.com
d09adabc5e46d9b20a2aa362bac980691248c9ff
fcaae47ab2e34c634b6965a7f7c85ffe064b0572
/cf/aresta_no_caminho_minimo.cpp
d5f26d055301c2d22baec01ebf4e6e726a39b2f7
[]
no_license
MatheusSanchez/Gema
de9769d4a491d7ac4ad66c514cbd929fc46ac25f
988f78a30c78477efcebc2676be3b19d107a3067
refs/heads/master
2021-07-13T13:30:25.138507
2018-11-07T18:51:17
2018-11-07T18:51:17
123,514,762
3
0
null
null
null
null
UTF-8
C++
false
false
1,976
cpp
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define MAX 100001 using namespace std; typedef pair <int,int> pii; typedef vector <pii> vpii; typedef vector<vpii> graph; typedef vector<int> vi; int n_nos,n_arestas,origem,destino,A,B,peso; graph g(MAX); int prede[MAX]; int dist[MAX]; void print_prede(){ //cout << endl; for (int i = 1; i <= n_nos; ++i){ cout << i << '(' <<prede[i] << ") "; } cout << endl; } void print_dist(){ cout << "DIST" <<endl; for (int i = 1; i <= n_nos; ++i){ cout << i << '(' <<dist[i] << ") "; } cout << endl; } void dijkstra(int no){ for (int i = 1; i <= n_nos; ++i){ dist[i] = inf; } for (int i = 1; i <= n_nos; ++i){ prede[i] = -1; } priority_queue <pair <int,int> >pq; dist[no] = 0; prede[no] = -1; pq.push(make_pair(0,no)); while(!pq.empty()){ int u = pq.top().second; pq.pop(); cout << "NO " << u << endl; for (int i = 0; i < g[u].size(); ++i){ int v = g[u][i].first; int w = g[u][i].second; cout << "V " << v <<" U " << u << endl; if(dist[v] >= dist[u] + w){ dist[v] = dist[u] + w; prede[v] = u; print_prede(); print_dist(); pq.push(make_pair(-dist[v],v)); } cout << endl; } } } void print_graph(){ for (int i = 0; i < n_arestas; ++i){ cout << i << "-> "; for (int j = 0; j < g[i].size(); j++){ cout << g[i][j].first << " "; } cout << endl; } } int main (){ cin >> n_nos >> n_arestas >> origem >> destino; vpii resp; for (int i = 0; i < n_arestas; ++i){ cin >> A >> B >> peso; //A--;B--; g[A].push_back(make_pair(B,peso)); g[B].push_back(make_pair(A,peso)); resp.push_back(make_pair(A,B)); } //origem--; //destino--; print_graph(); dijkstra(origem); int k = prede[destino]; while(){ } for (int i = 0; i < n_arestas; ++i){ if(prede[resp[i].first] == resp[i].second || prede[resp[i].second] == resp[i].first ){ cout << "sim" << endl; }else{ cout << "nao" << endl; } } return 0; }
[ "matheus2.sanchez@usp.br" ]
matheus2.sanchez@usp.br
f82bb97977b3e7f0407caf3dbe1a0e6a4f22ff0e
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/097/920/CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_w32CreateFile_52a.cpp
d64402cbff399fe47626d536024d6bb87543f66d
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446957
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C++
false
false
5,190
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_w32CreateFile_52a.cpp Label Definition File: CWE36_Absolute_Path_Traversal.label.xml Template File: sources-sink-52a.tmpl.cpp */ /* * @description * CWE: 36 Absolute Path Traversal * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Full path and file name * Sink: w32CreateFile * BadSink : Open the file named in data using CreateFile() * Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define LISTEN_BACKLOG 5 namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_w32CreateFile_52 { #ifndef OMITBAD /* bad function declaration */ void badSink_b(wchar_t * data); void bad() { wchar_t * data; wchar_t dataBuffer[FILENAME_MAX] = L""; data = dataBuffer; { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; wchar_t *replace; SOCKET listenSocket = INVALID_SOCKET; SOCKET acceptSocket = INVALID_SOCKET; size_t dataLen = wcslen(data); do { #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1; #endif /* POTENTIAL FLAW: Read data using a listen socket */ listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listenSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = INADDR_ANY; service.sin_port = htons(TCP_PORT); if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR) { break; } acceptSocket = accept(listenSocket, NULL, NULL); if (acceptSocket == SOCKET_ERROR) { break; } /* Abort on error or the connection was closed */ recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(wchar_t) * (FILENAME_MAX - dataLen - 1), 0); if (recvResult == SOCKET_ERROR || recvResult == 0) { break; } /* Append null terminator */ data[dataLen + recvResult / sizeof(wchar_t)] = L'\0'; /* Eliminate CRLF */ replace = wcschr(data, L'\r'); if (replace) { *replace = L'\0'; } replace = wcschr(data, L'\n'); if (replace) { *replace = L'\0'; } } while (0); if (listenSocket != INVALID_SOCKET) { CLOSE_SOCKET(listenSocket); } if (acceptSocket != INVALID_SOCKET) { CLOSE_SOCKET(acceptSocket); } #ifdef _WIN32 if (wsaDataInit) { WSACleanup(); } #endif } badSink_b(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declarations */ void goodG2BSink_b(wchar_t * data); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { wchar_t * data; wchar_t dataBuffer[FILENAME_MAX] = L""; data = dataBuffer; #ifdef _WIN32 /* FIX: Use a fixed, full path and file name */ wcscat(data, L"c:\\temp\\file.txt"); #else /* FIX: Use a fixed, full path and file name */ wcscat(data, L"/tmp/file.txt"); #endif goodG2BSink_b(data); } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_w32CreateFile_52; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "frank@fischer.com.mt" ]
frank@fischer.com.mt
a64d20f90834706f18fdd0eb0a9010cfd6238b2e
b6067f462d3bd91362ca9bb462b99f9a2890d980
/CSAcademy/76/C.cpp
e0d16db88f1d5f3577a89d3083fc8b5c076aaea8
[]
no_license
lionadis/CompetitiveProgramming
275cb251cccbed0669b35142b317943f9b5c72c5
f91d7ac19f09d7e89709bd825fe2cd95fa0cf985
refs/heads/master
2020-07-22T07:29:18.683302
2019-09-08T13:48:31
2019-09-08T13:48:31
207,116,093
0
0
null
null
null
null
UTF-8
C++
false
false
1,424
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define F first #define S second #define f_in freopen("test.in","r",stdin); #define f_out freopen("test.in","w",stdout); #define debug(x) cerr << #x << " : " << x << "\n"; #define _ cin.sync_with_stdio(0); cin.tie(0); typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; } template<typename T = int> inline T nxt(){ char c=nc();T x=0; int f=1; for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1; for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); x*=f; return x; } const int N = 100123; int a[N]; int main(){ #ifdef LOCAL_DEFINE f_in #else _ #endif int n = nxt(), m = nxt(), left = 0; rep(i,0,n) a[i] = nxt(); rep(i,0,m){ int op = nxt(); if(op == 1){ int x = nxt() - 1; if(!a[x]) left--, cout << x + 1 << '\n'; else a[x]--; } else left++; } rep(i,0,left) cout << 1 << '\n'; #ifdef LOCAL_DEFINE cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"; #endif }
[ "ahmed.ben.neji@ieee.org" ]
ahmed.ben.neji@ieee.org
b5e49a628c8e74c38643b3f6b74fac435ac4ed1a
75b418f5fb34a524e11d26c3e6928e89100e04e8
/homework2/btb_trial_2_2048.cpp
77fd11041a375552cfde1ce5a853e1b4ab98da31
[]
no_license
Krishna14/CSE240C
362bb272d7ce26772ee76dc030b17709ba3b0d57
d41949816bf440f58752bdb47fabe05d6c57a249
refs/heads/main
2023-03-25T14:41:38.109721
2021-03-23T09:27:11
2021-03-23T09:27:11
339,305,162
0
0
null
null
null
null
UTF-8
C++
false
false
122,890
cpp
#include <iostream> using namespace std; int main(void) { uint64_t i; uint64_t iter = 1000000; for (i=0; i < iter; i++) { __asm__ ( "clc\n" "clc\n" "mov $10, %eax\n" "cmp $15, %eax\n" "jle l780\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l780: jle l782\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l782: jle l784\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l784: jle l786\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l786: jle l788\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l788: jle l78a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l78a: jle l78c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l78c: jle l78e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l78e: jle l790\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l790: jle l792\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l792: jle l794\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l794: jle l796\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l796: jle l798\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l798: jle l79a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l79a: jle l79c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l79c: jle l79e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l79e: jle l7a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7a0: jle l7a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7a2: jle l7a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7a4: jle l7a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7a6: jle l7a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7a8: jle l7aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7aa: jle l7ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ac: jle l7ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ae: jle l7b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7b0: jle l7b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7b2: jle l7b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7b4: jle l7b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7b6: jle l7b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7b8: jle l7ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ba: jle l7bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7bc: jle l7be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7be: jle l7c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7c0: jle l7c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7c2: jle l7c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7c4: jle l7c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7c6: jle l7c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7c8: jle l7ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ca: jle l7cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7cc: jle l7ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ce: jle l7d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7d0: jle l7d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7d2: jle l7d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7d4: jle l7d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7d6: jle l7d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7d8: jle l7da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7da: jle l7dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7dc: jle l7de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7de: jle l7e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7e0: jle l7e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7e2: jle l7e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7e4: jle l7e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7e6: jle l7e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7e8: jle l7ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ea: jle l7ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ec: jle l7ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7ee: jle l7f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7f0: jle l7f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7f2: jle l7f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7f4: jle l7f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7f6: jle l7f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7f8: jle l7fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7fa: jle l7fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7fc: jle l7fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l7fe: jle l800\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l800: jle l802\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l802: jle l804\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l804: jle l806\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l806: jle l808\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l808: jle l80a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l80a: jle l80c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l80c: jle l80e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l80e: jle l810\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l810: jle l812\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l812: jle l814\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l814: jle l816\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l816: jle l818\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l818: jle l81a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l81a: jle l81c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l81c: jle l81e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l81e: jle l820\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l820: jle l822\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l822: jle l824\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l824: jle l826\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l826: jle l828\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l828: jle l82a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l82a: jle l82c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l82c: jle l82e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l82e: jle l830\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l830: jle l832\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l832: jle l834\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l834: jle l836\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l836: jle l838\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l838: jle l83a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l83a: jle l83c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l83c: jle l83e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l83e: jle l840\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l840: jle l842\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l842: jle l844\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l844: jle l846\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l846: jle l848\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l848: jle l84a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l84a: jle l84c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l84c: jle l84e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l84e: jle l850\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l850: jle l852\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l852: jle l854\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l854: jle l856\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l856: jle l858\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l858: jle l85a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l85a: jle l85c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l85c: jle l85e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l85e: jle l860\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l860: jle l862\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l862: jle l864\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l864: jle l866\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l866: jle l868\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l868: jle l86a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l86a: jle l86c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l86c: jle l86e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l86e: jle l870\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l870: jle l872\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l872: jle l874\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l874: jle l876\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l876: jle l878\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l878: jle l87a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l87a: jle l87c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l87c: jle l87e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l87e: jle l880\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l880: jle l882\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l882: jle l884\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l884: jle l886\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l886: jle l888\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l888: jle l88a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l88a: jle l88c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l88c: jle l88e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l88e: jle l890\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l890: jle l892\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l892: jle l894\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l894: jle l896\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l896: jle l898\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l898: jle l89a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l89a: jle l89c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l89c: jle l89e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l89e: jle l8a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8a0: jle l8a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8a2: jle l8a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8a4: jle l8a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8a6: jle l8a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8a8: jle l8aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8aa: jle l8ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ac: jle l8ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ae: jle l8b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8b0: jle l8b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8b2: jle l8b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8b4: jle l8b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8b6: jle l8b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8b8: jle l8ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ba: jle l8bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8bc: jle l8be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8be: jle l8c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8c0: jle l8c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8c2: jle l8c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8c4: jle l8c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8c6: jle l8c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8c8: jle l8ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ca: jle l8cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8cc: jle l8ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ce: jle l8d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8d0: jle l8d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8d2: jle l8d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8d4: jle l8d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8d6: jle l8d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8d8: jle l8da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8da: jle l8dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8dc: jle l8de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8de: jle l8e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8e0: jle l8e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8e2: jle l8e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8e4: jle l8e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8e6: jle l8e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8e8: jle l8ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ea: jle l8ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ec: jle l8ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8ee: jle l8f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8f0: jle l8f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8f2: jle l8f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8f4: jle l8f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8f6: jle l8f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8f8: jle l8fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8fa: jle l8fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8fc: jle l8fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l8fe: jle l900\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l900: jle l902\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l902: jle l904\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l904: jle l906\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l906: jle l908\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l908: jle l90a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l90a: jle l90c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l90c: jle l90e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l90e: jle l910\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l910: jle l912\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l912: jle l914\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l914: jle l916\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l916: jle l918\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l918: jle l91a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l91a: jle l91c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l91c: jle l91e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l91e: jle l920\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l920: jle l922\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l922: jle l924\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l924: jle l926\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l926: jle l928\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l928: jle l92a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l92a: jle l92c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l92c: jle l92e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l92e: jle l930\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l930: jle l932\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l932: jle l934\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l934: jle l936\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l936: jle l938\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l938: jle l93a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l93a: jle l93c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l93c: jle l93e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l93e: jle l940\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l940: jle l942\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l942: jle l944\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l944: jle l946\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l946: jle l948\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l948: jle l94a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l94a: jle l94c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l94c: jle l94e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l94e: jle l950\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l950: jle l952\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l952: jle l954\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l954: jle l956\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l956: jle l958\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l958: jle l95a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l95a: jle l95c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l95c: jle l95e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l95e: jle l960\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l960: jle l962\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l962: jle l964\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l964: jle l966\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l966: jle l968\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l968: jle l96a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l96a: jle l96c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l96c: jle l96e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l96e: jle l970\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l970: jle l972\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l972: jle l974\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l974: jle l976\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l976: jle l978\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l978: jle l97a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l97a: jle l97c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l97c: jle l97e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l97e: jle l980\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l980: jle l982\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l982: jle l984\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l984: jle l986\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l986: jle l988\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l988: jle l98a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l98a: jle l98c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l98c: jle l98e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l98e: jle l990\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l990: jle l992\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l992: jle l994\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l994: jle l996\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l996: jle l998\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l998: jle l99a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l99a: jle l99c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l99c: jle l99e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l99e: jle l9a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9a0: jle l9a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9a2: jle l9a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9a4: jle l9a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9a6: jle l9a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9a8: jle l9aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9aa: jle l9ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ac: jle l9ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ae: jle l9b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9b0: jle l9b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9b2: jle l9b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9b4: jle l9b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9b6: jle l9b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9b8: jle l9ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ba: jle l9bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9bc: jle l9be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9be: jle l9c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9c0: jle l9c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9c2: jle l9c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9c4: jle l9c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9c6: jle l9c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9c8: jle l9ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ca: jle l9cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9cc: jle l9ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ce: jle l9d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9d0: jle l9d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9d2: jle l9d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9d4: jle l9d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9d6: jle l9d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9d8: jle l9da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9da: jle l9dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9dc: jle l9de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9de: jle l9e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9e0: jle l9e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9e2: jle l9e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9e4: jle l9e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9e6: jle l9e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9e8: jle l9ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ea: jle l9ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ec: jle l9ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9ee: jle l9f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9f0: jle l9f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9f2: jle l9f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9f4: jle l9f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9f6: jle l9f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9f8: jle l9fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9fa: jle l9fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9fc: jle l9fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l9fe: jle la00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la00: jle la02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la02: jle la04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la04: jle la06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la06: jle la08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la08: jle la0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la0a: jle la0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la0c: jle la0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la0e: jle la10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la10: jle la12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la12: jle la14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la14: jle la16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la16: jle la18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la18: jle la1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la1a: jle la1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la1c: jle la1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la1e: jle la20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la20: jle la22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la22: jle la24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la24: jle la26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la26: jle la28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la28: jle la2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la2a: jle la2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la2c: jle la2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la2e: jle la30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la30: jle la32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la32: jle la34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la34: jle la36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la36: jle la38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la38: jle la3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la3a: jle la3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la3c: jle la3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la3e: jle la40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la40: jle la42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la42: jle la44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la44: jle la46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la46: jle la48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la48: jle la4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la4a: jle la4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la4c: jle la4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la4e: jle la50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la50: jle la52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la52: jle la54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la54: jle la56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la56: jle la58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la58: jle la5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la5a: jle la5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la5c: jle la5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la5e: jle la60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la60: jle la62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la62: jle la64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la64: jle la66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la66: jle la68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la68: jle la6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la6a: jle la6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la6c: jle la6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la6e: jle la70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la70: jle la72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la72: jle la74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la74: jle la76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la76: jle la78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la78: jle la7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la7a: jle la7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la7c: jle la7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la7e: jle la80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la80: jle la82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la82: jle la84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la84: jle la86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la86: jle la88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la88: jle la8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la8a: jle la8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la8c: jle la8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la8e: jle la90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la90: jle la92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la92: jle la94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la94: jle la96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la96: jle la98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la98: jle la9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la9a: jle la9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la9c: jle la9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "la9e: jle laa0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laa0: jle laa2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laa2: jle laa4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laa4: jle laa6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laa6: jle laa8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laa8: jle laaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laaa: jle laac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laac: jle laae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laae: jle lab0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lab0: jle lab2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lab2: jle lab4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lab4: jle lab6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lab6: jle lab8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lab8: jle laba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laba: jle labc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "labc: jle labe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "labe: jle lac0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lac0: jle lac2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lac2: jle lac4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lac4: jle lac6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lac6: jle lac8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lac8: jle laca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laca: jle lacc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lacc: jle lace\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lace: jle lad0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lad0: jle lad2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lad2: jle lad4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lad4: jle lad6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lad6: jle lad8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lad8: jle lada\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lada: jle ladc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ladc: jle lade\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lade: jle lae0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lae0: jle lae2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lae2: jle lae4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lae4: jle lae6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lae6: jle lae8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lae8: jle laea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laea: jle laec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laec: jle laee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laee: jle laf0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laf0: jle laf2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laf2: jle laf4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laf4: jle laf6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laf6: jle laf8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "laf8: jle lafa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lafa: jle lafc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lafc: jle lafe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lafe: jle lb00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb00: jle lb02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb02: jle lb04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb04: jle lb06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb06: jle lb08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb08: jle lb0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb0a: jle lb0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb0c: jle lb0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb0e: jle lb10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb10: jle lb12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb12: jle lb14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb14: jle lb16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb16: jle lb18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb18: jle lb1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb1a: jle lb1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb1c: jle lb1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb1e: jle lb20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb20: jle lb22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb22: jle lb24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb24: jle lb26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb26: jle lb28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb28: jle lb2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb2a: jle lb2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb2c: jle lb2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb2e: jle lb30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb30: jle lb32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb32: jle lb34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb34: jle lb36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb36: jle lb38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb38: jle lb3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb3a: jle lb3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb3c: jle lb3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb3e: jle lb40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb40: jle lb42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb42: jle lb44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb44: jle lb46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb46: jle lb48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb48: jle lb4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb4a: jle lb4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb4c: jle lb4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb4e: jle lb50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb50: jle lb52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb52: jle lb54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb54: jle lb56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb56: jle lb58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb58: jle lb5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb5a: jle lb5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb5c: jle lb5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb5e: jle lb60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb60: jle lb62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb62: jle lb64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb64: jle lb66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb66: jle lb68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb68: jle lb6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb6a: jle lb6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb6c: jle lb6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb6e: jle lb70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb70: jle lb72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb72: jle lb74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb74: jle lb76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb76: jle lb78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb78: jle lb7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb7a: jle lb7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb7c: jle lb7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb7e: jle lb80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb80: jle lb82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb82: jle lb84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb84: jle lb86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb86: jle lb88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb88: jle lb8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb8a: jle lb8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb8c: jle lb8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb8e: jle lb90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb90: jle lb92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb92: jle lb94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb94: jle lb96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb96: jle lb98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb98: jle lb9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb9a: jle lb9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb9c: jle lb9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lb9e: jle lba0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lba0: jle lba2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lba2: jle lba4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lba4: jle lba6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lba6: jle lba8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lba8: jle lbaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbaa: jle lbac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbac: jle lbae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbae: jle lbb0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbb0: jle lbb2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbb2: jle lbb4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbb4: jle lbb6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbb6: jle lbb8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbb8: jle lbba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbba: jle lbbc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbbc: jle lbbe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbbe: jle lbc0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbc0: jle lbc2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbc2: jle lbc4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbc4: jle lbc6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbc6: jle lbc8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbc8: jle lbca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbca: jle lbcc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbcc: jle lbce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbce: jle lbd0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbd0: jle lbd2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbd2: jle lbd4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbd4: jle lbd6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbd6: jle lbd8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbd8: jle lbda\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbda: jle lbdc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbdc: jle lbde\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbde: jle lbe0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbe0: jle lbe2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbe2: jle lbe4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbe4: jle lbe6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbe6: jle lbe8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbe8: jle lbea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbea: jle lbec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbec: jle lbee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbee: jle lbf0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbf0: jle lbf2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbf2: jle lbf4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbf4: jle lbf6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbf6: jle lbf8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbf8: jle lbfa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbfa: jle lbfc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbfc: jle lbfe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lbfe: jle lc00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc00: jle lc02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc02: jle lc04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc04: jle lc06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc06: jle lc08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc08: jle lc0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc0a: jle lc0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc0c: jle lc0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc0e: jle lc10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc10: jle lc12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc12: jle lc14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc14: jle lc16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc16: jle lc18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc18: jle lc1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc1a: jle lc1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc1c: jle lc1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc1e: jle lc20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc20: jle lc22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc22: jle lc24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc24: jle lc26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc26: jle lc28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc28: jle lc2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc2a: jle lc2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc2c: jle lc2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc2e: jle lc30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc30: jle lc32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc32: jle lc34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc34: jle lc36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc36: jle lc38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc38: jle lc3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc3a: jle lc3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc3c: jle lc3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc3e: jle lc40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc40: jle lc42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc42: jle lc44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc44: jle lc46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc46: jle lc48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc48: jle lc4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc4a: jle lc4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc4c: jle lc4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc4e: jle lc50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc50: jle lc52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc52: jle lc54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc54: jle lc56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc56: jle lc58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc58: jle lc5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc5a: jle lc5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc5c: jle lc5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc5e: jle lc60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc60: jle lc62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc62: jle lc64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc64: jle lc66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc66: jle lc68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc68: jle lc6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc6a: jle lc6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc6c: jle lc6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc6e: jle lc70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc70: jle lc72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc72: jle lc74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc74: jle lc76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc76: jle lc78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc78: jle lc7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc7a: jle lc7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc7c: jle lc7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc7e: jle lc80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc80: jle lc82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc82: jle lc84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc84: jle lc86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc86: jle lc88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc88: jle lc8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc8a: jle lc8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc8c: jle lc8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc8e: jle lc90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc90: jle lc92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc92: jle lc94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc94: jle lc96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc96: jle lc98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc98: jle lc9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc9a: jle lc9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc9c: jle lc9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lc9e: jle lca0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lca0: jle lca2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lca2: jle lca4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lca4: jle lca6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lca6: jle lca8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lca8: jle lcaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcaa: jle lcac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcac: jle lcae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcae: jle lcb0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcb0: jle lcb2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcb2: jle lcb4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcb4: jle lcb6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcb6: jle lcb8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcb8: jle lcba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcba: jle lcbc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcbc: jle lcbe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcbe: jle lcc0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcc0: jle lcc2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcc2: jle lcc4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcc4: jle lcc6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcc6: jle lcc8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcc8: jle lcca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcca: jle lccc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lccc: jle lcce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcce: jle lcd0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcd0: jle lcd2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcd2: jle lcd4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcd4: jle lcd6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcd6: jle lcd8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcd8: jle lcda\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcda: jle lcdc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcdc: jle lcde\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcde: jle lce0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lce0: jle lce2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lce2: jle lce4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lce4: jle lce6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lce6: jle lce8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lce8: jle lcea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcea: jle lcec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcec: jle lcee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcee: jle lcf0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcf0: jle lcf2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcf2: jle lcf4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcf4: jle lcf6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcf6: jle lcf8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcf8: jle lcfa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcfa: jle lcfc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcfc: jle lcfe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lcfe: jle ld00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld00: jle ld02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld02: jle ld04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld04: jle ld06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld06: jle ld08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld08: jle ld0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld0a: jle ld0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld0c: jle ld0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld0e: jle ld10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld10: jle ld12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld12: jle ld14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld14: jle ld16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld16: jle ld18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld18: jle ld1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld1a: jle ld1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld1c: jle ld1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld1e: jle ld20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld20: jle ld22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld22: jle ld24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld24: jle ld26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld26: jle ld28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld28: jle ld2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld2a: jle ld2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld2c: jle ld2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld2e: jle ld30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld30: jle ld32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld32: jle ld34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld34: jle ld36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld36: jle ld38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld38: jle ld3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld3a: jle ld3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld3c: jle ld3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld3e: jle ld40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld40: jle ld42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld42: jle ld44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld44: jle ld46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld46: jle ld48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld48: jle ld4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld4a: jle ld4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld4c: jle ld4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld4e: jle ld50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld50: jle ld52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld52: jle ld54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld54: jle ld56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld56: jle ld58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld58: jle ld5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld5a: jle ld5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld5c: jle ld5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld5e: jle ld60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld60: jle ld62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld62: jle ld64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld64: jle ld66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld66: jle ld68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld68: jle ld6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld6a: jle ld6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld6c: jle ld6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld6e: jle ld70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld70: jle ld72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld72: jle ld74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld74: jle ld76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld76: jle ld78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld78: jle ld7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld7a: jle ld7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld7c: jle ld7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld7e: jle ld80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld80: jle ld82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld82: jle ld84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld84: jle ld86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld86: jle ld88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld88: jle ld8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld8a: jle ld8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld8c: jle ld8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld8e: jle ld90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld90: jle ld92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld92: jle ld94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld94: jle ld96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld96: jle ld98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld98: jle ld9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld9a: jle ld9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld9c: jle ld9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ld9e: jle lda0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lda0: jle lda2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lda2: jle lda4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lda4: jle lda6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lda6: jle lda8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lda8: jle ldaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldaa: jle ldac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldac: jle ldae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldae: jle ldb0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldb0: jle ldb2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldb2: jle ldb4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldb4: jle ldb6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldb6: jle ldb8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldb8: jle ldba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldba: jle ldbc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldbc: jle ldbe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldbe: jle ldc0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldc0: jle ldc2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldc2: jle ldc4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldc4: jle ldc6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldc6: jle ldc8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldc8: jle ldca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldca: jle ldcc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldcc: jle ldce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldce: jle ldd0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldd0: jle ldd2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldd2: jle ldd4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldd4: jle ldd6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldd6: jle ldd8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldd8: jle ldda\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldda: jle lddc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lddc: jle ldde\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldde: jle lde0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lde0: jle lde2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lde2: jle lde4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lde4: jle lde6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lde6: jle lde8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lde8: jle ldea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldea: jle ldec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldec: jle ldee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldee: jle ldf0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldf0: jle ldf2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldf2: jle ldf4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldf4: jle ldf6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldf6: jle ldf8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldf8: jle ldfa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldfa: jle ldfc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldfc: jle ldfe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ldfe: jle le00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le00: jle le02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le02: jle le04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le04: jle le06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le06: jle le08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le08: jle le0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le0a: jle le0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le0c: jle le0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le0e: jle le10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le10: jle le12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le12: jle le14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le14: jle le16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le16: jle le18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le18: jle le1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le1a: jle le1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le1c: jle le1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le1e: jle le20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le20: jle le22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le22: jle le24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le24: jle le26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le26: jle le28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le28: jle le2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le2a: jle le2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le2c: jle le2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le2e: jle le30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le30: jle le32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le32: jle le34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le34: jle le36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le36: jle le38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le38: jle le3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le3a: jle le3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le3c: jle le3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le3e: jle le40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le40: jle le42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le42: jle le44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le44: jle le46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le46: jle le48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le48: jle le4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le4a: jle le4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le4c: jle le4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le4e: jle le50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le50: jle le52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le52: jle le54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le54: jle le56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le56: jle le58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le58: jle le5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le5a: jle le5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le5c: jle le5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le5e: jle le60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le60: jle le62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le62: jle le64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le64: jle le66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le66: jle le68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le68: jle le6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le6a: jle le6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le6c: jle le6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le6e: jle le70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le70: jle le72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le72: jle le74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le74: jle le76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le76: jle le78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le78: jle le7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le7a: jle le7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le7c: jle le7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le7e: jle le80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le80: jle le82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le82: jle le84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le84: jle le86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le86: jle le88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le88: jle le8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le8a: jle le8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le8c: jle le8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le8e: jle le90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le90: jle le92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le92: jle le94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le94: jle le96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le96: jle le98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le98: jle le9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le9a: jle le9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le9c: jle le9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "le9e: jle lea0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lea0: jle lea2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lea2: jle lea4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lea4: jle lea6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lea6: jle lea8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lea8: jle leaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leaa: jle leac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leac: jle leae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leae: jle leb0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leb0: jle leb2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leb2: jle leb4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leb4: jle leb6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leb6: jle leb8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leb8: jle leba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leba: jle lebc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lebc: jle lebe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lebe: jle lec0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lec0: jle lec2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lec2: jle lec4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lec4: jle lec6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lec6: jle lec8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lec8: jle leca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leca: jle lecc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lecc: jle lece\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lece: jle led0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "led0: jle led2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "led2: jle led4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "led4: jle led6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "led6: jle led8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "led8: jle leda\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leda: jle ledc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "ledc: jle lede\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lede: jle lee0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lee0: jle lee2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lee2: jle lee4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lee4: jle lee6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lee6: jle lee8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lee8: jle leea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leea: jle leec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leec: jle leee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "leee: jle lef0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lef0: jle lef2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lef2: jle lef4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lef4: jle lef6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lef6: jle lef8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lef8: jle lefa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lefa: jle lefc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lefc: jle lefe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lefe: jle lf00\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf00: jle lf02\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf02: jle lf04\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf04: jle lf06\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf06: jle lf08\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf08: jle lf0a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf0a: jle lf0c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf0c: jle lf0e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf0e: jle lf10\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf10: jle lf12\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf12: jle lf14\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf14: jle lf16\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf16: jle lf18\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf18: jle lf1a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf1a: jle lf1c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf1c: jle lf1e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf1e: jle lf20\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf20: jle lf22\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf22: jle lf24\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf24: jle lf26\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf26: jle lf28\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf28: jle lf2a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf2a: jle lf2c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf2c: jle lf2e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf2e: jle lf30\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf30: jle lf32\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf32: jle lf34\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf34: jle lf36\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf36: jle lf38\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf38: jle lf3a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf3a: jle lf3c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf3c: jle lf3e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf3e: jle lf40\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf40: jle lf42\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf42: jle lf44\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf44: jle lf46\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf46: jle lf48\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf48: jle lf4a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf4a: jle lf4c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf4c: jle lf4e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf4e: jle lf50\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf50: jle lf52\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf52: jle lf54\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf54: jle lf56\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf56: jle lf58\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf58: jle lf5a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf5a: jle lf5c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf5c: jle lf5e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf5e: jle lf60\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf60: jle lf62\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf62: jle lf64\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf64: jle lf66\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf66: jle lf68\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf68: jle lf6a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf6a: jle lf6c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf6c: jle lf6e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf6e: jle lf70\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf70: jle lf72\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf72: jle lf74\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf74: jle lf76\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf76: jle lf78\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf78: jle lf7a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf7a: jle lf7c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf7c: jle lf7e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf7e: jle lf80\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf80: jle lf82\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf82: jle lf84\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf84: jle lf86\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf86: jle lf88\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf88: jle lf8a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf8a: jle lf8c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf8c: jle lf8e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf8e: jle lf90\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf90: jle lf92\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf92: jle lf94\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf94: jle lf96\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf96: jle lf98\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf98: jle lf9a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf9a: jle lf9c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf9c: jle lf9e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lf9e: jle lfa0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfa0: jle lfa2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfa2: jle lfa4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfa4: jle lfa6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfa6: jle lfa8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfa8: jle lfaa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfaa: jle lfac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfac: jle lfae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfae: jle lfb0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfb0: jle lfb2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfb2: jle lfb4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfb4: jle lfb6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfb6: jle lfb8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfb8: jle lfba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfba: jle lfbc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfbc: jle lfbe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfbe: jle lfc0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfc0: jle lfc2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfc2: jle lfc4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfc4: jle lfc6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfc6: jle lfc8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfc8: jle lfca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfca: jle lfcc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfcc: jle lfce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfce: jle lfd0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfd0: jle lfd2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfd2: jle lfd4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfd4: jle lfd6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfd6: jle lfd8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfd8: jle lfda\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfda: jle lfdc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfdc: jle lfde\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfde: jle lfe0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfe0: jle lfe2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfe2: jle lfe4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfe4: jle lfe6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfe6: jle lfe8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfe8: jle lfea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfea: jle lfec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfec: jle lfee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lfee: jle lff0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lff0: jle lff2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lff2: jle lff4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lff4: jle lff6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lff6: jle lff8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lff8: jle lffa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lffa: jle lffc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lffc: jle lffe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "lffe: jle l1000\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1000: jle l1002\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1002: jle l1004\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1004: jle l1006\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1006: jle l1008\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1008: jle l100a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l100a: jle l100c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l100c: jle l100e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l100e: jle l1010\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1010: jle l1012\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1012: jle l1014\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1014: jle l1016\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1016: jle l1018\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1018: jle l101a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l101a: jle l101c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l101c: jle l101e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l101e: jle l1020\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1020: jle l1022\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1022: jle l1024\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1024: jle l1026\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1026: jle l1028\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1028: jle l102a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l102a: jle l102c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l102c: jle l102e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l102e: jle l1030\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1030: jle l1032\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1032: jle l1034\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1034: jle l1036\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1036: jle l1038\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1038: jle l103a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l103a: jle l103c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l103c: jle l103e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l103e: jle l1040\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1040: jle l1042\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1042: jle l1044\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1044: jle l1046\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1046: jle l1048\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1048: jle l104a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l104a: jle l104c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l104c: jle l104e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l104e: jle l1050\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1050: jle l1052\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1052: jle l1054\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1054: jle l1056\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1056: jle l1058\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1058: jle l105a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l105a: jle l105c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l105c: jle l105e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l105e: jle l1060\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1060: jle l1062\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1062: jle l1064\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1064: jle l1066\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1066: jle l1068\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1068: jle l106a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l106a: jle l106c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l106c: jle l106e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l106e: jle l1070\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1070: jle l1072\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1072: jle l1074\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1074: jle l1076\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1076: jle l1078\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1078: jle l107a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l107a: jle l107c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l107c: jle l107e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l107e: jle l1080\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1080: jle l1082\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1082: jle l1084\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1084: jle l1086\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1086: jle l1088\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1088: jle l108a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l108a: jle l108c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l108c: jle l108e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l108e: jle l1090\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1090: jle l1092\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1092: jle l1094\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1094: jle l1096\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1096: jle l1098\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1098: jle l109a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l109a: jle l109c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l109c: jle l109e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l109e: jle l10a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10a0: jle l10a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10a2: jle l10a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10a4: jle l10a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10a6: jle l10a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10a8: jle l10aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10aa: jle l10ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ac: jle l10ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ae: jle l10b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10b0: jle l10b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10b2: jle l10b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10b4: jle l10b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10b6: jle l10b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10b8: jle l10ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ba: jle l10bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10bc: jle l10be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10be: jle l10c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10c0: jle l10c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10c2: jle l10c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10c4: jle l10c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10c6: jle l10c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10c8: jle l10ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ca: jle l10cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10cc: jle l10ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ce: jle l10d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10d0: jle l10d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10d2: jle l10d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10d4: jle l10d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10d6: jle l10d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10d8: jle l10da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10da: jle l10dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10dc: jle l10de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10de: jle l10e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10e0: jle l10e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10e2: jle l10e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10e4: jle l10e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10e6: jle l10e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10e8: jle l10ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ea: jle l10ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ec: jle l10ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10ee: jle l10f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10f0: jle l10f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10f2: jle l10f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10f4: jle l10f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10f6: jle l10f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10f8: jle l10fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10fa: jle l10fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10fc: jle l10fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l10fe: jle l1100\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1100: jle l1102\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1102: jle l1104\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1104: jle l1106\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1106: jle l1108\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1108: jle l110a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l110a: jle l110c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l110c: jle l110e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l110e: jle l1110\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1110: jle l1112\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1112: jle l1114\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1114: jle l1116\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1116: jle l1118\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1118: jle l111a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l111a: jle l111c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l111c: jle l111e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l111e: jle l1120\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1120: jle l1122\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1122: jle l1124\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1124: jle l1126\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1126: jle l1128\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1128: jle l112a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l112a: jle l112c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l112c: jle l112e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l112e: jle l1130\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1130: jle l1132\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1132: jle l1134\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1134: jle l1136\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1136: jle l1138\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1138: jle l113a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l113a: jle l113c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l113c: jle l113e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l113e: jle l1140\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1140: jle l1142\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1142: jle l1144\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1144: jle l1146\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1146: jle l1148\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1148: jle l114a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l114a: jle l114c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l114c: jle l114e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l114e: jle l1150\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1150: jle l1152\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1152: jle l1154\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1154: jle l1156\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1156: jle l1158\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1158: jle l115a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l115a: jle l115c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l115c: jle l115e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l115e: jle l1160\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1160: jle l1162\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1162: jle l1164\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1164: jle l1166\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1166: jle l1168\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1168: jle l116a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l116a: jle l116c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l116c: jle l116e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l116e: jle l1170\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1170: jle l1172\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1172: jle l1174\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1174: jle l1176\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1176: jle l1178\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1178: jle l117a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l117a: jle l117c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l117c: jle l117e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l117e: jle l1180\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1180: jle l1182\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1182: jle l1184\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1184: jle l1186\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1186: jle l1188\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1188: jle l118a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l118a: jle l118c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l118c: jle l118e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l118e: jle l1190\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1190: jle l1192\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1192: jle l1194\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1194: jle l1196\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1196: jle l1198\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1198: jle l119a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l119a: jle l119c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l119c: jle l119e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l119e: jle l11a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11a0: jle l11a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11a2: jle l11a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11a4: jle l11a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11a6: jle l11a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11a8: jle l11aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11aa: jle l11ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ac: jle l11ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ae: jle l11b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11b0: jle l11b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11b2: jle l11b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11b4: jle l11b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11b6: jle l11b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11b8: jle l11ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ba: jle l11bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11bc: jle l11be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11be: jle l11c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11c0: jle l11c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11c2: jle l11c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11c4: jle l11c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11c6: jle l11c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11c8: jle l11ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ca: jle l11cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11cc: jle l11ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ce: jle l11d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11d0: jle l11d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11d2: jle l11d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11d4: jle l11d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11d6: jle l11d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11d8: jle l11da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11da: jle l11dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11dc: jle l11de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11de: jle l11e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11e0: jle l11e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11e2: jle l11e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11e4: jle l11e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11e6: jle l11e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11e8: jle l11ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ea: jle l11ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ec: jle l11ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11ee: jle l11f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11f0: jle l11f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11f2: jle l11f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11f4: jle l11f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11f6: jle l11f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11f8: jle l11fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11fa: jle l11fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11fc: jle l11fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l11fe: jle l1200\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1200: jle l1202\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1202: jle l1204\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1204: jle l1206\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1206: jle l1208\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1208: jle l120a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l120a: jle l120c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l120c: jle l120e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l120e: jle l1210\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1210: jle l1212\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1212: jle l1214\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1214: jle l1216\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1216: jle l1218\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1218: jle l121a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l121a: jle l121c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l121c: jle l121e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l121e: jle l1220\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1220: jle l1222\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1222: jle l1224\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1224: jle l1226\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1226: jle l1228\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1228: jle l122a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l122a: jle l122c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l122c: jle l122e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l122e: jle l1230\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1230: jle l1232\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1232: jle l1234\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1234: jle l1236\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1236: jle l1238\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1238: jle l123a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l123a: jle l123c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l123c: jle l123e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l123e: jle l1240\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1240: jle l1242\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1242: jle l1244\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1244: jle l1246\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1246: jle l1248\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1248: jle l124a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l124a: jle l124c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l124c: jle l124e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l124e: jle l1250\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1250: jle l1252\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1252: jle l1254\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1254: jle l1256\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1256: jle l1258\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1258: jle l125a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l125a: jle l125c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l125c: jle l125e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l125e: jle l1260\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1260: jle l1262\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1262: jle l1264\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1264: jle l1266\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1266: jle l1268\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1268: jle l126a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l126a: jle l126c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l126c: jle l126e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l126e: jle l1270\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1270: jle l1272\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1272: jle l1274\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1274: jle l1276\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1276: jle l1278\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1278: jle l127a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l127a: jle l127c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l127c: jle l127e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l127e: jle l1280\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1280: jle l1282\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1282: jle l1284\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1284: jle l1286\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1286: jle l1288\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1288: jle l128a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l128a: jle l128c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l128c: jle l128e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l128e: jle l1290\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1290: jle l1292\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1292: jle l1294\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1294: jle l1296\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1296: jle l1298\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1298: jle l129a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l129a: jle l129c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l129c: jle l129e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l129e: jle l12a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12a0: jle l12a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12a2: jle l12a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12a4: jle l12a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12a6: jle l12a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12a8: jle l12aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12aa: jle l12ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ac: jle l12ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ae: jle l12b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12b0: jle l12b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12b2: jle l12b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12b4: jle l12b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12b6: jle l12b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12b8: jle l12ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ba: jle l12bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12bc: jle l12be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12be: jle l12c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12c0: jle l12c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12c2: jle l12c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12c4: jle l12c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12c6: jle l12c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12c8: jle l12ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ca: jle l12cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12cc: jle l12ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ce: jle l12d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12d0: jle l12d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12d2: jle l12d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12d4: jle l12d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12d6: jle l12d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12d8: jle l12da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12da: jle l12dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12dc: jle l12de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12de: jle l12e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12e0: jle l12e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12e2: jle l12e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12e4: jle l12e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12e6: jle l12e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12e8: jle l12ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ea: jle l12ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ec: jle l12ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12ee: jle l12f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12f0: jle l12f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12f2: jle l12f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12f4: jle l12f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12f6: jle l12f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12f8: jle l12fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12fa: jle l12fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12fc: jle l12fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l12fe: jle l1300\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1300: jle l1302\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1302: jle l1304\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1304: jle l1306\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1306: jle l1308\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1308: jle l130a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l130a: jle l130c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l130c: jle l130e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l130e: jle l1310\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1310: jle l1312\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1312: jle l1314\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1314: jle l1316\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1316: jle l1318\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1318: jle l131a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l131a: jle l131c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l131c: jle l131e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l131e: jle l1320\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1320: jle l1322\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1322: jle l1324\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1324: jle l1326\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1326: jle l1328\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1328: jle l132a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l132a: jle l132c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l132c: jle l132e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l132e: jle l1330\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1330: jle l1332\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1332: jle l1334\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1334: jle l1336\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1336: jle l1338\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1338: jle l133a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l133a: jle l133c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l133c: jle l133e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l133e: jle l1340\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1340: jle l1342\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1342: jle l1344\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1344: jle l1346\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1346: jle l1348\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1348: jle l134a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l134a: jle l134c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l134c: jle l134e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l134e: jle l1350\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1350: jle l1352\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1352: jle l1354\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1354: jle l1356\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1356: jle l1358\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1358: jle l135a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l135a: jle l135c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l135c: jle l135e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l135e: jle l1360\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1360: jle l1362\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1362: jle l1364\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1364: jle l1366\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1366: jle l1368\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1368: jle l136a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l136a: jle l136c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l136c: jle l136e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l136e: jle l1370\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1370: jle l1372\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1372: jle l1374\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1374: jle l1376\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1376: jle l1378\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1378: jle l137a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l137a: jle l137c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l137c: jle l137e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l137e: jle l1380\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1380: jle l1382\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1382: jle l1384\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1384: jle l1386\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1386: jle l1388\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1388: jle l138a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l138a: jle l138c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l138c: jle l138e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l138e: jle l1390\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1390: jle l1392\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1392: jle l1394\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1394: jle l1396\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1396: jle l1398\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1398: jle l139a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l139a: jle l139c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l139c: jle l139e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l139e: jle l13a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13a0: jle l13a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13a2: jle l13a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13a4: jle l13a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13a6: jle l13a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13a8: jle l13aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13aa: jle l13ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ac: jle l13ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ae: jle l13b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13b0: jle l13b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13b2: jle l13b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13b4: jle l13b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13b6: jle l13b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13b8: jle l13ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ba: jle l13bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13bc: jle l13be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13be: jle l13c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13c0: jle l13c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13c2: jle l13c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13c4: jle l13c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13c6: jle l13c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13c8: jle l13ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ca: jle l13cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13cc: jle l13ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ce: jle l13d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13d0: jle l13d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13d2: jle l13d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13d4: jle l13d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13d6: jle l13d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13d8: jle l13da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13da: jle l13dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13dc: jle l13de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13de: jle l13e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13e0: jle l13e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13e2: jle l13e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13e4: jle l13e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13e6: jle l13e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13e8: jle l13ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ea: jle l13ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ec: jle l13ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13ee: jle l13f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13f0: jle l13f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13f2: jle l13f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13f4: jle l13f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13f6: jle l13f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13f8: jle l13fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13fa: jle l13fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13fc: jle l13fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l13fe: jle l1400\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1400: jle l1402\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1402: jle l1404\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1404: jle l1406\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1406: jle l1408\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1408: jle l140a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l140a: jle l140c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l140c: jle l140e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l140e: jle l1410\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1410: jle l1412\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1412: jle l1414\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1414: jle l1416\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1416: jle l1418\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1418: jle l141a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l141a: jle l141c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l141c: jle l141e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l141e: jle l1420\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1420: jle l1422\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1422: jle l1424\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1424: jle l1426\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1426: jle l1428\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1428: jle l142a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l142a: jle l142c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l142c: jle l142e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l142e: jle l1430\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1430: jle l1432\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1432: jle l1434\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1434: jle l1436\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1436: jle l1438\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1438: jle l143a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l143a: jle l143c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l143c: jle l143e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l143e: jle l1440\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1440: jle l1442\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1442: jle l1444\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1444: jle l1446\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1446: jle l1448\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1448: jle l144a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l144a: jle l144c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l144c: jle l144e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l144e: jle l1450\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1450: jle l1452\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1452: jle l1454\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1454: jle l1456\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1456: jle l1458\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1458: jle l145a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l145a: jle l145c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l145c: jle l145e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l145e: jle l1460\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1460: jle l1462\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1462: jle l1464\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1464: jle l1466\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1466: jle l1468\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1468: jle l146a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l146a: jle l146c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l146c: jle l146e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l146e: jle l1470\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1470: jle l1472\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1472: jle l1474\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1474: jle l1476\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1476: jle l1478\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1478: jle l147a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l147a: jle l147c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l147c: jle l147e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l147e: jle l1480\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1480: jle l1482\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1482: jle l1484\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1484: jle l1486\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1486: jle l1488\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1488: jle l148a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l148a: jle l148c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l148c: jle l148e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l148e: jle l1490\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1490: jle l1492\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1492: jle l1494\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1494: jle l1496\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1496: jle l1498\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1498: jle l149a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l149a: jle l149c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l149c: jle l149e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l149e: jle l14a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14a0: jle l14a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14a2: jle l14a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14a4: jle l14a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14a6: jle l14a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14a8: jle l14aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14aa: jle l14ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ac: jle l14ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ae: jle l14b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14b0: jle l14b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14b2: jle l14b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14b4: jle l14b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14b6: jle l14b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14b8: jle l14ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ba: jle l14bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14bc: jle l14be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14be: jle l14c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14c0: jle l14c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14c2: jle l14c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14c4: jle l14c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14c6: jle l14c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14c8: jle l14ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ca: jle l14cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14cc: jle l14ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ce: jle l14d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14d0: jle l14d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14d2: jle l14d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14d4: jle l14d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14d6: jle l14d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14d8: jle l14da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14da: jle l14dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14dc: jle l14de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14de: jle l14e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14e0: jle l14e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14e2: jle l14e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14e4: jle l14e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14e6: jle l14e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14e8: jle l14ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ea: jle l14ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ec: jle l14ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14ee: jle l14f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14f0: jle l14f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14f2: jle l14f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14f4: jle l14f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14f6: jle l14f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14f8: jle l14fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14fa: jle l14fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14fc: jle l14fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l14fe: jle l1500\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1500: jle l1502\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1502: jle l1504\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1504: jle l1506\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1506: jle l1508\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1508: jle l150a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l150a: jle l150c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l150c: jle l150e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l150e: jle l1510\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1510: jle l1512\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1512: jle l1514\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1514: jle l1516\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1516: jle l1518\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1518: jle l151a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l151a: jle l151c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l151c: jle l151e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l151e: jle l1520\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1520: jle l1522\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1522: jle l1524\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1524: jle l1526\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1526: jle l1528\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1528: jle l152a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l152a: jle l152c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l152c: jle l152e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l152e: jle l1530\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1530: jle l1532\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1532: jle l1534\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1534: jle l1536\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1536: jle l1538\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1538: jle l153a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l153a: jle l153c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l153c: jle l153e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l153e: jle l1540\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1540: jle l1542\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1542: jle l1544\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1544: jle l1546\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1546: jle l1548\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1548: jle l154a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l154a: jle l154c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l154c: jle l154e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l154e: jle l1550\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1550: jle l1552\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1552: jle l1554\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1554: jle l1556\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1556: jle l1558\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1558: jle l155a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l155a: jle l155c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l155c: jle l155e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l155e: jle l1560\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1560: jle l1562\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1562: jle l1564\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1564: jle l1566\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1566: jle l1568\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1568: jle l156a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l156a: jle l156c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l156c: jle l156e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l156e: jle l1570\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1570: jle l1572\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1572: jle l1574\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1574: jle l1576\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1576: jle l1578\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1578: jle l157a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l157a: jle l157c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l157c: jle l157e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l157e: jle l1580\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1580: jle l1582\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1582: jle l1584\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1584: jle l1586\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1586: jle l1588\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1588: jle l158a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l158a: jle l158c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l158c: jle l158e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l158e: jle l1590\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1590: jle l1592\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1592: jle l1594\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1594: jle l1596\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1596: jle l1598\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1598: jle l159a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l159a: jle l159c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l159c: jle l159e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l159e: jle l15a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15a0: jle l15a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15a2: jle l15a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15a4: jle l15a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15a6: jle l15a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15a8: jle l15aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15aa: jle l15ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ac: jle l15ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ae: jle l15b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15b0: jle l15b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15b2: jle l15b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15b4: jle l15b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15b6: jle l15b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15b8: jle l15ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ba: jle l15bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15bc: jle l15be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15be: jle l15c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15c0: jle l15c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15c2: jle l15c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15c4: jle l15c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15c6: jle l15c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15c8: jle l15ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ca: jle l15cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15cc: jle l15ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ce: jle l15d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15d0: jle l15d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15d2: jle l15d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15d4: jle l15d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15d6: jle l15d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15d8: jle l15da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15da: jle l15dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15dc: jle l15de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15de: jle l15e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15e0: jle l15e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15e2: jle l15e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15e4: jle l15e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15e6: jle l15e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15e8: jle l15ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ea: jle l15ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ec: jle l15ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15ee: jle l15f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15f0: jle l15f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15f2: jle l15f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15f4: jle l15f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15f6: jle l15f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15f8: jle l15fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15fa: jle l15fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15fc: jle l15fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l15fe: jle l1600\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1600: jle l1602\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1602: jle l1604\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1604: jle l1606\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1606: jle l1608\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1608: jle l160a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l160a: jle l160c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l160c: jle l160e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l160e: jle l1610\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1610: jle l1612\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1612: jle l1614\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1614: jle l1616\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1616: jle l1618\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1618: jle l161a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l161a: jle l161c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l161c: jle l161e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l161e: jle l1620\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1620: jle l1622\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1622: jle l1624\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1624: jle l1626\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1626: jle l1628\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1628: jle l162a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l162a: jle l162c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l162c: jle l162e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l162e: jle l1630\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1630: jle l1632\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1632: jle l1634\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1634: jle l1636\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1636: jle l1638\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1638: jle l163a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l163a: jle l163c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l163c: jle l163e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l163e: jle l1640\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1640: jle l1642\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1642: jle l1644\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1644: jle l1646\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1646: jle l1648\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1648: jle l164a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l164a: jle l164c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l164c: jle l164e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l164e: jle l1650\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1650: jle l1652\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1652: jle l1654\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1654: jle l1656\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1656: jle l1658\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1658: jle l165a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l165a: jle l165c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l165c: jle l165e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l165e: jle l1660\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1660: jle l1662\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1662: jle l1664\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1664: jle l1666\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1666: jle l1668\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1668: jle l166a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l166a: jle l166c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l166c: jle l166e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l166e: jle l1670\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1670: jle l1672\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1672: jle l1674\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1674: jle l1676\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1676: jle l1678\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1678: jle l167a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l167a: jle l167c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l167c: jle l167e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l167e: jle l1680\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1680: jle l1682\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1682: jle l1684\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1684: jle l1686\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1686: jle l1688\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1688: jle l168a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l168a: jle l168c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l168c: jle l168e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l168e: jle l1690\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1690: jle l1692\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1692: jle l1694\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1694: jle l1696\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1696: jle l1698\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1698: jle l169a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l169a: jle l169c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l169c: jle l169e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l169e: jle l16a0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16a0: jle l16a2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16a2: jle l16a4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16a4: jle l16a6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16a6: jle l16a8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16a8: jle l16aa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16aa: jle l16ac\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ac: jle l16ae\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ae: jle l16b0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16b0: jle l16b2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16b2: jle l16b4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16b4: jle l16b6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16b6: jle l16b8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16b8: jle l16ba\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ba: jle l16bc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16bc: jle l16be\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16be: jle l16c0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16c0: jle l16c2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16c2: jle l16c4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16c4: jle l16c6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16c6: jle l16c8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16c8: jle l16ca\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ca: jle l16cc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16cc: jle l16ce\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ce: jle l16d0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16d0: jle l16d2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16d2: jle l16d4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16d4: jle l16d6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16d6: jle l16d8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16d8: jle l16da\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16da: jle l16dc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16dc: jle l16de\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16de: jle l16e0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16e0: jle l16e2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16e2: jle l16e4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16e4: jle l16e6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16e6: jle l16e8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16e8: jle l16ea\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ea: jle l16ec\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ec: jle l16ee\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16ee: jle l16f0\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16f0: jle l16f2\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16f2: jle l16f4\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16f4: jle l16f6\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16f6: jle l16f8\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16f8: jle l16fa\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16fa: jle l16fc\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16fc: jle l16fe\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l16fe: jle l1700\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1700: jle l1702\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1702: jle l1704\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1704: jle l1706\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1706: jle l1708\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1708: jle l170a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l170a: jle l170c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l170c: jle l170e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l170e: jle l1710\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1710: jle l1712\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1712: jle l1714\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1714: jle l1716\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1716: jle l1718\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1718: jle l171a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l171a: jle l171c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l171c: jle l171e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l171e: jle l1720\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1720: jle l1722\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1722: jle l1724\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1724: jle l1726\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1726: jle l1728\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1728: jle l172a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l172a: jle l172c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l172c: jle l172e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l172e: jle l1730\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1730: jle l1732\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1732: jle l1734\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1734: jle l1736\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1736: jle l1738\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1738: jle l173a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l173a: jle l173c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l173c: jle l173e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l173e: jle l1740\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1740: jle l1742\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1742: jle l1744\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1744: jle l1746\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1746: jle l1748\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1748: jle l174a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l174a: jle l174c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l174c: jle l174e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l174e: jle l1750\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1750: jle l1752\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1752: jle l1754\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1754: jle l1756\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1756: jle l1758\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1758: jle l175a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l175a: jle l175c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l175c: jle l175e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l175e: jle l1760\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1760: jle l1762\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1762: jle l1764\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1764: jle l1766\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1766: jle l1768\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1768: jle l176a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l176a: jle l176c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l176c: jle l176e\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l176e: jle l1770\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1770: jle l1772\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1772: jle l1774\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1774: jle l1776\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1776: jle l1778\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l1778: jle l177a\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l177a: jle l177c\n" "clc\n" "clc\n" "clc\n" "clc\n" "clc\n" "l177c: clc" ); } }
[ "ec2-user@ip-172-31-19-38.us-east-2.compute.internal" ]
ec2-user@ip-172-31-19-38.us-east-2.compute.internal
bf9814661e3daa3099f71c75d4ab6cd1fd50b599
fc151e851d1d64eb94c0890bb7c99e0ce9a455eb
/include/vsg/viewer/ViewMatrix.h
42f0ec4b9bb12cec151ef53420af62772a6e0bc9
[ "MIT" ]
permissive
wangii/VulkanSceneGraph
dc4873221bb17b159e65e64c2f598ef9a695b687
1e480b333c5e241e57c033b5cdecbe819a27355b
refs/heads/master
2021-06-13T22:46:43.561844
2020-04-09T19:43:11
2020-04-09T19:43:11
254,459,430
0
0
MIT
2020-04-09T19:43:13
2020-04-09T19:22:24
null
UTF-8
C++
false
false
3,542
h
#pragma once /* <editor-fold desc="MIT License"> Copyright(c) 2018 Robert Osfield Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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. </editor-fold> */ #include <vsg/core/Inherit.h> #include <vsg/maths/transform.h> namespace vsg { class ViewMatrix : public Inherit<Object, ViewMatrix> { public: virtual void get(mat4& matrix) const = 0; virtual void get(dmat4& matrix) const = 0; virtual void get_inverse(mat4& matrix) const { get(matrix); matrix = inverse(matrix); } virtual void get_inverse(dmat4& matrix) const { get(matrix); matrix = inverse(matrix); } }; class LookAt : public Inherit<ViewMatrix, LookAt> { public: LookAt() : eye(0.0, 0.0, 0.0), center(0.0, 1.0, 0.0), up(0.0, 0.0, 1.0) { } LookAt(const dvec3& in_eye, const dvec3& in_center, const dvec3& in_up) : eye(in_eye), center(in_center), up(in_up) { dvec3 look = normalize(center - eye); dvec3 side = normalize(cross(look, up)); up = normalize(cross(side, look)); } void transform(const dmat4& matrix) { up = normalize(matrix * (eye + up) - matrix * eye); center = matrix * center; eye = matrix * eye; } void set(const dmat4& matrix) { up = normalize(matrix * (dvec3(0.0, 0.0, 0.0) + dvec3(0.0, 1.0, 0.0)) - matrix * dvec3(0.0, 0.0, 0.0)); center = matrix * dvec3(0.0, 0.0, -1.0); eye = matrix * dvec3(0.0, 0.0, 0.0); } void get(mat4& matrix) const override { matrix = lookAt(eye, center, up); } void get(dmat4& matrix) const override { matrix = lookAt(eye, center, up); } dvec3 eye; dvec3 center; dvec3 up; }; class RelativeView : public Inherit<ViewMatrix, RelativeView> { public: RelativeView(ref_ptr<ViewMatrix> vm, const dmat4& m) : viewMatrix(vm), matrix(m) { } void get(mat4& in_matrix) const override { viewMatrix->get(in_matrix); in_matrix = mat4(matrix) * in_matrix; } void get(dmat4& in_matrix) const override { viewMatrix->get(in_matrix); in_matrix = matrix * in_matrix; } ref_ptr<ViewMatrix> viewMatrix; dmat4 matrix; }; } // namespace vsg
[ "robert@openscenegraph.com" ]
robert@openscenegraph.com
1fec185bd70f1d3a10439cb0e21da9a5c0c534cf
db8f2e61e3c13862c540eddfdf8447e88bf53b72
/examples/timer-test/timer-test.cpp
fda09761de2f2d8eaf5a45aad594e469001f8e07
[ "MIT" ]
permissive
Gadgetoid/32blit-beta
87769a0b314443022688d849ccafee02e0408b00
ff77149e904e314f756f3c7df59ef45a6676fc02
refs/heads/master
2023-02-12T19:20:29.006400
2020-01-17T20:26:55
2020-01-17T20:26:55
234,631,151
1
1
MIT
2020-01-17T20:32:29
2020-01-17T20:32:29
null
UTF-8
C++
false
false
2,320
cpp
#include <string> #include <string.h> #include <memory> #include <cstdlib> #include "timer-test.hpp" /* TODO: This example is really dry, how can we make it awesome? Without making it so complicated that it fails to elucidate its point. */ using namespace blit; const uint16_t screen_width = 320; const uint16_t screen_height = 240; blit::timer timer_count; uint32_t count; void timer_count_update(blit::timer &t){ count++; // Instead of using loops we're going to stop the timer in our callback // In this case it will count to ten and then stop. // But you could depend upon any condition to stop the timer. if(count == 10) { t.stop(); } } void init() { blit::set_screen_mode(blit::screen_mode::hires); // Timers must be initialized // In this case we want our timer to call the `timer_count_update` function // very 1000ms, or 1 second. We also want it to loop indefinitely. // We can pass -1 to loop indefinitely, or just nothing at all since -1 // is the default. timer_count.init(timer_count_update, 1000, -1); // Next we probably want to start our timer! timer_count.start(); } int tick_count = 0; void render(uint32_t time_ms) { char text_buffer[60]; fb.pen(rgba(20, 30, 40)); fb.clear(); // Fancy title bar, nothing to see here. fb.pen(rgba(255, 255, 255)); fb.rectangle(rect(0, 0, 320, 14)); fb.pen(rgba(0, 0, 0)); fb.text("Timer Test", &minimal_font[0][0], point(5, 4)); // Since our timer callback is updating our `count` variable // we can just display it on the screen and watch it tick up! fb.pen(rgba(255, 255, 255)); sprintf(text_buffer, "Count: %d", count); fb.text(text_buffer, &minimal_font[0][0], point(120, 100)); // `is_running()` is a handy shorthand for checking the timer state if(timer_count.is_running()) { fb.text("Timer running...", &minimal_font[0][0], point(120, 110)); } else { fb.text("Timer stopped!", &minimal_font[0][0], point(120, 110)); fb.text("Press A to restart.", &minimal_font[0][0], point(120, 120)); } } void update(uint32_t time_ms) { // `is_stopped()` works too! if (blit::buttons & blit::button::A && timer_count.is_stopped()) { count = 0; timer_count.start(); } }
[ "phil@gadgetoid.com" ]
phil@gadgetoid.com
5246647eae33cf7a12fa273e5e73971653f1762b
1fea1b1bcb283931afea6aa3103795236f12fb6d
/read_xml/include/datatypes.h
ba255ef4cd7f5e7a28c94b45c10ad2d7f015a791
[]
no_license
LeoBaro/rtadqlibcpp_proto
09b3ec479117fec37ce5a5dd6441a16316a3bc8f
9802c180e29a3aecc9bfbee4735ec51c8328f755
refs/heads/master
2022-12-06T13:10:59.449412
2020-08-22T09:21:49
2020-08-22T09:21:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
680
h
#include <iostream> #include <vector> #include <assert.h> #include "tinyxml.h" #include "datatype.h" using std::string; using std::vector; using std::shared_ptr; class Datatypes { public: static Datatypes * Instance(); void load_datatypes_from_xml(const char * xml_file_path); shared_ptr<Datatype> getDatatype(string datatype_id); private: Datatypes() {} static Datatypes * _instance; vector< shared_ptr<Datatype> > datatypes; shared_ptr<Datatype> parse_datatype(TiXmlNode* datatypeElem); public: Datatypes(Datatypes const&) = delete; void operator=(Datatypes const&) = delete; };
[ "leonardo.baroncelli@inaf.it" ]
leonardo.baroncelli@inaf.it
2cce6fafdfbf795a56ca9febd33ed52c85f49fce
041896c4d54efd97e1896fb882f92b5c7df3a425
/RdcTable.h
0d14bf7bef44f31b005f5d166a328a1a75d66681
[]
no_license
double16/switchmin-w32
69ce34fce9a666dc21e62086a4d0bd0c0853e49f
aece48d3d6507b7811060d4fb75ab65e81798acb
refs/heads/master
2020-05-19T12:40:23.711046
2014-06-15T01:29:07
2014-06-15T01:29:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,119
h
////// AB CLASSGEN Wed Apr 02 22:04:50 1997 //////// // RdcTable Definition ////////////////////////////////////////////////////// #if !defined(RdcTable_HPP) #define RdcTable_HPP #if !defined(RC_INVOKED) // no Windows RC compiler #include "TermSet.HPP" #include <map.h> namespace swmin { #if defined(DLLUSE_SWSYSTEM) || defined(DLLBLD_SWSYSTEM_RDCTABLE) #pragma option -vi- DLLBLD_STLMAP(DLLBLD_SWSYSTEM, Term, unsigned long, std::less<Term>); #pragma option -vi #endif typedef std::map<Term, unsigned long, std::less<Term> > TermCostMap; class DLLBLD_SWSYSTEM RdcTable { public: // Following data MUST be built by external routine! TermSet Primes, // primes in system Cells; // cells required to cover TermCostMap PriceSheet; // cost of each prime RdcTable(); RdcTable(TermSet&, TermSet&); // Primes, Cells ~RdcTable(); void DeleteRow(Term); // Delete row _equal_ to term with given functions void DeleteCol(Term); // Delete column with given functions void DeleteRowAndCol(Term); // Delete row and columns belonging to row void DeleteCommonCol(TermSet&); // Deletes columns common to row in TermSet unsigned long PrimesCovering(const Term&) const; // # of primes covering given term unsigned long ColumnsInRow(const Term&) const; // # of columns left in row bool ColumnDominating(const Term&, const Term&) const; // returns true if c1 dominates c2 bool RowDominating(const Term&, const Term&) const; // returns true if r1 dominates r2 bool GetEquivalentPrimes(TermSet&); bool noCol() const; bool noRow() const; // returns true if there is at least one essential prime and puts one // of them into first parameter and column in second bool GetEssential(Term&, Term&) const; protected: void invariant(); bool RemoveEmptyRows(Term); // parm: column causing possible empty bool RemoveEmptyColumns(Term); // parm: row causing possible empty void BuildColumn(const Term&, TermSet&) const; void BuildRow(const Term&, TermSet&) const; private: void _commonCtorJob();// called from all ctors }; } #endif #endif
[ "pat@patdouble.com" ]
pat@patdouble.com
bac857f93600a56462531221680d4e3c6c1fb2c7
e484ee95ee030a3447efd6f6ffdc5802721553f8
/CoinWeight/weighresult.hpp
1caae8bdb9be1020f93eb1445f2efb748b6a084d
[]
no_license
mortarsanjaya/CoinWeight
1c04ebdf34f2e51dd6eea29e16d4aa5b9bfc03f0
77db1d8578e7e691d4d593ca20c8a73a99f981f2
refs/heads/master
2022-11-06T22:59:02.680403
2020-05-23T03:43:35
2020-05-23T03:43:35
244,746,700
1
0
null
2020-04-01T02:45:08
2020-03-03T21:36:38
C++
UTF-8
C++
false
false
326
hpp
// // weighresult.hpp // CoinWeight // // Created by Gian Cordana Sanjaya on 2020-03-25. // Copyright © 2020 -. All rights reserved. // #ifndef weighresult_hpp #define weighresult_hpp namespace CoinWeight { enum class WeighResult { Start, Invalid, Balance, LeftHeavy, RightHeavy }; }; #endif
[ "mortarsanjaya@gmail.com" ]
mortarsanjaya@gmail.com
d7e07e681b041b192ef28e3ab987139b107f67f1
81fe39a5d34edc7d0bdb92202aecaa7544ff107b
/DFS_tren_do_thi_co_huong.cpp
93efc27df3c69c00a54540ae1ee45b1b3fcb9f09
[]
no_license
Tran-Thanh-The/sam-sung-algorithm
d279af2c86317e14a3c33750f1a8e56bef9498a5
eabb62795b3bf2cf834ebe9b4848a4c221e3b772
refs/heads/master
2023-08-29T23:44:23.979146
2021-11-16T15:46:58
2021-11-16T15:46:58
422,822,201
0
0
null
null
null
null
UTF-8
C++
false
false
1,085
cpp
#include <bits/stdc++.h> using namespace std; vector<int> floo[1005]; bool check[1005]; int tr[1005]; void DFS( int f, int v) { if ( check[v]) return; check[f] = true; for ( int i = 0; i < floo[f].size(); ++i) { if ( !check[floo[f][i]]) { tr[floo[f][i]] = f; DFS( floo[f][i], v); } } } void trace( int u, int v) { if ( !check[v]) { cout << -1 << endl; return; } vector<int> a; while( u != v) { if ( v == 0) { cout << -1 << endl; return; } a.push_back(v); v = tr[v]; } a.push_back(u); for ( int i = a.size()-1; i >= 0; i--) cout << a[i] << " "; cout << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int test; cin >> test; while( test--) { for ( int i = 0; i < 1005; ++i) { floo[i].clear(); } memset( check, false, sizeof(check)); memset( tr, 0, sizeof(tr)); int E, V, B, F; cin >> V >> E >> B >> F; for ( int i = 0 ; i < E; ++i) { int u, v; cin >> u >> v; floo[u].push_back(v); // floo[v].push_back(u); } DFS( B, F); trace( B, F); cout << endl; } return 0; }
[ "phonvan128@gmail.com" ]
phonvan128@gmail.com
51f7b3c4d407cfc8659ea5c66f0299fb5d671b2b
2589ecea3012916196becdc75c7513aafdd5f994
/HackerRank/HR_BasicDataTypes/hr_basic_data_types.cpp
4f60c3ed780c1bddbda5c05e637584f08446c0ce
[]
no_license
outcastgeek/LL_kcaH
c4e104576c6db07c680f5d817aed4413ebe2188f
e7b44cb983d506edd659c533d5c7516e9e01badf
refs/heads/master
2023-02-02T08:21:48.397842
2020-12-21T02:18:03
2020-12-21T02:18:03
112,263,200
0
0
null
null
null
null
UTF-8
C++
false
false
195
cpp
#include <cstdio> int main() { int a; long b; char c; float d; double e; scanf("%i %li %c %f %lf",&a,&b,&c,&d,&e); printf("%i\n%li\n%c\n%.03f\n%.09lf\n",a,b,c,d,e); return 0; }
[ "outcastgeek+git@gmail.com" ]
outcastgeek+git@gmail.com
ac4bc86b9db81c565028a20288032ac4b38d71ab
a8fa9114a7ed19a11010c5151d513a7dee21dc55
/learnopenGL/Source/AI_Comp.h
a7905b0dbab33b6df1e64d0ff8b97ea74930f0dc
[]
no_license
Mamama22/Framework-C-
24694c752fa9ba9fbdb1de144486238fd3b53d86
7fd1de38b4544a9739d560386268a30df5d6ebd1
refs/heads/master
2020-05-21T14:54:01.935221
2016-10-27T23:53:42
2016-10-27T23:53:42
62,128,022
0
0
null
null
null
null
UTF-8
C++
false
false
2,198
h
#ifndef AI_COMP_H #define AI_COMP_H #include "Component.h" struct XY_grid { int x; int y; XY_grid(){ x = y = -1; } ~XY_grid(){} XY_grid& operator=(XY_grid& copyMe) { x = copyMe.x; y = copyMe.y; return *this; } }; /************************************************************* Author: Tan Yie Cher AI component, must ATTACH to a AI_Map entity How to use: 1) Attach to a AI_Map entity 2) Request a path from point A to B 3) AI comp will give entity a target pos. to go to, up to entity to decide how 4) when reached said point, AI comp will give another target pos. and so on !!!!!!!!!!!!!!!!!!!!!!!!! Can only be used in: Stage 3 points is used last to first (size - 1 --> 0) due to BFS usage Date: 17/9/2016 /*************************************************************/ class AI_Comp : public Component { public: enum STATE { IDLE, PATH_FOLLOWING, }; private: int AI_Map_id; STATE state; bool display_path; //AI_Map info-------------// int totalTiles_X; int totalTiles_Y; float tileScale; /**************** Path-finding var *******************/ vector<XY_grid> points; int pathSize; //how many points path currently have int target_index; //the index of current target point public: /******************** constructor/destructor **********************/ AI_Comp(); AI_Comp(const AI_Comp& copyMe); ~AI_Comp(); /************************** Core functions ****************************/ void Init(const char* name, int AI_Map_id, bool display_path); void Exit(); bool findPath(int startPt_X, int startPt_Y, int endPt_X, int endPt_Y); /************************** target ****************************/ Vector3 GetTargetPointPos(); //flags-------------------// void GetNextPoint(); bool Reached_Dest(); //settings----------------// void RemovePath(); /************************** For AI Map ****************************/ void AddPoint(int x, int y, int index); /************************** Get set ****************************/ int Get_currentPathSize(); int Get_target_index(); int Get_xPoint(int index); int Get_yPoint(int index); float Get_tileScale(); vector<XY_grid>& Get_XY_Grids(); void Set_PathSize(int s); }; #endif
[ "spotifyuser998@gmail.com" ]
spotifyuser998@gmail.com
92f56dacf3f1b4dcae0fe746d882c59c5a08c8b5
34138f011537a4c70e25b1618dae3552ee9af682
/mt_copy/src/mt_gamesvr/gameplay/gameplay_lottery.cpp
73b3e3a248c0a3cbd73955ade2d36e07d7816059
[]
no_license
marinemelody/MyUtility
1ce8f6d17742d7a4d361c7306bf5b608a83e403d
d4beb9d900b07fd579275d8670d385483c1f287f
refs/heads/master
2020-04-28T01:24:35.411752
2014-01-06T09:57:39
2014-01-06T09:57:39
null
0
0
null
null
null
null
GB18030
C++
false
false
2,983
cpp
#include "gameplay_lottery.h" #include "id_mgr.h" // 抽奖概率表 apr_hash_t * lottery_stone_prob_hash = NULL; apr_status_t lottery_stone_roll( apr_int32_t group_id, card_ptt_id_t * ptt_id) { lottery_group_prob * gp = NULL; gp = (lottery_group_prob *)apr_hash_get( lottery_stone_prob_hash, &group_id, sizeof(group_id)); if (gp == NULL) { fprintf(stderr, "[GMP] invalid group_id=%d\n", group_id); *ptt_id = 0; return -1; } apr_uint32_t i = 0; apr_int32_t roll_point = rand() % gp->prob_sum; for (i = 0; i < gp->count; ++ i) { roll_point -= gp->prob_array[i]; if (roll_point <= 0) { break; } } if (i < gp->count) { *ptt_id = gp->ptt_array[i]; return 0; } else { *ptt_id = 0; return -1; } } // 符石抽奖 static void stone_lottery_proc_ack( cache_session_cb_data * cbdata, void ** result_msg) { void * ack_msg = NULL; msghdr * ack_hdr = NULL; actor * obj = NULL; int net_id = 0; net_id = *(int *)cbdata->input; obj = (actor *)cbdata->output; if (actor_cards_can_add(obj, 1) && actor_stone_can_lottery(obj, 1)) { card_id_t c_id = ids_alloc_card(); card_ptt_id_t c_ptt_id = 0; if (lottery_stone_roll(1, &c_ptt_id) == APR_SUCCESS) { actor_cards_add(obj, c_id, c_ptt_id); actor_stone_inc(obj, -STONE_LOTTERY_COST); lottery_stone_ack * ack_body = NULL; MSG_INIT_TYPE(ack_msg, lottery_stone_ack, ack_hdr, ack_body, MSG_ID_LOTTERYSTONE_ACK, net_id); ack_body->new_card_id = c_id; ack_body->new_card_ptt_id = c_ptt_id; } else { default_err_ack * ack_body = NULL; MSG_INIT_TYPE(ack_msg, default_err_ack, ack_hdr, ack_body, MSG_ID_DEFAULTERROR_ACK, net_id); ack_body->reason = EC_LOTTERYGROUPNOTEXIST; } } else { default_err_ack * ack_body = NULL; MSG_INIT_TYPE(ack_msg, default_err_ack, ack_hdr, ack_body, MSG_ID_DEFAULTERROR_ACK, net_id); ack_body->reason = EC_STONENOTENOUGH; } *result_msg = ack_msg; } apr_status_t lottery_stone_proc( void * msg, void ** result_msg, apr_pool_t *) { apr_status_t rv = 0; void * req_msg = msg; msghdr * req_hdr = NULL; lottery_stone_req * req_body = NULL; MSG_LOCATE2(req_msg, lottery_stone_req, req_hdr, req_body); fprintf(stdout, "[GMP] HDR net_id=%x, msg_id=%d, body_len=%d\n", MSG_GETNETID(req_msg), MSG_GETMSGID(req_msg), MSG_GETBODYLEN(req_msg)); fprintf(stdout, "[GMP] BODY uin=%d\n", req_body->uin); int net_id = MSG_GETNETID(req_msg); rv = cache_mgr->exec_task( req_body->uin, ORM_MSG_LOAD_ACTOR, stone_lottery_proc_ack, default_error_handler, &net_id, sizeof(net_id), result_msg); return rv; } // 友情值抽奖 apr_status_t lottery_friend_proc( void * msg, void ** result_msg, apr_pool_t *) { return 0; }
[ "marinemelody@gmail.com" ]
marinemelody@gmail.com
ac8e1ad2f5be1a2f3ce6cd450b14a00998de2a44
eb376bf1655d1264e368ca70d0377b0b1a1ec127
/Bubble Sort/bubblesort.cpp
78ee59a24ff95a5bbc19ccca5f3be0f7bb19f579
[]
no_license
KamalDGRT/Implementation-of-Algorithms
a7900da1d71bde0e75693701035cdc77c34c2430
18ac768f669984b632d82399eade9ed0fb93183e
refs/heads/master
2020-08-28T04:04:55.568935
2020-05-20T14:49:27
2020-05-20T14:49:27
217,582,889
4
0
null
null
null
null
UTF-8
C++
false
false
1,423
cpp
// bubble sort for sorting numbers #include <iostream> using namespace std; int main() { //Variables that will be used int n, i, j, t, *array; char choice; do { system("cls"); // to clear the screen cout << "\t\t\t\t Bubble Sort \n"; cout << "\n How many values do you want to sort ? "; cin >> n; array = new int[n]; if (array == NULL) cout << "Sorry, not enough memory."; else { cout << "\n Now, enter the values : \n"; for (i = 0; i < n; i++) { cout << "\n Enter value " << (i + 1) <<" : "; cin >> array[i]; } //bubble sort logic for (i = 0; i < ( n - 1 ); i++) // for passes { for (j = 0; j < (n - i - 1); j++) // for comparisons { if (array[j] > array[j+1]) { t = array[j]; array[j] = array[j+1]; array[j+1] = t; } } } cout << "\n The list of numbers after sorting : \n"; for (i = 0; i < n; i++) { cout << array[i] << " "; } } //else block cout << "\n Do you want to sort another set of numbers? [y/n] : "; cin >> choice; }while(choice == 'y' or choice == 'Y'); return 0; }
[ "noreply@github.com" ]
KamalDGRT.noreply@github.com
69632c011239bf6195fe4b49b045813f3cbb24d9
a14e6279c6d7b027613dee37baee6e0cfd2e2c06
/iOS/core/plane.cpp
c820106df465f46cc63841152e05c2b8886a85b9
[]
no_license
psenzee/senzee5
e7caa80bfc3346fc98e2fc4809041f576647653f
dfe2a9f7a3b33f7ccfe9b12e09a20d1b10d6f3f4
refs/heads/master
2016-08-06T15:51:29.894387
2015-01-22T13:27:06
2015-01-22T13:27:06
23,462,247
1
0
null
null
null
null
UTF-8
C++
false
false
3,178
cpp
#include "tuple3f.h" #include "math.h" #include "plane.h" const Plane Plane::INVALID = Plane(); bool Plane::intersect(const Edge &line, point_t &at) { point_t nl = line.normal(); float denom = dot(nl), num = dot(line.a) + dist; if (math::eq(denom, 0.f)) return false; else at = line.a - nl * (num / denom); return true; } bool Plane::intersect(const Edge &line, float &t) { point_t nl = line.normal(); float denom = dot(nl), num = dot(line.a) + dist; if (math::eq(denom, 0.f)) return false; else t = num / denom; return true; } bool Plane::set(const point_t &a, const point_t &b, const point_t &c) { Tuple3f pa(a), pb(b), pc(c), n((pb - pa).cross(pc - pa)); float distance = -n.dot(pa), m = n.length(); if (m == 0.0) return false; m = 1 / m; n *= m; distance *= m; set(n, distance); return true; } bool Plane::intersect(const self &other, Edge &at) const { if (this == &other || math::eq(dot(other.normal), 1.f)) return false; float fn00 = normal.length(), // should be 1! fn01 = dot(other.normal), fn11 = other.normal.length(), // should be 1! det = fn00 * fn11 - fn01 * fn01; if (math::zero(det)) return false; det = 1.f / det; float fc0 = (fn11 * dist + fn01 * -other.dist) * det, fc1 = (fn00 * other.dist + fn01 * -dist) * det; at.a = normal * fc0 + other.normal * fc1; at.b = at.a + normal.cross(other.normal); return true; } /* Determines if an edge bounded by (x1,y1,z1)->(x2,y2,z2) intersects * the plane. * * If there's an intersection, * the sign of (x1,y1,z1), NEGATIVE or POSITIVE, w.r.t. the plane is * returned with the intersection (ixx,iyy,izz) updated. * Otherwise ZERO is returned. */ math::Sign Plane::intersect(const point_t &p1, const point_t &p2, point_t &at) const { float t1, t2; math::Sign s1, s2, zero = math::ZERO; if ((s1 = math::sign(t1 = distance(p1))) == zero) return zero; else if ((s2 = math::sign(t2 = distance(p2))) == zero) { at = p2; return s1; } else if (s1 == s2) return zero; return intersectat(p1, p2, at) ? s1 : zero; } bool Plane::intersectat(const point_t &p1, const point_t &p2, point_t &at) const // infinite line.. { float denom = 0.f; // intersection point point_t dp(p2 - p1); if (math::eq(denom = dot(dp), 0.f)) return false; at = p1 + (dp * (-distance(p1) / denom)); return true; } /* bool Plane::intersect(const self &b, const self &c, point_t &at) const { Edge ln; if (!intersect(b, ln)) return false; return c.intersectat(ln.a, ln.b, at); } */ bool Plane::normalize() { double da = normal.x, db = normal.y, dc = normal.z, dd = dist, lsq = da * da + db * db + dc * dc, m; if (!math::eq(lsq, 1.0)) { if (lsq == 0.0) return false; m = 1.0 / sqrt(lsq); da *= m; db *= m; dc *= m; dd *= m; _set((float)da, (float)db, (float)dc, (float)dd); } return true; }
[ "psenzee@yahoo.com" ]
psenzee@yahoo.com
a7ed7c0faa9fa18642e0a2f89ea057e47526b55d
605c89c38d3729e623a409979080913c0674ef7f
/coconut2d-x/controllers/CNScrollLayerController.h
0943a50146f4397928abe75cab4b41af77f9a634
[ "MIT" ]
permissive
moky/SpriteForest
02080ceb816492fc718e0c00b772e49b74e8c99a
b88f2be74a14157e9b25c2295f0efc7c516446b5
refs/heads/master
2021-01-18T20:29:38.450925
2014-04-28T03:33:06
2014-04-28T03:33:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
885
h
// // CNScrollLayerController.h // Coconut2D-X // // Created by Moky on 12-12-11. // Copyright 2012 Slanissue.com. All rights reserved. // #ifndef Coconut2D_X_CNScrollLayerController_h #define Coconut2D_X_CNScrollLayerController_h #include "CNTouchController.h" NS_CN_BEGIN class CNScrollLayerController : public CNTouchController { CC_SYNTHESIZE_RETAIN(cocos2d::CCAction *, m_pCurrentAction, CurrentAction); CC_SYNTHESIZE_PASS_BY_REF(cocos2d::CCPoint, m_tSwingBeganPoint, SwingBeganPoint); CC_SYNTHESIZE(time_t, m_fSwingBeganTime, SwingBeganTime); public: CNScrollLayerController(void); virtual ~CNScrollLayerController(void); virtual bool init(void); // CCTargetedTouchDelegate virtual bool ccTouchBegan(cocos2d::CCTouch * pTouch, cocos2d::CCEvent * pEvent); virtual void ccTouchEnded(cocos2d::CCTouch * pTouch, cocos2d::CCEvent * pEvent); }; NS_CN_END #endif
[ "albert.moky@gmail.com" ]
albert.moky@gmail.com
36d62bfbb4af479ab78e241f1ec4d1c6715ea48e
a087ef38b7f8ddce92f89ec609ad5bd22b68dc06
/Hamil/src/os/inputman.cpp
dd670fa23474f148aee38fb3d4af277a61df32cf
[]
no_license
miviwi/Hamil
329957b6ed76cfbd28d8b0d45fc56b22396d5998
110e2a66c7feca5890bf3b3a722138524444ff6b
refs/heads/master
2021-08-08T21:15:17.670327
2021-06-25T05:54:30
2021-06-25T05:54:30
114,602,019
0
0
null
null
null
null
UTF-8
C++
false
false
2,323
cpp
#include <os/inputman.h> #include <os/time.h> #include <math/geometry.h> namespace os { InputDeviceManager::InputDeviceManager() : m_mouse_buttons(0), m_kb_modifiers(0), m_capslock(0), m_mouse_speed(1.0f), m_dbl_click_seconds(0.25f) { } InputDeviceManager& InputDeviceManager::mouseSpeed(float speed) { m_mouse_speed = speed; return *this; } float InputDeviceManager::mouseSpeed() const { return m_mouse_speed; } InputDeviceManager& InputDeviceManager::doubleClickSpeed(float seconds) { // TODO: convert 'seconds' to 'Time' and store it in a memebr variable m_dbl_click_seconds = seconds; // Stored so the doubleClickSpeed() // getter can later return it // without doing any conversions return *this; } float InputDeviceManager::doubleClickSpeed() const { return m_dbl_click_seconds; } void InputDeviceManager::doDoubleClick(Mouse *mi) { // In case of some mose movenet during the clicks, check // if said movement doesn't exceed a set fudge factor if(mi->event != Mouse::Down) { auto d = vec2(mi->dx, mi->dy); if(d.length2() > 5.0f*5.0f) m_clicks.clear(); // And if it does make sure the next click // won't coun't as a double click return; } if(!m_clicks.empty()) { // This is the second Mouse::Down input of the double click... auto last_click = m_clicks.last(); auto dt = mi->timestamp - last_click.timestamp; m_clicks.clear(); // Ensure the clicks happened below the threshold if(last_click.ev_data == mi->ev_data && dt < tDoubleClickSpeed()) { mi->event = Mouse::DoubleClick; return; } } // ...and this is the first m_clicks.push(*mi); } Time InputDeviceManager::tDoubleClickSpeed() const { return Timers::s_to_ticks(m_dbl_click_seconds); } Input::Ptr InputDeviceManager::pollInput() { Input::Ptr ptr(nullptr, &Input::deleter); // Poll for any new/latent Input structures // and store them in an internal buffer... while(auto input = doPollInput()) { m_input_buf.push_back(std::move(input)); } // ...and return one if any were stored if(m_input_buf.size()) { ptr = std::move(m_input_buf.front()); m_input_buf.pop_front(); } return ptr; } }
[ "m.schwarz@cormo.pl" ]
m.schwarz@cormo.pl
846967f5c76a385d548bed3b949e1ff2a856bfd6
638e3aef6bde970bcc5afb2d39443e9558c3e778
/Project2/이차원 배열 원소.cpp
6895974bde7d5ce67b95e1ba69873da6289e73b7
[]
no_license
yyatta/Project2
95a023eed12eac97b1b2f85a73145a515830f336
69f73a8d120f22e190ad7c88d03ba17b67258489
refs/heads/master
2020-07-28T16:52:31.391436
2020-05-14T14:09:30
2020-05-14T14:09:30
209,471,569
0
0
null
null
null
null
UHC
C++
false
false
523
cpp
#include <stdio.h> #define ROWSIZE 2 #define COLSIZE 3 int main(void) { int td[ROWSIZE][COLSIZE]; td[0][0] = 1; td[0][1] = 2; td[0][2] = 3; td[1][0] = 4; td[1][1] = 5; td[1][2] = 6; printf("반복문 for을 이용하여 출력\n"); printf("행우선\n\n"); for (int i = 0; i < ROWSIZE; i++) { for (int j = 0; j < COLSIZE; j++) printf("%d ", td[i][j]); } printf("\n\n열우선\n\n"); for (int j = 0; j < COLSIZE; j++) { for (int i = 0; i < ROWSIZE; i++) printf("%d ", td[i][j]); } return 0; }
[ "wjdwldnjs178@naver.com" ]
wjdwldnjs178@naver.com
78440dee0c6c6f36a84639893d685ab71f56b40b
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/00/8fd9bb30c70e2d/main.cpp
cfca06445bdbe464aaf702234813fba4cb4ab835
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
1,558
cpp
#include <boost/thread.hpp> #include <boost/chrono.hpp> #include <mutex> #include <memory> #include <utility> #include <iostream> class ThreadRAII { public: enum class DtorAction {join, detach}; explicit ThreadRAII(DtorAction a = DtorAction::join) : action(a) {} ThreadRAII(boost::thread&& t, DtorAction a = DtorAction::join) : action(a), t(std::move(t)) {} ThreadRAII(ThreadRAII&&) = default; ThreadRAII& operator=(ThreadRAII&&) = default; void interrupt_and_join() { if (mtx) { std::lock_guard<std::mutex> lk{*mtx}; if (t.joinable()) { t.interrupt(); if (action == DtorAction::join) { t.join(); } else { t.detach(); } } } } ~ThreadRAII() { interrupt_and_join(); } boost::thread& get() { return t; } private: std::unique_ptr<std::mutex> mtx = std::make_unique<std::mutex>(); DtorAction action; boost::thread t; }; struct MyObj { void start() { // simplified example boost::packaged_task<void> task{[]() { std::cout << "Hello\n"; boost::this_thread::sleep_for(boost::chrono::milliseconds{2000}); std::cout << "World\n"; } }; thr = ThreadRAII{boost::thread{std::move(task)}}; } void stop() { // in real apoosp, might run concurrently with the thr destructor thr.interrupt_and_join(); } ThreadRAII thr; }; int main() { MyObj obj; obj.start(); }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df