@Override
	public VariableDB addLocalVariable(Variable var, SourceType source)
			throws DuplicateNameException, InvalidInputException {
		manager.lock.acquire();
		try {
			startUpdate();
			checkDeleted();
			if (thunkedFunction != null) {
				return thunkedFunction.addLocalVariable(var, source);
			}
			loadVariables();
			purgeBadVariables();

			var = getResolvedVariable(var, false, false);

			String name = var.getName();
			if (name == null || name.length() == 0 ||
				SymbolUtilities.isDefaultParameterName(name)) {
				name = DEFAULT_LOCAL_PREFIX;
				source = SourceType.DEFAULT;
			}

			VariableStorage storage = var.getVariableStorage();
			int firstUseOffset = var.getFirstUseOffset();
			if (var.hasStackStorage() && firstUseOffset != 0) {
				Msg.info(this, "WARNING! Stack variable firstUseOffset forced to 0 for function " +
					this + " at " + storage);
				firstUseOffset = 0;
			}

			// Check for duplicate storage address
			VariableDB v = null;
			for (VariableDB oldVar : locals) {
				if (oldVar.getFirstUseOffset() == firstUseOffset &&
					oldVar.getVariableStorage().intersects(storage)) {
					v = oldVar;
					break;
				}
			}

			try {
				if (validateEnabled) {
					VariableUtilities.checkVariableConflict(this, (v != null ? v : var), storage,
						true);
				}
				if (v != null) {
					// update existing variable
					Msg.info(this, "WARNING! Adding overlapping local variable for function " +
						this + " at " + v.getVariableStorage() + " - Modifying existing variable!");
					if (!DEFAULT_LOCAL_PREFIX.equals(name)) {
						v.setName(name, source);
					}
					v.setStorageAndDataType(storage, var.getDataType());
				}
				else {
					SymbolManager symbolMgr = program.getSymbolTable();
					VariableSymbolDB s = symbolMgr.createVariableSymbol(name, this,
						SymbolType.LOCAL_VAR, firstUseOffset, storage, source);
					s.setStorageAndDataType(storage, var.getDataType());
					v = new LocalVariableDB(this, s);
					locals.add(v);
					Collections.sort(locals);
					symbolMap.put(v.symbol, v);
				}
				if (var.getComment() != null) {
					v.symbol.setSymbolComment(var.getComment());
				}
				manager.functionChanged(this, null);
				return v;
			}
			finally {
				frame.setInvalid();
			}
		}
		finally {
			endUpdate();
			manager.lock.release();
		}
	}
@see ghidra.program.model.listing.Function#addLocalVariable(ghidra.program.model.listing.Variable, ghidra.program.model.symbol.SourceType)
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/function/FunctionDB.java