Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

use PPToken for preprocessor in native CC

<< < (2/3) > >>

blauzahn:
No, I mean this:

--- Code: ---if (IsEOF())
        {
            m_Lex = wxEmptyString;
            m_Lex.m_Lexeme = wxEmptyString;
            m_Lex.m_Kind = PPTokenKind::EndOfFile;

--- End code ---
I haven't looked into the context but setting several data-member usually is none of the caller's business. In addition to that, the data-member m_Lexeme was unnecessarily set twice, once through the implicit operator, once directly. Although I mostly avoid setter, a primitive one here may be like:

--- Code: ---class PToken
{
  // ...
  void setEof()
  {
  m_Lexeme = wxEmptyString; 
  m_Kind = PPTokenKind::EndOfFile;
  }
  // ...
};

if (IsEOF())
{
m_Lex.setEof();
return false;
}

--- End code ---
It's PToken's responsability to decide what to do with its data-members when tagged as eof. Granted, they are public anyway, so it can not maintain an invariant anyway.
 

blauzahn:
btw: Have you tried to use the gcc/clang sanitizer? It should be able to spot the ub.

ollydbg:

--- Quote from: blauzahn on September 18, 2024, 04:47:04 pm ---No, I mean this:
...
...
It's PToken's responsability to decide what to do with its data-members when tagged as eof. Granted, they are public anyway, so it can not maintain an invariant anyway.

--- End quote ---

Thanks, I understand your idea now.


--- Quote from: blauzahn on September 18, 2024, 04:49:27 pm ---btw: Have you tried to use the gcc/clang sanitizer? It should be able to spot the ub.

--- End quote ---

I think under windows, there is no such tool under the msys2/gcc environment. Am I correct?

All I know is a tool like: ssbssa/heob: Detects buffer overruns and memory leaks.

But it is also hard to read its log output, because the log is always long.

blauzahn:

--- Quote ---I think under windows, there is no such tool under the msys2/gcc environment. Am I correct?
--- End quote ---
I do not know. Look for (lib)asan. A quick search gave links like:

https://github.com/msys2/MSYS2-packages/discussions/3020

ollydbg:

--- Quote from: blauzahn on September 19, 2024, 09:45:40 am ---
--- Quote ---I think under windows, there is no such tool under the msys2/gcc environment. Am I correct?
--- End quote ---
I do not know. Look for (lib)asan. A quick search gave links like:

https://github.com/msys2/MSYS2-packages/discussions/3020

--- End quote ---

Thanks, but when reading that discussion, I think that feature is not implemented yet, at least for mingw64/gcc platform in msys2.  :(

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version