diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-02-25 21:38:21 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-02-25 21:38:21 +0000 |
| commit | f5c619f98c43821ce90ffaea1919159af0ba0a61 (patch) | |
| tree | 063fc2d60b84756b63e8a19dfc2b9d50bef3419b /clang/Lex | |
| parent | 3ed28de5ccb9cf4eab278c3ae55d1745d5638adb (diff) | |
| download | bcm5719-llvm-f5c619f98c43821ce90ffaea1919159af0ba0a61.tar.gz bcm5719-llvm-f5c619f98c43821ce90ffaea1919159af0ba0a61.zip | |
clarify comment, this is undefined behavior in any case, even if it only
bits VC++ right now.
llvm-svn: 47565
Diffstat (limited to 'clang/Lex')
| -rw-r--r-- | clang/Lex/HeaderSearch.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/clang/Lex/HeaderSearch.cpp b/clang/Lex/HeaderSearch.cpp index 899c9d87a93..44ae35c8b7e 100644 --- a/clang/Lex/HeaderSearch.cpp +++ b/clang/Lex/HeaderSearch.cpp @@ -228,22 +228,12 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart, if (const FileEntry *FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end())) { // Leave CurDir unset. // This file is a system header or C++ unfriendly if the old file is. - - // Note: Don't use: // - // getFileInfo(FE).DirInfo = getFileInfo(CurFileEnt).DirInfo; - // - // MSVC, behind the scenes, does this: - // - // PerFileInfo &pf1 = getFileInfo(CurFileEnt); - // PerFileInfo &pf2 = getFileInfo(FE); - // pf2.DirInfo = pf1.DirInfo - // - // The problem is that if there's a resize() of the FileInfo vector during - // the getFileInfo(FE) call, pf1 will point to invalid data. To fix - // this problem, make the assignment through a temporary. - unsigned int tmp = getFileInfo(CurFileEnt).DirInfo; - getFileInfo(FE).DirInfo = tmp; + // Note that the temporary 'DirInfo' is required here, as either call to + // getFileInfo could resize the vector and we don't want to rely on order + // of evaluation. + unsigned DirInfo = getFileInfo(CurFileEnt).DirInfo; + getFileInfo(FE).DirInfo = DirInfo; return FE; } } @@ -372,22 +362,12 @@ LookupSubframeworkHeader(const char *FilenameStart, } // This file is a system header or C++ unfriendly if the old file is. - - // Note: Don't use: - // - // getFileInfo(FE).DirInfo = getFileInfo(ContextFileEnt).DirInfo; - // - // MSVC, behind the scenes, does this: - // - // PerFileInfo &pf1 = getFileInfo(ContextFileEnt); - // PerFileInfo &pf2 = getFileInfo(FE); - // pf2.DirInfo = pf1.DirInfo // - // The problem is that if there's a resize() of the FileInfo vector during - // the getFileInfo(FE) call, pf1 will point to invalid data. The solution - // is to make the assignment through a temporary. - unsigned int tmp = getFileInfo(ContextFileEnt).DirInfo; - getFileInfo(FE).DirInfo = tmp; + // Note that the temporary 'DirInfo' is required here, as either call to + // getFileInfo could resize the vector and we don't want to rely on order + // of evaluation. + unsigned DirInfo = getFileInfo(ContextFileEnt).DirInfo; + getFileInfo(FE).DirInfo = DirInfo; return FE; } |

