MCPcopy Create free account
hub / github.com/beefytech/Beef / AddTranslationUnit

Method AddTranslationUnit

IDEHelper/Clang/ClangHelper.cpp:713–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711}
712
713void ClangHelper::AddTranslationUnit(const StringImpl& fileName, const char* headerPrefix, const StringImpl& clangArgs, BfSourceClassifier::CharData* charData, int charLen)
714{
715 // Remove any old temporary version
716 //TODO: Put back
717 //RemoveTranslationUnit(fileName);
718
719 ThreadProtect threadProtect(this);
720
721 String argsMem = clangArgs;
722 argsMem += "\n-c\n-x\nc++\n";
723
724 // Add Clang include path
725 char exePath[MAX_PATH];
726 GetModuleFileNameA(NULL, exePath, MAX_PATH);
727 char* pathPtr = exePath + strlen(exePath) - 1;
728 while ((*pathPtr != '\\') && (*pathPtr != '/'))
729 pathPtr--;
730 *pathPtr = 0;
731 argsMem += "-I";
732 argsMem += exePath;
733 argsMem += "/llvm/lib/clang/3.5.0/include";
734
735 std::vector<const char*> args;
736 bool isStrStart = true;
737 for (int i = 0; i < (int)argsMem.length(); i++)
738 {
739 if (argsMem[i] == '\n')
740 {
741 argsMem[i] = 0;
742 isStrStart = true;
743 }
744 else if (isStrStart)
745 {
746 args.push_back(argsMem.c_str() + i);
747 isStrStart = false;
748 }
749 }
750
751 auto transUnit = GetTranslationUnit(fileName, headerPrefix, charData, charLen, VecFirstRef(args), (int)args.size());
752 transUnit->mRefCount++;
753
754 BfLogClang("%d Clang clang_AddTranslationUnit %s %p refCount:%d\n", ::GetCurrentThreadId(), fileName.c_str(), transUnit->mTransUnit, transUnit->mRefCount);
755}
756
757typedef std::map<String, ClangTranslationUnit, StrPathCompare> ClangTranslationUnitMap2;
758

Callers 1

Calls 5

VecFirstRefFunction · 0.85
lengthMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected